@ninebone/datagrid 0.0.0-stage → 0.0.3
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/LICENSE +21 -0
- package/README.md +108 -2
- package/dist/css/nine-table.css +1713 -0
- package/dist/nine-table.js +4234 -0
- package/dist/nine-table.js.map +1 -0
- package/dist/nine-table.umd.js +223 -0
- package/dist/nine-table.umd.js.map +1 -0
- package/package.json +49 -4
|
@@ -0,0 +1,4234 @@
|
|
|
1
|
+
import { trace as e } from "@ninebone/util";
|
|
2
|
+
// src/core/protype.js
|
|
3
|
+
Array.prototype.nineBinarySearch = function(e) {
|
|
4
|
+
let t = 0, n = this.length - 1, r;
|
|
5
|
+
for (; t <= n;) {
|
|
6
|
+
if (r = parseInt((t + n) / 2), e === this[r]) return r;
|
|
7
|
+
e < this[r] ? n = r - 1 : t = r + 1;
|
|
8
|
+
}
|
|
9
|
+
return -1;
|
|
10
|
+
};
|
|
11
|
+
var t = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
HTMLElement.prototype.addDebounseEventListener = function(e, n, r, i, a = 500) {
|
|
13
|
+
let o = this;
|
|
14
|
+
t.has(o) || t.set(o, {
|
|
15
|
+
timer: null,
|
|
16
|
+
cancelFn: null
|
|
17
|
+
});
|
|
18
|
+
let s = t.get(o);
|
|
19
|
+
o.addEventListener(r, (e) => {
|
|
20
|
+
e.actualTarget = e.target, s.timer &&= (clearTimeout(s.timer), null), s.timer = setTimeout(() => {
|
|
21
|
+
s.timer = null, s.cancelFn = i.call(o, e);
|
|
22
|
+
}, a);
|
|
23
|
+
}), o.addEventListener(e, (e) => {
|
|
24
|
+
s.timer &&= (clearTimeout(s.timer), null), s.cancelFn &&= (s.cancelFn(), null), n.call(o, e);
|
|
25
|
+
});
|
|
26
|
+
}, nine.measureTextSize = (e, t = "12px sans-serif") => {
|
|
27
|
+
if (typeof e == "number" && (e += ""), !e) return {
|
|
28
|
+
width: null,
|
|
29
|
+
height: null
|
|
30
|
+
};
|
|
31
|
+
let n = (e) => {
|
|
32
|
+
let t = document.createElement("DIV");
|
|
33
|
+
return t.innerHTML = e, t.textContent || t.innerText || "";
|
|
34
|
+
};
|
|
35
|
+
e = e.replaceAll("\n", "<br>");
|
|
36
|
+
let r = document.body.querySelector("canvas#_nine_measure_canvas_");
|
|
37
|
+
r || (r = document.createElement("canvas"), r.id = "_nine_measure_canvas_", r.style.cssText = "position: absolute; visibility: hidden; pointer-events: none; left: -9999px;", document.body.appendChild(r));
|
|
38
|
+
let i = r.getContext("2d");
|
|
39
|
+
i.font = t;
|
|
40
|
+
let a = 0, o = 0;
|
|
41
|
+
for (let t of e.split("<br>")) {
|
|
42
|
+
let e = n(t), r = i.measureText(e);
|
|
43
|
+
a = Math.max(a, r.width);
|
|
44
|
+
let s = r.fontBoundingBoxAscent || 10, c = r.fontBoundingBoxDescent || 3;
|
|
45
|
+
o += s + c;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
width: a,
|
|
49
|
+
height: o
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
var n = new class extends e.constructor {
|
|
53
|
+
constructor() {
|
|
54
|
+
super(), this.init("nine-table", "green");
|
|
55
|
+
}
|
|
56
|
+
}(), r = {
|
|
57
|
+
META: { INDEX: {
|
|
58
|
+
ROWID: 0,
|
|
59
|
+
FILTER: 1,
|
|
60
|
+
GROUP: 2
|
|
61
|
+
} },
|
|
62
|
+
ROW_STATE: {
|
|
63
|
+
EMPTY: "EMPTY",
|
|
64
|
+
NORMAL: "NORMAL",
|
|
65
|
+
INSERT: "INSERT",
|
|
66
|
+
UPDATE: "UPDATE",
|
|
67
|
+
DELETE: "DELETE"
|
|
68
|
+
},
|
|
69
|
+
EVENT: {
|
|
70
|
+
LOAD: "load",
|
|
71
|
+
CELL_BUTTON_CLICK: "cell-button-click"
|
|
72
|
+
}
|
|
73
|
+
}, i = class {
|
|
74
|
+
#e;
|
|
75
|
+
#t = -1;
|
|
76
|
+
constructor(e) {
|
|
77
|
+
this.#e = e;
|
|
78
|
+
}
|
|
79
|
+
get at() {
|
|
80
|
+
return this.#t;
|
|
81
|
+
}
|
|
82
|
+
set at(e) {
|
|
83
|
+
this.#t = parseInt(e, 10);
|
|
84
|
+
}
|
|
85
|
+
count = () => this.#e.rawRecords.length;
|
|
86
|
+
}, a = class e {
|
|
87
|
+
#e;
|
|
88
|
+
#t;
|
|
89
|
+
#n = 0;
|
|
90
|
+
#r = [];
|
|
91
|
+
static META_INDEX = { FILTER: 0 };
|
|
92
|
+
static ROW_STATE = {
|
|
93
|
+
EMPTY: "EMPTY",
|
|
94
|
+
NORMAL: "NORMAL",
|
|
95
|
+
INSERT: "INSERT",
|
|
96
|
+
UPDATE: "UPDATE",
|
|
97
|
+
DELETE: "DELETE"
|
|
98
|
+
};
|
|
99
|
+
constructor(e, t) {
|
|
100
|
+
this.#e = e, this.#t = t, this.#a();
|
|
101
|
+
}
|
|
102
|
+
#i = () => (this.#t.rawRecords || []).filter((e) => !e.__ng?.deleted);
|
|
103
|
+
get count() {
|
|
104
|
+
return this.length;
|
|
105
|
+
}
|
|
106
|
+
count = () => this.length;
|
|
107
|
+
getArray = (e, t) => {
|
|
108
|
+
let n = this.#i();
|
|
109
|
+
if (e == null) return n;
|
|
110
|
+
if (e < 0 || e >= n.length) return null;
|
|
111
|
+
let r = n[e];
|
|
112
|
+
if (t != null) {
|
|
113
|
+
let e = this.getHostFields().indexOf(t);
|
|
114
|
+
return e >= 0 ? r.v[e] : null;
|
|
115
|
+
}
|
|
116
|
+
return r;
|
|
117
|
+
};
|
|
118
|
+
setArray = (t, n, r) => {
|
|
119
|
+
let i = this.#i()[t];
|
|
120
|
+
i.v[n] !== r && i.__ng.rowState !== e.ROW_STATE.INSERT && (i.__ng.rowState = e.ROW_STATE.UPDATE), i.v[n] = r;
|
|
121
|
+
};
|
|
122
|
+
get = (e, t) => {
|
|
123
|
+
let n = this.#i();
|
|
124
|
+
if (e == null) return this.#u(n);
|
|
125
|
+
if (e < 0 || e >= n.length) return null;
|
|
126
|
+
let r = n[e], i = this.getHostFields();
|
|
127
|
+
if (t != null) {
|
|
128
|
+
let e = i.indexOf(t);
|
|
129
|
+
return e >= 0 ? r.v[e] : null;
|
|
130
|
+
}
|
|
131
|
+
return this.#u(r);
|
|
132
|
+
};
|
|
133
|
+
getAll = () => this.#t.rawRecords || [];
|
|
134
|
+
getHostFields = () => typeof this.#e.fields?.get == "function" ? this.#e.fields.get() : [];
|
|
135
|
+
#a = () => {
|
|
136
|
+
this.#r = [];
|
|
137
|
+
let e = this.#e.template || [];
|
|
138
|
+
Array.from(e).forEach((e) => {
|
|
139
|
+
this.#r.push(e.getBoundingClientRect?.().height || 24);
|
|
140
|
+
}), (this.#t.rawRecords || []).forEach((e) => {
|
|
141
|
+
e.__ng ||= this.#s(), e.__ng.height = this.#r.slice();
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
get source() {
|
|
145
|
+
return this.#u(this.#t.rawRecords);
|
|
146
|
+
}
|
|
147
|
+
set source(e) {
|
|
148
|
+
this.set(e);
|
|
149
|
+
}
|
|
150
|
+
#o = () => {
|
|
151
|
+
this.#e.shadowRoot.querySelectorAll("nine-table-sheet").forEach((e) => {
|
|
152
|
+
e.invalidate();
|
|
153
|
+
}), this.#e.shadowRoot.querySelector("nine-table-sheets-footer")?.refresh();
|
|
154
|
+
};
|
|
155
|
+
set = (e) => {
|
|
156
|
+
let t = () => {
|
|
157
|
+
this.#e.loading = !0, setTimeout(() => {
|
|
158
|
+
try {
|
|
159
|
+
this.clear(), this.add(e, !1), this.#o();
|
|
160
|
+
} finally {
|
|
161
|
+
this.#e.loading = !1;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
this.#e.loaded ? t() : this.#e.addEventListener(r.EVENT.LOAD, (e) => {
|
|
166
|
+
t();
|
|
167
|
+
}, { once: !0 });
|
|
168
|
+
};
|
|
169
|
+
get nextId() {
|
|
170
|
+
return this.#n++;
|
|
171
|
+
}
|
|
172
|
+
get length() {
|
|
173
|
+
return this.#i().length;
|
|
174
|
+
}
|
|
175
|
+
get count() {
|
|
176
|
+
return this.length;
|
|
177
|
+
}
|
|
178
|
+
getRowCount() {
|
|
179
|
+
return this.length;
|
|
180
|
+
}
|
|
181
|
+
#s = (t = 0) => ({
|
|
182
|
+
rowState: e.ROW_STATE.EMPTY,
|
|
183
|
+
deleted: !1,
|
|
184
|
+
filtered: !1,
|
|
185
|
+
height: this.#r.slice(),
|
|
186
|
+
o: {},
|
|
187
|
+
c: {},
|
|
188
|
+
__: [
|
|
189
|
+
0,
|
|
190
|
+
0,
|
|
191
|
+
0,
|
|
192
|
+
0,
|
|
193
|
+
e.ROW_STATE.EMPTY,
|
|
194
|
+
!1,
|
|
195
|
+
!1,
|
|
196
|
+
!0,
|
|
197
|
+
!1,
|
|
198
|
+
!0,
|
|
199
|
+
!0,
|
|
200
|
+
!1,
|
|
201
|
+
this.#r.slice(),
|
|
202
|
+
-1,
|
|
203
|
+
{},
|
|
204
|
+
{}
|
|
205
|
+
],
|
|
206
|
+
_: [t, []]
|
|
207
|
+
});
|
|
208
|
+
reset = () => {
|
|
209
|
+
this.#t.rawRecords = [], this.#o();
|
|
210
|
+
};
|
|
211
|
+
clear = () => {
|
|
212
|
+
this.#t.rawRecords = [], this.#t.viewRecords?.reset && this.#t.viewRecords.reset(), this.#n = 0, this.#o();
|
|
213
|
+
};
|
|
214
|
+
#c = (e) => {
|
|
215
|
+
Array.isArray(e) || (e = [e]);
|
|
216
|
+
let t = this.getHostFields().length > 0 ? this.getHostFields() : Object.keys(e[0] || {}), n = [];
|
|
217
|
+
return e.forEach((e) => {
|
|
218
|
+
let r = { v: [] };
|
|
219
|
+
t.forEach((t) => {
|
|
220
|
+
r.v.push(e[t] !== void 0 && e[t] !== null ? e[t] : "");
|
|
221
|
+
}), n.push(r);
|
|
222
|
+
}), n;
|
|
223
|
+
};
|
|
224
|
+
#l = (t) => (Array.isArray(t) || (t = [t]), t.forEach((t) => {
|
|
225
|
+
let n = this.nextId;
|
|
226
|
+
t.m = this.#s(n), t.__ng = t.m, t.__ng.rowid = n, t.__ng.rowState = e.ROW_STATE.INSERT, t.__ng._[0] = n;
|
|
227
|
+
}), t);
|
|
228
|
+
add = (t, n = !0) => {
|
|
229
|
+
t === void 0 && (t = {});
|
|
230
|
+
let r = this.#c(t);
|
|
231
|
+
this.#t.rawRecords = this.#t.rawRecords.concat(this.#l(r));
|
|
232
|
+
let i = this.count() - 1;
|
|
233
|
+
return n || r.forEach((t, n) => {
|
|
234
|
+
let r = this.#t.rawRecords[this.#t.rawRecords.length - 1 - n];
|
|
235
|
+
r && (r.__ng.rowState = e.ROW_STATE.EMPTY);
|
|
236
|
+
}), this.#o(), i;
|
|
237
|
+
};
|
|
238
|
+
delete = (t) => {
|
|
239
|
+
let n = [];
|
|
240
|
+
n = Array.isArray(t) ? t : t === void 0 ? [this.#t.host.row.at] : [parseInt(t, 10)];
|
|
241
|
+
let r = this.#i();
|
|
242
|
+
n.sort((e, t) => t - e).forEach((t) => {
|
|
243
|
+
if (r[t]) {
|
|
244
|
+
let n = r[t].__ng.rowid;
|
|
245
|
+
r[t].__ng.rowState === e.ROW_STATE.INSERT ? this.#t.rawRecords = this.#t.rawRecords.filter((e) => e.__ng.rowid !== n) : this.#t.rawRecords.forEach((t) => {
|
|
246
|
+
t.__ng.rowid === n && (t.__ng.deleted = !0, t.__ng.rowState = e.ROW_STATE.DELETE);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}), this.#o();
|
|
250
|
+
};
|
|
251
|
+
setValue = (t, n, r) => {
|
|
252
|
+
t = parseInt(t, 10);
|
|
253
|
+
let i = this.getHostFields().indexOf(n);
|
|
254
|
+
if (i < 0) return;
|
|
255
|
+
let a = this.#i()[t];
|
|
256
|
+
if (!a) return;
|
|
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;
|
|
259
|
+
};
|
|
260
|
+
#u = (e) => {
|
|
261
|
+
if (!e) return e;
|
|
262
|
+
let t = !Array.isArray(e), n = t ? [e] : e, r = this.getHostFields(), i = n.filter((e) => !e.__ng?.deleted).map((e) => {
|
|
263
|
+
let t = {};
|
|
264
|
+
return r.forEach((n, r) => {
|
|
265
|
+
t[n] = e.v ? e.v[r] : e[n];
|
|
266
|
+
}), t.__ng = e.__ng, t;
|
|
267
|
+
});
|
|
268
|
+
return t ? i[0] : i;
|
|
269
|
+
};
|
|
270
|
+
}, o = class {
|
|
271
|
+
#e;
|
|
272
|
+
constructor(e) {
|
|
273
|
+
this.#e = e, this.row = new i(this), this.data = new a(this.#e, this), this.rawRecords = [], this.viewRecords = [], this.delRecords = [], this.pageCnt = 25, this.viewRecords.reset = () => {
|
|
274
|
+
this.#e.view?.redraw && this.#e.view.redraw();
|
|
275
|
+
}, this.setDataSource = (e) => {
|
|
276
|
+
this.data && this.data.reset(), this.rawRecords = [], this.viewRecords = [], this.delRecords = [], this.data.set(e || []);
|
|
277
|
+
}, this.getRowState = (e) => {
|
|
278
|
+
let t = parseInt(e, 10);
|
|
279
|
+
if (!(t >= this.data.count())) return this.data.getValidData()[t]?.__ng?.rowState;
|
|
280
|
+
}, this.getRowPosition = () => this.row.at, this.setRowPosition = (e) => {
|
|
281
|
+
this.row.at = e;
|
|
282
|
+
}, this.scrollTo_V1 = (e) => (e < 0 && (e = 0), e >= this.rawRecords.length && (e = this.rawRecords.length - 1), this.viewRecords.rawIndex = e, this.viewRecords.reset && this.viewRecords.reset(), !(e <= 0 || e >= this.rawRecords.length - 1)), this.getColumn = (e, t) => this.data.get(e, t), this.setColumn = (e, t, n) => {
|
|
283
|
+
e = parseInt(e, 10), this.data.setValue(e, t, n);
|
|
284
|
+
}, this.setDataSource([]);
|
|
285
|
+
}
|
|
286
|
+
}, s = class {
|
|
287
|
+
#e;
|
|
288
|
+
#t = [];
|
|
289
|
+
constructor(e) {
|
|
290
|
+
this.#e = e, this.#r();
|
|
291
|
+
}
|
|
292
|
+
get() {
|
|
293
|
+
return this.#t.map((e) => e.name);
|
|
294
|
+
}
|
|
295
|
+
getFields() {
|
|
296
|
+
return this.#t;
|
|
297
|
+
}
|
|
298
|
+
getType(e) {
|
|
299
|
+
let t = this.#t.find((t) => t.name === e);
|
|
300
|
+
return t ? t.type : "string";
|
|
301
|
+
}
|
|
302
|
+
add = (e, t = "string") => {
|
|
303
|
+
e.forEach((e) => {
|
|
304
|
+
this.#t.some((t) => t.name === e) || this.#t.push({
|
|
305
|
+
name: e,
|
|
306
|
+
type: t
|
|
307
|
+
});
|
|
308
|
+
}), this.#n();
|
|
309
|
+
};
|
|
310
|
+
indexOf(e) {
|
|
311
|
+
return this.#t.findIndex((t) => t.name === e);
|
|
312
|
+
}
|
|
313
|
+
includes(e) {
|
|
314
|
+
return this.#t.some((t) => t.name === e);
|
|
315
|
+
}
|
|
316
|
+
#n = () => {
|
|
317
|
+
let e = /* @__PURE__ */ new Map();
|
|
318
|
+
this.#t.forEach((t) => {
|
|
319
|
+
e.set(t.name, t.type);
|
|
320
|
+
}), this.#t = Array.from(e, ([e, t]) => ({
|
|
321
|
+
name: e,
|
|
322
|
+
type: t
|
|
323
|
+
})), this.#t = this.#t.filter((e) => e.name !== "" && e.name !== "__ng"), this.#t.sort((e, t) => e.name.length < t.name.length ? 1 : -1);
|
|
324
|
+
};
|
|
325
|
+
#r = () => {
|
|
326
|
+
this.#t = [], n.log(this.#e.querySelectorAll("table"));
|
|
327
|
+
let e = Array.from(this.#e.querySelectorAll("table"));
|
|
328
|
+
if (e && e.length !== 0) {
|
|
329
|
+
for (let t of e) n.log(t), t.querySelectorAll("[data-bind]").forEach((e) => {
|
|
330
|
+
let t = e.dataset.bind, n = e.getAttribute("data-type") || "string";
|
|
331
|
+
t && this.#t.push({
|
|
332
|
+
name: t,
|
|
333
|
+
type: n
|
|
334
|
+
});
|
|
335
|
+
}), [
|
|
336
|
+
"data-expr",
|
|
337
|
+
"background-color",
|
|
338
|
+
"color",
|
|
339
|
+
"tooltip",
|
|
340
|
+
"visible",
|
|
341
|
+
"readonly",
|
|
342
|
+
"enable-button",
|
|
343
|
+
"enable-check",
|
|
344
|
+
"class-expr",
|
|
345
|
+
"icon-color",
|
|
346
|
+
"icon-src"
|
|
347
|
+
].forEach((e) => {
|
|
348
|
+
t.querySelectorAll(`[${e}]`).forEach((t) => {
|
|
349
|
+
let n = t.getAttribute(e);
|
|
350
|
+
if (n) {
|
|
351
|
+
if (n.indexOf("data.") < 0) {
|
|
352
|
+
let e = n.search(/[(]/g);
|
|
353
|
+
if (e > 0) try {
|
|
354
|
+
n = String(window[n.substring(0, e).trim()]);
|
|
355
|
+
} catch {
|
|
356
|
+
n = "";
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
n.split("data.").forEach((e) => {
|
|
360
|
+
if (e.trim() != "") {
|
|
361
|
+
let t = e.search(/[^_A-Za-z0-9]/g), r = "";
|
|
362
|
+
t >= 0 ? r = e.substring(0, t) : n.startsWith("data.") && (r = e.replace("data.", "")), r && this.#t.push({
|
|
363
|
+
name: r,
|
|
364
|
+
type: "string"
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
this.#n();
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}, c = class extends HTMLElement {
|
|
375
|
+
constructor() {
|
|
376
|
+
super();
|
|
377
|
+
}
|
|
378
|
+
connectedCallback() {
|
|
379
|
+
this.#e();
|
|
380
|
+
}
|
|
381
|
+
#e = () => {};
|
|
382
|
+
};
|
|
383
|
+
customElements.get("nine-table-sheets") || customElements.define("nine-table-sheets", c);
|
|
384
|
+
// src/layout/nine-table-sheets-footer.js
|
|
385
|
+
var l = class extends HTMLElement {
|
|
386
|
+
#e;
|
|
387
|
+
constructor() {
|
|
388
|
+
super();
|
|
389
|
+
}
|
|
390
|
+
connectedCallback() {
|
|
391
|
+
this.#t();
|
|
392
|
+
}
|
|
393
|
+
refresh = () => {
|
|
394
|
+
this.querySelector("#row-count").innerHTML = this.#e.data.count().toLocaleString();
|
|
395
|
+
};
|
|
396
|
+
#t = () => {
|
|
397
|
+
this.#e = this.getRootNode().host, this.#r(), this.querySelector(".nine-tab-bar")?.addEventListener("click", (e) => {
|
|
398
|
+
let t = e.ctrlKey || e.metaKey || e.shiftKey, n = e.target.closest("nt-sheets-tab-item");
|
|
399
|
+
if (!n) return;
|
|
400
|
+
let r = parseInt(n.dataset.index, 10);
|
|
401
|
+
this.#n(r, t);
|
|
402
|
+
}), setTimeout(() => {
|
|
403
|
+
this.#n(0, !1);
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
#n = (e, t = !1) => {
|
|
407
|
+
let n = () => {
|
|
408
|
+
let e = Array.from(this.#e.shadowRoot.querySelectorAll("nine-table-sheet"));
|
|
409
|
+
Array.from(this.#e.shadowRoot.querySelectorAll("nine-splitter")).forEach((e) => e.style.setProperty("display", "none"));
|
|
410
|
+
let t = e.map((e, t) => ({
|
|
411
|
+
sheet: e,
|
|
412
|
+
idx: t
|
|
413
|
+
})).filter(({ sheet: e }) => e.classList.contains("active"));
|
|
414
|
+
if (!(t.length < 2)) for (let e = 0; e < t.length - 1; e++) {
|
|
415
|
+
let n = t[e].idx, r = this.#e.shadowRoot.querySelector(`nine-splitter[data-split-index="${n}"]`);
|
|
416
|
+
r && r.style.setProperty("display", "");
|
|
417
|
+
}
|
|
418
|
+
}, r = this.querySelector(".nine-tab-bar"), i = this.#e.shadowRoot.querySelector("nine-table-sheets-body"), a = r.querySelectorAll("nt-sheets-tab-item"), o = i.querySelectorAll("nine-table-sheet");
|
|
419
|
+
if (!a[e]) return;
|
|
420
|
+
if (!t) a.forEach((t, n) => {
|
|
421
|
+
t.setActive(n === e);
|
|
422
|
+
}), o.forEach((t, n) => {
|
|
423
|
+
let r = n === e;
|
|
424
|
+
t.classList.toggle("active", r), t.style.flex = r ? "1 1 100%" : "";
|
|
425
|
+
});
|
|
426
|
+
else {
|
|
427
|
+
let t = a[e], n = r.querySelectorAll("nt-sheets-tab-item.active");
|
|
428
|
+
if (t.classList.contains("active") && n.length <= 1) return;
|
|
429
|
+
t.classList.toggle("active");
|
|
430
|
+
let o = i.querySelector(`nine-table-sheet[data-index="${e}"]`);
|
|
431
|
+
o && (o.classList.toggle("active"), o.classList.contains("active") || (o.style.flex = ""));
|
|
432
|
+
}
|
|
433
|
+
let s = i.querySelectorAll("nine-table-sheet.active");
|
|
434
|
+
s?.forEach((e) => {
|
|
435
|
+
e.style.flex = s.length > 1 ? "1 1 0%" : "1 1 100%", typeof e.refreshLayout == "function" ? e.refreshLayout() : e.invalidate?.();
|
|
436
|
+
}), n();
|
|
437
|
+
};
|
|
438
|
+
#r() {
|
|
439
|
+
let e = Array.from(this.#e.children).filter((e) => e.tagName.toUpperCase() === "TABLE").map((e, t) => `<nt-sheets-tab-item class="${t === 0 ? "active" : ""}" data-index="${t}">${e.getAttribute("caption") || `Sheet ${t + 1}`}</nt-sheets-tab-item>`).join("");
|
|
440
|
+
this.innerHTML = `
|
|
441
|
+
<div class="nine-tab-bar">${e}</div>
|
|
442
|
+
<div class="sheets-counter">Total : <span id="row-count">0</span></div>
|
|
443
|
+
`;
|
|
444
|
+
}
|
|
445
|
+
}, u = class extends HTMLElement {
|
|
446
|
+
constructor() {
|
|
447
|
+
super();
|
|
448
|
+
}
|
|
449
|
+
connectedCallback() {}
|
|
450
|
+
setActive(e) {
|
|
451
|
+
this.classList.toggle("active", e);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
customElements.get("nt-sheets-tab-item") || customElements.define("nt-sheets-tab-item", u), customElements.get("nine-table-sheets-footer") || customElements.define("nine-table-sheets-footer", l);
|
|
455
|
+
// src/layout/nine-table-toolbar.js
|
|
456
|
+
var d = class extends HTMLElement {
|
|
457
|
+
#e;
|
|
458
|
+
#t;
|
|
459
|
+
connectedCallback() {
|
|
460
|
+
this.#e = this.getRootNode().host, this.#n(), this.#i();
|
|
461
|
+
}
|
|
462
|
+
#n() {
|
|
463
|
+
this.innerHTML = "\n <div class=\"ng-toolbar-left\">\n <button type=\"button\" class=\"ng-toolbar-menu-btn\" title=\"Menu\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#374151\" stroke-width=\"2\">\n <line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\"></line>\n <line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"></line>\n <line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\"></line>\n </svg>\n </button>\n <span class=\"ng-toolbar-title\"></span>\n </div>\n\n <div class=\"ng-toolbar-custom\" id=\"custom-container\"></div>\n ", this.#t = this.querySelector("#custom-container"), this.#r();
|
|
464
|
+
}
|
|
465
|
+
#r() {
|
|
466
|
+
let e = this.#e.getAttribute("theme") === "simple" || this.#e.classList.contains("simple"), t = this.#e.getAttribute("show-toolbar") !== "false", n = this.#e.getAttribute("show-menu") !== "false", r = this.#e.getAttribute("caption") || "";
|
|
467
|
+
e || !t ? this.setAttribute("hidden", "") : this.removeAttribute("hidden"), this.setAttribute("show-menu", n ? "true" : "false"), this.updateCaption(r);
|
|
468
|
+
}
|
|
469
|
+
#i() {
|
|
470
|
+
let e = this.querySelector(".ng-toolbar-title");
|
|
471
|
+
e && e.addEventListener("dblclick", () => {
|
|
472
|
+
let t = "<font color=\"green\">https://www.ninegrid.net</font>", n = this.#e.getAttribute("caption") || "";
|
|
473
|
+
e.innerHTML = e.innerHTML === t ? n : t;
|
|
474
|
+
});
|
|
475
|
+
let t = this.querySelector(".ng-toolbar-menu-btn");
|
|
476
|
+
t && t.addEventListener("click", () => {
|
|
477
|
+
this.#e.dispatchEvent(new CustomEvent("toolbar-menu-click", {
|
|
478
|
+
bubbles: !0,
|
|
479
|
+
composed: !0,
|
|
480
|
+
detail: { targetTable: this.#e }
|
|
481
|
+
}));
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
addCustomElement(e) {
|
|
485
|
+
this.#t && this.#t.append(e);
|
|
486
|
+
}
|
|
487
|
+
updateCaption(e) {
|
|
488
|
+
let t = this.querySelector(".ng-toolbar-title");
|
|
489
|
+
t && (t.textContent = e);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
customElements.get("nine-table-toolbar") || customElements.define("nine-table-toolbar", d);
|
|
493
|
+
// src/layout/nine-table-hscrollbar.js
|
|
494
|
+
var f = class extends HTMLElement {
|
|
495
|
+
#e;
|
|
496
|
+
#t = !1;
|
|
497
|
+
#n;
|
|
498
|
+
#r;
|
|
499
|
+
#i;
|
|
500
|
+
#a;
|
|
501
|
+
constructor() {
|
|
502
|
+
super();
|
|
503
|
+
}
|
|
504
|
+
connectedCallback() {
|
|
505
|
+
if (this.#e = this.closest("nine-table-sheet") || this.getRootNode().host, !this.#e) return;
|
|
506
|
+
this.innerHTML = "\n <button class='scroll-left' disabled><div class='scroll-icon'></div></button>\n <div class='scroll-track'><div class='scroll-thumb'></div></div>\n <button class='scroll-right' disabled><div class='scroll-icon'></div></button>\n ";
|
|
507
|
+
let e = () => {
|
|
508
|
+
let t = this.#e.querySelector(".ng-sheet-body .ng-container-body");
|
|
509
|
+
t ? (this.#n = {
|
|
510
|
+
container: t,
|
|
511
|
+
track: this.querySelector(".scroll-track"),
|
|
512
|
+
thumb: this.querySelector(".scroll-thumb"),
|
|
513
|
+
left: this.querySelector(".scroll-left"),
|
|
514
|
+
right: this.querySelector(".scroll-right")
|
|
515
|
+
}, this.#c(), this.#o(), this.refresh()) : setTimeout(e, 10);
|
|
516
|
+
};
|
|
517
|
+
e();
|
|
518
|
+
}
|
|
519
|
+
disconnectedCallback() {
|
|
520
|
+
this.#a && this.#a.disconnect();
|
|
521
|
+
}
|
|
522
|
+
#o = () => {
|
|
523
|
+
if (!this.#e) return;
|
|
524
|
+
let e = this.#e.querySelector(".ng-sheet-body .ng-container-body");
|
|
525
|
+
e && (this.#a = new ResizeObserver(() => {
|
|
526
|
+
this.refresh();
|
|
527
|
+
}), this.#a.observe(e));
|
|
528
|
+
};
|
|
529
|
+
refresh = () => {
|
|
530
|
+
if (!this.#e || !this.#n || this.#t) return;
|
|
531
|
+
let e = this.#n.container, t = e.querySelector("table");
|
|
532
|
+
if (!t) return;
|
|
533
|
+
let n = this.#n.track, r = this.#n.thumb, i = e.clientWidth, a = t.scrollWidth, o = i !== 0 && a > i;
|
|
534
|
+
if (this.#e.classList.toggle("hscroll-visible", o), !o) return;
|
|
535
|
+
let s = n.clientWidth;
|
|
536
|
+
if (s <= 0) return;
|
|
537
|
+
let c = Math.max(Math.min(i / a * s, s), 20);
|
|
538
|
+
r.style.width = `${c}px`;
|
|
539
|
+
let l = e.scrollLeft, u = a - i, d = 0;
|
|
540
|
+
u > 0 && (d = parseInt(l / u * (s - c), 10)), d < 0 && (d = 0);
|
|
541
|
+
let f = s - c;
|
|
542
|
+
d > f && (d = f), r.style.left = `${d}px`, this.#n.left.disabled = d === 0, this.#n.right.disabled = d >= f - 1;
|
|
543
|
+
};
|
|
544
|
+
#s = (e) => {
|
|
545
|
+
if (!this.#n) return !1;
|
|
546
|
+
let t = this.#n.container, n = t.querySelector("table");
|
|
547
|
+
if (!n) return !1;
|
|
548
|
+
let r = this.#n.track.getBoundingClientRect(), i = this.#n.thumb.clientWidth, a = e;
|
|
549
|
+
a < 0 && (a = 0);
|
|
550
|
+
let o = r.width - i;
|
|
551
|
+
a > o && (a = o), a = parseInt(a, 10), this.#n.thumb.style.left = `${a}px`, this.#n.left.disabled = a === 0, this.#n.right.disabled = a >= o - 1;
|
|
552
|
+
let s = t.clientWidth, c = n.scrollWidth - s;
|
|
553
|
+
return o > 0 && c > 0 && (t.scrollLeft = a / o * c), a > 0 && a < o - 1;
|
|
554
|
+
};
|
|
555
|
+
#c = () => {
|
|
556
|
+
let e = (e) => {
|
|
557
|
+
clearInterval(this.#r), clearInterval(this.#i);
|
|
558
|
+
let t = parseInt(this.#n.thumb.style.left || 0, 10);
|
|
559
|
+
this.#s(t + e), this.#r = setInterval(() => {
|
|
560
|
+
clearInterval(this.#r), this.#i = setInterval(() => {
|
|
561
|
+
let t = parseInt(this.#n.thumb.style.left || 0, 10);
|
|
562
|
+
this.#s(t + e) || clearInterval(this.#i);
|
|
563
|
+
}, 50);
|
|
564
|
+
}, 500);
|
|
565
|
+
}, t = () => {
|
|
566
|
+
clearInterval(this.#r), clearInterval(this.#i);
|
|
567
|
+
};
|
|
568
|
+
[
|
|
569
|
+
"mouseup",
|
|
570
|
+
"mouseleave",
|
|
571
|
+
"touchend"
|
|
572
|
+
].forEach((e) => {
|
|
573
|
+
this.#n.left.addEventListener(e, t), this.#n.right.addEventListener(e, t), this.#n.track.addEventListener(e, t);
|
|
574
|
+
}), this.#n.left.addEventListener("mousedown", (t) => {
|
|
575
|
+
t.button === 0 && e(-20);
|
|
576
|
+
}), this.#n.right.addEventListener("mousedown", (t) => {
|
|
577
|
+
t.button === 0 && e(20);
|
|
578
|
+
}), this.#n.left.addEventListener("touchstart", () => e(-20)), this.#n.right.addEventListener("touchstart", () => e(20)), this.#n.track.addEventListener("mousedown", (e) => {
|
|
579
|
+
if (e.button !== 0) return;
|
|
580
|
+
e.preventDefault();
|
|
581
|
+
let t = this.#n.track.getBoundingClientRect(), n = this.#n.thumb.clientWidth;
|
|
582
|
+
this.#s(e.clientX - t.left - n / 2);
|
|
583
|
+
}), this.#n.thumb.addEventListener("mousedown", (e) => {
|
|
584
|
+
if (e.button !== 0) return;
|
|
585
|
+
e.stopPropagation(), e.preventDefault(), this.#t = !0, this.shiftX = e.clientX - this.#n.thumb.getBoundingClientRect().left;
|
|
586
|
+
let n = (e) => {
|
|
587
|
+
if (!this.#t) return;
|
|
588
|
+
let t = this.#n.track.getBoundingClientRect();
|
|
589
|
+
this.#s(e.clientX - t.left - this.shiftX);
|
|
590
|
+
}, r = () => {
|
|
591
|
+
this.#t = !1, t(), document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", r), this.refresh();
|
|
592
|
+
};
|
|
593
|
+
document.addEventListener("mousemove", n), document.addEventListener("mouseup", r);
|
|
594
|
+
});
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
customElements.get("nine-table-hscrollbar") || customElements.define("nine-table-hscrollbar", f);
|
|
598
|
+
// src/layout/nine-table-vscrollbar.js
|
|
599
|
+
var p = class extends HTMLElement {
|
|
600
|
+
#e;
|
|
601
|
+
#t;
|
|
602
|
+
#n = !1;
|
|
603
|
+
#r;
|
|
604
|
+
#i = 0;
|
|
605
|
+
#a = 0;
|
|
606
|
+
constructor() {
|
|
607
|
+
super();
|
|
608
|
+
}
|
|
609
|
+
connectedCallback() {
|
|
610
|
+
this.#e = this.getRootNode().host, this.#t = this.closest("nine-table-sheet"), this.innerHTML = "\n <button class='scroll-top' disabled><div class='scroll-icon'></div></button>\n <div class='scroll-track'><div class='scroll-thumb'></div></div>\n <button class='scroll-bottom' disabled><div class='scroll-icon'></div></button>\n ";
|
|
611
|
+
let e = () => {
|
|
612
|
+
let t = this.#t.querySelector(".ng-sheet-body");
|
|
613
|
+
t ? (this.#r = {
|
|
614
|
+
container: t,
|
|
615
|
+
track: this.querySelector(".scroll-track"),
|
|
616
|
+
thumb: this.querySelector(".scroll-thumb"),
|
|
617
|
+
top: this.querySelector(".scroll-top"),
|
|
618
|
+
bottom: this.querySelector(".scroll-bottom")
|
|
619
|
+
}, this.#s(), this.refresh()) : setTimeout(e, 10);
|
|
620
|
+
};
|
|
621
|
+
e();
|
|
622
|
+
}
|
|
623
|
+
#o = () => {
|
|
624
|
+
let e = this.#t.view.getArray(), t = e ? e.length : 0, n = this.#t.elements?.scrollHolder, r = n && parseFloat(n.style.height) || 0;
|
|
625
|
+
(!r || r <= 0) && (r = this.#t.sourceTable?.querySelector("tbody tr[grouping='true']") && this.#t.rowManager ? body.scrollHeight > body.clientHeight ? body.scrollHeight : t * 30 : t * (this.#t.getRowHeight() || 1));
|
|
626
|
+
let i = 15e6, a = r > i, o = 1, s = r;
|
|
627
|
+
return a && (o = i / r, s = i), {
|
|
628
|
+
rawContentHeight: r,
|
|
629
|
+
contentHeight: s,
|
|
630
|
+
scaleFactor: o,
|
|
631
|
+
useScaling: a,
|
|
632
|
+
totalCount: t
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
refresh = () => {
|
|
636
|
+
if (this.#n || !this.#t || !this.#t.elements || !this.#r) return;
|
|
637
|
+
let e = this.#r.container, t = this.#r.track, n = this.#r.thumb, { contentHeight: r } = this.#o(), i = (this.#t.querySelector("thead")?.offsetHeight || 0) + (this.#t.querySelector("tfoot")?.offsetHeight || 0) + (this.#t.querySelector("tbody.head")?.offsetHeight || 0), a = this.#t.querySelector(".ng-sheet-body").offsetHeight || 0, o = a - i, s = this.#t.view.getArray().length, c = this.#t.getRowHeight() * s, l = c > o;
|
|
638
|
+
if (this.#t.classList.toggle("vscroll-visible", l), !l) return;
|
|
639
|
+
let u = t.clientHeight;
|
|
640
|
+
if (u <= 0) return;
|
|
641
|
+
let d = Math.max(Math.min(a / c * u, u), 20);
|
|
642
|
+
n.style.height = `${d}px`;
|
|
643
|
+
let f = e.scrollTop, p = Math.max(r - this.#t.rowManager.getRowHeight(), 1), m = 0;
|
|
644
|
+
p > 0 && (m = f / p * (u - d));
|
|
645
|
+
let h = u - d;
|
|
646
|
+
m < 0 && (m = 0), m > h && (m = h), n.style.top = `${m}px`, this.#r.top.disabled = f <= 0, this.#r.bottom.disabled = f >= p - 1;
|
|
647
|
+
};
|
|
648
|
+
#s = () => {
|
|
649
|
+
n.log("nine-table-vscrollbar.#init"), this.#r.container, this.#r.thumb.addEventListener("mousedown", (e) => {
|
|
650
|
+
if (e.button !== 0) return;
|
|
651
|
+
e.stopPropagation(), e.preventDefault(), this.#n = !0, this.#i = e.clientY, this.#a = parseFloat(this.#r.thumb.style.top) || 0;
|
|
652
|
+
let t = this.#r.track.getBoundingClientRect().height - this.#r.thumb.clientHeight, n = (e) => {
|
|
653
|
+
if (!this.#n || t <= 0) return;
|
|
654
|
+
let n = e.clientY - this.#i, r = this.#a + n;
|
|
655
|
+
r < 0 && (r = 0), r > t && (r = t), this.#r.thumb.style.top = `${r}px`;
|
|
656
|
+
let i = r / t, a = this.#t.getRowHeight(), o = (this.#t.querySelector(".ng-sheet-body").offsetHeight || 0) - (this.#t.elements.body.thead?.offsetHeight || 0) - (this.#t.elements.body.tfoot?.offsetHeight || 0) - (this.#t.elements.body.tbody.head.offsetHeight || 0), s = Math.floor(o / a), { totalCount: c } = this.#o(), l = Math.floor(i * (c - s + 1));
|
|
657
|
+
this.#t.rowManager.scrollToDataRow(l);
|
|
658
|
+
let { rawContentHeight: u, contentHeight: d } = this.#o(), f = this.#r.container.scrollTop, p = Math.max(d - this.#t.rowManager.getRowHeight(), 0);
|
|
659
|
+
this.#r.top.disabled = f <= 0, this.#r.bottom.disabled = f >= p - 1;
|
|
660
|
+
}, r = () => {
|
|
661
|
+
this.#n = !1, document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", r);
|
|
662
|
+
};
|
|
663
|
+
document.addEventListener("mousemove", n), document.addEventListener("mouseup", r);
|
|
664
|
+
}), this.#r.track.addEventListener("mousedown", (e) => {
|
|
665
|
+
if (e.button !== 0 || e.target === this.#r.thumb) return;
|
|
666
|
+
let t = this.#r.track.getBoundingClientRect(), r = this.#r.thumb.clientHeight, i = this.#r.track.clientHeight - r;
|
|
667
|
+
if (i > 0) {
|
|
668
|
+
let a = e.clientY - t.top - r / 2, o = Math.max(0, Math.min(1, a / i)), { totalCount: s } = this.#o(), c = Math.max(0, Math.min(Math.floor(o * (s - 1)), s - 1));
|
|
669
|
+
n.log("🎯 [VScroll Track Click]", {
|
|
670
|
+
ratio: o,
|
|
671
|
+
clickY: a,
|
|
672
|
+
totalCount: s,
|
|
673
|
+
targetRow: c
|
|
674
|
+
}), c >= 0 && this.#t.rowManager && typeof this.#t.rowManager.scrollToDataRow == "function" && this.#t.rowManager.scrollToDataRow(c, "top");
|
|
675
|
+
}
|
|
676
|
+
this.refresh();
|
|
677
|
+
});
|
|
678
|
+
let e = null, t = (t) => {
|
|
679
|
+
if (e) return;
|
|
680
|
+
let r = () => {
|
|
681
|
+
let e = this.#t.querySelector("tbody.body tr");
|
|
682
|
+
if (!e || e.dataset.row === void 0 || (n.log(this.#t.isLastRow()), t === "down" && this.#t.isLastRow())) return;
|
|
683
|
+
let r = parseInt(e.dataset.row, 10), i = t === "down" ? r + 1 : Math.max(0, r - 1);
|
|
684
|
+
this.#t.rowManager.scrollToDataRow(i, null, () => {
|
|
685
|
+
this.refresh();
|
|
686
|
+
});
|
|
687
|
+
};
|
|
688
|
+
r(), e = setInterval(r, 200);
|
|
689
|
+
}, r = () => {
|
|
690
|
+
e &&= (clearInterval(e), null);
|
|
691
|
+
};
|
|
692
|
+
this.#r.top.addEventListener("mousedown", (e) => {
|
|
693
|
+
e.button === 0 && t("up");
|
|
694
|
+
}), this.#r.bottom.addEventListener("mousedown", (e) => {
|
|
695
|
+
e.button === 0 && t("down");
|
|
696
|
+
}), document.addEventListener("mouseup", r), this.#r.top.addEventListener("mouseleave", r), this.#r.bottom.addEventListener("mouseleave", r);
|
|
697
|
+
};
|
|
698
|
+
};
|
|
699
|
+
customElements.get("nine-table-vscrollbar") || customElements.define("nine-table-vscrollbar", p);
|
|
700
|
+
// src/data/Grouping.js
|
|
701
|
+
var m = {
|
|
702
|
+
ID: 0,
|
|
703
|
+
DEPTH: 1,
|
|
704
|
+
NAME: 2,
|
|
705
|
+
CHILDREN: 3
|
|
706
|
+
}, h = class {
|
|
707
|
+
#e;
|
|
708
|
+
#t;
|
|
709
|
+
#n = [];
|
|
710
|
+
#r = /* @__PURE__ */ new Map();
|
|
711
|
+
#i = !1;
|
|
712
|
+
constructor(e) {
|
|
713
|
+
this.#e = e, this.#t = this.#e.getRootNode().host;
|
|
714
|
+
}
|
|
715
|
+
get columns() {
|
|
716
|
+
return this.#n;
|
|
717
|
+
}
|
|
718
|
+
get groupMap() {
|
|
719
|
+
return this.#r;
|
|
720
|
+
}
|
|
721
|
+
initialize = () => {
|
|
722
|
+
let e = [], t = this.#e.sourceTable;
|
|
723
|
+
t && t.querySelectorAll("tbody tr[grouping=\"true\"]").forEach((t) => {
|
|
724
|
+
let n = t.querySelector("[cell-type=\"tree\"]");
|
|
725
|
+
n && n.dataset.bind && e.push(n.dataset.bind);
|
|
726
|
+
}), this.#n = e;
|
|
727
|
+
};
|
|
728
|
+
apply() {
|
|
729
|
+
if (n.log("==================", "Grouping.Apply"), this.#i) return;
|
|
730
|
+
this.#i = !0;
|
|
731
|
+
let e = [], t = this.#e.sourceTable;
|
|
732
|
+
t && t.querySelectorAll("tbody tr[grouping=\"true\"]").forEach((t) => {
|
|
733
|
+
let n = t.querySelector("[cell-type=\"tree\"]");
|
|
734
|
+
n && n.dataset.bind && e.push(n.dataset.bind);
|
|
735
|
+
}), this.#n = e, this.#i = !1, this.#e.scrollToY(0), this.#e.view.refresh();
|
|
736
|
+
}
|
|
737
|
+
clear() {
|
|
738
|
+
this.#n = [], this.#r.clear(), this.#i = !1, this.#e.scrollToY(0), this.#e.view.refresh();
|
|
739
|
+
}
|
|
740
|
+
setGroupMap(e) {
|
|
741
|
+
this.#r = e;
|
|
742
|
+
}
|
|
743
|
+
getChildrenRowIds(e) {
|
|
744
|
+
return this.#r.get(e) || [];
|
|
745
|
+
}
|
|
746
|
+
getChildrenRecords(e) {
|
|
747
|
+
let t = this.getChildrenRowIds(e), n = this.#t.data;
|
|
748
|
+
return t.map((e) => n.getArray(e)).filter(Boolean);
|
|
749
|
+
}
|
|
750
|
+
}, g = class e {
|
|
751
|
+
static apply(t, n = [], r = []) {
|
|
752
|
+
if (!n || n.length === 0) return {
|
|
753
|
+
headers: [],
|
|
754
|
+
renderItems: [],
|
|
755
|
+
groupMap: /* @__PURE__ */ new Map()
|
|
756
|
+
};
|
|
757
|
+
let i = t.filter((e) => !e.__ng?.deleted), a = /* @__PURE__ */ new Map(), o = e.#t(i, n, r), s = [], c = [];
|
|
758
|
+
return e.#e(o, 0, n, s, c, a, ""), {
|
|
759
|
+
headers: s,
|
|
760
|
+
renderItems: c,
|
|
761
|
+
groupMap: a
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
static #e(t, n, r, i, a, o, s) {
|
|
765
|
+
let c = 0, l = n === r.length - 1;
|
|
766
|
+
for (let [u, d] of t.entries()) {
|
|
767
|
+
let t = s ? `${s}_${c++}` : `g_${c++}`, f = e.#n(d);
|
|
768
|
+
o.set(t, f);
|
|
769
|
+
let p = [];
|
|
770
|
+
p[m.ID] = t, p[m.DEPTH] = n, p[m.NAME] = u, p[m.CHILDREN] = f, p.__isGroupHeader = !0, p.__groupId = t, i.push(p), a.push({
|
|
771
|
+
type: "group",
|
|
772
|
+
record: p,
|
|
773
|
+
groupId: t
|
|
774
|
+
}), !l && d instanceof Map ? e.#e(d, n + 1, r, i, a, o, t) : e.#r(d).forEach((e) => {
|
|
775
|
+
e.__isGroupHeader = !1, e.__groupId = t, i.push(e), a.push({
|
|
776
|
+
type: "data",
|
|
777
|
+
record: e,
|
|
778
|
+
groupId: t
|
|
779
|
+
});
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
static #t(t, n, r) {
|
|
784
|
+
let i = r.indexOf(n[0]), a = n.slice(1), o = /* @__PURE__ */ new Map();
|
|
785
|
+
if (t.forEach((e) => {
|
|
786
|
+
let t = i >= 0 ? e.v[i] : "(Unknown)";
|
|
787
|
+
o.has(t) || o.set(t, []), o.get(t).push(e);
|
|
788
|
+
}), a.length > 0) {
|
|
789
|
+
let t = /* @__PURE__ */ new Map();
|
|
790
|
+
for (let [n, i] of o.entries()) t.set(n, e.#t(i, a, r));
|
|
791
|
+
return t;
|
|
792
|
+
}
|
|
793
|
+
return o;
|
|
794
|
+
}
|
|
795
|
+
static #n(t) {
|
|
796
|
+
let n = [];
|
|
797
|
+
if (t instanceof Map) for (let r of t.values()) n = n.concat(e.#n(r));
|
|
798
|
+
else Array.isArray(t) && (n = n.concat(t.map((e) => e.__ng?.rowid ?? e.m?._?.[0])));
|
|
799
|
+
return n;
|
|
800
|
+
}
|
|
801
|
+
static #r(t) {
|
|
802
|
+
let n = [];
|
|
803
|
+
if (t instanceof Map) for (let r of t.values()) n = n.concat(e.#r(r));
|
|
804
|
+
else Array.isArray(t) && (n = n.concat(t));
|
|
805
|
+
return n;
|
|
806
|
+
}
|
|
807
|
+
}, _ = class {
|
|
808
|
+
#e = 3;
|
|
809
|
+
#t;
|
|
810
|
+
#n;
|
|
811
|
+
#r;
|
|
812
|
+
#i = /* @__PURE__ */ new Map();
|
|
813
|
+
#a = [];
|
|
814
|
+
#o = null;
|
|
815
|
+
#s = null;
|
|
816
|
+
#c = 0;
|
|
817
|
+
#l;
|
|
818
|
+
#u = !1;
|
|
819
|
+
#d = !1;
|
|
820
|
+
constructor(e) {
|
|
821
|
+
this.#t = e.getRootNode().host, this.#n = e, this.#x();
|
|
822
|
+
}
|
|
823
|
+
getRowHeight() {
|
|
824
|
+
return this.#a.reduce((e, t) => e + t, 0);
|
|
825
|
+
}
|
|
826
|
+
refresh = (e = !1) => {
|
|
827
|
+
if (!this.#n.classList.contains("active")) return;
|
|
828
|
+
let t = this.#n.querySelector(".ng-sheet-body");
|
|
829
|
+
t && ((!this.#o || this.#o <= 0) && (this.#g(), this.#o && this.#o > 0 && this.#v()), this.#f(t.scrollTop, e), this.#n.querySelector("nine-table-vscrollbar")?.refresh());
|
|
830
|
+
};
|
|
831
|
+
#f = (e, t = !1) => {
|
|
832
|
+
if (this.#d) {
|
|
833
|
+
this.#p(e, t);
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
let n = this.#o;
|
|
837
|
+
if (!n || n <= 0) return;
|
|
838
|
+
let i = this.#n.view.getArray(), a = i.length;
|
|
839
|
+
if (a === 0) {
|
|
840
|
+
this.#n.elements.scrollHolder.style.height = "0px";
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
let o = this.#n.templateLength, s = (this.#n.elements.body.thead?.offsetHeight || 0) + (this.#n.elements.body.tfoot?.offsetHeight || 0) + this.#n.elements.body.tbody.head.offsetHeight, c = this.#n.querySelector(".ng-sheet-body").offsetHeight || 0, l = Math.max(a * n - (c - s - n), 0), u = 15e6, d = l > u, f = 1, p = l;
|
|
844
|
+
d && (f = u / l, p = u), this.#n.elements.scrollHolder.style.height = `${p}px`;
|
|
845
|
+
let m = d ? e / f : e, h = Math.max(0, a - 1), g = Math.min(m, l), _ = Math.max(0, Math.min(Math.floor(g / n), h)), v = g % n;
|
|
846
|
+
this.#n.elements.left.tbody.body.style.top = this.#n.elements.body.tbody.body.style.top = this.#n.elements.right.tbody.body.style.top = `-${v}px`;
|
|
847
|
+
let y = this.#r.firstTr, b = y && y.dataset.row !== void 0 ? parseInt(y.dataset.row, 10) : -1;
|
|
848
|
+
(t || b !== _) && ([
|
|
849
|
+
this.#n.elements.left.tbody.body,
|
|
850
|
+
this.#n.elements.body.tbody.body,
|
|
851
|
+
this.#n.elements.right.tbody.body
|
|
852
|
+
].forEach((e, t) => {
|
|
853
|
+
e && e.querySelectorAll("tbody.body tr").forEach((e, t) => {
|
|
854
|
+
let n = _ + Math.floor(t / o);
|
|
855
|
+
if (n >= a) {
|
|
856
|
+
e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null;
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
let s = i[n];
|
|
860
|
+
if (!s) {
|
|
861
|
+
e.style.display = "none";
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
let c = s.m._[r.META.INDEX.ROWID];
|
|
865
|
+
e.style.display = "", this.#h(e, s, c, n);
|
|
866
|
+
});
|
|
867
|
+
}), this.#n.selection.refresh());
|
|
868
|
+
};
|
|
869
|
+
#p = (e, t = !1) => {
|
|
870
|
+
n.log("handleGroupdScroll() start");
|
|
871
|
+
let r = this.#n.view.getArray() || [], i = r.length;
|
|
872
|
+
if (i === 0) {
|
|
873
|
+
this.#n.elements.scrollHolder.style.height = "0px";
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
let a = this.#n.querySelector(".ng-sheet-body .ng-sheet-body-content"), o = this.#n.templateLength || 1, s = (e) => {
|
|
877
|
+
if (e.type === "group") {
|
|
878
|
+
let t = e.record[m.DEPTH] || 0;
|
|
879
|
+
return this.#a[t] || this.#o / o;
|
|
880
|
+
}
|
|
881
|
+
{
|
|
882
|
+
let e = 0, t = this.#n.templateLength || 1, n = 0;
|
|
883
|
+
for (let e = 0; e < t - 1; e++) n += this.#a[e] || 0;
|
|
884
|
+
return e = this.#o - n, e > 0 ? e : this.#o;
|
|
885
|
+
}
|
|
886
|
+
}, c = 0, l = Array(i);
|
|
887
|
+
for (let e = 0; e < i; e++) {
|
|
888
|
+
let t = s(r[e]);
|
|
889
|
+
l[e] = t, c += t;
|
|
890
|
+
}
|
|
891
|
+
this.#n.elements.scrollHolder.style.height = `${c}px`, n.log("*************", c);
|
|
892
|
+
let u = this.#n.clientHeight, d = 0, f = 0;
|
|
893
|
+
for (let t = 0; t < i; t++) {
|
|
894
|
+
let n = l[t];
|
|
895
|
+
if (d + n > e) {
|
|
896
|
+
f = t;
|
|
897
|
+
break;
|
|
898
|
+
}
|
|
899
|
+
d += n, f = t;
|
|
900
|
+
}
|
|
901
|
+
let p = e - d;
|
|
902
|
+
a && a.querySelectorAll("tbody").forEach((e) => {
|
|
903
|
+
e.style.top = `-${Math.max(0, p)}px`;
|
|
904
|
+
});
|
|
905
|
+
let h = this.#r.firstTr, g = h && h.dataset.virtualIndex !== void 0 ? parseInt(h.dataset.virtualIndex, 10) : -1;
|
|
906
|
+
if (!t && g === f) return;
|
|
907
|
+
let _ = Math.ceil(u / (this.#o / o)), v = (this.#n.grouping.columns?.length || 1) * 15, y = f, b = Math.min(i, f + _ + v), x = r.slice(y, b);
|
|
908
|
+
[
|
|
909
|
+
".ng-container-body",
|
|
910
|
+
".ng-container-left",
|
|
911
|
+
".ng-container-right"
|
|
912
|
+
].forEach((e) => {
|
|
913
|
+
let t = this.#n.querySelector(`.ng-sheet-body ${e}`);
|
|
914
|
+
if (!t) return;
|
|
915
|
+
let n = Array.from(t.querySelectorAll("tbody.body tr"));
|
|
916
|
+
for (let e = 0; e < n.length; e += o) {
|
|
917
|
+
let t = Math.floor(e / o), i = x[t], a = n.slice(e, e + o);
|
|
918
|
+
if (!i || t >= x.length) {
|
|
919
|
+
a.forEach((e) => {
|
|
920
|
+
e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null;
|
|
921
|
+
});
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
let s = f + t;
|
|
925
|
+
a.forEach((e, n) => {
|
|
926
|
+
let a = f + t;
|
|
927
|
+
e.dataset.virtualIndex = a, e.dataset.row = i.type === "data" ? s : "";
|
|
928
|
+
let o = e.getAttribute("grouping") === "true";
|
|
929
|
+
if (i.type === "group") o && n === i.record[m.DEPTH] ? (e.style.display = "", this.#m(e, r, i.record, a)) : (e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null);
|
|
930
|
+
else if (o) e.style.display = "none", e.dataset.matrixRow = null, e.dataset.row = null, e.dataset.index = null;
|
|
931
|
+
else {
|
|
932
|
+
e.style.display = "";
|
|
933
|
+
let t = i.record.m?.rowid ?? 0;
|
|
934
|
+
this.#h(e, i.record, t, a);
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
}), this.#n.selection.refresh(), n.log("handleGroupdScroll() end");
|
|
939
|
+
};
|
|
940
|
+
#m = (e, t, n, r) => {
|
|
941
|
+
let i = this.#n.templateLength || 1, a = parseInt(e.dataset.subrow, 10) || 0, o = r * i + a, s = n[m.CHILDREN], c = this.#t.data.getArray(), l = s ? s.map((e) => c[e]).filter(Boolean) : [];
|
|
942
|
+
e.dataset.virtualIndex = r, e.dataset.row = "", e.dataset.matrixRow = o, e.data = l, e.dataset.groupId = n[m.ID], Array.from(e.cells).forEach((e) => {
|
|
943
|
+
e.dataset.row = r;
|
|
944
|
+
let t = Array.from(e.children).find((e) => e.tagName.toLowerCase().startsWith("cell-") || typeof e.refresh == "function");
|
|
945
|
+
t !== void 0 && typeof t.refresh == "function" && t?.refresh();
|
|
946
|
+
});
|
|
947
|
+
};
|
|
948
|
+
#h = (e, t, n, r) => {
|
|
949
|
+
let i = this.#n.templateLength || 1, a = parseInt(e.dataset.subrow, 10) || 0, o = r * i + a;
|
|
950
|
+
e.dataset.index = r, e.dataset.row = n, e.dataset.matrixRow = o, e.data = t, Array.from(e.cells).forEach((e) => {
|
|
951
|
+
e.dataset.index = r, e.dataset.row = n, Array.from(e.children).find((e) => e.tagName.toLowerCase().startsWith("cell-") && typeof e.refresh == "function")?.refresh();
|
|
952
|
+
});
|
|
953
|
+
};
|
|
954
|
+
initialize = () => {
|
|
955
|
+
this.#d = !!this.#n.sourceTable.querySelector("tbody tr[grouping='true']"), this.#o = null, this.#i.clear(), this.#r = {
|
|
956
|
+
scrollTables: this.#n.querySelectorAll(".ng-sheet-body table"),
|
|
957
|
+
firstTr: this.#n.querySelector(".ng-sheet-body .ng-container-body tbody.body tr")
|
|
958
|
+
}, [
|
|
959
|
+
".ng-container-body",
|
|
960
|
+
".ng-container-left",
|
|
961
|
+
".ng-container-right"
|
|
962
|
+
].forEach((e) => {
|
|
963
|
+
let t = this.#n.querySelector(`.ng-sheet-body ${e}`);
|
|
964
|
+
if (!t) return;
|
|
965
|
+
let n = t.querySelector("table");
|
|
966
|
+
if (!n) return;
|
|
967
|
+
let r = n.querySelector("tbody.body");
|
|
968
|
+
if (!r) return;
|
|
969
|
+
let i = Array.from(r.querySelectorAll("tr")).map((e) => e.cloneNode(!0));
|
|
970
|
+
this.#i.set(e, i);
|
|
971
|
+
});
|
|
972
|
+
let e = this.#n.querySelector(".ng-sheet-body");
|
|
973
|
+
e && (this.#c = e.clientHeight, this.#g(), this.#v(), this.#f(e.scrollTop, !0), e.addEventListener("scroll", (t) => {
|
|
974
|
+
if (this.#u) return;
|
|
975
|
+
let r = this.#o || 0, i = (this.#n.view.getArray()?.length || 0) * r;
|
|
976
|
+
i <= e.clientHeight ? n.log(i, e.clientHeight) : (this.#f(e.scrollTop), this.#n.querySelector("nine-table-vscrollbar").refresh());
|
|
977
|
+
}, { passive: !0 }));
|
|
978
|
+
};
|
|
979
|
+
scrollToDataRow(e, t = "top", r) {
|
|
980
|
+
let i = this.#n.querySelector(".ng-sheet-body"), a = this.#n.view.getArray()?.length || 0, o = Math.max(0, Math.min(e, a - 1)), s = 0;
|
|
981
|
+
if (this.#d) {
|
|
982
|
+
let e = Math.max(i.scrollHeight - i.clientHeight, 1);
|
|
983
|
+
s = o / Math.max(a - 1, 1) * e;
|
|
984
|
+
} else {
|
|
985
|
+
let e = this.#o, t = o * e, n = (this.#n.elements.body.thead?.offsetHeight || 0) + (this.#n.elements.body.tfoot?.offsetHeight || 0) + this.#n.elements.body.tbody.head.offsetHeight, r = i.offsetHeight || 0, c = Math.max(a * e + n - r, 0), l = 15e6, u = c > l, d = 1;
|
|
986
|
+
u && (d = l / c), s = t * d;
|
|
987
|
+
}
|
|
988
|
+
n.log(s), this.#u = !0, i.scrollTop = s, this.#f(s), requestAnimationFrame(() => {
|
|
989
|
+
requestAnimationFrame(() => {
|
|
990
|
+
this.#u = !1, typeof r == "function" && r();
|
|
991
|
+
});
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
destroy = () => {
|
|
995
|
+
this.#s &&= (this.#s.disconnect(), null);
|
|
996
|
+
};
|
|
997
|
+
#g = () => {
|
|
998
|
+
if (!this.#n.classList.contains("active") || !this.#n.sourceTable) return;
|
|
999
|
+
let e = this.#n.sourceTable?.querySelectorAll("tbody.body tr"), t = this.#n.querySelector(".ng-sheet-body .ng-container-body tbody.body");
|
|
1000
|
+
t.querySelectorAll("tr").forEach((e) => e.remove());
|
|
1001
|
+
let r = document.createDocumentFragment();
|
|
1002
|
+
e.forEach((e) => r.appendChild(e.cloneNode(!0))), t.appendChild(r);
|
|
1003
|
+
let i = t.querySelectorAll("tr");
|
|
1004
|
+
this.#a = [], i.forEach((e) => {
|
|
1005
|
+
if (e?.offsetHeight === 2) {
|
|
1006
|
+
n.log("================================"), n.log(this.#n), n.log(e), n.log(e.cloneNode(!0));
|
|
1007
|
+
let t = window.getComputedStyle(e);
|
|
1008
|
+
n.log("================================", t, t.height, t.minHeight);
|
|
1009
|
+
}
|
|
1010
|
+
this.#a.push(Math.max(e.offsetHeight, 24));
|
|
1011
|
+
}), i.forEach((e) => e.remove()), this.#o = this.#a.reduce((e, t) => e + t, 0), this.#_();
|
|
1012
|
+
};
|
|
1013
|
+
#_ = () => {
|
|
1014
|
+
if (n.log("[DEBUG #updateRowCount] sheetHeight:", this.#c, "cachedTemplateHeight:", this.#o), this.#c > 0 && this.#o > 0) {
|
|
1015
|
+
let e = Math.ceil(this.#c / this.#o), t = this.#e;
|
|
1016
|
+
if (this.#d && this.#n.grouping) {
|
|
1017
|
+
let e = this.#n.grouping.columns?.length || 1;
|
|
1018
|
+
t += e * 15;
|
|
1019
|
+
}
|
|
1020
|
+
this.#l = e + t, n.log("[DEBUG #updateRowCount] calculated cachedRowCount:", this.#t, this.#l);
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
#v = () => {
|
|
1024
|
+
n.log("rowManager.#renderAllContainers"), [
|
|
1025
|
+
".ng-container-body",
|
|
1026
|
+
".ng-container-left",
|
|
1027
|
+
".ng-container-right"
|
|
1028
|
+
].forEach((e) => {
|
|
1029
|
+
let t = this.#n.querySelector(`.ng-sheet-body ${e}`);
|
|
1030
|
+
t && t.querySelector("tbody") && this.#y(t);
|
|
1031
|
+
}), this.#b();
|
|
1032
|
+
};
|
|
1033
|
+
#y = (e) => {
|
|
1034
|
+
let t = null;
|
|
1035
|
+
e.classList.contains("ng-container-left") ? t = "left" : e.classList.contains("ng-container-right") && (t = "right");
|
|
1036
|
+
let n = Array.from(this.#n.sourceTable.querySelectorAll("tbody.body tr")).map((e) => {
|
|
1037
|
+
let n = e.cloneNode(!0);
|
|
1038
|
+
return t === "left" ? n.querySelectorAll("th,td").forEach((e) => {
|
|
1039
|
+
e.getAttribute("fixed") !== "left" && e.remove();
|
|
1040
|
+
}) : t === "right" ? n.querySelectorAll("th,td").forEach((e) => {
|
|
1041
|
+
e.getAttribute("fixed") !== "right" && e.remove();
|
|
1042
|
+
}) : n.querySelectorAll("[fixed=left], [fixed=right]").forEach((e) => {
|
|
1043
|
+
e.remove();
|
|
1044
|
+
}), n;
|
|
1045
|
+
});
|
|
1046
|
+
if (n.length === 0) return;
|
|
1047
|
+
let r = e.querySelector("tbody.body");
|
|
1048
|
+
if (!r) return;
|
|
1049
|
+
r.querySelectorAll("tr").forEach((e) => e.remove());
|
|
1050
|
+
let i = document.createDocumentFragment();
|
|
1051
|
+
for (let e = 0; e < this.#l; e++) n.forEach((e) => i.appendChild(e.cloneNode(!0)));
|
|
1052
|
+
r.appendChild(i), e.classList.contains("ng-container-body") && (this.#r.firstTr = r.querySelector("tr"));
|
|
1053
|
+
};
|
|
1054
|
+
#b = () => {
|
|
1055
|
+
let e = this.#n.querySelector(".ng-sheet-body .ng-container-left table"), t = this.#n.querySelector(".ng-sheet-body .ng-container-body table"), n = this.#n.querySelector(".ng-sheet-body .ng-container-right table");
|
|
1056
|
+
if (t) {
|
|
1057
|
+
let r = e ? Array.from(e.querySelectorAll("tbody tr")) : [], i = Array.from(t.querySelectorAll("tbody tr")), a = n ? Array.from(n.querySelectorAll("tbody tr")) : [], o = Math.max(r.length, i.length, a.length);
|
|
1058
|
+
for (let e = 0; e < o; e++) {
|
|
1059
|
+
let t = [
|
|
1060
|
+
r[e]?.getBoundingClientRect().height || 0,
|
|
1061
|
+
i[e]?.getBoundingClientRect().height || 0,
|
|
1062
|
+
a[e]?.getBoundingClientRect().height || 0
|
|
1063
|
+
], n = Math.max(...t);
|
|
1064
|
+
n > 0 && (r[e] && (r[e].style.height = `${n}px`), i[e] && (i[e].style.height = `${n}px`), a[e] && (a[e].style.height = `${n}px`));
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
#x = () => {
|
|
1069
|
+
this.#n && this.#n instanceof HTMLElement && (this.#s = new ResizeObserver((e) => {
|
|
1070
|
+
for (let t of e) {
|
|
1071
|
+
if (!t.target.classList.contains("active")) continue;
|
|
1072
|
+
let e = t.contentRect.height;
|
|
1073
|
+
t.contentRect.width > 0 && this.#n.isAutoFitCol && this.#n.autoFit(!0), e > 0 && this.#c !== e && (this.#c = e, this.#_(), this.#o !== null && (this.#v(), this.refresh()));
|
|
1074
|
+
}
|
|
1075
|
+
}), this.#s.observe(this.#n));
|
|
1076
|
+
};
|
|
1077
|
+
}, v = class e {
|
|
1078
|
+
static compile(t) {
|
|
1079
|
+
let n = t.cloneNode(!0);
|
|
1080
|
+
return e.resetColIndex(n, n.querySelectorAll("thead tr")), e.resetColIndex(n, n.querySelectorAll("tbody.body tr[grouping=\"true\"]")), e.resetColIndex(n, n.querySelectorAll("tbody.body tr:not([grouping=\"true\"])")), e.resetColIndex(n, n.querySelectorAll("tfoot tr")), e.#e(n), n;
|
|
1081
|
+
}
|
|
1082
|
+
static recompile(t) {
|
|
1083
|
+
return e.resetColIndex(t, t.querySelectorAll("thead tr")), e.resetColIndex(t, t.querySelectorAll("tbody.body tr[grouping=\"true\"]")), e.resetColIndex(t, t.querySelectorAll("tbody.body tr:not([grouping=\"true\"])")), e.resetColIndex(t, t.querySelectorAll("tfoot tr")), e.#e(t), t;
|
|
1084
|
+
}
|
|
1085
|
+
static #e(e) {
|
|
1086
|
+
e.querySelectorAll("colgroup col").forEach((t, n) => {
|
|
1087
|
+
t.setAttribute("data-col", n);
|
|
1088
|
+
let r = t.getAttribute("fixed");
|
|
1089
|
+
e.querySelectorAll(`[data-col="${n}"]`).forEach((e) => {
|
|
1090
|
+
r ? e.setAttribute("fixed", r) : e.removeAttribute("fixed");
|
|
1091
|
+
});
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
static resetColIndex(e, t) {
|
|
1095
|
+
let n = e.querySelectorAll("colgroup col"), r = Array.from({ length: t.length }, () => Array(n.length).fill(null));
|
|
1096
|
+
t.forEach((e, i) => {
|
|
1097
|
+
e.dataset.subrow = i;
|
|
1098
|
+
let a = 0;
|
|
1099
|
+
e.querySelectorAll("th, td").forEach((e) => {
|
|
1100
|
+
for (; a < n.length && r[i][a] !== null;) a++;
|
|
1101
|
+
e.dataset.col = a;
|
|
1102
|
+
let o = e.rowSpan || 1, s = e.colSpan || 1;
|
|
1103
|
+
for (let c = 0; c < o; c++) for (let o = 0; o < s; o++) i + c < t.length && a + o < n.length && (r[i + c][a + o] = e);
|
|
1104
|
+
a += s;
|
|
1105
|
+
});
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
}, y = class {
|
|
1109
|
+
#e;
|
|
1110
|
+
#t = {
|
|
1111
|
+
startRow: -1,
|
|
1112
|
+
startCol: -1,
|
|
1113
|
+
endRow: -1,
|
|
1114
|
+
endCol: -1
|
|
1115
|
+
};
|
|
1116
|
+
constructor(e) {
|
|
1117
|
+
this.#e = e, this.#r(), n.log("🎯 [CellSelection] Initialized (New Structure Compatible)");
|
|
1118
|
+
}
|
|
1119
|
+
#n(e) {
|
|
1120
|
+
if (!e) return {
|
|
1121
|
+
dataRow: -1,
|
|
1122
|
+
subRowIndex: -1,
|
|
1123
|
+
matrixRow: -1
|
|
1124
|
+
};
|
|
1125
|
+
let t = parseInt(e.dataset.index, 10);
|
|
1126
|
+
if (isNaN(t)) return {
|
|
1127
|
+
dataRow: -1,
|
|
1128
|
+
subRowIndex: -1,
|
|
1129
|
+
matrixRow: -1
|
|
1130
|
+
};
|
|
1131
|
+
let n = e.closest("tbody"), r = Array.from(n.querySelectorAll("tr")).filter((e) => parseInt(e.dataset.index, 10) === t), i = r.indexOf(e), a = r.length > 0 ? r.length : 1;
|
|
1132
|
+
return {
|
|
1133
|
+
dataRow: t,
|
|
1134
|
+
subRowIndex: i,
|
|
1135
|
+
matrixRow: t * a + (i >= 0 ? i : e.sectionRowIndex % a)
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
setFocus(e, t) {
|
|
1139
|
+
this.#e.querySelectorAll("tr.selected-start").forEach((e) => {
|
|
1140
|
+
e.classList.remove("selected-start"), e.querySelectorAll("td.selected-start").forEach((e) => {
|
|
1141
|
+
e.classList.remove("selected-start");
|
|
1142
|
+
});
|
|
1143
|
+
});
|
|
1144
|
+
let n = this.#e.querySelector(`.ng-sheet-body-content tr[data-matrix-row="${e}"] td[data-col="${t}"]`);
|
|
1145
|
+
n && (n.classList.add("selected-start"), n.closest("tr")?.classList.add("selected-start"));
|
|
1146
|
+
}
|
|
1147
|
+
setRange(e, t, n, r) {
|
|
1148
|
+
let i = Math.min(e, n), a = Math.max(e, n), o = Math.min(t, r), s = Math.max(t, r), c = this.#e.querySelectorAll(".ng-container-left, .ng-container-body, .ng-container-right"), l = !0, u = 0;
|
|
1149
|
+
for (; l && u < 5;) l = !1, u++, c.forEach((e) => {
|
|
1150
|
+
Array.from(e.querySelectorAll("tbody tr")).filter((e) => e.style.display !== "none").forEach((e) => {
|
|
1151
|
+
let { matrixRow: t } = this.#n(e);
|
|
1152
|
+
t < 0 || e.querySelectorAll("td, th").forEach((e) => {
|
|
1153
|
+
let n = parseInt(e.dataset.col, 10);
|
|
1154
|
+
if (isNaN(n)) return;
|
|
1155
|
+
let r = parseInt(e.rowSpan || 1, 10), c = parseInt(e.colSpan || 1, 10), u = t + r - 1, d = n + c - 1;
|
|
1156
|
+
if (u >= i && t <= a && d >= o && n <= s) {
|
|
1157
|
+
let e = Math.min(i, t), r = Math.max(a, u), c = Math.min(o, n), f = Math.max(s, d);
|
|
1158
|
+
(e !== i || r !== a || c !== o || f !== s) && (i = e, a = r, o = c, s = f, l = !0);
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1162
|
+
});
|
|
1163
|
+
this.#t = {
|
|
1164
|
+
startRow: i,
|
|
1165
|
+
startCol: o,
|
|
1166
|
+
endRow: a,
|
|
1167
|
+
endCol: s
|
|
1168
|
+
}, this.render();
|
|
1169
|
+
}
|
|
1170
|
+
refresh = () => {
|
|
1171
|
+
this.render();
|
|
1172
|
+
};
|
|
1173
|
+
render = () => {
|
|
1174
|
+
let { startRow: e, startCol: t, endRow: n, endCol: r } = this.#t, i = this.#e.querySelectorAll(".ng-container-left, .ng-container-body, .ng-container-right");
|
|
1175
|
+
i.forEach((e) => {
|
|
1176
|
+
e.querySelectorAll(".selected, .selected-top, .selected-bottom, .selected-left, .selected-right, .selected-start").forEach((e) => {
|
|
1177
|
+
e.classList.remove("selected", "selected-top", "selected-bottom", "selected-left", "selected-right", "selected-start");
|
|
1178
|
+
}), e.querySelectorAll("tr.selected-start").forEach((e) => {
|
|
1179
|
+
e.classList.remove("selected-start");
|
|
1180
|
+
});
|
|
1181
|
+
}), e < 0 || t < 0 || i.forEach((i) => {
|
|
1182
|
+
Array.from(i.querySelectorAll("tbody tr")).filter((e) => e.style.display !== "none").forEach((i) => {
|
|
1183
|
+
let { matrixRow: a } = this.#n(i);
|
|
1184
|
+
a < 0 || i.querySelectorAll("td, th").forEach((i) => {
|
|
1185
|
+
let o = parseInt(i.dataset.col, 10);
|
|
1186
|
+
if (isNaN(o)) return;
|
|
1187
|
+
let s = parseInt(i.rowSpan || 1, 10), c = parseInt(i.colSpan || 1, 10), l = a + s - 1, u = o + c - 1;
|
|
1188
|
+
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"));
|
|
1189
|
+
});
|
|
1190
|
+
});
|
|
1191
|
+
});
|
|
1192
|
+
};
|
|
1193
|
+
#r() {
|
|
1194
|
+
let e = this.#e.querySelector(".ng-sheet-body");
|
|
1195
|
+
e ? e.addEventListener("mousedown", (e) => {
|
|
1196
|
+
if (e.button !== 0) return;
|
|
1197
|
+
let t = e.target.closest("td, th");
|
|
1198
|
+
if (!t || t.dataset.row === void 0 || t.dataset.col === void 0) return;
|
|
1199
|
+
this.#e.style.userSelect = "none", this.#e.style.webkitUserSelect = "none";
|
|
1200
|
+
let n = t.closest("tr"), { matrixRow: r } = this.#n(n), i = parseInt(t.dataset.col, 10);
|
|
1201
|
+
if (r < 0) {
|
|
1202
|
+
this.#e.style.userSelect = "", this.#e.style.webkitUserSelect = "";
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
this.setFocus(r, i), this.setRange(r, i, r, i);
|
|
1206
|
+
let a = r, o = i, s = (e) => {
|
|
1207
|
+
let t = document.elementFromPoint(e.clientX, e.clientY)?.closest("td, th");
|
|
1208
|
+
if (!t || !this.#e.contains(t)) {
|
|
1209
|
+
let n = this.#e.querySelectorAll(".ng-sheet-body-content tbody tr td, .ng-sheet-body-content tbody tr:not(.nodata) th");
|
|
1210
|
+
for (let r of n) {
|
|
1211
|
+
let n = r.getBoundingClientRect();
|
|
1212
|
+
if (e.clientX >= n.left && e.clientX <= n.right && e.clientY >= n.top && e.clientY <= n.bottom) {
|
|
1213
|
+
t = r;
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
if (!t || t.dataset.row === void 0 || t.dataset.col === void 0) return;
|
|
1219
|
+
let n = t.closest("tr"), { matrixRow: s } = this.#n(n), c = parseInt(t.dataset.col, 10);
|
|
1220
|
+
s < 0 || (a !== s || o !== c) && (a = s, o = c, this.setRange(r, i, s, c));
|
|
1221
|
+
}, c = () => {
|
|
1222
|
+
this.#e.style.userSelect = "", this.#e.style.webkitUserSelect = "", document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", c);
|
|
1223
|
+
};
|
|
1224
|
+
document.addEventListener("mousemove", s), document.addEventListener("mouseup", c);
|
|
1225
|
+
}) : n.log("❌ [CellSelection] .ng-sheet-body not found!");
|
|
1226
|
+
}
|
|
1227
|
+
}, b = class {
|
|
1228
|
+
#e;
|
|
1229
|
+
#t;
|
|
1230
|
+
#n = null;
|
|
1231
|
+
#r = null;
|
|
1232
|
+
constructor(e) {
|
|
1233
|
+
this.#e = e, this.#t = e.getRootNode().host, this.#g(), n.log("🎯 [CellNavigation] Initialized (Diagnostic Logging Restored)");
|
|
1234
|
+
}
|
|
1235
|
+
get currentCell() {
|
|
1236
|
+
return this.#n;
|
|
1237
|
+
}
|
|
1238
|
+
set currentCell(e) {
|
|
1239
|
+
if (!e) return;
|
|
1240
|
+
this.#n = e, e.focus({ preventScroll: !0 }), this.#r = e.closest("tr");
|
|
1241
|
+
let t = parseInt(this.#r.dataset.matrixRow, 10);
|
|
1242
|
+
this.#e.selection.setFocus(t, this.#n.dataset.col);
|
|
1243
|
+
}
|
|
1244
|
+
#i = (e, t) => {
|
|
1245
|
+
if (t) {
|
|
1246
|
+
switch (e.code) {
|
|
1247
|
+
case "Tab":
|
|
1248
|
+
e.shiftKey ? this.#p(t) || t.scrollIntoView({
|
|
1249
|
+
inline: "nearest",
|
|
1250
|
+
block: "nearest"
|
|
1251
|
+
}) : this.#m(t) || t.scrollIntoView({
|
|
1252
|
+
inline: "nearest",
|
|
1253
|
+
block: "nearest"
|
|
1254
|
+
});
|
|
1255
|
+
break;
|
|
1256
|
+
case "ArrowRight":
|
|
1257
|
+
this.#m(t) || t.scrollIntoView({
|
|
1258
|
+
inline: "nearest",
|
|
1259
|
+
block: "nearest"
|
|
1260
|
+
});
|
|
1261
|
+
break;
|
|
1262
|
+
case "ArrowLeft": this.#p(t) || t.scrollIntoView({
|
|
1263
|
+
inline: "nearest",
|
|
1264
|
+
block: "nearest"
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
this.currentCell = t, this.#e.selection.setRange(this.#r.dataset.matrixRow, t.dataset.col, this.#r.dataset.matrixRow, t.dataset.col);
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
#a = (e, t) => {
|
|
1271
|
+
if (t) {
|
|
1272
|
+
let n = !1;
|
|
1273
|
+
switch (e.code) {
|
|
1274
|
+
case "Enter":
|
|
1275
|
+
e.shiftKey, this.#f(t) && (n = !0);
|
|
1276
|
+
break;
|
|
1277
|
+
case "ArrowDown":
|
|
1278
|
+
this.#f(t) && (n = !0);
|
|
1279
|
+
break;
|
|
1280
|
+
case "ArrowUp": this.#d(t) && (n = !0);
|
|
1281
|
+
}
|
|
1282
|
+
if (n) {
|
|
1283
|
+
this.currentCell = t, this.#e.selection.setRange(this.#r.dataset.matrixRow, t.dataset.col, this.#r.dataset.matrixRow, t.dataset.col);
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
let n = parseInt(this.#r.dataset.index, 10), r = -1;
|
|
1288
|
+
switch (e.code) {
|
|
1289
|
+
case "Enter":
|
|
1290
|
+
if (e.shiftKey) {
|
|
1291
|
+
let e = this.#h();
|
|
1292
|
+
r = Math.max(n - e + 0, 0);
|
|
1293
|
+
} else r = Math.min(n, this.#e.view.count());
|
|
1294
|
+
break;
|
|
1295
|
+
case "ArrowDown":
|
|
1296
|
+
r = Math.min(n, this.#e.view.count());
|
|
1297
|
+
break;
|
|
1298
|
+
case "ArrowUp":
|
|
1299
|
+
let t = this.#h();
|
|
1300
|
+
r = Math.max(n - t + 0, 0);
|
|
1301
|
+
}
|
|
1302
|
+
if (r < 0) return;
|
|
1303
|
+
let i = parseInt(this.#r.dataset.matrixRow, 10), a = parseInt(this.#n.dataset.col, 10), o = parseInt(this.#n.rowSpan, 10) || 1;
|
|
1304
|
+
switch (e.code) {
|
|
1305
|
+
case "ArrowDown":
|
|
1306
|
+
i += o;
|
|
1307
|
+
break;
|
|
1308
|
+
case "ArrowUp": i--;
|
|
1309
|
+
}
|
|
1310
|
+
this.#e.rowManager.scrollToDataRow(r, null, () => {
|
|
1311
|
+
let e = this.#c(i, a);
|
|
1312
|
+
e && (this.currentCell = e, this.#e.selection.setRange(this.#r.dataset.matrixRow, e.dataset.col, this.#r.dataset.matrixRow, e.dataset.col));
|
|
1313
|
+
});
|
|
1314
|
+
};
|
|
1315
|
+
moveCell = (e) => {
|
|
1316
|
+
if (e.target.tagName === "INPUT" && (["text"].includes(e.target.type) && [
|
|
1317
|
+
"ArrowLeft",
|
|
1318
|
+
"ArrowRight",
|
|
1319
|
+
"Home",
|
|
1320
|
+
"End"
|
|
1321
|
+
].includes(e.code) || [
|
|
1322
|
+
"date",
|
|
1323
|
+
"datetime-local",
|
|
1324
|
+
"time",
|
|
1325
|
+
"week",
|
|
1326
|
+
"month"
|
|
1327
|
+
].includes(e.target.type))) return;
|
|
1328
|
+
if (!this.#n || !this.#r) {
|
|
1329
|
+
n.log("⚠️ [moveCell] currentCell or currentTr is missing!");
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
let t;
|
|
1333
|
+
switch (e.code) {
|
|
1334
|
+
case "Tab":
|
|
1335
|
+
t = e.shiftKey ? this.#s() : this.#o();
|
|
1336
|
+
break;
|
|
1337
|
+
case "ArrowRight":
|
|
1338
|
+
t = this.#o();
|
|
1339
|
+
break;
|
|
1340
|
+
case "ArrowLeft":
|
|
1341
|
+
t = this.#s();
|
|
1342
|
+
break;
|
|
1343
|
+
case "Enter":
|
|
1344
|
+
t = e.shiftKey ? this.#l() : this.#u();
|
|
1345
|
+
break;
|
|
1346
|
+
case "ArrowDown":
|
|
1347
|
+
t = this.#u();
|
|
1348
|
+
break;
|
|
1349
|
+
case "ArrowUp": t = this.#l();
|
|
1350
|
+
}
|
|
1351
|
+
e.preventDefault(), [
|
|
1352
|
+
"ArrowLeft",
|
|
1353
|
+
"ArrowRight",
|
|
1354
|
+
"Tab"
|
|
1355
|
+
].includes(e.code) ? this.#i(e, t) : [
|
|
1356
|
+
"Enter",
|
|
1357
|
+
"ArrowUp",
|
|
1358
|
+
"ArrowDown"
|
|
1359
|
+
].includes(e.code) && this.#a(e, t);
|
|
1360
|
+
};
|
|
1361
|
+
#o = () => {
|
|
1362
|
+
let e = parseInt(this.#n.dataset.col, 10), t = parseInt(this.#n.colSpan, 10) || 1, n = parseInt(this.#r.dataset.index, 10), r = parseInt(this.#r.dataset.matrixRow, 10), i = e + t, a = this.#e.querySelector(`tbody tr[data-matrix-row="${r}"] td[data-col="${i}"]`);
|
|
1363
|
+
return a ||= this.#e.querySelector(`tbody tr[data-index="${n}"] td[data-col="${i}"]`), a;
|
|
1364
|
+
};
|
|
1365
|
+
#s = () => {
|
|
1366
|
+
let e = parseInt(this.#n.dataset.col, 10), t = parseInt(this.#r.dataset.index, 10), n = parseInt(this.#r.dataset.matrixRow, 10), r;
|
|
1367
|
+
for (let i = e - 1; i >= 0 && (r = this.#e.querySelector(`tbody tr[data-matrix-row="${n}"] td[data-col="${i}"]`), r ||= this.#e.querySelector(`tbody tr[data-index="${t}"] td[data-col="${i}"]`), !r); i--);
|
|
1368
|
+
return r;
|
|
1369
|
+
};
|
|
1370
|
+
#c = (e, t) => {
|
|
1371
|
+
let n = this.#e.querySelector(`tbody tr[data-matrix-row="${e}"]`);
|
|
1372
|
+
if (!n) return;
|
|
1373
|
+
let r = parseInt(n.dataset.index, 10), i = this.#e.querySelector(`tbody tr[data-matrix-row="${e}"] td[data-col="${t}"]`);
|
|
1374
|
+
return i || (this.#e.querySelectorAll(`tbody tr[data-matrix-row="${e}"] td`).forEach((e) => {
|
|
1375
|
+
let n = parseInt(e.dataset.col, 10), r = parseInt(e.colSpan, 10) || 1;
|
|
1376
|
+
t >= n && t < n + r && (i = e);
|
|
1377
|
+
}), i || (i = this.#e.querySelector(`tbody tr[data-index="${r}"] td[data-col="${t}"]`), i || this.#e.querySelectorAll(`tbody tr[data-index="${r}"] td`).forEach((e) => {
|
|
1378
|
+
let n = parseInt(e.dataset.col, 10), r = parseInt(e.colSpan, 10) || 1;
|
|
1379
|
+
t >= n && t < n + r && (i = e);
|
|
1380
|
+
}))), i;
|
|
1381
|
+
};
|
|
1382
|
+
#l = () => {
|
|
1383
|
+
let e = parseInt(this.#n.dataset.col, 10), t = parseInt(this.#r.dataset.matrixRow, 10);
|
|
1384
|
+
return this.#c(t - 1, e);
|
|
1385
|
+
};
|
|
1386
|
+
#u = () => {
|
|
1387
|
+
let e = parseInt(this.#n.dataset.col, 10), t = parseInt(this.#r.dataset.matrixRow, 10), n = parseInt(this.#n.rowSpan, 10) || 1;
|
|
1388
|
+
return this.#c(t + n, e);
|
|
1389
|
+
};
|
|
1390
|
+
#d = (e) => {
|
|
1391
|
+
let t = this.#e.querySelector(".ng-sheet-body");
|
|
1392
|
+
if (!t || !e) return !0;
|
|
1393
|
+
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = t.querySelector("thead")?.offsetHeight || 0;
|
|
1394
|
+
return n.top >= r.top + i;
|
|
1395
|
+
};
|
|
1396
|
+
#f = (e) => {
|
|
1397
|
+
let t = this.#e.querySelector(".ng-sheet-body");
|
|
1398
|
+
if (!t || !e) return !0;
|
|
1399
|
+
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
1400
|
+
return n.bottom <= r.bottom;
|
|
1401
|
+
};
|
|
1402
|
+
#p = (e) => {
|
|
1403
|
+
let t = this.#e.querySelector(".ng-container-body");
|
|
1404
|
+
if (!t || !e) return !0;
|
|
1405
|
+
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
1406
|
+
return n.left >= r.left;
|
|
1407
|
+
};
|
|
1408
|
+
#m = (e) => {
|
|
1409
|
+
let t = this.#e.querySelector(".ng-container-body");
|
|
1410
|
+
if (!t || !e) return !0;
|
|
1411
|
+
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
1412
|
+
return n.right <= r.right;
|
|
1413
|
+
};
|
|
1414
|
+
#h = () => {
|
|
1415
|
+
let e = this.#e.querySelector(".ng-sheet-body"), t = e.clientHeight - (e.querySelector("thead")?.offsetHeight || 0), n = this.#e.rowManager.getRowHeight();
|
|
1416
|
+
return Math.max(1, Math.floor(t / n));
|
|
1417
|
+
};
|
|
1418
|
+
#g() {
|
|
1419
|
+
this.#e.addEventListener("mousedown", (e) => {
|
|
1420
|
+
if (e.button !== 0) return;
|
|
1421
|
+
let t = e.target.closest("td, th");
|
|
1422
|
+
t && t.dataset.index !== void 0 && t.dataset.col !== void 0 && (this.currentCell = t);
|
|
1423
|
+
}), this.#e.addEventListener("keydown", (e) => {
|
|
1424
|
+
[
|
|
1425
|
+
"Enter",
|
|
1426
|
+
"Tab",
|
|
1427
|
+
"ArrowUp",
|
|
1428
|
+
"ArrowDown",
|
|
1429
|
+
"ArrowLeft",
|
|
1430
|
+
"ArrowRight"
|
|
1431
|
+
].includes(e.code) && this.moveCell(e);
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
}, x = 2, S = class {
|
|
1435
|
+
#e;
|
|
1436
|
+
#t;
|
|
1437
|
+
#n;
|
|
1438
|
+
#r;
|
|
1439
|
+
#i = null;
|
|
1440
|
+
#a = null;
|
|
1441
|
+
#o = null;
|
|
1442
|
+
#s = null;
|
|
1443
|
+
#c = 0;
|
|
1444
|
+
#l = 0;
|
|
1445
|
+
#u = 0;
|
|
1446
|
+
#d = 0;
|
|
1447
|
+
#f = 0;
|
|
1448
|
+
constructor(e) {
|
|
1449
|
+
this.#e = e, this.#t = e.getRootNode().host, this.#n = this.#e.querySelector("nine-table-col-resizer-panel"), this.#r = this.#n.querySelector(".resizer-overlay"), this.bindEvents();
|
|
1450
|
+
}
|
|
1451
|
+
destroy() {
|
|
1452
|
+
this.#e.removeEventListener("pointermove", this.#h), this.#e.removeEventListener("pointerdown", this.#g), this.#e.removeEventListener("dblclick", this.#b);
|
|
1453
|
+
}
|
|
1454
|
+
refreshLayout(e = "body") {
|
|
1455
|
+
let t = Array.from(this.#e.querySelectorAll(`.ng-container-${e}`));
|
|
1456
|
+
if (t.length !== 0) {
|
|
1457
|
+
if (e === "left" || e === "right" || !this.#e.isAutoFitCol && t[0].querySelector("table")?.getAttribute("auto-fit-col") !== "true") {
|
|
1458
|
+
let r = t[0].querySelector("table colgroup");
|
|
1459
|
+
if (!r) return;
|
|
1460
|
+
let i = 0, a = {};
|
|
1461
|
+
Array.from(r.querySelectorAll("col")).forEach((e) => {
|
|
1462
|
+
let t = e.getAttribute("data-col"), n = parseInt(e.getAttribute("width"), 10);
|
|
1463
|
+
isNaN(n) || (a[t] = n, i += n);
|
|
1464
|
+
}), t.forEach((r) => {
|
|
1465
|
+
let o = r.querySelectorAll("table");
|
|
1466
|
+
n.log("====================", t, e), e === "body" ? o.forEach((e) => {
|
|
1467
|
+
e.style.width = `${i}px`;
|
|
1468
|
+
}) : (r.style.flex = `0 0 ${i}px`, r.style.width = `${i}px`, r.style.minWidth = `${i}px`, r.style.maxWidth = `${i}px`, o.forEach((e) => {
|
|
1469
|
+
e.style.width = `${i}px`, e.style.minWidth = `${i}px`, e.style.maxWidth = `${i}px`, Object.entries(a).forEach(([t, n]) => {
|
|
1470
|
+
e.querySelectorAll(`th[data-col="${t}"], td[data-col="${t}"]`).forEach((e) => {
|
|
1471
|
+
e.style.width = `${n}px`, e.style.minWidth = `${n}px`, e.style.maxWidth = `${n}px`;
|
|
1472
|
+
});
|
|
1473
|
+
});
|
|
1474
|
+
}));
|
|
1475
|
+
});
|
|
1476
|
+
} else t.forEach((e) => {
|
|
1477
|
+
e.querySelectorAll("table").forEach((e) => {});
|
|
1478
|
+
});
|
|
1479
|
+
this.#e.querySelector("nine-table-hscrollbar")?.refresh();
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
setColumnWidth(e, t, r = null) {
|
|
1483
|
+
n.log("setColumnWidth");
|
|
1484
|
+
let i = [];
|
|
1485
|
+
if (i = Array.from(this.#e.querySelectorAll(`table colgroup col[data-col="${e}"]`)), i.length === 0) return;
|
|
1486
|
+
let a = i[0].closest(".ng-container-left, .ng-container-body, .ng-container-right"), o = r || (a?.classList.contains("ng-container-left") ? "left" : a?.classList.contains("ng-container-right") ? "right" : "body");
|
|
1487
|
+
i.forEach((e) => {
|
|
1488
|
+
e.setAttribute("width", t), e.style.width = `${t}px`, n.log(e, t);
|
|
1489
|
+
});
|
|
1490
|
+
let s = this.#e.sourceTable?.querySelector(`colgroup col[data-col="${e}"]`);
|
|
1491
|
+
s && (s.setAttribute("width", t), s.style.width = `${t}px`), this.refreshLayout(o), (o === "left" || o === "right") && this.refreshLayout("body"), this.#e.rowManager?.refresh();
|
|
1492
|
+
}
|
|
1493
|
+
#p(e) {
|
|
1494
|
+
if (this.#e.isAutoFitCol) return !0;
|
|
1495
|
+
let t = e?.closest("table");
|
|
1496
|
+
return !!(t && t.getAttribute("auto-fit-col") === "true");
|
|
1497
|
+
}
|
|
1498
|
+
bindEvents() {
|
|
1499
|
+
this.#e.addEventListener("pointermove", this.#h), this.#e.addDebounseEventListener("dblclick", this.#b, "pointerdown", this.#g);
|
|
1500
|
+
}
|
|
1501
|
+
#m(e) {
|
|
1502
|
+
let t = e.closest(".ng-container-left, .ng-container-body, .ng-container-right");
|
|
1503
|
+
return t ? t.classList.contains("ng-container-left") ? "left" : t.classList.contains("ng-container-right") ? "right" : "body" : null;
|
|
1504
|
+
}
|
|
1505
|
+
#h = (e) => {
|
|
1506
|
+
let t = e.target.closest("thead");
|
|
1507
|
+
if (!t) return;
|
|
1508
|
+
let n = e.target.closest("th, td");
|
|
1509
|
+
if (t.querySelectorAll(".resizable-edge").forEach((e) => {
|
|
1510
|
+
e !== n && e.classList.remove("resizable-edge");
|
|
1511
|
+
}), !n || n.dataset.col === void 0 || n.getAttribute("collapsed") === "true") return;
|
|
1512
|
+
let r = n.getBoundingClientRect(), i = e.clientX - r.left, a = i <= x, o = r.width - i <= x;
|
|
1513
|
+
if (a) {
|
|
1514
|
+
let e = n.previousElementSibling;
|
|
1515
|
+
if (!e || e.getAttribute("collapsed") === "true") {
|
|
1516
|
+
n.classList.remove("resizable-edge");
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
a || o ? n.classList.add("resizable-edge") : n.classList.remove("resizable-edge");
|
|
1521
|
+
};
|
|
1522
|
+
#g = (e) => {
|
|
1523
|
+
if (n.log("onPointerDown"), !e.actualTarget.closest("thead")) return;
|
|
1524
|
+
let t = e.actualTarget.closest("th, td");
|
|
1525
|
+
if (n.log(t, e.actualTarget), !t || !t.classList.contains("resizable-edge")) return;
|
|
1526
|
+
e.preventDefault();
|
|
1527
|
+
let r = t.getBoundingClientRect(), i = e.clientX - r.left, a = t;
|
|
1528
|
+
if (i <= x) {
|
|
1529
|
+
let e = t.previousElementSibling;
|
|
1530
|
+
if (e && e.dataset.col !== void 0 && e.getAttribute("collapsed") !== "true") a = e;
|
|
1531
|
+
else if (!t.previousElementSibling) return;
|
|
1532
|
+
}
|
|
1533
|
+
this.#s = a, this.#o = this.#m(a);
|
|
1534
|
+
let o = this.#e.querySelector(`.ng-container-${this.#o}`);
|
|
1535
|
+
if (!o) return;
|
|
1536
|
+
let s = parseInt(a.dataset.col, 10), c = a.colSpan || 1;
|
|
1537
|
+
if (this.#i = s + c - 1, this.#p(a)) {
|
|
1538
|
+
this.#a = this.#i + 1;
|
|
1539
|
+
let e = o.querySelector(`col[data-col="${this.#a}"]`);
|
|
1540
|
+
e ? this.#u = parseInt(e.getAttribute("width"), 10) || 100 : this.#a = null;
|
|
1541
|
+
} else this.#a = null;
|
|
1542
|
+
let l = a.getBoundingClientRect(), u = this.#e.getBoundingClientRect();
|
|
1543
|
+
this.#d = l.width, this.#f = l.left - u.left;
|
|
1544
|
+
let d = o.querySelector(`col[data-col="${this.#i}"]`)?.getAttribute("width");
|
|
1545
|
+
this.#l = d && !isNaN(parseInt(d, 10)) ? parseInt(d, 10) : l.width / c, this.#c = e.clientX, this.#n && (this.#n.classList.add("active"), this.#_(e.clientX)), window.addEventListener("pointermove", this.#v), window.addEventListener("pointerup", this.#y, { once: !0 });
|
|
1546
|
+
};
|
|
1547
|
+
#_(e) {
|
|
1548
|
+
let t = e - this.#c, n = this.#p(this.#s);
|
|
1549
|
+
if (n && this.#a !== null) {
|
|
1550
|
+
let e = this.#u - 16, n = -(this.#l - 16);
|
|
1551
|
+
t = Math.max(n, Math.min(t, e));
|
|
1552
|
+
}
|
|
1553
|
+
let r = Math.max(16, this.#l + t), i = e - this.#s.getBoundingClientRect().left;
|
|
1554
|
+
if (n && this.#a !== null) {
|
|
1555
|
+
let e = this.#d + (this.#u - 16);
|
|
1556
|
+
i = Math.min(i, e);
|
|
1557
|
+
}
|
|
1558
|
+
let a = Math.max(16, i);
|
|
1559
|
+
this.#n && (this.#n.style.setProperty("--col-resizer-tooltip-left", `${this.#f}px`), this.#n.style.setProperty("--col-resizer-tooltip-width", `${a}px`));
|
|
1560
|
+
let o = this.#r?.querySelector(".size-badge");
|
|
1561
|
+
o && (o.textContent = `${Math.round(r)}px`);
|
|
1562
|
+
}
|
|
1563
|
+
#v = (e) => {
|
|
1564
|
+
n.log(e), this.#_(e.clientX);
|
|
1565
|
+
};
|
|
1566
|
+
#y = (e) => {
|
|
1567
|
+
window.removeEventListener("pointermove", this.#v);
|
|
1568
|
+
let t = e.clientX - this.#c, n = this.#p(this.#s), r = 0;
|
|
1569
|
+
if (n && this.#a !== null) {
|
|
1570
|
+
let e = Math.max(16, this.#l + t), n = this.#l + this.#u - e;
|
|
1571
|
+
n < 16 && (n = 16, e = this.#l + this.#u - 16), this.setColumnWidth(this.#i, e, this.#o), this.setColumnWidth(this.#a, n, this.#o), r = e;
|
|
1572
|
+
} else {
|
|
1573
|
+
let e = Math.max(16, this.#l + t);
|
|
1574
|
+
this.#i !== null && this.#o && (this.setColumnWidth(this.#i, e, this.#o), r = e);
|
|
1575
|
+
}
|
|
1576
|
+
if (this.#s) {
|
|
1577
|
+
let e = this.#s;
|
|
1578
|
+
e.getAttribute("collapsed") !== "true" && r > 20 && (e.dataset.expandWidth = String(r));
|
|
1579
|
+
}
|
|
1580
|
+
this.#n && (this.#r?.classList.add("fade-out"), setTimeout(() => {
|
|
1581
|
+
this.#n.classList.remove("active"), this.#r?.classList.remove("fade-out");
|
|
1582
|
+
}, 150)), this.#i = null, this.#a = null, this.#o = null, this.#s = null;
|
|
1583
|
+
};
|
|
1584
|
+
#b = (e) => {
|
|
1585
|
+
let t = e.target.closest("th, td");
|
|
1586
|
+
if (!t || !t.classList.contains("resizable-edge")) return;
|
|
1587
|
+
let r = t.getBoundingClientRect();
|
|
1588
|
+
e.clientX - r.left <= x && (t = t.previousElementSibling);
|
|
1589
|
+
let i = parseInt(t.dataset.col, 10), a = this.#e.querySelector(`tbody.body [data-col="${i}"]`);
|
|
1590
|
+
if (!a || !a.dataset.bind || a.classList.contains("CELL-RADIO")) return;
|
|
1591
|
+
let o = 0;
|
|
1592
|
+
Array.from(a.firstElementChild.children).forEach((e) => {
|
|
1593
|
+
switch (e.tagName) {
|
|
1594
|
+
case "SPAN":
|
|
1595
|
+
o += 8;
|
|
1596
|
+
break;
|
|
1597
|
+
case "DIV":
|
|
1598
|
+
o += 8;
|
|
1599
|
+
break;
|
|
1600
|
+
case "BUTTON":
|
|
1601
|
+
o += 32;
|
|
1602
|
+
break;
|
|
1603
|
+
case "SELECT":
|
|
1604
|
+
o += 32;
|
|
1605
|
+
break;
|
|
1606
|
+
case "INPUT": switch ((e.type || "text").toLowerCase()) {
|
|
1607
|
+
case "checkbox":
|
|
1608
|
+
case "radio":
|
|
1609
|
+
o += 12;
|
|
1610
|
+
break;
|
|
1611
|
+
case "button":
|
|
1612
|
+
case "submit":
|
|
1613
|
+
case "reset":
|
|
1614
|
+
case "image":
|
|
1615
|
+
o += 16;
|
|
1616
|
+
break;
|
|
1617
|
+
case "color":
|
|
1618
|
+
case "file":
|
|
1619
|
+
case "range":
|
|
1620
|
+
o += 24;
|
|
1621
|
+
break;
|
|
1622
|
+
case "hidden":
|
|
1623
|
+
o += 0;
|
|
1624
|
+
break;
|
|
1625
|
+
default: o += 16;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}), n.log(o);
|
|
1629
|
+
let s = this.#t.fields.get().indexOf(a.dataset.bind), c = window.getComputedStyle(a).font || "12px sans-serif", l = t.innerText || "", u = (nine.measureTextSize(l, c).width || 0) + 16;
|
|
1630
|
+
this.#t.execute(() => {
|
|
1631
|
+
this.#e.view.getArray().forEach((e, t) => {
|
|
1632
|
+
let n = String(a.dataset.expr ? this.#t.exprEngine.evaluate(a.dataset.expr, e, t) : e.v[s] ?? "").trim(), r = nine.measureTextSize(n, c);
|
|
1633
|
+
r.width && r.width > u && (u = r.width);
|
|
1634
|
+
});
|
|
1635
|
+
let e = Math.max(32, Math.min(400, Math.ceil(u) + o));
|
|
1636
|
+
this.setColumnWidth(a.dataset.col, e, this.#m(t));
|
|
1637
|
+
});
|
|
1638
|
+
};
|
|
1639
|
+
}, C = class extends HTMLElement {
|
|
1640
|
+
constructor() {
|
|
1641
|
+
super();
|
|
1642
|
+
}
|
|
1643
|
+
connectedCallback() {
|
|
1644
|
+
this.#e();
|
|
1645
|
+
}
|
|
1646
|
+
#e = () => {
|
|
1647
|
+
this.innerHTML = "\n <div class=\"resizer-overlay\">\n <span class=\"size-badge\">0px</span>\n </div>\n ";
|
|
1648
|
+
};
|
|
1649
|
+
};
|
|
1650
|
+
customElements.get("nine-table-col-resizer-panel") || customElements.define("nine-table-col-resizer-panel", C);
|
|
1651
|
+
// src/col/ColMover.js
|
|
1652
|
+
var w = class {
|
|
1653
|
+
#e;
|
|
1654
|
+
#t;
|
|
1655
|
+
#n;
|
|
1656
|
+
#r = !1;
|
|
1657
|
+
#i = null;
|
|
1658
|
+
#a = null;
|
|
1659
|
+
#o = null;
|
|
1660
|
+
#s = 0;
|
|
1661
|
+
#c = null;
|
|
1662
|
+
constructor(e) {
|
|
1663
|
+
this.#e = e, this.#t = this.#e.querySelector(".ng-col-mover-grip"), this.#n = this.#e.querySelector(".ng-col-mover-indi"), this.bindEvents();
|
|
1664
|
+
}
|
|
1665
|
+
bindEvents() {
|
|
1666
|
+
this.#e.addEventListener("pointerdown", this.#p);
|
|
1667
|
+
}
|
|
1668
|
+
#l() {
|
|
1669
|
+
let e = this.#e.getRootNode()?.host;
|
|
1670
|
+
return this.#e.getAttribute("col-movable") === "true" || e?.getAttribute("col-movable") === "true";
|
|
1671
|
+
}
|
|
1672
|
+
#u(e, t) {
|
|
1673
|
+
let n = this.#e.getRootNode(), r = n.elementFromPoint ? n.elementFromPoint(e, t) : document.elementFromPoint(e, t);
|
|
1674
|
+
for (; r && r.shadowRoot && r.shadowRoot.elementFromPoint;) {
|
|
1675
|
+
let n = r.shadowRoot.elementFromPoint(e, t);
|
|
1676
|
+
if (!n || n === r) break;
|
|
1677
|
+
r = n;
|
|
1678
|
+
}
|
|
1679
|
+
return r;
|
|
1680
|
+
}
|
|
1681
|
+
#d(e) {
|
|
1682
|
+
if (!e || e.dataset.col === void 0) return null;
|
|
1683
|
+
let t = parseInt(e.dataset.col, 10), n = e.colSpan || 1, r = t + n - 1, i = e.closest("tr")?.sectionRowIndex ?? 0, a = e.closest("table");
|
|
1684
|
+
if (!a) return {
|
|
1685
|
+
startCol: t,
|
|
1686
|
+
colSpan: n,
|
|
1687
|
+
endCol: r,
|
|
1688
|
+
rowIndex: i,
|
|
1689
|
+
isGroup: !1,
|
|
1690
|
+
parentGroupRange: null,
|
|
1691
|
+
isValidGroup: !0
|
|
1692
|
+
};
|
|
1693
|
+
let o = a.querySelectorAll("thead th, thead td"), s = !1, c = !0, l = null;
|
|
1694
|
+
for (let a of o) {
|
|
1695
|
+
if (a === e || a.dataset.col === void 0) continue;
|
|
1696
|
+
let o = parseInt(a.dataset.col, 10), u = a.colSpan || 1, d = o + u - 1;
|
|
1697
|
+
(a.closest("tr")?.sectionRowIndex ?? 0) < i && o <= t && d >= r && u > n && (l ? (l.startCol = Math.max(l.startCol, o), l.endCol = Math.min(l.endCol, d)) : l = {
|
|
1698
|
+
startCol: o,
|
|
1699
|
+
endCol: d
|
|
1700
|
+
}), d < t || o > r || (o >= t && d <= r ? u < n && (s = !0) : (o < t || d > r) && (o <= t && d >= r || (c = !1)));
|
|
1701
|
+
}
|
|
1702
|
+
let u = s && c;
|
|
1703
|
+
return {
|
|
1704
|
+
startCol: t,
|
|
1705
|
+
colSpan: u ? n : 1,
|
|
1706
|
+
endCol: u ? r : t,
|
|
1707
|
+
rowIndex: i,
|
|
1708
|
+
isGroup: u,
|
|
1709
|
+
parentGroupRange: l,
|
|
1710
|
+
isValidGroup: c
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
#f(e) {
|
|
1714
|
+
let t = this.#d(e);
|
|
1715
|
+
if (!t) return null;
|
|
1716
|
+
let { startCol: n, endCol: r, isGroup: i } = t, a = e.closest("table");
|
|
1717
|
+
if (!a) return null;
|
|
1718
|
+
let o = Infinity, s = -Infinity, c = Infinity, l = -Infinity, u = [];
|
|
1719
|
+
if (a.querySelectorAll("thead th, thead td").forEach((t) => {
|
|
1720
|
+
if (t.dataset.col === void 0) return;
|
|
1721
|
+
let a = parseInt(t.dataset.col, 10), d = a + (t.colSpan || 1) - 1;
|
|
1722
|
+
if (i ? a >= n && d <= r : t === e) {
|
|
1723
|
+
let e = t.getBoundingClientRect();
|
|
1724
|
+
o = Math.min(o, e.left), s = Math.max(s, e.right), c = Math.min(c, e.top), l = Math.max(l, e.bottom);
|
|
1725
|
+
let n = window.getComputedStyle(t);
|
|
1726
|
+
u.push({
|
|
1727
|
+
el: t,
|
|
1728
|
+
rect: e,
|
|
1729
|
+
style: n
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
}), u.length === 0) return null;
|
|
1733
|
+
let d = s - o, f = l - c, p = document.createElement("div");
|
|
1734
|
+
return p.className = "grip-header-content", p.style.position = "relative", p.style.width = `${d}px`, p.style.height = `${f}px`, u.forEach(({ el: e, rect: t, style: n }) => {
|
|
1735
|
+
let r = e.cloneNode(!0);
|
|
1736
|
+
r.style.position = "absolute", r.style.left = `${t.left - o}px`, r.style.top = `${t.top - c}px`, r.style.width = `${t.width}px`, r.style.minWidth = `${t.width}px`, r.style.maxWidth = "none", r.style.height = `${t.height}px`, r.style.boxSizing = "border-box", r.style.margin = "0", r.style.backgroundColor = n.backgroundColor !== "transparent" && n.backgroundColor !== "rgba(0, 0, 0, 0)" ? n.backgroundColor : "#f9fafb", r.style.color = n.color, r.style.font = n.font, r.style.fontWeight = n.fontWeight, r.style.fontSize = n.fontSize, r.style.textAlign = n.textAlign, r.style.padding = n.padding, r.style.border = n.border, r.style.borderRight = n.borderRight, r.style.borderBottom = n.borderBottom, r.style.display = "flex", r.style.alignItems = "center", r.style.justifyContent = n.textAlign === "center" ? "center" : n.textAlign === "right" ? "flex-end" : "flex-start", p.appendChild(r);
|
|
1737
|
+
}), {
|
|
1738
|
+
element: p,
|
|
1739
|
+
bounds: {
|
|
1740
|
+
left: o,
|
|
1741
|
+
right: s,
|
|
1742
|
+
top: c,
|
|
1743
|
+
bottom: l,
|
|
1744
|
+
width: d,
|
|
1745
|
+
height: f
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
#p = (e) => {
|
|
1750
|
+
if (!this.#l() || !e.target.closest(".ng-sheet-header")) return;
|
|
1751
|
+
let t = e.target.closest("th, td");
|
|
1752
|
+
if (!t || t.classList.contains("resizable-edge") || ["INPUT", "BUTTON"].includes(e.target.tagName) || t.dataset.col === void 0) return;
|
|
1753
|
+
e.preventDefault();
|
|
1754
|
+
let n = e.clientX, r = e.clientY, i = () => {
|
|
1755
|
+
this.#c &&= (clearTimeout(this.#c), null), window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", i), window.removeEventListener("pointercancel", i);
|
|
1756
|
+
}, a = (e) => {
|
|
1757
|
+
Math.hypot(e.clientX - n, e.clientY - r) > 5 && i();
|
|
1758
|
+
};
|
|
1759
|
+
this.#c = setTimeout(() => {
|
|
1760
|
+
i(), this.#m(e, t);
|
|
1761
|
+
}, 500), window.addEventListener("pointermove", a), window.addEventListener("pointerup", i, { once: !0 }), window.addEventListener("pointercancel", i, { once: !0 });
|
|
1762
|
+
};
|
|
1763
|
+
#m(e, t) {
|
|
1764
|
+
if (this.#r) return;
|
|
1765
|
+
let n = this.#f(t);
|
|
1766
|
+
if (!n) return;
|
|
1767
|
+
this.#r = !0, this.#i = t, this.#a = parseInt(t.dataset.col, 10);
|
|
1768
|
+
let r = this.#e.getBoundingClientRect(), { bounds: i, element: a } = n;
|
|
1769
|
+
if (this.#s = e.clientX - i.left, this.#t) {
|
|
1770
|
+
this.#t.replaceChildren(a);
|
|
1771
|
+
let t = i.top - r.top, n = r.height - t;
|
|
1772
|
+
this.#t.style.width = `${i.width}px`, this.#t.style.height = `${n}px`, this.#t.style.top = `${t}px`, this.#t.style.display = "block", this.#g(e.clientX);
|
|
1773
|
+
}
|
|
1774
|
+
document.body.style.cursor = "move", window.addEventListener("pointermove", this.#h), window.addEventListener("pointerup", this.#_, { once: !0 });
|
|
1775
|
+
}
|
|
1776
|
+
#h = (e) => {
|
|
1777
|
+
if (!this.#r) return;
|
|
1778
|
+
this.#g(e.clientX), this.#t && (this.#t.style.pointerEvents = "none"), this.#n && (this.#n.style.pointerEvents = "none");
|
|
1779
|
+
let t = this.#u(e.clientX, e.clientY)?.closest(".ng-sheet-header th, .ng-sheet-header td");
|
|
1780
|
+
if (t && t.dataset.col !== void 0) {
|
|
1781
|
+
let n = parseInt(t.dataset.col, 10), r = this.#e.getBoundingClientRect(), i = t.closest("table"), a = Infinity, o = -Infinity;
|
|
1782
|
+
if (i && i.querySelectorAll("thead th, thead td").forEach((e) => {
|
|
1783
|
+
if (e.dataset.col === void 0) return;
|
|
1784
|
+
let t = parseInt(e.dataset.col, 10), r = t + (e.colSpan || 1) - 1;
|
|
1785
|
+
if (t <= n && r >= n) {
|
|
1786
|
+
let t = e.getBoundingClientRect();
|
|
1787
|
+
a = Math.min(a, t.left), o = Math.max(o, t.right);
|
|
1788
|
+
}
|
|
1789
|
+
}), a === Infinity) {
|
|
1790
|
+
let e = t.getBoundingClientRect();
|
|
1791
|
+
a = e.left, o = e.right;
|
|
1792
|
+
}
|
|
1793
|
+
let s = a + (o - a) / 2, c = 0, l = 0;
|
|
1794
|
+
e.clientX < s ? (c = n, l = a - r.left) : (c = n + (t.colSpan || 1), l = o - r.left);
|
|
1795
|
+
let u = this.#d(this.#i), d = u.colSpan, f = u.rowIndex, p = f + (this.#i.rowSpan || 1) - 1, m = t.closest("tr")?.sectionRowIndex ?? 0, h = m + (t.rowSpan || 1) - 1, g = !(p < m || f > h), _ = !1;
|
|
1796
|
+
if (u.parentGroupRange) {
|
|
1797
|
+
let { startCol: e, endCol: t } = u.parentGroupRange;
|
|
1798
|
+
(c < e || c + d - 1 > t) && (_ = !0);
|
|
1799
|
+
}
|
|
1800
|
+
let v = !1;
|
|
1801
|
+
if (i) {
|
|
1802
|
+
let e = i.querySelectorAll("thead th[colspan], thead td[colspan]");
|
|
1803
|
+
for (let t of e) {
|
|
1804
|
+
if (t === this.#i) continue;
|
|
1805
|
+
let e = t.closest("tr")?.sectionRowIndex ?? 0, n = e + (t.rowSpan || 1) - 1;
|
|
1806
|
+
if (p < e || f > n) continue;
|
|
1807
|
+
let r = parseInt(t.dataset.col, 10), i = r + (t.colSpan || 1) - 1;
|
|
1808
|
+
if (c > r && c < i + 1) {
|
|
1809
|
+
v = !0;
|
|
1810
|
+
break;
|
|
1811
|
+
}
|
|
1812
|
+
let a = c + d - 1;
|
|
1813
|
+
if (c > r && c <= i && a > i || c < r && a >= r && a < i) {
|
|
1814
|
+
v = !0;
|
|
1815
|
+
break;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
let y = c >= u.startCol && c <= u.endCol + 1;
|
|
1820
|
+
if (!g || y || _ || v || !u.isValidGroup) this.#o = null, this.#n && (this.#n.style.display = "none"), this.#t && this.#t.classList.add("invalid");
|
|
1821
|
+
else if (this.#o = c, this.#t && this.#t.classList.remove("invalid"), this.#n) {
|
|
1822
|
+
let e = t.closest(".ng-sheet-header").getBoundingClientRect().top - r.top, n = r.height - e;
|
|
1823
|
+
this.#n.style.top = `${e}px`, this.#n.style.height = `${n}px`, this.#n.style.left = `${l - 1}px`, this.#n.style.display = "block";
|
|
1824
|
+
}
|
|
1825
|
+
} else this.#n && (this.#n.style.display = "none"), this.#t && this.#t.classList.add("invalid"), this.#o = null;
|
|
1826
|
+
};
|
|
1827
|
+
#g(e) {
|
|
1828
|
+
if (!this.#t) return;
|
|
1829
|
+
let t = e - this.#e.getBoundingClientRect().left - this.#s;
|
|
1830
|
+
this.#t.style.left = `${t}px`;
|
|
1831
|
+
}
|
|
1832
|
+
#_ = (e) => {
|
|
1833
|
+
this.#r && (window.removeEventListener("pointermove", this.#h), document.body.style.cursor = "", this.#t && (this.#t.style.display = "none", this.#t.replaceChildren()), this.#n && (this.#n.style.display = "none"), this.#o !== null && this.#a !== null && this.#o !== this.#a && this.#o !== this.#a + 1 && this.moveColumn(this.#a, this.#o), this.#r = !1, this.#i = null, this.#a = null, this.#o = null);
|
|
1834
|
+
};
|
|
1835
|
+
moveColumn(e, t) {
|
|
1836
|
+
n.log(this.#e.sourceTable.cloneNode(!0));
|
|
1837
|
+
let r = this.#e.sourceTable.querySelector("colgroup"), i = r.querySelector(`col[data-col="${t}"]`), a = this.#d(this.#i);
|
|
1838
|
+
if (!a || !a.isValidGroup) return;
|
|
1839
|
+
let o = a.colSpan, s = (t) => t >= e && t < e + o, c = this.#e.querySelector(`.ng-sheet-body-content col[data-col="${t}"]`), l = c?.closest(".ng-container-left") ? "left" : c?.closest(".ng-container-right") ? "right" : null;
|
|
1840
|
+
r.querySelectorAll("col").forEach((e) => {
|
|
1841
|
+
s(parseInt(e.getAttribute("data-col"), 10)) && (l ? e.setAttribute("fixed", l) : e.removeAttribute("fixed"), r.insertBefore(e, i));
|
|
1842
|
+
}), [
|
|
1843
|
+
"thead",
|
|
1844
|
+
"tbody",
|
|
1845
|
+
"tfoot"
|
|
1846
|
+
].forEach((e) => {
|
|
1847
|
+
this.#e.sourceTable.querySelectorAll(`${e} tr`).forEach((e) => {
|
|
1848
|
+
let n = Array.from(e.children), r = n.find((e) => parseInt(e.dataset.col, 10) >= t);
|
|
1849
|
+
n.forEach((t) => {
|
|
1850
|
+
s(parseInt(t.dataset.col, 10)) && e.insertBefore(t, r || null);
|
|
1851
|
+
});
|
|
1852
|
+
});
|
|
1853
|
+
}), this.#e.recompileAndRefresh();
|
|
1854
|
+
}
|
|
1855
|
+
destroy() {
|
|
1856
|
+
this.#e.removeEventListener("pointerdown", this.#p);
|
|
1857
|
+
}
|
|
1858
|
+
}, T = class {
|
|
1859
|
+
#e;
|
|
1860
|
+
constructor(e) {
|
|
1861
|
+
this.#e = e;
|
|
1862
|
+
}
|
|
1863
|
+
getFixState(e, t) {
|
|
1864
|
+
if (!e || !t) return "none";
|
|
1865
|
+
let n = e.closest(".ng-container-left, .ng-container-right, .ng-container-body");
|
|
1866
|
+
if (n?.classList.contains("ng-container-left")) return "left";
|
|
1867
|
+
if (n?.classList.contains("ng-container-right")) return "right";
|
|
1868
|
+
let r = parseInt(e.dataset.col, 10);
|
|
1869
|
+
if (!isNaN(r)) {
|
|
1870
|
+
let e = t.querySelector(`colgroup col[data-col="${r}"]`)?.getAttribute("fixed");
|
|
1871
|
+
if (e) return e;
|
|
1872
|
+
}
|
|
1873
|
+
return "none";
|
|
1874
|
+
}
|
|
1875
|
+
canFixColumn(e, t) {
|
|
1876
|
+
if (!e || e.tagName !== "TH" || !t) return !1;
|
|
1877
|
+
let n = parseInt(e.dataset.col, 10), r = e.colSpan || 1;
|
|
1878
|
+
if (isNaN(n)) return !1;
|
|
1879
|
+
let i = n + r - 1, a = Array.from(t.querySelectorAll("thead tr"));
|
|
1880
|
+
if (a.length <= 1) return !0;
|
|
1881
|
+
for (let e of a) {
|
|
1882
|
+
let t = Array.from(e.querySelectorAll("th, td")), n = !1;
|
|
1883
|
+
for (let e of t) {
|
|
1884
|
+
let t = parseInt(e.dataset.col, 10), r = t + (e.colSpan || 1) - 1;
|
|
1885
|
+
if (t <= i && i < r) return !1;
|
|
1886
|
+
if (r === i) {
|
|
1887
|
+
n = !0;
|
|
1888
|
+
break;
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
if (!n) return !1;
|
|
1892
|
+
}
|
|
1893
|
+
return !0;
|
|
1894
|
+
}
|
|
1895
|
+
executeFixToggle(e, t, r = "left") {
|
|
1896
|
+
if (!this.#e || !t) return;
|
|
1897
|
+
let i = this.#e.sourceTable;
|
|
1898
|
+
if (!i) return;
|
|
1899
|
+
let a = parseInt(t.dataset.col, 10), o = t.colSpan || 1, s = a + o - 1;
|
|
1900
|
+
if (isNaN(s)) return;
|
|
1901
|
+
let c = i.querySelector("colgroup");
|
|
1902
|
+
if (!c) return;
|
|
1903
|
+
let l = Array.from(c.querySelectorAll("col"));
|
|
1904
|
+
if (e === "fix-column") l.forEach((e) => {
|
|
1905
|
+
parseInt(e.getAttribute("data-col"), 10) <= s && e.setAttribute("fixed", r);
|
|
1906
|
+
}), [
|
|
1907
|
+
"thead",
|
|
1908
|
+
"tbody",
|
|
1909
|
+
"tfoot"
|
|
1910
|
+
].forEach((e) => {
|
|
1911
|
+
i.querySelectorAll(`${e} tr`).forEach((e) => {
|
|
1912
|
+
Array.from(e.children).forEach((e) => {
|
|
1913
|
+
let t = parseInt(e.dataset.col, 10);
|
|
1914
|
+
!isNaN(t) && t <= s && e.setAttribute("fixed", r);
|
|
1915
|
+
});
|
|
1916
|
+
});
|
|
1917
|
+
});
|
|
1918
|
+
else if (e === "unfix-column") {
|
|
1919
|
+
let e = a, t = a + o - 1;
|
|
1920
|
+
[
|
|
1921
|
+
"thead",
|
|
1922
|
+
"tbody",
|
|
1923
|
+
"tfoot"
|
|
1924
|
+
].forEach((n) => {
|
|
1925
|
+
i.querySelectorAll(`${n} tr`).forEach((n, r) => {
|
|
1926
|
+
Array.from(n.children).forEach((i) => {
|
|
1927
|
+
let o = parseInt(i.dataset.col, 10), c = o + (i.colSpan || 1) - 1, l = i.rowSpan || 1;
|
|
1928
|
+
(n.sectionRowIndex ?? r) + l - 1 < i.closest("tr").sectionRowIndex || i.closest("tr").sectionRowIndex + l - 1, c < a || o > s || (e = Math.min(e, o), t = Math.max(t, c));
|
|
1929
|
+
});
|
|
1930
|
+
});
|
|
1931
|
+
}), l.forEach((t) => {
|
|
1932
|
+
parseInt(t.getAttribute("data-col"), 10) >= e && t.removeAttribute("fixed");
|
|
1933
|
+
});
|
|
1934
|
+
let n = !1;
|
|
1935
|
+
l.forEach((e) => {
|
|
1936
|
+
n ? e.removeAttribute("fixed") : e.getAttribute("fixed") || (n = !0);
|
|
1937
|
+
}), [
|
|
1938
|
+
"thead",
|
|
1939
|
+
"tbody",
|
|
1940
|
+
"tfoot"
|
|
1941
|
+
].forEach((e) => {
|
|
1942
|
+
i.querySelectorAll(`${e} tr`).forEach((e) => {
|
|
1943
|
+
Array.from(e.children).forEach((e) => {
|
|
1944
|
+
let t = parseInt(e.dataset.col, 10);
|
|
1945
|
+
if (isNaN(t)) return;
|
|
1946
|
+
let n = l.find((e) => parseInt(e.getAttribute("data-col"), 10) === t)?.getAttribute("fixed");
|
|
1947
|
+
n ? e.setAttribute("fixed", n) : e.removeAttribute("fixed");
|
|
1948
|
+
});
|
|
1949
|
+
});
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
n.log(this.#e.sourceTable), this.#e.recompileAndRefresh?.();
|
|
1953
|
+
}
|
|
1954
|
+
}, E = class extends HTMLElement {
|
|
1955
|
+
#e;
|
|
1956
|
+
#t;
|
|
1957
|
+
#n;
|
|
1958
|
+
#r;
|
|
1959
|
+
#i;
|
|
1960
|
+
currentCol = null;
|
|
1961
|
+
connectedCallback() {
|
|
1962
|
+
this.#a(), document.addEventListener("mousedown", this.#s);
|
|
1963
|
+
}
|
|
1964
|
+
#a = () => {
|
|
1965
|
+
this.#o(), this.#e = this.closest("nine-table-sheet"), this.#t = this.getRootNode().host, this.#n = this.querySelector("nine-table-simple"), setTimeout(() => {
|
|
1966
|
+
this.#r = this.#n.shadowRoot.querySelector("nine-table-sheet");
|
|
1967
|
+
}), this.querySelector(".search-box").addEventListener("focusin", (e) => {
|
|
1968
|
+
e.stopPropagation();
|
|
1969
|
+
}), this.querySelector(".search-box").addEventListener("input", this.#u), this.querySelector("#chkSelectAll").addEventListener("change", this.#d), this.querySelector("#btnOk").addEventListener("click", this.#l);
|
|
1970
|
+
};
|
|
1971
|
+
#o = () => {
|
|
1972
|
+
this.innerHTML = "\n <input type=\"text\" class=\"search-box\" placeholder=\"Search...\">\n \n <nine-table-simple class=\"filter-list\" theme=\"simple\">\n <table auto-fit-col=\"true\">\n <colgroup>\n <col width=\"32\" fixed=\"left\" />\n <col width=\"180\" />\n <col width=\"0\" fixed=\"right\"/>\n </colgroup>\n <tbody>\n <tr>\n <td cell-type=\"checkbox\" data-bind=\"CHK\"></td>\n <td data-bind=\"DATA2\" html=\"true\"></td>\n <td data-bind=\"DATA\"></td>\n </tr>\n </tbody>\n </table>\n </nine-table-simple>\n\n <div class=\"footer-section\">\n <div class=\"footer-btns\">\n <label><input type=\"checkbox\" id=\"chkSelectAll\" checked> Select All</label>\n <div class=\"btn-group\">\n <button id=\"btnOk\">Apply</button>\n </div>\n </div>\n </div>\n ";
|
|
1973
|
+
};
|
|
1974
|
+
open(e) {
|
|
1975
|
+
this.#i = e;
|
|
1976
|
+
let t = e.closest("th, td");
|
|
1977
|
+
this.currentCol = t?.dataset.col;
|
|
1978
|
+
let n = t.getBoundingClientRect(), r = this.#e.getBoundingClientRect(), i = this.offsetWidth || 240, a = n.right - r.left - i, o = n.bottom - r.top;
|
|
1979
|
+
a < 0 && (a = Math.max(0, n.left - r.left)), this.style.left = `${a}px`, this.style.top = `${o}px`;
|
|
1980
|
+
let s = this.querySelector(".search-box");
|
|
1981
|
+
s.value = "", this.classList.add("active"), this.classList.add("loading"), setTimeout(() => {
|
|
1982
|
+
try {
|
|
1983
|
+
this.#c(), this.#r.rowManager.scrollToDataRow(0), s.focus();
|
|
1984
|
+
} finally {
|
|
1985
|
+
this.classList.remove("loading");
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
#s = (e) => {
|
|
1990
|
+
let t = e.composedPath ? e.composedPath() : [];
|
|
1991
|
+
t.includes(this) || this.#i && t.includes(this.#i) || this.close();
|
|
1992
|
+
};
|
|
1993
|
+
close() {
|
|
1994
|
+
this.currentCol = null, this.classList.remove("active"), this.#i = null;
|
|
1995
|
+
}
|
|
1996
|
+
#c() {
|
|
1997
|
+
let e = this.#t.data.getArray(), t = this.#i?.columns || [], n = this.#t.fields.get() || [], r = this.#e.filtering?.filters || {}, i = this.#t.exprEngine, a = t.flatMap((t) => {
|
|
1998
|
+
let a = t.bind, o = t.expr, s = a || o, c = a ? n.indexOf(a) : -1, l = r[s] || [], u = /* @__PURE__ */ new Map();
|
|
1999
|
+
for (let t = 0; t < e.length; t++) {
|
|
2000
|
+
let n = e[t];
|
|
2001
|
+
if (!n) continue;
|
|
2002
|
+
let r;
|
|
2003
|
+
c >= 0 && n.v ? r = n.v[c] : a && a.includes("data.") ? r = i ? i.evaluate(a, n, t) : void 0 : o && i && (r = i.evaluate(o, n, t));
|
|
2004
|
+
let s = r;
|
|
2005
|
+
o && i && (s = i.evaluate(o, n, t)), s != null && !u.has(s) && u.set(s, {
|
|
2006
|
+
v: r,
|
|
2007
|
+
v2: s
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
let d = [...u.values()];
|
|
2011
|
+
return d.sort((e, t) => {
|
|
2012
|
+
let n = e.v2, r = t.v2;
|
|
2013
|
+
if (n === r) return 0;
|
|
2014
|
+
if (n == null || n === "") return 1;
|
|
2015
|
+
if (r == null || r === "") return -1;
|
|
2016
|
+
let i = Number(n), a = Number(r);
|
|
2017
|
+
return !isNaN(i) && !isNaN(a) ? i - a : String(n).localeCompare(String(r));
|
|
2018
|
+
}), l.sort((e, t) => e > t ? 1 : -1), d.map((e) => ({
|
|
2019
|
+
LVL: 2,
|
|
2020
|
+
DATA: e.v,
|
|
2021
|
+
DATA2: e.v2 === "" || e.v2 === null || e.v2 === void 0 ? "<span class=\"empty-value\">(empty)</span>" : e.v2,
|
|
2022
|
+
COLNM: s,
|
|
2023
|
+
CHK: l.length === 0 || l.nineBinarySearch(e.v) >= 0 ? "Y" : "N"
|
|
2024
|
+
}));
|
|
2025
|
+
});
|
|
2026
|
+
this.#n.data.set(a);
|
|
2027
|
+
let o = this.querySelector("#chkSelectAll");
|
|
2028
|
+
o && (o.checked = a.length > 0 && a.every((e) => e.CHK === "Y"));
|
|
2029
|
+
}
|
|
2030
|
+
#l = () => {
|
|
2031
|
+
this.#t.loading = !0;
|
|
2032
|
+
let e = this.#r.view.getArray(), t = this.#n.data.getHostFields(), n = e.filter((e) => {
|
|
2033
|
+
let n = e.v[t.indexOf("CHK")];
|
|
2034
|
+
return n === "Y" || n === !0;
|
|
2035
|
+
}), r = { ...this.#e.filtering?.filters || {} };
|
|
2036
|
+
this.#i.columns.forEach((e) => {
|
|
2037
|
+
let i = e.expr || e.bind, a = e.expr ? t.indexOf("DATA2") : t.indexOf("DATA"), o = n.map((e) => e.v[a]);
|
|
2038
|
+
o.length > 0 ? r[i] = o : delete r[i];
|
|
2039
|
+
});
|
|
2040
|
+
let i = this.#n.data.count();
|
|
2041
|
+
setTimeout(() => {
|
|
2042
|
+
try {
|
|
2043
|
+
i === n.length ? this.#i.columns.forEach((e) => {
|
|
2044
|
+
let t = e.expr || e.bind;
|
|
2045
|
+
t && this.#e.filtering.clear(t);
|
|
2046
|
+
}) : this.#e.filtering.set(r), this.#e.querySelectorAll("nine-table-filter-button").forEach((e) => {
|
|
2047
|
+
e.updateFilteredState();
|
|
2048
|
+
}), this.#e.invalidate(), this.close();
|
|
2049
|
+
} finally {
|
|
2050
|
+
this.#t.loading = !1;
|
|
2051
|
+
}
|
|
2052
|
+
});
|
|
2053
|
+
};
|
|
2054
|
+
#u = (e) => {
|
|
2055
|
+
let t = e.target.value.toLowerCase().trim();
|
|
2056
|
+
if (!t) this.#r.filtering.clear();
|
|
2057
|
+
else {
|
|
2058
|
+
let e = this.#n.data.getArray(), r = this.#n.data.getHostFields().indexOf("DATA2"), i = [];
|
|
2059
|
+
e.forEach((e) => {
|
|
2060
|
+
let n = r >= 0 && e.v ? e.v[r] : "";
|
|
2061
|
+
String(n).replace(/<[^>]*>?/gm, "").toLowerCase().includes(t) && i.push(n);
|
|
2062
|
+
}), n.log(i), this.#r.filtering.set({ DATA2: [...new Set(i)] });
|
|
2063
|
+
}
|
|
2064
|
+
};
|
|
2065
|
+
#d = (e) => {
|
|
2066
|
+
let t = e.target.checked, n = this.#n?.data?.getArray() || [], r = this.#n.data.getHostFields().indexOf("CHK");
|
|
2067
|
+
r >= 0 && n.forEach((e) => {
|
|
2068
|
+
e.v[r] = t ? "Y" : "N";
|
|
2069
|
+
}), this.#n.refresh();
|
|
2070
|
+
};
|
|
2071
|
+
}, D = class extends HTMLElement {
|
|
2072
|
+
#e;
|
|
2073
|
+
#t = null;
|
|
2074
|
+
connectedCallback() {
|
|
2075
|
+
this.#e = this.closest("nine-table-sheet") || this.getRootNode().host, this.removeEventListener("click", this.#n), this.addEventListener("click", this.#n);
|
|
2076
|
+
}
|
|
2077
|
+
get columns() {
|
|
2078
|
+
if (this.#t) return this.#t;
|
|
2079
|
+
let e = this.closest("th, td")?.dataset.col, t = this.#e.sourceTable, n = [], r = /* @__PURE__ */ new Set();
|
|
2080
|
+
return t && e !== void 0 && t.querySelectorAll(`tbody [data-col="${e}"]`).forEach((e) => {
|
|
2081
|
+
let t = e.dataset.bind, i = e.dataset.expr;
|
|
2082
|
+
if (t || i) {
|
|
2083
|
+
let e = `${t || ""}_${i || ""}`;
|
|
2084
|
+
r.has(e) || (r.add(e), n.push({
|
|
2085
|
+
bind: t,
|
|
2086
|
+
expr: i
|
|
2087
|
+
}));
|
|
2088
|
+
}
|
|
2089
|
+
}), this.#t = n, this.#t;
|
|
2090
|
+
}
|
|
2091
|
+
updateFilteredState = () => {
|
|
2092
|
+
let e = this.#e.filtering?.filters || {}, t = this.columns.some((t) => {
|
|
2093
|
+
let n = t.expr || t.bind;
|
|
2094
|
+
return n && e[n] && e[n].length > 0;
|
|
2095
|
+
});
|
|
2096
|
+
this.classList.toggle("filtered", t);
|
|
2097
|
+
};
|
|
2098
|
+
#n = (e) => {
|
|
2099
|
+
n.log(e), e.preventDefault(), e.stopPropagation();
|
|
2100
|
+
let t = this.#e.querySelector("nine-table-filter-panel"), r = this.closest("th, td").dataset.col;
|
|
2101
|
+
t && t.currentCol === r && t.classList.contains("active") ? t.close() : t && t.open(this);
|
|
2102
|
+
};
|
|
2103
|
+
}, O = class {
|
|
2104
|
+
#e;
|
|
2105
|
+
#t;
|
|
2106
|
+
#n = !1;
|
|
2107
|
+
#r = null;
|
|
2108
|
+
#i = {};
|
|
2109
|
+
constructor(e) {
|
|
2110
|
+
this.#e = e, this.#t = this.#e.getRootNode().host, this.#a();
|
|
2111
|
+
}
|
|
2112
|
+
get filters() {
|
|
2113
|
+
return this.#i;
|
|
2114
|
+
}
|
|
2115
|
+
#a = () => {
|
|
2116
|
+
this.#o();
|
|
2117
|
+
};
|
|
2118
|
+
#o = () => {
|
|
2119
|
+
if (this.#t.tagName.toLowerCase() === "nine-table-simple") return;
|
|
2120
|
+
let e = this.#e.querySelector("nine-table-filter-panel");
|
|
2121
|
+
e || (e = document.createElement("nine-table-filter-panel"), this.#e.appendChild(e)), this.#r = e;
|
|
2122
|
+
};
|
|
2123
|
+
isFiltering() {
|
|
2124
|
+
return this.#n;
|
|
2125
|
+
}
|
|
2126
|
+
clear = (e) => {
|
|
2127
|
+
e ? delete this.#i[e] : this.#i = {}, this.#n = Object.keys(this.#i).length > 0, this.#s(), this.#e.querySelectorAll("nine-table-filter-button").forEach((e) => {
|
|
2128
|
+
e.updateFilteredState();
|
|
2129
|
+
}), n.log(`🔄 [NineTableFiltering] Filter cleared for ${e || "all"}`);
|
|
2130
|
+
};
|
|
2131
|
+
set = (e) => {
|
|
2132
|
+
n.log(e);
|
|
2133
|
+
let t = Array.isArray(e) ? Object.fromEntries(Object.keys(e[0]).map((t) => [t, [...new Set(e.map((e) => e[t]))]])) : e;
|
|
2134
|
+
this.#i = t, this.#n = Object.keys(t).length > 0, this.#e.toggleAttribute("filtering", this.#n), this.#s();
|
|
2135
|
+
};
|
|
2136
|
+
#s() {
|
|
2137
|
+
let e = this.#t.data.getArray(), t = this.#t.data.getHostFields(), n = this.#e.index, i = this.#t.exprEngine;
|
|
2138
|
+
if (!(Object.keys(this.#i).length > 0)) {
|
|
2139
|
+
e.forEach((e) => {
|
|
2140
|
+
e?.m?._?.[r.META.INDEX.FILTER] && (e.m._[r.META.INDEX.FILTER][n] = !0);
|
|
2141
|
+
}), this.#e.invalidate();
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
let a = Object.entries(this.#i).map(([e, n]) => {
|
|
2145
|
+
let r = e.includes("data.") || e.includes("host.") || e.includes("rowItem.v");
|
|
2146
|
+
return {
|
|
2147
|
+
targetKey: e,
|
|
2148
|
+
isExpr: r,
|
|
2149
|
+
fieldIdx: r ? -1 : t.indexOf(e),
|
|
2150
|
+
allowedSet: new Set(n)
|
|
2151
|
+
};
|
|
2152
|
+
});
|
|
2153
|
+
e.forEach((e, t) => {
|
|
2154
|
+
if (!e) return;
|
|
2155
|
+
e.m._[r.META.INDEX.FILTER] || (e.m._[r.META.INDEX.FILTER] = []);
|
|
2156
|
+
let o = !0;
|
|
2157
|
+
for (let n = 0; n < a.length; n++) {
|
|
2158
|
+
let { targetKey: r, isExpr: s, fieldIdx: c, allowedSet: l } = a[n], u;
|
|
2159
|
+
if (s && i ? u = i.evaluate(r, e, t) : c >= 0 && e.v && (u = e.v[c]), !l.has(u)) {
|
|
2160
|
+
o = !1;
|
|
2161
|
+
break;
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
e.m._[r.META.INDEX.FILTER][n] = o;
|
|
2165
|
+
}), this.#e.invalidate();
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
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);
|
|
2169
|
+
// src/data/Sorting.js
|
|
2170
|
+
var k = class {
|
|
2171
|
+
#e;
|
|
2172
|
+
#t;
|
|
2173
|
+
#n = [];
|
|
2174
|
+
constructor(e) {
|
|
2175
|
+
this.#e = e, this.#t = e.getRootNode().host, setTimeout(() => {
|
|
2176
|
+
this.#r();
|
|
2177
|
+
}, 300);
|
|
2178
|
+
}
|
|
2179
|
+
#r() {
|
|
2180
|
+
this.#e.querySelectorAll("thead").forEach((e) => {
|
|
2181
|
+
e.addEventListener("dblclick", (e) => {
|
|
2182
|
+
let t = e.target.closest("th, td");
|
|
2183
|
+
if (!t || t.classList.contains("resizable-edge") || ["INPUT", "CELL-CHECKBOX"].includes(e.target.tagName) || e.offsetX <= 2 || e.offsetX >= t.offsetWidth - 2) return;
|
|
2184
|
+
let n = this.#e.getRootNode().host;
|
|
2185
|
+
n.loading = !0, setTimeout(() => {
|
|
2186
|
+
try {
|
|
2187
|
+
this.#i(e, t);
|
|
2188
|
+
} finally {
|
|
2189
|
+
n.loading = !1;
|
|
2190
|
+
}
|
|
2191
|
+
});
|
|
2192
|
+
});
|
|
2193
|
+
}), n.log("🎯 [NineTableSorting] Initialized");
|
|
2194
|
+
}
|
|
2195
|
+
#i(e, t) {
|
|
2196
|
+
let n = t.dataset.col, r = t.closest("tr"), i = r ? r.dataset.subrow || String(r.sectionRowIndex) : "0";
|
|
2197
|
+
if (n === void 0) return;
|
|
2198
|
+
let a = this.#e.sourceTable;
|
|
2199
|
+
if (!a) return;
|
|
2200
|
+
let o = null, s = null;
|
|
2201
|
+
if (a.querySelectorAll(`tbody [data-col="${n}"]`).forEach((e) => {
|
|
2202
|
+
e.dataset.bind && (o = e.dataset.bind), e.dataset.expr && (s = e.dataset.expr);
|
|
2203
|
+
}), !o && !s) return;
|
|
2204
|
+
let c = t.classList.contains("asc"), l = t.classList.contains("desc");
|
|
2205
|
+
!e.ctrlKey && !e.shiftKey && (this.#n = []);
|
|
2206
|
+
let u = this.#n.findIndex((e) => e.colIndex === n && e.subRowIndex === i || e.colName === o), d = {
|
|
2207
|
+
colIndex: n,
|
|
2208
|
+
subRowIndex: i,
|
|
2209
|
+
colname: o || s,
|
|
2210
|
+
colName: o || s,
|
|
2211
|
+
expr: s,
|
|
2212
|
+
asc: !0,
|
|
2213
|
+
"expr-func": s ? (e, t) => this.#t.exprEngine(s, e, t) : null
|
|
2214
|
+
};
|
|
2215
|
+
!c && !l ? u >= 0 ? this.#n[u].asc = !0 : this.#n.push({
|
|
2216
|
+
...d,
|
|
2217
|
+
asc: !0
|
|
2218
|
+
}) : c ? u >= 0 ? this.#n[u].asc = !1 : this.#n.push({
|
|
2219
|
+
...d,
|
|
2220
|
+
asc: !1
|
|
2221
|
+
}) : this.#n = this.#n.filter((e) => !(e.colIndex === n && e.subRowIndex === i || e.colName === o)), this.#a();
|
|
2222
|
+
}
|
|
2223
|
+
#a() {
|
|
2224
|
+
this.#e.view ? (this.#e.view.setSorting(this.#n), this.#o(), this.#e.invalidate(), n.log("🔄 [NineTableSorting] Sorting applied via RowManager.refresh(true)")) : console.warn("⚠️ [NineTableSorting] Sheet view (SheetView) is not initialized.");
|
|
2225
|
+
}
|
|
2226
|
+
#o() {
|
|
2227
|
+
this.#e.querySelectorAll("thead th, thead td").forEach((e) => {
|
|
2228
|
+
e.classList.remove("asc", "desc");
|
|
2229
|
+
}), this.#n.length !== 0 && this.#n.forEach((e) => {
|
|
2230
|
+
let { colIndex: t, subRowIndex: n, asc: r } = e;
|
|
2231
|
+
if (t !== void 0) {
|
|
2232
|
+
let e = `thead [data-col="${t}"]`;
|
|
2233
|
+
n !== void 0 && (e = `thead tr[data-subrow="${n}"] [data-col="${t}"]`), this.#e.querySelectorAll(e).forEach((e) => {
|
|
2234
|
+
e.classList.add(r ? "asc" : "desc");
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
restore() {
|
|
2240
|
+
this.#n = [], this.#e.view && this.#e.view.resetSorting(), this.#o(), this.#e.rowManager?.refresh(!0);
|
|
2241
|
+
}
|
|
2242
|
+
}, A = class {
|
|
2243
|
+
#e;
|
|
2244
|
+
#t;
|
|
2245
|
+
#n = [];
|
|
2246
|
+
#r = [];
|
|
2247
|
+
#i = null;
|
|
2248
|
+
constructor(e) {
|
|
2249
|
+
this.#e = e, this.#t = e.getRootNode().host, this.refresh();
|
|
2250
|
+
}
|
|
2251
|
+
getArray = (e, t) => {
|
|
2252
|
+
if (!this.#i) {
|
|
2253
|
+
let e = this.#t.data.getArray();
|
|
2254
|
+
this.#i = this.#r.map((t) => e[t]);
|
|
2255
|
+
}
|
|
2256
|
+
let n = this.#i;
|
|
2257
|
+
if (e == null) return n;
|
|
2258
|
+
if (e < 0 || e >= n.length) return null;
|
|
2259
|
+
let r = n[e];
|
|
2260
|
+
if (t != null) {
|
|
2261
|
+
let e = this.#t.data.getHostFields().indexOf(t);
|
|
2262
|
+
return e >= 0 && r.v ? r.v[e] : null;
|
|
2263
|
+
}
|
|
2264
|
+
return r;
|
|
2265
|
+
};
|
|
2266
|
+
count = () => {
|
|
2267
|
+
if (!this.#i) {
|
|
2268
|
+
let e = this.#t.data.getArray();
|
|
2269
|
+
this.#i = this.#r.map((t) => e[t]);
|
|
2270
|
+
}
|
|
2271
|
+
return this.#i.length;
|
|
2272
|
+
};
|
|
2273
|
+
get = (e, t) => {
|
|
2274
|
+
let n = this.getArray(), r = this.#t.data.getHostFields?.() || [];
|
|
2275
|
+
if (e == null) return n.map((e) => this.#a(e, r));
|
|
2276
|
+
if (e < 0 || e >= n.length) return null;
|
|
2277
|
+
let i = n[e];
|
|
2278
|
+
if (!i) return null;
|
|
2279
|
+
if (t != null) {
|
|
2280
|
+
let e = r.indexOf(t);
|
|
2281
|
+
return e >= 0 && i.v ? i.v[e] : null;
|
|
2282
|
+
}
|
|
2283
|
+
return this.#a(i, r);
|
|
2284
|
+
};
|
|
2285
|
+
#a = (e, t) => {
|
|
2286
|
+
if (!e) return null;
|
|
2287
|
+
let n = {};
|
|
2288
|
+
return t.forEach((t, r) => {
|
|
2289
|
+
n[t] = e.v ? e.v[r] : e[t];
|
|
2290
|
+
}), e.m && (n.m = e.m), e._ && (n._ = e._), n;
|
|
2291
|
+
};
|
|
2292
|
+
refresh = () => {
|
|
2293
|
+
this.#i = null;
|
|
2294
|
+
let e = this.#t.data.getArray(), t = [];
|
|
2295
|
+
e.forEach((e, n) => {
|
|
2296
|
+
if (!e) return;
|
|
2297
|
+
let i = e.m?._?.[r.META.INDEX.FILTER];
|
|
2298
|
+
i && i[this.#e.index] === !1 || t.push(n);
|
|
2299
|
+
}), this.#n.length > 0 && (t = this.#o(t, e)), this.#r = t;
|
|
2300
|
+
let n = t.map((t) => e[t]), i = this.#e.grouping?.columns || [];
|
|
2301
|
+
if (i.length > 0) {
|
|
2302
|
+
let e = g.apply(n, i, this.#t.data.getHostFields());
|
|
2303
|
+
this.#i = e.renderItems, this.#e.grouping.setGroupMap(e.groupMap);
|
|
2304
|
+
} else this.#i = n;
|
|
2305
|
+
};
|
|
2306
|
+
setSorting = (e) => {
|
|
2307
|
+
this.#n = e || [], this.refresh();
|
|
2308
|
+
};
|
|
2309
|
+
getSorting = () => this.#n;
|
|
2310
|
+
resetSorting = () => {
|
|
2311
|
+
this.#n = [], this.refresh();
|
|
2312
|
+
};
|
|
2313
|
+
#o = (e, t) => {
|
|
2314
|
+
n.log(/* @__PURE__ */ new Date());
|
|
2315
|
+
let r = typeof this.#t.data.getHostFields == "function" ? this.#t.data.getHostFields() : [], i = this.#n.map((e) => ({
|
|
2316
|
+
...e,
|
|
2317
|
+
colIndex: r.indexOf(e.colname || e.colName)
|
|
2318
|
+
}));
|
|
2319
|
+
return e.sort((e, n) => {
|
|
2320
|
+
let r = t[e], a = t[n];
|
|
2321
|
+
for (let t of i) {
|
|
2322
|
+
let i = t.asc, o = t.expr, s, c;
|
|
2323
|
+
o ? (s = this.#t.exprEngine.evaluate(o, r, e), c = this.#t.exprEngine.evaluate(o, a, n)) : t.colIndex >= 0 && r.v && a.v && (s = r.v[t.colIndex], c = a.v[t.colIndex]);
|
|
2324
|
+
let l = s == null || s === "", u = c == null || c === "";
|
|
2325
|
+
if (!(l && u)) {
|
|
2326
|
+
if (l) return 1;
|
|
2327
|
+
if (u) return -1;
|
|
2328
|
+
if (s !== c) {
|
|
2329
|
+
let e = 0;
|
|
2330
|
+
if (typeof s == "number" && typeof c == "number") e = s - c;
|
|
2331
|
+
else {
|
|
2332
|
+
let t = String(s), n = String(c);
|
|
2333
|
+
e = t > n ? 1 : t < n ? -1 : 0;
|
|
2334
|
+
}
|
|
2335
|
+
if (e !== 0) return i ? e : -e;
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
return e - n;
|
|
2340
|
+
});
|
|
2341
|
+
};
|
|
2342
|
+
}, j = class e {
|
|
2343
|
+
static initializeTable(t, n) {
|
|
2344
|
+
return e.#r(n), e.#a(n), e.#n(n), e.#u(n), e.#i(n), v.resetColIndex(n, n.querySelectorAll("thead tr")), v.resetColIndex(n, n.querySelectorAll("tbody.body tr[grouping=\"true\"]")), v.resetColIndex(n, n.querySelectorAll("tbody.body tr:not([grouping=\"true\"])")), v.resetColIndex(n, n.querySelectorAll("tfoot tr")), e.#e(n), e.#o(n), e.#s(t, n), e.#l(n), e.#c(t, n), e.#d(n), n;
|
|
2345
|
+
}
|
|
2346
|
+
static #e(t) {
|
|
2347
|
+
let n = t.querySelector("thead");
|
|
2348
|
+
if (!n || n.querySelector(".col-indicator-rowgroup")) return;
|
|
2349
|
+
let r = n.insertRow(0);
|
|
2350
|
+
r.setAttribute("role", "row"), r.classList.add("col-indicator-rowgroup"), r.classList.add("collapse");
|
|
2351
|
+
let i = t.querySelector("tbody tr");
|
|
2352
|
+
if (!i) return;
|
|
2353
|
+
let a = 0;
|
|
2354
|
+
i.querySelectorAll("th, td").forEach((t) => {
|
|
2355
|
+
if (!t.classList.contains("dummy")) {
|
|
2356
|
+
let n = t.colSpan || 1;
|
|
2357
|
+
for (let t = 0; t < n; t++) {
|
|
2358
|
+
let t = "<th data-col=\"@col\" class=\"col-indicator\" scope=\"col\"></th>".replace("@col", a).replace("@text", e.#t(a++));
|
|
2359
|
+
r.insertAdjacentHTML("beforeend", t);
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
});
|
|
2363
|
+
let o = Array.from(t.querySelectorAll("colgroup col"));
|
|
2364
|
+
r.querySelectorAll(".col-indicator").forEach((e, t) => {
|
|
2365
|
+
let n = o[t].getAttribute("background");
|
|
2366
|
+
n && (e.style.background = n);
|
|
2367
|
+
});
|
|
2368
|
+
}
|
|
2369
|
+
static #t(e) {
|
|
2370
|
+
let t = "";
|
|
2371
|
+
for (let n = e; n >= 0; n = Math.floor(n / 26) - 1) t = String.fromCharCode(65 + n % 26) + t;
|
|
2372
|
+
return t;
|
|
2373
|
+
}
|
|
2374
|
+
static #n(e) {
|
|
2375
|
+
let t = e.querySelector("tbody:not(.head):not(.foot)");
|
|
2376
|
+
if (t) {
|
|
2377
|
+
if (t.classList.add("body"), !e.querySelector("tbody.head")) {
|
|
2378
|
+
let e = document.createElement("tbody");
|
|
2379
|
+
e.classList.add("head"), t.before(e);
|
|
2380
|
+
}
|
|
2381
|
+
if (!e.querySelector("tbody.foot")) {
|
|
2382
|
+
let e = document.createElement("tbody");
|
|
2383
|
+
e.classList.add("foot"), t.after(e);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
static #r(e) {
|
|
2388
|
+
let t = e.querySelector("colgroup");
|
|
2389
|
+
if (t || (t = document.createElement("colgroup"), e.prepend(t)), t.querySelectorAll("col").length === 0) {
|
|
2390
|
+
let n = e.querySelector("tbody tr"), r = 1;
|
|
2391
|
+
n && (r = Array.from(n.querySelectorAll("th, td")).reduce((e, t) => e + (parseInt(t.getAttribute("colspan") || t.colSpan, 10) || 1), 0)), r = Math.max(r, 1);
|
|
2392
|
+
for (let e = 0; e < r; e++) {
|
|
2393
|
+
let e = document.createElement("col");
|
|
2394
|
+
t.appendChild(e);
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
static #i(e) {
|
|
2399
|
+
let t = Array.from(e.querySelectorAll("colgroup col"));
|
|
2400
|
+
if (t.length === 0) return;
|
|
2401
|
+
let n = e.clientWidth || 0, r = Math.max(Math.floor(n / t.length), 100);
|
|
2402
|
+
t.forEach((e, t) => {
|
|
2403
|
+
e.hasAttribute("data-col") || e.setAttribute("data-col", t);
|
|
2404
|
+
let n = e.getAttribute("width") || parseInt(e.style.width, 10) || r;
|
|
2405
|
+
e.setAttribute("width", n);
|
|
2406
|
+
let i = String(n).includes("px") ? n : `${n}px`;
|
|
2407
|
+
e.style.width = i;
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
static #a(e) {
|
|
2411
|
+
if (e.querySelector("thead")) return;
|
|
2412
|
+
let t = document.createElement("thead"), n = e.querySelector("colgroup");
|
|
2413
|
+
n ? n.after(t) : e.prepend(t);
|
|
2414
|
+
}
|
|
2415
|
+
static #o(e) {
|
|
2416
|
+
e.querySelectorAll("thead th, thead td").forEach((e) => {
|
|
2417
|
+
e.getAttribute("collapsed") === "true" && e.getAttribute("collapsible") !== "true" && e.setAttribute("collapsible", "true");
|
|
2418
|
+
});
|
|
2419
|
+
}
|
|
2420
|
+
static #s(e, t) {
|
|
2421
|
+
let n = [
|
|
2422
|
+
"data-bind",
|
|
2423
|
+
"data-expr",
|
|
2424
|
+
"type"
|
|
2425
|
+
], r = 0;
|
|
2426
|
+
t.querySelectorAll("tbody th, tbody td").forEach((t) => {
|
|
2427
|
+
let i = `cell-${t.getAttribute("cell-type") || "renderer"}`, a = t.querySelector("datalist");
|
|
2428
|
+
if (a) {
|
|
2429
|
+
let n = [];
|
|
2430
|
+
a.querySelectorAll("option").forEach((e) => {
|
|
2431
|
+
n.push({
|
|
2432
|
+
k: e.getAttribute("k"),
|
|
2433
|
+
v: e.getAttribute("v"),
|
|
2434
|
+
value: e.getAttribute("value")
|
|
2435
|
+
});
|
|
2436
|
+
});
|
|
2437
|
+
let i = `__ds_${Date.now()}_${++r}`;
|
|
2438
|
+
e && (e[i] = () => n), t.setAttribute("data-source", `host.${i}()`), a.remove();
|
|
2439
|
+
}
|
|
2440
|
+
let o = t.dataset.expr;
|
|
2441
|
+
o && t.setAttribute("data-expr", e.exprEngine.precompile(o)), Array.from(t.attributes).forEach((n) => {
|
|
2442
|
+
[
|
|
2443
|
+
"data-bind",
|
|
2444
|
+
"data-expr",
|
|
2445
|
+
"cell-type",
|
|
2446
|
+
"validator"
|
|
2447
|
+
].includes(n.name) || (n.value.includes("data.") || n.value.includes("host.")) && t.setAttribute(n.name, e.exprEngine.precompile(n.value));
|
|
2448
|
+
}), t.innerHTML = `<${i} ${n.filter((e) => t.hasAttribute(e)).map((e) => `${e}="${t.getAttribute(e)}"`).join(" ")}></${i}>`, t.setAttribute("tabindex", "0");
|
|
2449
|
+
}), t.querySelectorAll("thead th, thead td, tfoot th, tfoot td").forEach((e) => {
|
|
2450
|
+
let t = e.getAttribute("cell-type");
|
|
2451
|
+
if (t) {
|
|
2452
|
+
let r = e.innerHTML, i = `cell-${t}`;
|
|
2453
|
+
e.innerHTML = `<${i} ${n.filter((t) => e.hasAttribute(t)).map((t) => `${t}="${e.getAttribute(t)}"`).join(" ")} content="${r}"></${i}>`;
|
|
2454
|
+
}
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
static #c(e, t) {
|
|
2458
|
+
let n = e.getAttribute("filtering") === "true", r = t.getAttribute("filtering") === "true";
|
|
2459
|
+
t.querySelectorAll("thead tr:not(.col-indicator-rowgroup) th, thead tr:not(.col-indicator-rowgroup) td").forEach((e) => {
|
|
2460
|
+
let t = e.getAttribute("filtering") === "true" || r || n;
|
|
2461
|
+
e.setAttribute("filtering", t ? "true" : "false"), t && e.appendChild(document.createElement("nine-table-filter-button"));
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
static #l(e) {
|
|
2465
|
+
e.querySelectorAll("thead th, thead td").forEach((t) => {
|
|
2466
|
+
if (t.getAttribute("collapsible") !== "true" && t.getAttribute("expandable") !== "true") return;
|
|
2467
|
+
let n = parseInt(t.dataset.col, 10), r = t.colSpan || 1, i = e.querySelector(`colgroup col[data-col="${n}"]`), a = i && parseInt(i.getAttribute("width"), 10) || 100;
|
|
2468
|
+
(!t.dataset.expandWidth || parseInt(t.dataset.expandWidth, 10) <= 16) && (t.dataset.expandWidth = String(a > 16 ? a : 100));
|
|
2469
|
+
let o = t.querySelector("nine-table-col-expand");
|
|
2470
|
+
if (o || (o = document.createElement("nine-table-col-expand"), t.insertBefore(o, t.firstChild)), t.getAttribute("collapsed") === "true") {
|
|
2471
|
+
o.classList.add("collapsed"), o.classList.remove("expand"), o.setAttribute("collapsed", "true"), t.style.color = "transparent";
|
|
2472
|
+
let i = Math.max(10, Math.floor(16 / r));
|
|
2473
|
+
if (!isNaN(n)) for (let t = 0; t < r; t++) {
|
|
2474
|
+
let r = e.querySelector(`colgroup col[data-col="${n + t}"]`);
|
|
2475
|
+
r && (r.setAttribute("width", i), r.style.width = `${i}px`);
|
|
2476
|
+
}
|
|
2477
|
+
} else o.classList.remove("collapsed"), o.classList.add("expand"), o.setAttribute("collapsed", "false"), t.style.color = "";
|
|
2478
|
+
});
|
|
2479
|
+
}
|
|
2480
|
+
static #u(e, t) {
|
|
2481
|
+
let n = e.getAttribute("row-indicator") === "true" ? 48 : 0, r = e.querySelector("colgroup"), i = document.createElement("col");
|
|
2482
|
+
i.setAttribute("fixed", "left"), i.setAttribute("width", n), i.style.width = `${n}px`, r.prepend(i), e.querySelectorAll("thead, tbody, tfoot").forEach((e) => {
|
|
2483
|
+
let t = Array.from(e.querySelectorAll("tr"));
|
|
2484
|
+
if (t.length === 0) return;
|
|
2485
|
+
let n = t[0], r = document.createElement("th");
|
|
2486
|
+
r.className = "row-indicator", r.setAttribute("cell-type", "row-indicator"), t.length > 1 && (r.rowSpan = t.length), n.insertBefore(r, n.firstElementChild);
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
static #d(e) {
|
|
2490
|
+
e.querySelectorAll("th[data-col], td[data-col]").forEach((t) => {
|
|
2491
|
+
let n = parseInt(t.getAttribute("data-col"), 10);
|
|
2492
|
+
if (isNaN(n)) return;
|
|
2493
|
+
let r = parseInt(t.getAttribute("colspan") || t.colSpan, 10) || 1, i = 0;
|
|
2494
|
+
for (let t = 0; t < r; t++) {
|
|
2495
|
+
let r = n + t, a = e.querySelector(`colgroup col[data-col="${r}"]`);
|
|
2496
|
+
a && (i += parseInt(a.getAttribute("width"), 10) || 100);
|
|
2497
|
+
}
|
|
2498
|
+
if (i > 0) {
|
|
2499
|
+
let e = `${i}px`;
|
|
2500
|
+
t.style.width = e, t.style.minWidth = e, t.style.maxWidth = e;
|
|
2501
|
+
}
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
}, M = class extends HTMLElement {
|
|
2505
|
+
#e;
|
|
2506
|
+
#t;
|
|
2507
|
+
#n;
|
|
2508
|
+
#r;
|
|
2509
|
+
#i;
|
|
2510
|
+
#a;
|
|
2511
|
+
#o;
|
|
2512
|
+
#s;
|
|
2513
|
+
#c;
|
|
2514
|
+
#l;
|
|
2515
|
+
#u;
|
|
2516
|
+
#d;
|
|
2517
|
+
#f = { table: null };
|
|
2518
|
+
#p;
|
|
2519
|
+
static SCROLLBAR_SIZE = 16;
|
|
2520
|
+
constructor() {
|
|
2521
|
+
super(), this.#t = this.getRootNode().host, this.#n = new _(this);
|
|
2522
|
+
}
|
|
2523
|
+
connectedCallback() {
|
|
2524
|
+
this.#b();
|
|
2525
|
+
}
|
|
2526
|
+
get index() {
|
|
2527
|
+
return this.#e;
|
|
2528
|
+
}
|
|
2529
|
+
get colResizer() {
|
|
2530
|
+
return this.#a;
|
|
2531
|
+
}
|
|
2532
|
+
get filtering() {
|
|
2533
|
+
return this.#l;
|
|
2534
|
+
}
|
|
2535
|
+
get grouping() {
|
|
2536
|
+
return this.#u;
|
|
2537
|
+
}
|
|
2538
|
+
get colMover() {
|
|
2539
|
+
return this.#o;
|
|
2540
|
+
}
|
|
2541
|
+
get colFix() {
|
|
2542
|
+
return this.#s;
|
|
2543
|
+
}
|
|
2544
|
+
get rowManager() {
|
|
2545
|
+
return this.#n;
|
|
2546
|
+
}
|
|
2547
|
+
get selection() {
|
|
2548
|
+
return this.#r;
|
|
2549
|
+
}
|
|
2550
|
+
get navigation() {
|
|
2551
|
+
return this.#i;
|
|
2552
|
+
}
|
|
2553
|
+
get templateLength() {
|
|
2554
|
+
return this.#f.tbody.tr.length || 0;
|
|
2555
|
+
}
|
|
2556
|
+
get elements() {
|
|
2557
|
+
return this.#p;
|
|
2558
|
+
}
|
|
2559
|
+
get isAutoFitCol() {
|
|
2560
|
+
let e = this.getAttribute("auto-fit-col") === "true" || this.#t?.getAttribute("auto-fit-col") === "true", t = this.#f.table?.getAttribute("auto-fit-col") === "true";
|
|
2561
|
+
return e || t;
|
|
2562
|
+
}
|
|
2563
|
+
get sourceTable() {
|
|
2564
|
+
return this.#f.table;
|
|
2565
|
+
}
|
|
2566
|
+
get source() {
|
|
2567
|
+
return this.#f;
|
|
2568
|
+
}
|
|
2569
|
+
get #m() {
|
|
2570
|
+
return this.#t.hasAttribute("simple") || this.#t.getAttribute("theme") === "simple";
|
|
2571
|
+
}
|
|
2572
|
+
recompileAndRefresh() {
|
|
2573
|
+
this.#f.table && (v.recompile(this.#f.table), [
|
|
2574
|
+
"left",
|
|
2575
|
+
"right",
|
|
2576
|
+
"body"
|
|
2577
|
+
].forEach((e) => {
|
|
2578
|
+
[
|
|
2579
|
+
"header",
|
|
2580
|
+
"body",
|
|
2581
|
+
"footer"
|
|
2582
|
+
].forEach((t) => {
|
|
2583
|
+
let n = this.querySelector(`.ng-sheet-${t} .ng-container-${e}`);
|
|
2584
|
+
n && n.querySelectorAll("table").forEach((e) => e.remove());
|
|
2585
|
+
});
|
|
2586
|
+
}), this.#v(), this.#_(), this.#n.initialize(), this.isAutoFitCol ? this.autoFit(!0) : this.querySelector("nine-table-hscrollbar")?.refresh(), requestAnimationFrame(() => {
|
|
2587
|
+
this.#_(), this.#n?.refresh();
|
|
2588
|
+
}));
|
|
2589
|
+
}
|
|
2590
|
+
refreshLayout() {
|
|
2591
|
+
requestAnimationFrame(() => {
|
|
2592
|
+
n.log("*************************", this.classList, this.#f.table), this.classList.contains("active") && this.#f.table && (this.#_(), this.isAutoFitCol ? this.autoFit(!0) : this.querySelector("nine-table-hscrollbar")?.refresh(), this.#h(), this.#a?.refreshLayout(), this.#n?.refresh());
|
|
2593
|
+
});
|
|
2594
|
+
}
|
|
2595
|
+
#h = () => {
|
|
2596
|
+
let e = this.querySelector(".ng-container-body thead"), t = this.querySelector(".nodata-overlay");
|
|
2597
|
+
t.style.top = `${e.offsetHeight}px`, n.log("***************************************", e), n.log(e.offsetHeight);
|
|
2598
|
+
};
|
|
2599
|
+
get view() {
|
|
2600
|
+
return !this.#d && this.#t?.data && (this.#d = new A(this)), this.#d;
|
|
2601
|
+
}
|
|
2602
|
+
invalidate = () => {
|
|
2603
|
+
this.view.refresh(), this.#n.refresh(!0), this.isAutoFitCol && this.autoFit(!0);
|
|
2604
|
+
};
|
|
2605
|
+
autoFit = (e = !0) => {
|
|
2606
|
+
requestAnimationFrame(() => {
|
|
2607
|
+
this.#g?.(e);
|
|
2608
|
+
});
|
|
2609
|
+
};
|
|
2610
|
+
#g = (e = !0) => {
|
|
2611
|
+
n.log("***************** autoFit", this);
|
|
2612
|
+
let t = this.querySelector(".ng-sheet-body .ng-container-body");
|
|
2613
|
+
if (!t) return;
|
|
2614
|
+
let r = this.querySelector(".ng-container-body table colgroup");
|
|
2615
|
+
if (r) {
|
|
2616
|
+
if (e) {
|
|
2617
|
+
this.setAttribute("auto-fit-col", "true");
|
|
2618
|
+
let e = t.clientWidth;
|
|
2619
|
+
if (e <= 0) return;
|
|
2620
|
+
let i = 0, a = [];
|
|
2621
|
+
r.querySelectorAll("col").forEach((e) => {
|
|
2622
|
+
let t = e.getAttribute("data-col");
|
|
2623
|
+
if (this.querySelector(`thead th[data-col="${t}"]`)?.getAttribute("collapsed") === "true") a.unshift({
|
|
2624
|
+
globalColIndex: t,
|
|
2625
|
+
width: 16,
|
|
2626
|
+
isCollapsed: !0
|
|
2627
|
+
}), n.log(`[AutoFit Col] Index ${t}: COLLAPSED (forced 16px)`);
|
|
2628
|
+
else {
|
|
2629
|
+
let r = parseInt(e.getAttribute("width"), 10) || 100;
|
|
2630
|
+
a.push({
|
|
2631
|
+
globalColIndex: t,
|
|
2632
|
+
width: r,
|
|
2633
|
+
isCollapsed: !1
|
|
2634
|
+
}), i += r, n.log(`[AutoFit Col] Index ${t}: NORMAL (original width: ${r}px)`);
|
|
2635
|
+
}
|
|
2636
|
+
}), n.log(`[AutoFit] Total Original Width of Normal Cols: ${i}px`);
|
|
2637
|
+
let o = a.filter((e) => e.isCollapsed).reduce((e, t) => e + t.width, 0), s = Math.max(0, e - o);
|
|
2638
|
+
if (n.log(`[AutoFit] Collapsed Total Width: ${o}px | Available Width for Normal Cols: ${s}px`), i > 0 && a.length > 0) {
|
|
2639
|
+
let t = 0, r = a.map((e) => {
|
|
2640
|
+
if (e.isCollapsed) return {
|
|
2641
|
+
globalColIndex: e.globalColIndex,
|
|
2642
|
+
remainder: 0,
|
|
2643
|
+
width: 16
|
|
2644
|
+
};
|
|
2645
|
+
let n = e.width * s / i, r = Math.max(30, Math.floor(n));
|
|
2646
|
+
return t += r, {
|
|
2647
|
+
globalColIndex: e.globalColIndex,
|
|
2648
|
+
remainder: n - Math.floor(n),
|
|
2649
|
+
width: r
|
|
2650
|
+
};
|
|
2651
|
+
}), o = s - t;
|
|
2652
|
+
n.log(`[AutoFit] Initial Allocated Total: ${t}px | Remainder Pixels to distribute: ${o}`);
|
|
2653
|
+
let c = r.filter((e) => !a.find((t) => t.globalColIndex === e.globalColIndex)?.isCollapsed);
|
|
2654
|
+
if (o > 0 && c.length > 0) {
|
|
2655
|
+
c.sort((e, t) => t.remainder - e.remainder);
|
|
2656
|
+
for (let e = 0; e < o; e++) c[e % c.length].width += 1;
|
|
2657
|
+
} else if (o < 0 && c.length > 0) {
|
|
2658
|
+
c.sort((e, t) => e.remainder - t.remainder);
|
|
2659
|
+
for (let e = 0; e < Math.abs(o); e++) {
|
|
2660
|
+
let t = c[e % c.length];
|
|
2661
|
+
t.width > 30 && --t.width;
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
let l = r.reduce((e, t) => e + t.width, 0);
|
|
2665
|
+
n.log(`[AutoFit Verification] Target Container Width: ${e}px | Sum of All Calculated Cols: ${l}px`), e === l ? n.log("✅ [AutoFit Success] 완벽하게 일치합니다!") : n.log(`⚠️ [AutoFit Mismatch Warning!] 오차 발생: ${e - l}px 차이가 납니다.`), r.forEach(({ globalColIndex: e, width: t }) => {
|
|
2666
|
+
n.log(`[AutoFit Apply] Col Index ${e} -> ${t}px`), this.#a?.setColumnWidth(e, t, "body");
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
} else this.removeAttribute("auto-fit-col");
|
|
2670
|
+
this.querySelector("nine-table-hscrollbar")?.refresh();
|
|
2671
|
+
}
|
|
2672
|
+
};
|
|
2673
|
+
generate = (e, t) => {
|
|
2674
|
+
e.style.display = "none", this.#e = t, j.initializeTable(this.#t, e), e.style.display = "", this.#f = {
|
|
2675
|
+
table: v.compile(e),
|
|
2676
|
+
tbody: { tr: e.querySelectorAll("tbody tr") }
|
|
2677
|
+
}, this.#v(), this.#_(), this.#S(), this.#w(), [
|
|
2678
|
+
"left",
|
|
2679
|
+
"body",
|
|
2680
|
+
"right"
|
|
2681
|
+
].forEach((e) => {
|
|
2682
|
+
let t = `.ng-container-${e}`;
|
|
2683
|
+
this.#p[e] = {
|
|
2684
|
+
thead: this.querySelector(`${t} thead`),
|
|
2685
|
+
tbody: {
|
|
2686
|
+
head: this.querySelector(`${t} tbody.head`),
|
|
2687
|
+
body: this.querySelector(`${t} tbody.body`),
|
|
2688
|
+
foot: this.querySelector(`${t} tbody.foot`)
|
|
2689
|
+
},
|
|
2690
|
+
tfoot: this.querySelector(`${t} tfoot`)
|
|
2691
|
+
};
|
|
2692
|
+
}), this.#n.initialize(), this.isAutoFitCol ? this.autoFit(!0) : this.querySelector("nine-table-hscrollbar").refresh(), this.#u.initialize(), this.loaded = !0;
|
|
2693
|
+
};
|
|
2694
|
+
#_ = () => {
|
|
2695
|
+
this.isAutoFitCol, [
|
|
2696
|
+
"left",
|
|
2697
|
+
"right",
|
|
2698
|
+
"body"
|
|
2699
|
+
].forEach((e) => {
|
|
2700
|
+
let t = this.querySelectorAll(`.ng-container-${e}`);
|
|
2701
|
+
if (t.length === 0) return;
|
|
2702
|
+
let n = t[0].querySelector("table");
|
|
2703
|
+
if (!n) return;
|
|
2704
|
+
let r = 0;
|
|
2705
|
+
n.querySelectorAll("col").forEach((e) => {
|
|
2706
|
+
let t = parseInt(e.getAttribute("width"), 10);
|
|
2707
|
+
isNaN(t) || (r += t);
|
|
2708
|
+
}), t.forEach((t) => {
|
|
2709
|
+
let n = t.querySelectorAll("table");
|
|
2710
|
+
e === "body" ? (t.style.flex = "1", n.forEach((e) => {})) : (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) => {}));
|
|
2711
|
+
});
|
|
2712
|
+
});
|
|
2713
|
+
};
|
|
2714
|
+
#v = () => {
|
|
2715
|
+
[
|
|
2716
|
+
{
|
|
2717
|
+
selector: ".ng-container-left",
|
|
2718
|
+
type: "left"
|
|
2719
|
+
},
|
|
2720
|
+
{
|
|
2721
|
+
selector: ".ng-container-body",
|
|
2722
|
+
type: null
|
|
2723
|
+
},
|
|
2724
|
+
{
|
|
2725
|
+
selector: ".ng-container-right",
|
|
2726
|
+
type: "right"
|
|
2727
|
+
}
|
|
2728
|
+
].forEach(({ selector: e, type: t }) => {
|
|
2729
|
+
this.querySelector(`.ng-sheet-body ${e}`).appendChild(this.#y(t));
|
|
2730
|
+
});
|
|
2731
|
+
};
|
|
2732
|
+
#y = (e) => {
|
|
2733
|
+
let t = this.#f.table.cloneNode(!0);
|
|
2734
|
+
return e === "left" ? t.querySelectorAll("col, th, td").forEach((e) => {
|
|
2735
|
+
e.getAttribute("fixed") !== "left" && e.remove();
|
|
2736
|
+
}) : e === "right" ? t.querySelectorAll("col, th, td").forEach((e) => {
|
|
2737
|
+
e.getAttribute("fixed") !== "right" && e.remove();
|
|
2738
|
+
}) : t.querySelectorAll("[fixed=left], [fixed=right]").forEach((e) => {
|
|
2739
|
+
e.remove();
|
|
2740
|
+
}), t;
|
|
2741
|
+
};
|
|
2742
|
+
getRowHeight = () => this.#n.getRowHeight();
|
|
2743
|
+
getViewHeight = () => (this.#p.content.offsetHeight || 0) - ((this.#p.body.thead?.offsetHeight || 0) + (this.#p.body.tfoot?.offsetHeight || 0) + (this.#p.body.tbody.head.offsetHeight || 0));
|
|
2744
|
+
isLastRow = () => {
|
|
2745
|
+
let e = this.querySelector(".ng-sheet-body"), t = this.querySelector(".ng-container-body tbody.body"), r = this.#p.body.tfoot?.offsetHeight || 0, i = e.getBoundingClientRect().bottom, a = t.getBoundingClientRect().bottom;
|
|
2746
|
+
return n.log(i, a, r), i - r >= a;
|
|
2747
|
+
};
|
|
2748
|
+
scrollToX = (e) => {
|
|
2749
|
+
let t = this.querySelector(".ng-sheet-body .ng-container-body");
|
|
2750
|
+
t && (t.scrollLeft = e);
|
|
2751
|
+
};
|
|
2752
|
+
scrollToY = (e) => {
|
|
2753
|
+
let t = this.querySelector(".ng-sheet-body");
|
|
2754
|
+
t && (t.scrollTop = e);
|
|
2755
|
+
};
|
|
2756
|
+
#b = () => {
|
|
2757
|
+
this.#x(), 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.#d = new A(this), this.#l = new O(this), this.#u = new h(this), this.#m || (this.#c = new k(this)), this.#p.mainBody.addEventListener("scroll", () => {
|
|
2758
|
+
this.querySelector("nine-table-hscrollbar").refresh();
|
|
2759
|
+
});
|
|
2760
|
+
};
|
|
2761
|
+
#x = () => {
|
|
2762
|
+
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\"></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 <!-- [Grid Row 1, Col 2] 세로 스크롤바 -->\n <nine-table-vscrollbar></nine-table-vscrollbar>\n\n <!-- [Grid Row 2, Col 1] 가로 스크롤바 -->\n <nine-table-hscrollbar></nine-table-hscrollbar>\n\n <!-- [Grid Row 2, Col 2] 우하단 엣지 -->\n <div class=\"scroll-edge\"></div>\n \n <!-- 리사이저 및 드래그 패널들 -->\n <nine-table-col-resizer-panel></nine-table-col-resizer-panel>\n <!--\n <div class=\"ng-col-resizer-panel\">\n <div class=\"resizer-overlay\">\n <span class=\"size-badge\">0px</span>\n </div>\n </div> ->\n \n <div class=\"ng-col-mover-grip\"></div>\n <div class=\"ng-col-mover-indi\"></div>\n ", this.#p = {
|
|
2763
|
+
mainBody: this.querySelector(".ng-sheet-body .ng-container-body"),
|
|
2764
|
+
hscrollbar: this.querySelector("nine-table-hscrollbar"),
|
|
2765
|
+
vscrollbar: this.querySelector("nine-table-vscrollbar"),
|
|
2766
|
+
content: this.querySelector(".ng-sheet-body .ng-sheet-body-content"),
|
|
2767
|
+
scrollHolder: this.querySelector(".ng-sheet-body .ng-virtual-height-holder")
|
|
2768
|
+
}, n.log("444*****************");
|
|
2769
|
+
};
|
|
2770
|
+
#S = () => {
|
|
2771
|
+
n.log("**********************", "#syncHeaderAndFooterHeights");
|
|
2772
|
+
let e = this.querySelector(".ng-container-left table"), t = this.querySelector(".ng-container-body table"), r = this.querySelector(".ng-container-right table"), i = Array.from(e.querySelectorAll("thead tr:not(.col-indicator-rowgroup)")), a = Array.from(t.querySelectorAll("thead tr:not(.col-indicator-rowgroup)")), o = Array.from(r.querySelectorAll("thead tr:not(.col-indicator-rowgroup)"));
|
|
2773
|
+
this.#C(i, a, o);
|
|
2774
|
+
let s = Array.from(e.querySelectorAll("tfoot tr")), c = Array.from(t.querySelectorAll("tfoot tr")), l = Array.from(r.querySelectorAll("tfoot tr"));
|
|
2775
|
+
this.#C(s, c, l);
|
|
2776
|
+
};
|
|
2777
|
+
#C = (e, t, r) => {
|
|
2778
|
+
setTimeout(() => {
|
|
2779
|
+
let i = Math.max(e.length, t.length, r.length);
|
|
2780
|
+
n.log(this.#t);
|
|
2781
|
+
for (let a = 0; a < i; a++) {
|
|
2782
|
+
n.log(i);
|
|
2783
|
+
let o = [
|
|
2784
|
+
e[a]?.getBoundingClientRect().height || 0,
|
|
2785
|
+
t[a]?.getBoundingClientRect().height || 0,
|
|
2786
|
+
r[a]?.getBoundingClientRect().height || 0
|
|
2787
|
+
], s = Math.max(...o);
|
|
2788
|
+
n.log(o, s), s > 0 && (e[a] && (e[a].style.height = `${s}px`), t[a] && (t[a].style.height = `${s}px`), r[a] && (r[a].style.height = `${s}px`));
|
|
2789
|
+
}
|
|
2790
|
+
});
|
|
2791
|
+
};
|
|
2792
|
+
#w = () => {
|
|
2793
|
+
let e = this.querySelector(".ng-sheet-body");
|
|
2794
|
+
if (!e) return;
|
|
2795
|
+
let t = null;
|
|
2796
|
+
e.addEventListener("mouseover", (n) => {
|
|
2797
|
+
let r = n.target.closest("tr");
|
|
2798
|
+
if (!r || !r.dataset.row && r.dataset.row !== "0") return;
|
|
2799
|
+
let i = r.dataset.row;
|
|
2800
|
+
t !== i && (t = i, e.querySelectorAll(`tr[data-row="${i}"]`).forEach((e) => {
|
|
2801
|
+
e.classList.add("hover");
|
|
2802
|
+
}));
|
|
2803
|
+
}), e.addEventListener("mouseout", (n) => {
|
|
2804
|
+
let r = n.target.closest("tr");
|
|
2805
|
+
if (!r) return;
|
|
2806
|
+
let i = n.relatedTarget;
|
|
2807
|
+
r.contains(i) || (e.querySelectorAll("tr.hover").forEach((e) => {
|
|
2808
|
+
e.classList.remove("hover");
|
|
2809
|
+
}), t = null);
|
|
2810
|
+
});
|
|
2811
|
+
};
|
|
2812
|
+
disconnectedCallback() {
|
|
2813
|
+
this.#a?.destroy(), this.#o?.destroy(), this.innerHTML = "";
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2816
|
+
customElements.get("nine-table-sheet") || customElements.define("nine-table-sheet", M);
|
|
2817
|
+
// src/layout/core/LayoutManager.js
|
|
2818
|
+
var N = class {
|
|
2819
|
+
#e;
|
|
2820
|
+
constructor(e) {
|
|
2821
|
+
this.#e = e, this.#t();
|
|
2822
|
+
}
|
|
2823
|
+
#t = () => {
|
|
2824
|
+
this.#r(), new ResizeObserver((e) => {
|
|
2825
|
+
for (let t of e) this.#e.getAttribute("auto-height") === "true" && this.#n();
|
|
2826
|
+
}).observe(this.#e);
|
|
2827
|
+
};
|
|
2828
|
+
set loading(e) {
|
|
2829
|
+
e ? this.#e.classList.add("loading") : this.#e.classList.remove("loading");
|
|
2830
|
+
}
|
|
2831
|
+
#n = () => {
|
|
2832
|
+
let e = Array.from(this.#e.shadowRoot.querySelectorAll("nine-table-sheet.active"));
|
|
2833
|
+
if (e.length === 0) return;
|
|
2834
|
+
let t = parseInt(this.#e.getAttribute("max-display-row"), 10) || 10, n = Math.max(...e.map((e) => e.getRowHeight())), r = this.#e.shadowRoot.querySelector("nine-table-toolbar"), i = this.#e.shadowRoot.querySelector("nine-table-sheets-footer"), a = r ? r.getBoundingClientRect().height : 0, o = i ? i.getBoundingClientRect().height : 0, s = M.SCROLLBAR_SIZE, c = t * n + a + o + s;
|
|
2835
|
+
this.#e.style.height = `${c}px`;
|
|
2836
|
+
};
|
|
2837
|
+
#r = () => {
|
|
2838
|
+
let e = Array.from(this.#e.children).filter((e) => e.tagName.toUpperCase() === "TABLE"), t = this.#e.getAttribute("auto-height") === "true", r = e.length, i = e.map((e, t) => {
|
|
2839
|
+
let n = t === 0 ? "active" : "", i = e.id || `sheet${t + 1}`;
|
|
2840
|
+
return `<nine-table-sheet class="${n}" data-index="${t}" data-sheet-id="${i}" id="${i}"></nine-table-sheet>` + (t < r - 1 ? `<nine-splitter class="h" data-split-index="${t}"></nine-splitter>` : "");
|
|
2841
|
+
}).join("");
|
|
2842
|
+
n.log("Welcome nine-table", "0.2.2");
|
|
2843
|
+
let a = ["@import \"https://cdn.jsdelivr.net/npm/@ninebone/table@0.2.2/dist/css/nine-table.css\";"];
|
|
2844
|
+
nine["nine-table"] && nine["nine-table"].cssFile && a.push(`@import "${nine["nine-table"].cssFile}";`), this.#e.shadowRoot.innerHTML = `
|
|
2845
|
+
<style>
|
|
2846
|
+
${a.join("\n")}
|
|
2847
|
+
</style>
|
|
2848
|
+
|
|
2849
|
+
<nine-table-toolbar></nine-table-toolbar>
|
|
2850
|
+
|
|
2851
|
+
<nine-table-body>
|
|
2852
|
+
<nine-table-summary></nine-table-summary>
|
|
2853
|
+
<div class="ng-loading-bar"></div>
|
|
2854
|
+
<nine-table-sheets>
|
|
2855
|
+
<nine-table-sheets-body>
|
|
2856
|
+
${i}
|
|
2857
|
+
</nine-table-sheets-body>
|
|
2858
|
+
<nine-table-sheets-footer></nine-table-sheets-footer>
|
|
2859
|
+
</nine-table-sheets>
|
|
2860
|
+
<nine-table-analysis></nine-table-analysis>
|
|
2861
|
+
</nine-table-body>
|
|
2862
|
+
<nine-table-footer></nine-table-footer>
|
|
2863
|
+
`, this.#e.shadowRoot.querySelectorAll("nine-table-sheet").forEach((n, r) => {
|
|
2864
|
+
e[r] && setTimeout(() => {
|
|
2865
|
+
n.generate(e[r], r), t && this.#n();
|
|
2866
|
+
});
|
|
2867
|
+
});
|
|
2868
|
+
};
|
|
2869
|
+
}, P = class {
|
|
2870
|
+
#e;
|
|
2871
|
+
#t;
|
|
2872
|
+
#n = /* @__PURE__ */ new Map();
|
|
2873
|
+
constructor(e) {
|
|
2874
|
+
this.#e = e, this.#t = e.fields.get();
|
|
2875
|
+
}
|
|
2876
|
+
rewriteExpr(e) {
|
|
2877
|
+
return !e || !this.#t.length ? e : e.replace(/data\.([a-zA-Z_$][\w$]*)/g, (e, t) => {
|
|
2878
|
+
let n = this.#t.indexOf(t);
|
|
2879
|
+
return n >= 0 ? `rowItem.v[${n}]` : e;
|
|
2880
|
+
});
|
|
2881
|
+
}
|
|
2882
|
+
precompile(e) {
|
|
2883
|
+
return e && this.rewriteExpr(e);
|
|
2884
|
+
}
|
|
2885
|
+
evaluate(e, t, n = 0) {
|
|
2886
|
+
if (e == null) return "";
|
|
2887
|
+
try {
|
|
2888
|
+
let r = String(e).trim(), i = this.rewriteExpr(r);
|
|
2889
|
+
if (i.includes("data.") || i.includes("rowItem.v") || i.includes("host.") || i.includes("(")) {
|
|
2890
|
+
let e = this.#n.get(i);
|
|
2891
|
+
return e || (e = Function("rowItem", "row", "host", `
|
|
2892
|
+
const data = rowItem;
|
|
2893
|
+
|
|
2894
|
+
if (!data && !host) return "";
|
|
2895
|
+
return ${i};
|
|
2896
|
+
`), this.#n.set(i, e)), e(t, n, this.#e);
|
|
2897
|
+
}
|
|
2898
|
+
return i;
|
|
2899
|
+
} catch {
|
|
2900
|
+
return e;
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
}, F = class extends HTMLElement {
|
|
2904
|
+
#e;
|
|
2905
|
+
#t;
|
|
2906
|
+
#n;
|
|
2907
|
+
#r = 0;
|
|
2908
|
+
constructor() {
|
|
2909
|
+
super(), this.#e = this.attachShadow({ mode: "open" }), this.#t = new o(this);
|
|
2910
|
+
}
|
|
2911
|
+
connectedCallback() {
|
|
2912
|
+
setTimeout(() => {
|
|
2913
|
+
this.#r = this.querySelectorAll("table")?.length, this.fields = new s(this), this.exprEngine = new P(this), this.#a(), this.#n = new N(this), this.#i();
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2916
|
+
disconnectedCallback() {
|
|
2917
|
+
n.log("NineTable disconnected.");
|
|
2918
|
+
}
|
|
2919
|
+
#i = () => {
|
|
2920
|
+
let e = 0, t = setInterval(() => {
|
|
2921
|
+
e++;
|
|
2922
|
+
let n = this.shadow.querySelectorAll("nine-table-sheet");
|
|
2923
|
+
if (e >= 50 && clearInterval(t), n.length >= this.#r) {
|
|
2924
|
+
let e = 0;
|
|
2925
|
+
n.forEach((t) => {
|
|
2926
|
+
t.loaded && e++;
|
|
2927
|
+
}), e >= this.#r && (clearInterval(t), this.loaded = !0, this.dispatchEvent(new CustomEvent(r.EVENT.LOAD, {
|
|
2928
|
+
bubbles: !0,
|
|
2929
|
+
detail: { target: this }
|
|
2930
|
+
})));
|
|
2931
|
+
}
|
|
2932
|
+
}, 100);
|
|
2933
|
+
};
|
|
2934
|
+
get shadow() {
|
|
2935
|
+
return this.#e;
|
|
2936
|
+
}
|
|
2937
|
+
get dataManager() {
|
|
2938
|
+
return this.#t;
|
|
2939
|
+
}
|
|
2940
|
+
get data() {
|
|
2941
|
+
return this.#t.data;
|
|
2942
|
+
}
|
|
2943
|
+
get row() {
|
|
2944
|
+
return this.#t.row;
|
|
2945
|
+
}
|
|
2946
|
+
setData(e) {
|
|
2947
|
+
this.#t.data.set(e), this.refresh();
|
|
2948
|
+
}
|
|
2949
|
+
refresh() {
|
|
2950
|
+
this.activeSheet?.invalidate();
|
|
2951
|
+
}
|
|
2952
|
+
set loading(e) {
|
|
2953
|
+
this.#n && (this.#n.loading = e);
|
|
2954
|
+
}
|
|
2955
|
+
rerenderer() {
|
|
2956
|
+
this.activeSheet?.querySelectorAll("tbody.body th,tbody.body td").forEach((e) => {
|
|
2957
|
+
Array.from(e.children).find((e) => e.tagName.toLowerCase().startsWith("cell-") && typeof e.rerenderer == "function")?.rerenderer();
|
|
2958
|
+
});
|
|
2959
|
+
}
|
|
2960
|
+
sheet = (e) => {
|
|
2961
|
+
if (e === null || e < 0) return this.activeSheet;
|
|
2962
|
+
let t = Array.from(this.shadow.querySelectorAll("nine-table-sheet"));
|
|
2963
|
+
return typeof e == "number" ? t[e] || null : typeof e == "string" ? this.shadow.querySelector(`nine-table-sheet#${e}, nine-table-sheet[data-sheet-id="${e}"]`) || null : t[0] || null;
|
|
2964
|
+
};
|
|
2965
|
+
get sheets() {
|
|
2966
|
+
return Array.from(this.shadow.querySelectorAll("nine-table-sheet"));
|
|
2967
|
+
}
|
|
2968
|
+
get activeSheet() {
|
|
2969
|
+
return this.shadow.querySelector("nine-table-sheet.active") || null;
|
|
2970
|
+
}
|
|
2971
|
+
#a() {
|
|
2972
|
+
let e = /* @__PURE__ */ new Set();
|
|
2973
|
+
this.querySelectorAll("[data-source]").forEach((t) => {
|
|
2974
|
+
let n = t.getAttribute("data-source");
|
|
2975
|
+
if (!n) return;
|
|
2976
|
+
let r = n.matchAll(/(?:host\.)?([a-zA-Z0-9_$]+)\s*\(/g);
|
|
2977
|
+
for (let t of r) {
|
|
2978
|
+
let n = t[1];
|
|
2979
|
+
n && n !== "host" && e.add(n);
|
|
2980
|
+
}
|
|
2981
|
+
}), e.forEach((e) => {
|
|
2982
|
+
let t = null;
|
|
2983
|
+
Object.defineProperty(this, e, {
|
|
2984
|
+
set: (e) => {
|
|
2985
|
+
t = e, this.rerenderer();
|
|
2986
|
+
},
|
|
2987
|
+
get: () => t,
|
|
2988
|
+
configurable: !0,
|
|
2989
|
+
enumerable: !0
|
|
2990
|
+
});
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
execute = (e) => {
|
|
2994
|
+
setTimeout(() => {
|
|
2995
|
+
this.loading = !0, setTimeout(() => {
|
|
2996
|
+
try {
|
|
2997
|
+
e.call(this);
|
|
2998
|
+
} finally {
|
|
2999
|
+
this.loading = !1;
|
|
3000
|
+
}
|
|
3001
|
+
});
|
|
3002
|
+
});
|
|
3003
|
+
};
|
|
3004
|
+
};
|
|
3005
|
+
customElements.get("nine-table") || customElements.define("nine-table", F), customElements.get("nine-table-simple") || customElements.define("nine-table-simple", class extends F {
|
|
3006
|
+
connectedCallback() {
|
|
3007
|
+
this.setAttribute("theme", "simple"), super.connectedCallback();
|
|
3008
|
+
}
|
|
3009
|
+
});
|
|
3010
|
+
// src/cell/core/BasicCellElement.js
|
|
3011
|
+
var I = class extends HTMLElement {
|
|
3012
|
+
static _styleCache = /* @__PURE__ */ new Map();
|
|
3013
|
+
static _customStyleCache = /* @__PURE__ */ new Map();
|
|
3014
|
+
constructor() {
|
|
3015
|
+
super();
|
|
3016
|
+
}
|
|
3017
|
+
applyBaseStyle() {
|
|
3018
|
+
this.constructor.name;
|
|
3019
|
+
}
|
|
3020
|
+
connectedCallback() {}
|
|
3021
|
+
}, L = /* @__PURE__ */ new Map(), R = class extends I {
|
|
3022
|
+
#e;
|
|
3023
|
+
#t;
|
|
3024
|
+
#n;
|
|
3025
|
+
#r;
|
|
3026
|
+
#i;
|
|
3027
|
+
constructor() {
|
|
3028
|
+
super();
|
|
3029
|
+
}
|
|
3030
|
+
get host() {
|
|
3031
|
+
return this.#e;
|
|
3032
|
+
}
|
|
3033
|
+
get sheet() {
|
|
3034
|
+
return this.#t;
|
|
3035
|
+
}
|
|
3036
|
+
get cell() {
|
|
3037
|
+
return this.#r;
|
|
3038
|
+
}
|
|
3039
|
+
get tr() {
|
|
3040
|
+
return this.#n;
|
|
3041
|
+
}
|
|
3042
|
+
get attr() {
|
|
3043
|
+
return this.#i;
|
|
3044
|
+
}
|
|
3045
|
+
connectedCallback() {
|
|
3046
|
+
super.connectedCallback(), this.#e = this.getRootNode().host, this.#r = this.closest("th,td"), this.#n = this.#r.closest("tr"), this.#t = this.#n.closest("nine-table-sheet"), this.#r.classList.add(this.tagName), this.#i = {};
|
|
3047
|
+
for (let e = 0; e < this.#r.attributes.length; e++) {
|
|
3048
|
+
let t = this.#r.attributes[e].name;
|
|
3049
|
+
[
|
|
3050
|
+
"text-align",
|
|
3051
|
+
"class",
|
|
3052
|
+
"cell-type",
|
|
3053
|
+
"data-bind",
|
|
3054
|
+
"data-expr",
|
|
3055
|
+
"data-col",
|
|
3056
|
+
"tabindex"
|
|
3057
|
+
].includes(t) || (this.#i[t] = this.#r.attributes[e].value);
|
|
3058
|
+
}
|
|
3059
|
+
if (!this.#r) return;
|
|
3060
|
+
let e = this.shadowRoot || this;
|
|
3061
|
+
e.querySelectorAll("button, ng-expand-button").forEach((e) => {
|
|
3062
|
+
e.addEventListener("click", () => {
|
|
3063
|
+
let e = this.getAttribute("onbuttonclick") || this.getAttribute("onButtonClick") || this.#r?.getAttribute("onbuttonclick") || this.#r?.getAttribute("onButtonClick"), t = this.data, n = parseInt(this.#r.dataset.row, 10);
|
|
3064
|
+
if (e && this.#e) {
|
|
3065
|
+
e = e.replace("()", "");
|
|
3066
|
+
let r = e.match(/^(\w+)\s*\(/)?.[1] || e;
|
|
3067
|
+
typeof this.#e[r] == "function" ? this.#e[r].call(this.#e, t, n, this.#r) : typeof this.#e.exprFunction == "function" && this.#e.exprFunction(e).call(this, t, n);
|
|
3068
|
+
}
|
|
3069
|
+
});
|
|
3070
|
+
});
|
|
3071
|
+
let t = e.querySelector(".renderer");
|
|
3072
|
+
t && this.getAttribute("link") === "true" && (t.classList.add("link"), t.addEventListener("click", () => {
|
|
3073
|
+
let e = this.getAttribute("onlinkclick") || this.getAttribute("onLinkClick"), t = this.data, n = parseInt(this.#r.dataset.row, 10);
|
|
3074
|
+
if (e && this.#e) {
|
|
3075
|
+
e = e.replace("()", "");
|
|
3076
|
+
let r = e.match(/^(\w+)\s*\(/)?.[1] || e;
|
|
3077
|
+
typeof this.#e[r] == "function" ? this.#e[r].call(this.#e, t, n, this.#r) : typeof this.#e.exprFunction == "function" && this.#e.exprFunction(e).call(this, t, n);
|
|
3078
|
+
}
|
|
3079
|
+
this.#e?.dispatchEvent(new CustomEvent(ninegrid.EVENT.LINK_CLICK, {
|
|
3080
|
+
detail: {
|
|
3081
|
+
target: this.#r,
|
|
3082
|
+
data: t,
|
|
3083
|
+
currow: n
|
|
3084
|
+
},
|
|
3085
|
+
bubbles: !0,
|
|
3086
|
+
composed: !0
|
|
3087
|
+
}));
|
|
3088
|
+
}));
|
|
3089
|
+
}
|
|
3090
|
+
get data() {
|
|
3091
|
+
let e = this.#n?.data;
|
|
3092
|
+
if (!e) return null;
|
|
3093
|
+
if (!e.v) return e;
|
|
3094
|
+
let t = this.#e;
|
|
3095
|
+
return new Proxy(e, { get(e, n) {
|
|
3096
|
+
if (n === "__ng") return e.__ng;
|
|
3097
|
+
if (n === "v") return e.v;
|
|
3098
|
+
let r = t?.fields?.indexOf?.(n) ?? -1;
|
|
3099
|
+
return r >= 0 ? e.v[r] : e[n];
|
|
3100
|
+
} });
|
|
3101
|
+
}
|
|
3102
|
+
get value() {
|
|
3103
|
+
if (!this.#r || !this.#n?.data) return "";
|
|
3104
|
+
let e = this.#r.dataset?.bind;
|
|
3105
|
+
if (!e) return "";
|
|
3106
|
+
let t = this.#n.data;
|
|
3107
|
+
if (t.v && Array.isArray(t.v)) {
|
|
3108
|
+
let n = this.#e.fields.get().indexOf(e) ?? -1;
|
|
3109
|
+
return n >= 0 ? t.v[n] ?? "" : "";
|
|
3110
|
+
}
|
|
3111
|
+
return t[e] ?? "";
|
|
3112
|
+
}
|
|
3113
|
+
set value(e) {
|
|
3114
|
+
if (!this.#r || !this.#e?.data) return;
|
|
3115
|
+
let t = parseInt(this.#r.dataset.row, 10), n = this.#r.dataset.bind;
|
|
3116
|
+
if (isNaN(t) || !n) return;
|
|
3117
|
+
let r = this.getAttribute("update-row-state") !== "false";
|
|
3118
|
+
this.#e.data.setValue(t, n, e, r);
|
|
3119
|
+
}
|
|
3120
|
+
get row() {
|
|
3121
|
+
return parseInt(this.#r?.dataset?.row, 10);
|
|
3122
|
+
}
|
|
3123
|
+
get index() {
|
|
3124
|
+
return parseInt(this.#r?.dataset?.index, 10);
|
|
3125
|
+
}
|
|
3126
|
+
isValid() {
|
|
3127
|
+
return !this.#r.classList.contains("invalid");
|
|
3128
|
+
}
|
|
3129
|
+
isInvalid() {
|
|
3130
|
+
return !this.isValid();
|
|
3131
|
+
}
|
|
3132
|
+
getDisplayText = (e = "") => {
|
|
3133
|
+
if (!this.#r || !this.#r.closest("tbody") || !this.#n.data) return e;
|
|
3134
|
+
let t = this.#r.dataset.expr, n = this.#r.dataset.bind, r = parseInt(this.#r.dataset.row, 10);
|
|
3135
|
+
if (t) try {
|
|
3136
|
+
return this.#n.getAttribute("grouping") === "true" ? this.getGroupExprValue(t, this.#n.data, r, this.#r) : this.#e.exprEngine.evaluate(t, this.#n.data, r);
|
|
3137
|
+
} catch (t) {
|
|
3138
|
+
return console.trace(t), e;
|
|
3139
|
+
}
|
|
3140
|
+
return n ? this.value ?? e : e;
|
|
3141
|
+
};
|
|
3142
|
+
refresh() {
|
|
3143
|
+
if (!this.#r || !this.#n) return;
|
|
3144
|
+
let e = this.value;
|
|
3145
|
+
return this.#r.classList.remove("invalid"), [
|
|
3146
|
+
"color",
|
|
3147
|
+
"background",
|
|
3148
|
+
"background-color",
|
|
3149
|
+
"visible",
|
|
3150
|
+
"enable",
|
|
3151
|
+
"validator"
|
|
3152
|
+
].forEach((e) => {
|
|
3153
|
+
let t = this.#i[e];
|
|
3154
|
+
if (t) {
|
|
3155
|
+
let n = this.#e.exprEngine.evaluate(t, this.#n.data, parseInt(this.#r.dataset.row, 10));
|
|
3156
|
+
e === "validator" ? n || this.#r.classList.add("invalid") : e === "visible" ? this.style.display = n ? "" : "none" : e === "enable" ? (this.querySelectorAll("input, button, textarea, select").forEach((e) => {
|
|
3157
|
+
e.disabled = !n;
|
|
3158
|
+
}), n ? this.#r.removeAttribute("disabled") : this.#r.setAttribute("disabled", "true")) : this.#r.style[e] = n;
|
|
3159
|
+
}
|
|
3160
|
+
}), e;
|
|
3161
|
+
}
|
|
3162
|
+
getExprValue(e, t, n) {
|
|
3163
|
+
return !this.#e || !this.#e.exprEngine || e == null || e === "" ? e : this.#e.exprEngine.evaluate(e, t, n);
|
|
3164
|
+
}
|
|
3165
|
+
getGroupExprValue = (e, t, n, r) => {
|
|
3166
|
+
if (!e) return "";
|
|
3167
|
+
try {
|
|
3168
|
+
n = parseInt(n, 10);
|
|
3169
|
+
let i = e.replace("()", "").trim();
|
|
3170
|
+
if (this.#e && typeof this.#e[i] == "function") return this.#e[i].call(this, t, n, r);
|
|
3171
|
+
let a = i.match(/^(\w+)\s*\(\s*([\w\-]*)\s*\)/);
|
|
3172
|
+
if (a) {
|
|
3173
|
+
let e = t[GROUP_IDX.CHILDREN], n = this.#e?.data?.getArray ? this.#e.data.getArray() : [], r = e ? e.map((e) => n[e]).filter(Boolean) : [], [, i, o] = a, s = this.#e;
|
|
3174
|
+
switch (i.toLowerCase()) {
|
|
3175
|
+
case "count": return r.length;
|
|
3176
|
+
case "sum": {
|
|
3177
|
+
let e = s?.fields?.indexOf?.(o) ?? -1;
|
|
3178
|
+
return r.reduce((t, n) => {
|
|
3179
|
+
let r = e >= 0 ? n.v?.[e] : n[o];
|
|
3180
|
+
return t + (Number(r) || 0);
|
|
3181
|
+
}, 0);
|
|
3182
|
+
}
|
|
3183
|
+
case "avg": {
|
|
3184
|
+
if (r.length === 0) return 0;
|
|
3185
|
+
let e = s?.fields?.indexOf?.(o) ?? -1;
|
|
3186
|
+
return r.reduce((t, n) => {
|
|
3187
|
+
let r = e >= 0 ? n.v?.[e] : n[o];
|
|
3188
|
+
return t + (Number(r) || 0);
|
|
3189
|
+
}, 0) / r.length;
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
if (this.#e && typeof this.#e.exprFunction == "function") return this.#e.exprFunction(e).call(this, t, n, this.#e.data);
|
|
3194
|
+
if (e.includes("data.") || e.includes("childRecords") || e.includes("groupRecord")) {
|
|
3195
|
+
let i = L.get("grp_" + e);
|
|
3196
|
+
return i || (i = Function("groupRecord", "row", "cell", "host", `
|
|
3197
|
+
const indices = groupRecord[3]; // GROUP_IDX.CHILDREN = 3
|
|
3198
|
+
const allRecords = host?.data?.getArray ? host.data.getArray() : [];
|
|
3199
|
+
|
|
3200
|
+
let childRecords = [];
|
|
3201
|
+
if (Array.isArray(indices)) {
|
|
3202
|
+
// indices가 숫자 인덱스 배열인지, rowid 문자열 배열인지 판별하여 안전하게 추출
|
|
3203
|
+
childRecords = indices.map(idx => {
|
|
3204
|
+
if (typeof idx === 'number') {
|
|
3205
|
+
return allRecords[idx];
|
|
3206
|
+
} else {
|
|
3207
|
+
// rowid 등 문자열 식별자인 경우 전체 배열에서 찾거나 dataManager 활용
|
|
3208
|
+
return allRecords.find(r => r?.__ng?.rowid === idx || r?.m?._?.[0] === idx);
|
|
3209
|
+
}
|
|
3210
|
+
}).filter(Boolean);
|
|
3211
|
+
}
|
|
3212
|
+
|
|
3213
|
+
// 만약 위에서 못 찾았는데 host.grouping을 쓸 수 있다면 매니저 위임 시도
|
|
3214
|
+
if (childRecords.length === 0 && host?.grouping?.getChildrenRecords && groupRecord[0]) {
|
|
3215
|
+
childRecords = host.grouping.getChildrenRecords(groupRecord[0]);
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
const data = childRecords; // data.length 등을 쓸 수 있도록 호환
|
|
3219
|
+
return ${e};
|
|
3220
|
+
`), L.set("grp_" + e, i)), i(t, n, r, this.#e);
|
|
3221
|
+
}
|
|
3222
|
+
return e;
|
|
3223
|
+
} catch (t) {
|
|
3224
|
+
return console.error("Group expr evaluation error:", e, t), e;
|
|
3225
|
+
}
|
|
3226
|
+
};
|
|
3227
|
+
}, z = class extends R {
|
|
3228
|
+
get host() {
|
|
3229
|
+
return super.host;
|
|
3230
|
+
}
|
|
3231
|
+
get sheet() {
|
|
3232
|
+
return super.sheet;
|
|
3233
|
+
}
|
|
3234
|
+
get cell() {
|
|
3235
|
+
return super.cell;
|
|
3236
|
+
}
|
|
3237
|
+
get tr() {
|
|
3238
|
+
return super.tr;
|
|
3239
|
+
}
|
|
3240
|
+
get attr() {
|
|
3241
|
+
return super.attr;
|
|
3242
|
+
}
|
|
3243
|
+
getExprValue(e, t, n, r) {
|
|
3244
|
+
return super.getExprValue(e, t, n, r);
|
|
3245
|
+
}
|
|
3246
|
+
constructor() {
|
|
3247
|
+
super();
|
|
3248
|
+
}
|
|
3249
|
+
connectedCallback() {
|
|
3250
|
+
super.connectedCallback();
|
|
3251
|
+
}
|
|
3252
|
+
refresh() {
|
|
3253
|
+
return super.refresh();
|
|
3254
|
+
}
|
|
3255
|
+
getExprValue = (e, t, n, r) => super.getExprValue(e, t, n, r);
|
|
3256
|
+
isValid = () => super.isValid();
|
|
3257
|
+
isInvalid = () => super.isInvalid();
|
|
3258
|
+
}, B = class extends z {
|
|
3259
|
+
#e;
|
|
3260
|
+
constructor() {
|
|
3261
|
+
super();
|
|
3262
|
+
}
|
|
3263
|
+
connectedCallback() {
|
|
3264
|
+
super.connectedCallback(), this.#n(), this.#e = this.querySelector("input"), this.#t();
|
|
3265
|
+
}
|
|
3266
|
+
refresh = () => {
|
|
3267
|
+
let e = super.refresh();
|
|
3268
|
+
this.#e.value = e;
|
|
3269
|
+
};
|
|
3270
|
+
#t = () => {
|
|
3271
|
+
this.#e.addEventListener("input", (e) => {
|
|
3272
|
+
if (this.#r) {
|
|
3273
|
+
let t = Number(this.#r);
|
|
3274
|
+
nine.getByteLength(e.target.value) > t && (e.target.value = nine.cut(e.target.value, t), this.value = e.target.value);
|
|
3275
|
+
}
|
|
3276
|
+
}), this.#e.addEventListener("change", (e) => {
|
|
3277
|
+
this.value = e.target.value, this.sheet.rowManager.refresh(!0);
|
|
3278
|
+
});
|
|
3279
|
+
};
|
|
3280
|
+
#n = () => {
|
|
3281
|
+
this.innerHTML = "\n <input type=\"text\" ondragstart=\"return false;\">\n ";
|
|
3282
|
+
};
|
|
3283
|
+
get #r() {
|
|
3284
|
+
return this.cell.getAttribute("maxbyte") || this.cell.getAttribute("max-byte");
|
|
3285
|
+
}
|
|
3286
|
+
};
|
|
3287
|
+
customElements.get("cell-input") || customElements.define("cell-input", B);
|
|
3288
|
+
// src/cell/cell-input-number.js
|
|
3289
|
+
var V = class extends z {
|
|
3290
|
+
#e;
|
|
3291
|
+
constructor() {
|
|
3292
|
+
super();
|
|
3293
|
+
}
|
|
3294
|
+
connectedCallback() {
|
|
3295
|
+
super.connectedCallback(), this.#t(), this.#e = this.querySelector("input"), this.#n();
|
|
3296
|
+
}
|
|
3297
|
+
#t = () => {
|
|
3298
|
+
this.innerHTML = "\n <input type=\"text\" ondragstart=\"return false;\">\n ";
|
|
3299
|
+
};
|
|
3300
|
+
#n = () => {
|
|
3301
|
+
this.#e.addEventListener("keydown", this.#i), this.#e.addEventListener("input", (e) => {
|
|
3302
|
+
this.value = e.target.value, this.sheet.rowManager.refresh(!0);
|
|
3303
|
+
}), this.#e.addEventListener("change", (e) => {
|
|
3304
|
+
this.value = e.target.value, this.sheet.rowManager.refresh(!0);
|
|
3305
|
+
});
|
|
3306
|
+
};
|
|
3307
|
+
refresh = () => {
|
|
3308
|
+
let e = super.refresh();
|
|
3309
|
+
this.#e.value = e, this.isValid() && this.#r();
|
|
3310
|
+
};
|
|
3311
|
+
#r = () => {
|
|
3312
|
+
let e = this.#e.value;
|
|
3313
|
+
if (e !== "" && e != null) {
|
|
3314
|
+
let t = Number(e);
|
|
3315
|
+
if (isNaN(t) || this.#o && t > Number(this.#o) || this.#a && t < Number(this.#a)) this.cell.classList.add("invalid");
|
|
3316
|
+
else if (this.#s) {
|
|
3317
|
+
let t = String(e), n = t.indexOf(".");
|
|
3318
|
+
n >= 0 && t.substring(n + 1).length > Number(this.#s) && this.cell.classList.add("invalid");
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
};
|
|
3322
|
+
#i = (e) => {
|
|
3323
|
+
if ([
|
|
3324
|
+
"Escape",
|
|
3325
|
+
"Enter",
|
|
3326
|
+
"Tab",
|
|
3327
|
+
"Home",
|
|
3328
|
+
"End",
|
|
3329
|
+
"ArrowLeft",
|
|
3330
|
+
"ArrowRight",
|
|
3331
|
+
"PageUp",
|
|
3332
|
+
"PageDown",
|
|
3333
|
+
"Backspace",
|
|
3334
|
+
"Delete"
|
|
3335
|
+
].includes(e.code)) return;
|
|
3336
|
+
let t = e.target, n = t.value, r = t.selectionStart, i = e.key;
|
|
3337
|
+
if (i === "-" && (n.includes("-") || r !== 0)) {
|
|
3338
|
+
e.preventDefault();
|
|
3339
|
+
return;
|
|
3340
|
+
}
|
|
3341
|
+
if (i === ".") {
|
|
3342
|
+
let t = Number(this.#s);
|
|
3343
|
+
if (isNaN(t) || t <= 0 || n.includes(".")) {
|
|
3344
|
+
e.preventDefault();
|
|
3345
|
+
return;
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
let a = [];
|
|
3349
|
+
this.#s && Number(this.#s) > 0 && a.push("."), (this.#a || Number(this.#a) > 0) && a.push("-");
|
|
3350
|
+
let o = e.keyCode >= 48 && e.keyCode <= 57 || e.keyCode >= 96 && e.keyCode <= 105;
|
|
3351
|
+
if (!o && !a.includes(e.key)) e.preventDefault();
|
|
3352
|
+
else {
|
|
3353
|
+
if (this.#s && o && e.target.selectionStart == e.target.selectionEnd) {
|
|
3354
|
+
let t = e.target.value, n = t.indexOf(".");
|
|
3355
|
+
n >= 0 && e.target.selectionStart > n && t.substr(n + 1).length >= Number(this.#s) && e.preventDefault();
|
|
3356
|
+
}
|
|
3357
|
+
this.#c && nine.getByteLength(e.target.value) >= Number(this.#c) && e.target.selectionStart == e.target.selectionEnd && e.preventDefault();
|
|
3358
|
+
}
|
|
3359
|
+
};
|
|
3360
|
+
get #a() {
|
|
3361
|
+
return this.cell.getAttribute("min") || "";
|
|
3362
|
+
}
|
|
3363
|
+
get #o() {
|
|
3364
|
+
return this.cell.getAttribute("max") || "";
|
|
3365
|
+
}
|
|
3366
|
+
get #s() {
|
|
3367
|
+
return this.cell.getAttribute("scale") || "";
|
|
3368
|
+
}
|
|
3369
|
+
get #c() {
|
|
3370
|
+
return this.cell.getAttribute("maxbyte") || this.cell.getAttribute("max-byte");
|
|
3371
|
+
}
|
|
3372
|
+
};
|
|
3373
|
+
customElements.get("cell-input-number") || customElements.define("cell-input-number", V);
|
|
3374
|
+
// src/cell/cell-input-color.js
|
|
3375
|
+
var H = class extends z {
|
|
3376
|
+
#e;
|
|
3377
|
+
#t;
|
|
3378
|
+
#n;
|
|
3379
|
+
constructor() {
|
|
3380
|
+
super();
|
|
3381
|
+
}
|
|
3382
|
+
connectedCallback() {
|
|
3383
|
+
super.connectedCallback(), this.#i(), this.#e = this.querySelector("input[type=color]"), this.#t = this.querySelector("button"), this.#r();
|
|
3384
|
+
}
|
|
3385
|
+
#r = () => {
|
|
3386
|
+
this.#t.addEventListener("click", () => {
|
|
3387
|
+
this.#e.click();
|
|
3388
|
+
}), this.#e.addEventListener("input", (e) => {
|
|
3389
|
+
let t = e.target.value;
|
|
3390
|
+
this.value = t, this.#o(t), this.sheet.rowManager.refresh(!0);
|
|
3391
|
+
}), this.#e.addEventListener("change", (e) => {
|
|
3392
|
+
let t = e.target.value;
|
|
3393
|
+
this.value = t, this.#o(t), this.sheet.rowManager.refresh(!0);
|
|
3394
|
+
});
|
|
3395
|
+
};
|
|
3396
|
+
#i = () => {
|
|
3397
|
+
this.innerHTML = "\n <input type=\"color\" ondragstart=\"return false;\">\n <button tabindex=\"-1\" type=\"button\"></button>\n ";
|
|
3398
|
+
};
|
|
3399
|
+
rerenderer = () => {
|
|
3400
|
+
this.refresh();
|
|
3401
|
+
};
|
|
3402
|
+
#a = () => {
|
|
3403
|
+
this.tr.data;
|
|
3404
|
+
let e = this.cell.getAttribute("data-source");
|
|
3405
|
+
if (e && (this.#n = super.getExprValue(e, this.tr.data, this.tr.dataset.row), this.querySelector("datalist")?.remove(), this.#n && Array.isArray(this.#n))) {
|
|
3406
|
+
let e = `color-list-${Math.random().toString(36).substr(2, 9)}`, t = document.createElement("datalist");
|
|
3407
|
+
t.id = e;
|
|
3408
|
+
let n = document.createDocumentFragment();
|
|
3409
|
+
this.#n.forEach((e) => {
|
|
3410
|
+
if (e.value) {
|
|
3411
|
+
let t = document.createElement("option");
|
|
3412
|
+
t.value = e.value, n.appendChild(t);
|
|
3413
|
+
}
|
|
3414
|
+
}), t.appendChild(n), this.appendChild(t), this.#e.setAttribute("list", e);
|
|
3415
|
+
}
|
|
3416
|
+
};
|
|
3417
|
+
refresh = () => {
|
|
3418
|
+
if (!this.tr.data) return;
|
|
3419
|
+
let e = super.refresh();
|
|
3420
|
+
this.#a(), this.#e.value = e != null && e !== "" ? e : "#ffffff", this.isValid() && this.#o();
|
|
3421
|
+
};
|
|
3422
|
+
#o = () => {
|
|
3423
|
+
let e = this.#e.value;
|
|
3424
|
+
e !== "" && e != null && (this.#s(e) ? this.#n && Array.isArray(this.#n) && this.#n.length > 0 && (this.#n.some((t) => (t.value === void 0 ? t.code === void 0 ? "" : t.code : t.value).toLowerCase() === e.toLowerCase()) || this.cell.classList.add("invalid")) : this.cell.classList.add("invalid"));
|
|
3425
|
+
};
|
|
3426
|
+
#s = (e) => {
|
|
3427
|
+
if (typeof e != "string" || e.length != 7 || !e.startsWith("#")) return !1;
|
|
3428
|
+
var t = parseInt(e.substr(1, 2), 16), n = parseInt(e.substr(3, 2), 16), r = parseInt(e.substr(5, 2), 16);
|
|
3429
|
+
return !(isNaN(t) || isNaN(n) || isNaN(r) || t < 0 || t > 255 || n < 0 || n > 255 || r < 0 || r > 255);
|
|
3430
|
+
};
|
|
3431
|
+
};
|
|
3432
|
+
customElements.get("cell-input-color") || customElements.define("cell-input-color", H);
|
|
3433
|
+
// src/cell/cell-input-date.js
|
|
3434
|
+
var U = class extends z {
|
|
3435
|
+
#e;
|
|
3436
|
+
#t;
|
|
3437
|
+
constructor() {
|
|
3438
|
+
super();
|
|
3439
|
+
}
|
|
3440
|
+
connectedCallback() {
|
|
3441
|
+
super.connectedCallback(), this.#n(), this.#e = this.querySelector("input"), this.#e.addEventListener("input", (e) => {
|
|
3442
|
+
let t = e.target.value;
|
|
3443
|
+
this.value = t, this.#e.classList.toggle("has-value", !!t), this.#r(t), super.sheet.rowManager.refresh(!0);
|
|
3444
|
+
}), this.#e.addEventListener("change", (e) => {
|
|
3445
|
+
let t = e.target.value;
|
|
3446
|
+
this.value = t, this.#r(t), super.sheet.rowManager.refresh(!0);
|
|
3447
|
+
});
|
|
3448
|
+
}
|
|
3449
|
+
#n = () => {
|
|
3450
|
+
if (this.#t = this.cell.getAttribute("date-type") || "date", ![
|
|
3451
|
+
"date",
|
|
3452
|
+
"datetime-local",
|
|
3453
|
+
"time",
|
|
3454
|
+
"week",
|
|
3455
|
+
"month"
|
|
3456
|
+
].includes(this.#t)) throw `invalid type : ${this.#t}`;
|
|
3457
|
+
let e = [];
|
|
3458
|
+
for (let t = 0; t < this.cell.attributes.length; t++) [
|
|
3459
|
+
"value",
|
|
3460
|
+
"max",
|
|
3461
|
+
"min",
|
|
3462
|
+
"step"
|
|
3463
|
+
].includes(this.cell.attributes[t].name) && e.push(`${this.cell.attributes[t].name}="${this.cell.attributes[t].value}"`);
|
|
3464
|
+
this.innerHTML = `
|
|
3465
|
+
<input
|
|
3466
|
+
type="${this.#t}"
|
|
3467
|
+
data-placeholder="${this.cell.getAttribute("placeholder") || "Select"}"
|
|
3468
|
+
${e.join(" ")}
|
|
3469
|
+
required
|
|
3470
|
+
/>
|
|
3471
|
+
`;
|
|
3472
|
+
};
|
|
3473
|
+
refresh = () => {
|
|
3474
|
+
let e = super.refresh(), t = e;
|
|
3475
|
+
if (t) switch (this.#t) {
|
|
3476
|
+
case "date":
|
|
3477
|
+
t = t.substr(0, 10);
|
|
3478
|
+
break;
|
|
3479
|
+
case "datetime-local":
|
|
3480
|
+
t = t.substr(0, 16);
|
|
3481
|
+
break;
|
|
3482
|
+
case "time":
|
|
3483
|
+
var n = new Date(e);
|
|
3484
|
+
n != "Invalid Date" && !isNaN(n) && (t = ("00" + n.getHours()).slice(-2) + ":" + ("00" + n.getMinutes()).slice(-2));
|
|
3485
|
+
break;
|
|
3486
|
+
case "month":
|
|
3487
|
+
var n = new Date(e);
|
|
3488
|
+
n != "Invalid Date" && !isNaN(n) && (t = ("0000" + n.getFullYear()).slice(-4) + "-" + ("00" + (n.getMonth() + 1)).slice(-2));
|
|
3489
|
+
}
|
|
3490
|
+
this.#e.value = t || "", this.#e.classList.toggle("has-value", !!t), this.isValid() && this.#r(t);
|
|
3491
|
+
};
|
|
3492
|
+
#r = (e) => {
|
|
3493
|
+
if (e !== "" && e != null) {
|
|
3494
|
+
let t = this.#i(e);
|
|
3495
|
+
t && (this.#a && e < this.#a && (t = !1), this.#o && e > this.#o && (t = !1)), t || super.cell.classList.add("invalid");
|
|
3496
|
+
}
|
|
3497
|
+
};
|
|
3498
|
+
#i = (e) => {
|
|
3499
|
+
if (typeof e != "string") return !1;
|
|
3500
|
+
let t = !0;
|
|
3501
|
+
switch (this.#t) {
|
|
3502
|
+
case "date":
|
|
3503
|
+
case "datetime-local":
|
|
3504
|
+
let n = Number(e.substr(0, 4)), r = Number(e.substr(5, 2)), i = Number(e.substr(8, 2));
|
|
3505
|
+
if (isNaN(n) || isNaN(r) || isNaN(i)) t = !1;
|
|
3506
|
+
else if (r < 1 || r > 12 || i < 1 || i > 31) t = !1;
|
|
3507
|
+
else if ([
|
|
3508
|
+
4,
|
|
3509
|
+
6,
|
|
3510
|
+
9,
|
|
3511
|
+
11
|
|
3512
|
+
].includes(r) && i == 31) t = !1;
|
|
3513
|
+
else if (r == 2) {
|
|
3514
|
+
let e = n % 4 == 0 && (n % 100 != 0 || n % 400 == 0);
|
|
3515
|
+
(i > 29 || i == 29 && !e) && (t = !1);
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
if (t) switch (this.#t) {
|
|
3519
|
+
case "datetime-local":
|
|
3520
|
+
var n = e.substr(10, 1), r = Number(e.substr(11, 2)), i = Number(e.substr(14, 2));
|
|
3521
|
+
n == "T" ? (isNaN(r) || isNaN(i) || r < 0 || r > 23 || i < 0 || i > 59) && (t = !1) : t = !1;
|
|
3522
|
+
break;
|
|
3523
|
+
case "month":
|
|
3524
|
+
var a = Number(e.substr(0, 4)), o = Number(e.substr(5, 2));
|
|
3525
|
+
(isNaN(a) || isNaN(o) || o < 1 || o > 12) && (t = !1);
|
|
3526
|
+
break;
|
|
3527
|
+
case "week":
|
|
3528
|
+
var a = Number(e.substr(0, 4)), s = e.substr(5, 1), c = Number(e.substr(6, 2));
|
|
3529
|
+
s == "W" ? (isNaN(a) || isNaN(c) || c <= 0 || c > 53) && (t = !1) : t = !1;
|
|
3530
|
+
}
|
|
3531
|
+
return t;
|
|
3532
|
+
};
|
|
3533
|
+
get #a() {
|
|
3534
|
+
return this.cell.getAttribute("min");
|
|
3535
|
+
}
|
|
3536
|
+
get #o() {
|
|
3537
|
+
return this.cell.getAttribute("max");
|
|
3538
|
+
}
|
|
3539
|
+
};
|
|
3540
|
+
customElements.get("cell-input-date") || customElements.define("cell-input-date", U);
|
|
3541
|
+
// src/cell/cell-checkbox.js
|
|
3542
|
+
var W = class extends z {
|
|
3543
|
+
#e;
|
|
3544
|
+
#t;
|
|
3545
|
+
constructor() {
|
|
3546
|
+
super();
|
|
3547
|
+
}
|
|
3548
|
+
connectedCallback() {
|
|
3549
|
+
super.connectedCallback(), this.#r(), this.#e = this.querySelector("input"), this.#t = this.querySelector("span"), this.#n();
|
|
3550
|
+
}
|
|
3551
|
+
get dataSource() {
|
|
3552
|
+
return [{
|
|
3553
|
+
value: this.trueValue,
|
|
3554
|
+
text: this.#a
|
|
3555
|
+
}, {
|
|
3556
|
+
value: this.falseValue,
|
|
3557
|
+
text: this.#o
|
|
3558
|
+
}];
|
|
3559
|
+
}
|
|
3560
|
+
#n = () => {
|
|
3561
|
+
this.closest("thead") && this.#e.addEventListener("change", (e) => {
|
|
3562
|
+
super.sheet.querySelector(`tbody.body [data-col="${super.cell.dataset.col}"] cell-checkbox`)?.selectAll(e.target.checked);
|
|
3563
|
+
}), this.#e.addEventListener("change", (e) => {
|
|
3564
|
+
this.closest("tbody") && (this.#s ? (this.selectAll(!1), this.value = this.trueValue) : this.value = e.target.checked ? this.trueValue : this.falseValue, this.sheet.rowManager.refresh(!0));
|
|
3565
|
+
});
|
|
3566
|
+
};
|
|
3567
|
+
#r = () => {
|
|
3568
|
+
let e = this.trueValue, t = this.cell.getAttribute("content") || "", n = this.#s ? `<input type="radio" value="${e}" />` : `<label><input type="checkbox" /><span>${t}</span></label>`;
|
|
3569
|
+
this.innerHTML = `
|
|
3570
|
+
${n}
|
|
3571
|
+
`;
|
|
3572
|
+
};
|
|
3573
|
+
refresh = () => {
|
|
3574
|
+
let e = super.refresh();
|
|
3575
|
+
this.#e.checked = e === this.trueValue, this.isValid() && this.#i(e);
|
|
3576
|
+
let t = e === this.trueValue ? this.#a : e === this.falseValue ? this.#o : e;
|
|
3577
|
+
this.#t && (this.#t.textContent = t);
|
|
3578
|
+
};
|
|
3579
|
+
#i = (e) => {
|
|
3580
|
+
this.cell.classList.remove("invalid"), e !== "" && e != null && e !== this.trueValue && e !== this.falseValue && this.cell.classList.add("invalid");
|
|
3581
|
+
};
|
|
3582
|
+
selectAll = (e) => {
|
|
3583
|
+
if (this.closest("thead")) return;
|
|
3584
|
+
let t = this.host.data.getArray(), n = this.host.fields.indexOf(this.cell.dataset.bind);
|
|
3585
|
+
if (!(n < 0)) {
|
|
3586
|
+
for (let r = 0; r < t.length; r++) this.#c && super.getExprValue(this.#c, t[r], r, this.cell) === !1 || this.#l && super.getExprValue(this.#l, t[r], r, this.cell) === !0 || this.#u && super.getExprValue(this.#u, t[r], r, this.cell) === !1 || (t[r].v[n] = e ? this.trueValue : this.falseValue);
|
|
3587
|
+
super.sheet.invalidate();
|
|
3588
|
+
}
|
|
3589
|
+
};
|
|
3590
|
+
get trueValue() {
|
|
3591
|
+
return this.cell.getAttribute("true-value") || "Y";
|
|
3592
|
+
}
|
|
3593
|
+
get falseValue() {
|
|
3594
|
+
return this.cell.getAttribute("false-value") || "N";
|
|
3595
|
+
}
|
|
3596
|
+
get #a() {
|
|
3597
|
+
return this.cell.getAttribute("true-text") || "";
|
|
3598
|
+
}
|
|
3599
|
+
get #o() {
|
|
3600
|
+
return this.cell.getAttribute("false-text") || "";
|
|
3601
|
+
}
|
|
3602
|
+
get #s() {
|
|
3603
|
+
return this.cell.getAttribute("is-radio") || !1;
|
|
3604
|
+
}
|
|
3605
|
+
get #c() {
|
|
3606
|
+
return this.cell.getAttribute("enable") || !1;
|
|
3607
|
+
}
|
|
3608
|
+
get #l() {
|
|
3609
|
+
return this.cell.getAttribute("readonly") || !1;
|
|
3610
|
+
}
|
|
3611
|
+
get #u() {
|
|
3612
|
+
return this.cell.getAttribute("visible") || !1;
|
|
3613
|
+
}
|
|
3614
|
+
};
|
|
3615
|
+
customElements.get("cell-checkbox") || customElements.define("cell-checkbox", W);
|
|
3616
|
+
// src/cell/cell-radio.js
|
|
3617
|
+
var G = class extends z {
|
|
3618
|
+
#e;
|
|
3619
|
+
#t;
|
|
3620
|
+
#n = [];
|
|
3621
|
+
constructor() {
|
|
3622
|
+
super();
|
|
3623
|
+
}
|
|
3624
|
+
connectedCallback() {
|
|
3625
|
+
super.connectedCallback(), this.#a(), this.#i(), this.#r();
|
|
3626
|
+
}
|
|
3627
|
+
#r = () => {
|
|
3628
|
+
this.cell.addEventListener("keydown", (e) => {
|
|
3629
|
+
if (!(this.cell.hasAttribute("readonly") || this.cell.classList.contains("readonly")) && this.cell.getAttribute("disabled") !== "true" && e.code === "Space") {
|
|
3630
|
+
e.preventDefault();
|
|
3631
|
+
let t = -1;
|
|
3632
|
+
this.#t.forEach((e, n) => {
|
|
3633
|
+
if (this.value === e.getAttribute("value")) return t = n, !1;
|
|
3634
|
+
}), t = t === this.#t.length - 1 ? 0 : t >= 0 ? t + 1 : 0, this.value = this.#t[t].getAttribute("value"), this.sheet.rowManager.refresh(!0);
|
|
3635
|
+
}
|
|
3636
|
+
});
|
|
3637
|
+
};
|
|
3638
|
+
#i = () => {
|
|
3639
|
+
n.log("rendererRadio");
|
|
3640
|
+
let e = this.cell.getAttribute("data-source");
|
|
3641
|
+
if (e && (this.#n = super.getExprValue(e, this.tr.data, this.tr.dataset.row), this.#e.replaceChildren(), this.#n && Array.isArray(this.#n))) {
|
|
3642
|
+
let e = document.createDocumentFragment();
|
|
3643
|
+
this.#n.forEach((t) => {
|
|
3644
|
+
let n = t[this.#s] === void 0 ? "" : t[this.#s], r = t[this.#c] === void 0 ? "" : t[this.#c], i = document.createElement("label"), a = document.createElement("input");
|
|
3645
|
+
a.type = "radio", a.value = n;
|
|
3646
|
+
let o = document.createElement("span");
|
|
3647
|
+
o.textContent = r, i.appendChild(a), i.appendChild(o), e.appendChild(i);
|
|
3648
|
+
}), this.#e.appendChild(e), this.#t = Array.from(this.querySelectorAll("input")), this.#t.forEach((e) => {
|
|
3649
|
+
e.addEventListener("change", (e) => {
|
|
3650
|
+
this.value = e.target.value, this.sheet.rowManager.refresh(!0);
|
|
3651
|
+
});
|
|
3652
|
+
});
|
|
3653
|
+
}
|
|
3654
|
+
};
|
|
3655
|
+
#a = () => {
|
|
3656
|
+
this.innerHTML = "\n <div></div>\n ", this.#e = this.querySelector("div");
|
|
3657
|
+
};
|
|
3658
|
+
rerenderer = () => {
|
|
3659
|
+
this.#i(), this.refresh();
|
|
3660
|
+
};
|
|
3661
|
+
refresh = () => {
|
|
3662
|
+
let e = super.refresh();
|
|
3663
|
+
this.#t.forEach((t) => {
|
|
3664
|
+
t.checked = e === t.value;
|
|
3665
|
+
}), this.isValid() && this.#o();
|
|
3666
|
+
};
|
|
3667
|
+
#o = () => {
|
|
3668
|
+
this.value !== null && this.value !== void 0 && this.value !== "" && Array.isArray(this.#n) && this.#n.findIndex((e) => this.value === e[this.#s]) < 0 && this.cell.classList.add("invalid");
|
|
3669
|
+
};
|
|
3670
|
+
get dataSource() {
|
|
3671
|
+
return this.#n;
|
|
3672
|
+
}
|
|
3673
|
+
get #s() {
|
|
3674
|
+
return this.cell.getAttribute("key-name") || "k";
|
|
3675
|
+
}
|
|
3676
|
+
get #c() {
|
|
3677
|
+
return this.cell.getAttribute("value-name") || "v";
|
|
3678
|
+
}
|
|
3679
|
+
};
|
|
3680
|
+
customElements.get("cell-radio") || customElements.define("cell-radio", G);
|
|
3681
|
+
// src/cell/cell-combo-panel.js
|
|
3682
|
+
var K = class extends HTMLElement {
|
|
3683
|
+
#e;
|
|
3684
|
+
#t;
|
|
3685
|
+
#n;
|
|
3686
|
+
#r = !1;
|
|
3687
|
+
constructor() {
|
|
3688
|
+
super();
|
|
3689
|
+
}
|
|
3690
|
+
connectedCallback() {
|
|
3691
|
+
this.#u(), this.#l();
|
|
3692
|
+
}
|
|
3693
|
+
#i = (e, t, r, i, a) => {
|
|
3694
|
+
let o = this.querySelector("nine-table-simple");
|
|
3695
|
+
if (!o || !e || e.length === 0) return;
|
|
3696
|
+
let s = this.#e.getAttribute("items"), c = [];
|
|
3697
|
+
c = s ? s.split(",").map((e) => e.trim()) : [r].filter(Boolean);
|
|
3698
|
+
let l = c.length;
|
|
3699
|
+
o.shadowRoot.querySelector(".ng-container-left").style.display = i ? "" : "none", o.shadowRoot.querySelectorAll("table colgroup col, tbody td").forEach((e, t) => {
|
|
3700
|
+
n.log(e);
|
|
3701
|
+
let r = parseInt(e.dataset.col, 10);
|
|
3702
|
+
r >= 2 && (e.style.display = r - 2 >= l ? "none" : "");
|
|
3703
|
+
});
|
|
3704
|
+
let u = e.map((e) => {
|
|
3705
|
+
let n = {
|
|
3706
|
+
CHK: "N",
|
|
3707
|
+
k: t && e[t] !== void 0 ? e[t] : e[0] === void 0 ? "" : e[0]
|
|
3708
|
+
};
|
|
3709
|
+
return c.forEach((t, r) => {
|
|
3710
|
+
n[`tmp${r + 1}`] = e[t] === void 0 ? e[r] === void 0 ? "" : e[r] : e[t];
|
|
3711
|
+
}), n;
|
|
3712
|
+
});
|
|
3713
|
+
if (o.data.set(u), i && this.#e.value) {
|
|
3714
|
+
let e = String(this.#e.value).split(a || ",");
|
|
3715
|
+
o.data.getValidData().forEach((t) => {
|
|
3716
|
+
e.includes(String(t.v[1])) && (t.v[0] = "Y");
|
|
3717
|
+
}), o.refreshData();
|
|
3718
|
+
}
|
|
3719
|
+
};
|
|
3720
|
+
open = (e, t, r, i, a, o) => {
|
|
3721
|
+
this.#e = e, this.#t = r, this.#n = i, this.#r = !0, n.log(/* @__PURE__ */ new Date()), this.classList.add("active");
|
|
3722
|
+
let s = this.querySelector("nine-table-simple");
|
|
3723
|
+
if (!s || !t) return;
|
|
3724
|
+
this.querySelector(".search-input").value = "", this.querySelector("#chkAll").checked = !0, t.length > 10 ? this.classList.add("expand") : this.classList.remove("expand"), a ? this.classList.add("multi") : this.classList.remove("multi");
|
|
3725
|
+
let c = e.closest("nine-table-sheet"), l = e.querySelector(".btn1");
|
|
3726
|
+
if (!l || !c) return;
|
|
3727
|
+
let u = l.getBoundingClientRect(), d = c.getBoundingClientRect(), f = u.left - d.left, p = u.bottom - d.top + 2, m = this.offsetWidth || 250, h = this.offsetHeight || 250;
|
|
3728
|
+
if (f + m > d.width && (f = Math.max(0, d.width - m - 5)), f < 0 && (f = 5), p + h > d.height) {
|
|
3729
|
+
let e = u.top - d.top - h - 2;
|
|
3730
|
+
p = e >= 0 ? e : Math.max(0, d.height - h - 5);
|
|
3731
|
+
}
|
|
3732
|
+
this.style.left = `${f}px`, this.style.top = `${p}px`, n.log(/* @__PURE__ */ new Date()), setTimeout(() => {
|
|
3733
|
+
n.log(/* @__PURE__ */ new Date()), this.#i(t, r, i, a, o), n.log(/* @__PURE__ */ new Date());
|
|
3734
|
+
let e = s.shadowRoot.querySelector(".ng-container-body table tbody.body");
|
|
3735
|
+
e.__hasClickEvent ||= (e.addEventListener("mousedown", (e) => {
|
|
3736
|
+
n.log("==========================================", e.target), e.target.closest("tr") && (n.log("==========================================", a), a || this.#a(e));
|
|
3737
|
+
}), !0), n.log(/* @__PURE__ */ new Date());
|
|
3738
|
+
}, 100);
|
|
3739
|
+
};
|
|
3740
|
+
close = () => {
|
|
3741
|
+
this.classList.remove("active"), this.#r = !1, this.#e && this.#e.cell && this.#e.cell.focus();
|
|
3742
|
+
};
|
|
3743
|
+
#a = (e) => {
|
|
3744
|
+
let t = e.target.closest("nine-table-sheet"), n = e.target.closest("tr"), r = parseInt(n.dataset.row, 10), i = t.view.get(r);
|
|
3745
|
+
this.#e.value = i.k, this.#e.sheet.rowManager.refresh(!0), this.close();
|
|
3746
|
+
};
|
|
3747
|
+
#o = () => {
|
|
3748
|
+
let e = this.querySelector("nine-table-simple").data.getValidData(), t = [];
|
|
3749
|
+
e.forEach((e) => {
|
|
3750
|
+
e.v[0] === "Y" && t.push(e.v[1]);
|
|
3751
|
+
}), this.#e.value = t.join(this.#e.getAttribute("multi-separator") || ","), this.#e.sheet.rowManager.refresh(!0), this.close();
|
|
3752
|
+
};
|
|
3753
|
+
#s = (e) => {
|
|
3754
|
+
let t = this.querySelector("nine-table-simple"), n = e.target.checked ? "Y" : "N";
|
|
3755
|
+
t.data.getValidData().forEach((e) => {
|
|
3756
|
+
e.v[0] = n;
|
|
3757
|
+
}), t.refreshData();
|
|
3758
|
+
};
|
|
3759
|
+
#c = (e) => {
|
|
3760
|
+
let t = e.target.value.toLowerCase(), n = this.querySelector("nine-table-simple");
|
|
3761
|
+
n.data.getValidDataNF().forEach((e) => {
|
|
3762
|
+
let n = Object.values(e.v).some((e) => e != null && String(e).toLowerCase().includes(t));
|
|
3763
|
+
e.__ng.filtered = !n;
|
|
3764
|
+
}), n.data.resetRecords(), n.dataManager.viewRecords.reset();
|
|
3765
|
+
};
|
|
3766
|
+
get isOpen() {
|
|
3767
|
+
return this.#r;
|
|
3768
|
+
}
|
|
3769
|
+
get targetCell() {
|
|
3770
|
+
return this.#e;
|
|
3771
|
+
}
|
|
3772
|
+
#l = () => {
|
|
3773
|
+
this.querySelector(".search-input").addEventListener("input", this.#c), this.querySelector("#btnOk").addEventListener("click", this.#o), this.querySelector("#chkAll").addEventListener("change", this.#s), document.addEventListener("mousedown", (e) => {
|
|
3774
|
+
(e.composedPath ? e.composedPath() : []).includes(this) || this.close();
|
|
3775
|
+
});
|
|
3776
|
+
};
|
|
3777
|
+
#u = () => {
|
|
3778
|
+
this.innerHTML = "\n <div class=\"head\">\n <input type=\"text\" class=\"search-input\" placeholder=\"Search...\" />\n </div>\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 <div>\n <input id=\"chkAll\" type=\"checkbox\" checked>\n <label for=\"chkAll\">Select All</label>\n </div>\n <button id=\"btnOk\">OK</button>\n </div>\n ";
|
|
3779
|
+
};
|
|
3780
|
+
};
|
|
3781
|
+
customElements.get("cell-combo-panel") || customElements.define("cell-combo-panel", K);
|
|
3782
|
+
// src/cell/cell-combo.js
|
|
3783
|
+
var q = class extends z {
|
|
3784
|
+
#e;
|
|
3785
|
+
#t = [];
|
|
3786
|
+
#n;
|
|
3787
|
+
#r;
|
|
3788
|
+
#i;
|
|
3789
|
+
#a;
|
|
3790
|
+
#o;
|
|
3791
|
+
constructor() {
|
|
3792
|
+
super(), this.applyBaseStyle();
|
|
3793
|
+
}
|
|
3794
|
+
connectedCallback() {
|
|
3795
|
+
this.#u(), super.connectedCallback(), this.#n = super.cell.getAttribute("key-name") || "k", this.#r = super.cell.getAttribute("value-name") || "v", this.#i = super.cell.getAttribute("multi") === "true", this.#a = super.cell.getAttribute("multi-separator") || ",", this.#s(), this.#c();
|
|
3796
|
+
}
|
|
3797
|
+
rerenderer = () => {
|
|
3798
|
+
n.log("rerenderer"), this.#s(), this.refresh();
|
|
3799
|
+
};
|
|
3800
|
+
#s = () => {
|
|
3801
|
+
if (!super.sheet || !super.cell) return;
|
|
3802
|
+
let e = super.cell?.getAttribute("data-source");
|
|
3803
|
+
e && (this.#t = super.getExprValue(e, super.tr.data, super.tr.dataset.row));
|
|
3804
|
+
};
|
|
3805
|
+
#c = () => {
|
|
3806
|
+
this.querySelectorAll("button").forEach((e) => {
|
|
3807
|
+
e.addEventListener("click", (e) => {
|
|
3808
|
+
e.stopPropagation(), this.#l();
|
|
3809
|
+
});
|
|
3810
|
+
});
|
|
3811
|
+
};
|
|
3812
|
+
#l = () => {
|
|
3813
|
+
n.log(/* @__PURE__ */ new Date()), this.#o || (this.#o = super.sheet.querySelector("cell-combo-panel"), this.#o || (this.#o = document.createElement("cell-combo-panel"), super.sheet.appendChild(this.#o))), n.log(/* @__PURE__ */ new Date()), this.#o.isOpen && this.#o.targetCell === this ? this.#o.close() : this.#o.open(this, this.#t, this.#n, this.#r, this.#i, this.#a), n.log(/* @__PURE__ */ new Date());
|
|
3814
|
+
};
|
|
3815
|
+
#u = () => {
|
|
3816
|
+
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");
|
|
3817
|
+
};
|
|
3818
|
+
refresh = () => {
|
|
3819
|
+
let e = super.refresh();
|
|
3820
|
+
return this.#e && (this.#e.textContent = this.#d() || "Select", this.#f()), e;
|
|
3821
|
+
};
|
|
3822
|
+
#d = () => {
|
|
3823
|
+
if (!this.value || !Array.isArray(this.#t)) return "";
|
|
3824
|
+
if (this.#i) {
|
|
3825
|
+
let e = String(this.value).split(this.#a);
|
|
3826
|
+
return this.#t.filter((t) => e.includes(String(t[this.#n]))).map((e) => e[this.#r]).join(this.#a);
|
|
3827
|
+
}
|
|
3828
|
+
{
|
|
3829
|
+
let e = this.#t.find((e) => String(e[this.#n]) === String(this.value));
|
|
3830
|
+
return e ? e[this.#r] : this.value;
|
|
3831
|
+
}
|
|
3832
|
+
};
|
|
3833
|
+
#f = () => {
|
|
3834
|
+
if (!super.cell || (super.cell.classList.remove("invalid"), this.value === null || this.value === void 0 || this.value === "" || !Array.isArray(this.#t))) return;
|
|
3835
|
+
let e = this.#i ? String(this.value).split(this.#a) : [this.value];
|
|
3836
|
+
for (let t of e) if (this.#t.findIndex((e) => String(t) === String(e[this.#n])) < 0) {
|
|
3837
|
+
super.cell.classList.add("invalid");
|
|
3838
|
+
break;
|
|
3839
|
+
}
|
|
3840
|
+
};
|
|
3841
|
+
get dataSource() {
|
|
3842
|
+
return this.#t;
|
|
3843
|
+
}
|
|
3844
|
+
};
|
|
3845
|
+
customElements.get("cell-combo") || customElements.define("cell-combo", q);
|
|
3846
|
+
// src/cell/cell-renderer.js
|
|
3847
|
+
var J = class extends R {
|
|
3848
|
+
#e;
|
|
3849
|
+
constructor() {
|
|
3850
|
+
super();
|
|
3851
|
+
}
|
|
3852
|
+
connectedCallback() {
|
|
3853
|
+
super.connectedCallback(), this.#t(), this.#e = this.querySelector("span");
|
|
3854
|
+
}
|
|
3855
|
+
refresh = () => {
|
|
3856
|
+
super.refresh(), this.cell.getAttribute("html") === "true" ? this.#e.innerHTML = this.getDisplayText() : this.#e.textContent = this.getDisplayText();
|
|
3857
|
+
};
|
|
3858
|
+
#t = () => {
|
|
3859
|
+
this.innerHTML = "\n <span class=\"wrapper\"></span>\n ";
|
|
3860
|
+
};
|
|
3861
|
+
};
|
|
3862
|
+
customElements.get("cell-renderer") || customElements.define("cell-renderer", J);
|
|
3863
|
+
// src/cell/cell-button.js
|
|
3864
|
+
var Y = class extends R {
|
|
3865
|
+
#e;
|
|
3866
|
+
constructor() {
|
|
3867
|
+
super();
|
|
3868
|
+
}
|
|
3869
|
+
connectedCallback() {
|
|
3870
|
+
this.#n(), super.connectedCallback(), this.#e = this.querySelector("button"), this.#e.removeEventListener("click", this.#t), this.#e.addEventListener("click", this.#t);
|
|
3871
|
+
}
|
|
3872
|
+
#t = (e) => {
|
|
3873
|
+
e.stopPropagation();
|
|
3874
|
+
let t = parseInt(this.cell.dataset.row, 10), n = new CustomEvent(r.EVENT.CELL_BUTTON_CLICK, {
|
|
3875
|
+
bubbles: !0,
|
|
3876
|
+
composed: !0,
|
|
3877
|
+
detail: {
|
|
3878
|
+
originalEvent: e,
|
|
3879
|
+
cell: this.cell,
|
|
3880
|
+
row: t,
|
|
3881
|
+
col: parseInt(this.cell.dataset.col, 10),
|
|
3882
|
+
bind: this.dataset.bind,
|
|
3883
|
+
data: this.host.data.get(t),
|
|
3884
|
+
value: this.value
|
|
3885
|
+
}
|
|
3886
|
+
});
|
|
3887
|
+
this.dispatchEvent(n);
|
|
3888
|
+
};
|
|
3889
|
+
refresh = () => {
|
|
3890
|
+
let e = super.refresh ? super.refresh() : this.value;
|
|
3891
|
+
this.#e.innerHTML = this.getDisplayText(e);
|
|
3892
|
+
};
|
|
3893
|
+
#n = () => {
|
|
3894
|
+
let e = this.closest("th,td");
|
|
3895
|
+
(parseInt(e.offsetHeight, 10) || 32) - 8, this.innerHTML = "\n <button class=\"button\">...</button>\n ";
|
|
3896
|
+
};
|
|
3897
|
+
};
|
|
3898
|
+
customElements.get("cell-button") || customElements.define("cell-button", Y);
|
|
3899
|
+
// src/cell/cell-row-indicator.js
|
|
3900
|
+
var X = class extends R {
|
|
3901
|
+
#e;
|
|
3902
|
+
#t;
|
|
3903
|
+
#n;
|
|
3904
|
+
constructor() {
|
|
3905
|
+
super(), this.applyBaseStyle();
|
|
3906
|
+
}
|
|
3907
|
+
connectedCallback() {
|
|
3908
|
+
this.#r(), super.connectedCallback?.(), this.cell && (this.cell.removeAttribute("tabindex"), this.cell.dataset.bind = "rowState", this.cell.dataset.expr || (this.cell.dataset.expr = "data.__ng._[ninegrid.ROW.ORDER]"), this.cell.setAttribute("text-align", "center")), this.#e = this.querySelector(".ng-row-main"), this.#t = this.querySelector(".ng-row-sub"), this.#n = this.querySelector(".ng-row-status");
|
|
3909
|
+
}
|
|
3910
|
+
#r = () => {
|
|
3911
|
+
this.innerHTML = "\n <span class=\"ng-row-main\"></span>\n <span class=\"ng-row-sub\"></span>\n <span class=\"ng-row-status\"></span>\n ";
|
|
3912
|
+
};
|
|
3913
|
+
refresh = () => {
|
|
3914
|
+
if (!this.cell || !this.tr) return;
|
|
3915
|
+
let e = this.row;
|
|
3916
|
+
if (isNaN(e)) return;
|
|
3917
|
+
let t = this.tr.data;
|
|
3918
|
+
t && t.__ng && t.__ng.rowState;
|
|
3919
|
+
let n = this.index + 1, r = n.toLocaleString();
|
|
3920
|
+
if (n >= 1e4) {
|
|
3921
|
+
let e = r.length - 4, t = r.substring(0, e + 1), n = r.substring(e + 1);
|
|
3922
|
+
this.#e.innerHTML = `
|
|
3923
|
+
<span class="ng-row-prefix">${t}</span>
|
|
3924
|
+
<span class="ng-row-suffix">${n}</span>
|
|
3925
|
+
`;
|
|
3926
|
+
} else this.#e.innerHTML = `${r}`;
|
|
3927
|
+
let i = !!this.sheet.querySelector("thead .asc,thead .desc"), a = !!this.sheet.querySelector("thead nine-table-filter-button.filtered");
|
|
3928
|
+
this.#t.innerHTML = e, this.#t.style.display = i || a ? "" : "none";
|
|
3929
|
+
};
|
|
3930
|
+
};
|
|
3931
|
+
customElements.get("cell-row-indicator") || customElements.define("cell-row-indicator", X);
|
|
3932
|
+
// src/col/col-expand.js
|
|
3933
|
+
var Z = class extends HTMLElement {
|
|
3934
|
+
#e;
|
|
3935
|
+
#t;
|
|
3936
|
+
constructor() {
|
|
3937
|
+
super();
|
|
3938
|
+
}
|
|
3939
|
+
connectedCallback() {
|
|
3940
|
+
this.#t = this.closest("th, td"), this.#e = this.closest("nine-table-sheet"), this.#t && (this.#t.style.position = "relative"), this.getAttribute("collapsed") === "true" || this.#t?.getAttribute("collapsed") === "true" ? requestAnimationFrame(() => {
|
|
3941
|
+
this.collapse(!0);
|
|
3942
|
+
}) : (this.classList.remove("collapsed"), this.classList.add("expand")), this.removeEventListener("click", this.#n), this.addEventListener("click", this.#n);
|
|
3943
|
+
}
|
|
3944
|
+
#n = (e) => {
|
|
3945
|
+
e.preventDefault(), e.stopPropagation(), this.classList.contains("expand") ? this.collapse() : this.expand();
|
|
3946
|
+
};
|
|
3947
|
+
expand = () => {
|
|
3948
|
+
if (!this.#e?.colResizer || !this.#t) return;
|
|
3949
|
+
let e = parseInt(this.#t.dataset.col, 10), t = this.#t.colSpan || 1;
|
|
3950
|
+
this.classList.remove("collapsed"), this.classList.add("expand"), this.#t.setAttribute("collapsed", "false"), this.#t.style.color = "";
|
|
3951
|
+
let n = parseInt(this.#t.dataset.expandWidth, 10) || 100;
|
|
3952
|
+
if (t === 1) this.#e.colResizer.setColumnWidth(e, n);
|
|
3953
|
+
else {
|
|
3954
|
+
let r = Math.max(30, Math.floor(n / t));
|
|
3955
|
+
for (let n = 0; n < t; n++) this.#e.colResizer.setColumnWidth(e + n, r);
|
|
3956
|
+
}
|
|
3957
|
+
requestAnimationFrame(() => {
|
|
3958
|
+
typeof this.#e.refreshLayout == "function" && this.#e.refreshLayout();
|
|
3959
|
+
});
|
|
3960
|
+
};
|
|
3961
|
+
collapse = (e = !1) => {
|
|
3962
|
+
if (!this.#e?.colResizer || !this.#t) return;
|
|
3963
|
+
let t = parseInt(this.#t.dataset.col, 10), n = this.#t.colSpan || 1;
|
|
3964
|
+
if (this.classList.contains("expand")) {
|
|
3965
|
+
let e = this.#e.querySelector(`colgroup col[data-col="${t}"]`), r = e ? parseInt(e.getAttribute("width"), 10) : 0;
|
|
3966
|
+
r > 16 && (this.#t.dataset.expandWidth = String(r * n));
|
|
3967
|
+
}
|
|
3968
|
+
if (this.classList.remove("expand"), this.classList.add("collapsed"), this.#t.setAttribute("collapsed", "true"), this.#t.style.color = "transparent", n === 1) this.#e.colResizer.setColumnWidth(t, 16);
|
|
3969
|
+
else {
|
|
3970
|
+
let e = Math.max(10, Math.floor(16 / n));
|
|
3971
|
+
for (let r = 0; r < n; r++) this.#e.colResizer.setColumnWidth(t + r, e);
|
|
3972
|
+
}
|
|
3973
|
+
requestAnimationFrame(() => {
|
|
3974
|
+
typeof this.#e.refreshLayout == "function" && this.#e.refreshLayout();
|
|
3975
|
+
});
|
|
3976
|
+
};
|
|
3977
|
+
disconnectedCallback() {
|
|
3978
|
+
this.removeEventListener("click", this.#n);
|
|
3979
|
+
}
|
|
3980
|
+
};
|
|
3981
|
+
customElements.get("nine-table-col-expand") || customElements.define("nine-table-col-expand", Z);
|
|
3982
|
+
// src/menu/nine-table-menu.js
|
|
3983
|
+
var Q = class extends HTMLElement {
|
|
3984
|
+
#e;
|
|
3985
|
+
#t;
|
|
3986
|
+
connectedCallback() {
|
|
3987
|
+
let e = this.getRootNode();
|
|
3988
|
+
this.#e = e instanceof ShadowRoot ? e.host : this.closest("nine-table") || e.host, this.#e ||= this.parentElement?.closest("nine-table") || this.assignedSlot?.closest("nine-table"), this.#e;
|
|
3989
|
+
}
|
|
3990
|
+
#n = (e) => {
|
|
3991
|
+
let t = e.composedPath ? e.composedPath() : [], n = t.find((e) => e.tagName === "TH" || e.tagName === "TD");
|
|
3992
|
+
if (!n) return;
|
|
3993
|
+
let r = t.find((e) => e.tagName === "TABLE") || n.closest("table");
|
|
3994
|
+
e.preventDefault(), e.stopPropagation(), this.openMenu(e.clientX, e.clientY, n, r);
|
|
3995
|
+
};
|
|
3996
|
+
#r(e) {
|
|
3997
|
+
return e?.closest("nine-table-sheet") || this.#e.activeSheet || this.#e;
|
|
3998
|
+
}
|
|
3999
|
+
#i(e) {
|
|
4000
|
+
let t = this.#r(e);
|
|
4001
|
+
return t ? (t.colFix ||= new T(t), t.colFix) : null;
|
|
4002
|
+
}
|
|
4003
|
+
#a(e, t) {
|
|
4004
|
+
let n = [], r = t?.id;
|
|
4005
|
+
return Array.from(e.querySelectorAll(":scope > ul")).forEach((e) => {
|
|
4006
|
+
let t = e.getAttribute("target-table");
|
|
4007
|
+
if (!t || r && t === r) {
|
|
4008
|
+
let t = this.#o(e);
|
|
4009
|
+
n.push(...t);
|
|
4010
|
+
}
|
|
4011
|
+
}), n;
|
|
4012
|
+
}
|
|
4013
|
+
#o(e) {
|
|
4014
|
+
let t = [];
|
|
4015
|
+
return Array.from(e.children).forEach((e) => {
|
|
4016
|
+
let n = e.tagName.toLowerCase();
|
|
4017
|
+
if (n === "hr" || e.classList.contains("separator")) t.push({ type: "separator" });
|
|
4018
|
+
else if (n === "li") {
|
|
4019
|
+
let n = "", r = e.querySelector(":scope > span");
|
|
4020
|
+
n = r ? r.textContent.trim() : Array.from(e.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent.trim()).join("");
|
|
4021
|
+
let i = e.querySelector(":scope > ul"), a = {
|
|
4022
|
+
menuId: e.id || n,
|
|
4023
|
+
name: n,
|
|
4024
|
+
className: e.className || "",
|
|
4025
|
+
disabled: e.hasAttribute("disabled") || e.getAttribute("disabled") === "true",
|
|
4026
|
+
isCustom: !0
|
|
4027
|
+
};
|
|
4028
|
+
i && (a.items = this.#o(i)), t.push(a);
|
|
4029
|
+
}
|
|
4030
|
+
}), t;
|
|
4031
|
+
}
|
|
4032
|
+
#s(e, t, n) {
|
|
4033
|
+
let r = this.getAttribute("use-default-menu") !== "false", i = [], a = this.#a(this, e);
|
|
4034
|
+
a.length > 0 && i.push(...a);
|
|
4035
|
+
let o = this.#i(n), s = o?.getFixState(n, e) ?? "none", c = t && (o?.canFixColumn(n, e) ?? !1), l = null;
|
|
4036
|
+
l = s === "left" || s === "right" ? {
|
|
4037
|
+
menuId: "unfix-column",
|
|
4038
|
+
name: "Unfix Column",
|
|
4039
|
+
className: "ng-menu-unfix-col",
|
|
4040
|
+
disabled: !t
|
|
4041
|
+
} : {
|
|
4042
|
+
menuId: "fix-column",
|
|
4043
|
+
name: "Fix Column",
|
|
4044
|
+
className: "ng-menu-fix-col",
|
|
4045
|
+
disabled: !c
|
|
4046
|
+
}, r && i.push({ type: "separator" }, {
|
|
4047
|
+
menuId: "sort",
|
|
4048
|
+
name: "Sort",
|
|
4049
|
+
className: "ng-menu-sort",
|
|
4050
|
+
disabled: !t
|
|
4051
|
+
}, l, { type: "separator" }, {
|
|
4052
|
+
menuId: "filtering",
|
|
4053
|
+
name: "Filtering",
|
|
4054
|
+
className: "ng-menu-filtering"
|
|
4055
|
+
}, {
|
|
4056
|
+
menuId: "maximize",
|
|
4057
|
+
name: "Maximize",
|
|
4058
|
+
className: "maximize"
|
|
4059
|
+
}, {
|
|
4060
|
+
menuId: "export",
|
|
4061
|
+
name: "Export",
|
|
4062
|
+
className: "export",
|
|
4063
|
+
items: [{
|
|
4064
|
+
menuId: "export-excel",
|
|
4065
|
+
name: "Excel",
|
|
4066
|
+
className: "export-excel"
|
|
4067
|
+
}, {
|
|
4068
|
+
menuId: "export-pdf",
|
|
4069
|
+
name: "PDF",
|
|
4070
|
+
className: "export-pdf",
|
|
4071
|
+
disabled: !0
|
|
4072
|
+
}]
|
|
4073
|
+
}, {
|
|
4074
|
+
menuId: "properties",
|
|
4075
|
+
name: "Options",
|
|
4076
|
+
className: "options",
|
|
4077
|
+
items: [
|
|
4078
|
+
{
|
|
4079
|
+
menuId: "show-title-bar",
|
|
4080
|
+
name: "Title Bar Show/Hide",
|
|
4081
|
+
className: "show-title-bar"
|
|
4082
|
+
},
|
|
4083
|
+
{
|
|
4084
|
+
menuId: "show-status-bar",
|
|
4085
|
+
name: "Status Bar Show/Hide",
|
|
4086
|
+
className: "show-status-bar"
|
|
4087
|
+
},
|
|
4088
|
+
{
|
|
4089
|
+
menuId: "auto-fit-col",
|
|
4090
|
+
name: "Auto Fit Columns",
|
|
4091
|
+
className: "auto-fit-col"
|
|
4092
|
+
}
|
|
4093
|
+
]
|
|
4094
|
+
});
|
|
4095
|
+
let u = [];
|
|
4096
|
+
return i.forEach((e) => {
|
|
4097
|
+
(e.type !== "separator" || u.length !== 0 && u[u.length - 1].type !== "separator") && u.push(e);
|
|
4098
|
+
}), u.length > 0 && u[u.length - 1].type === "separator" && u.pop(), u;
|
|
4099
|
+
}
|
|
4100
|
+
openMenu(e, t, n, r) {
|
|
4101
|
+
let i = this.#e.shadowRoot || this.#e;
|
|
4102
|
+
this.#t || (this.#t = document.createElement("nine-table-menu-panel"), i.appendChild(this.#t));
|
|
4103
|
+
let a = !!n.closest("thead"), o = this.#s(r, a, n);
|
|
4104
|
+
this.#t.render(o, (e) => this.#l(e, n, r));
|
|
4105
|
+
let s = this.#r(n);
|
|
4106
|
+
this.#c(s), this.#t.openAt(e, t);
|
|
4107
|
+
}
|
|
4108
|
+
#c(e) {
|
|
4109
|
+
if (!this.#t || !e) return;
|
|
4110
|
+
let t = e.filtering?.isFiltering?.() || !1;
|
|
4111
|
+
this.#t.toggleItemState("filtering", "on", t);
|
|
4112
|
+
let n = this.#e.getAttribute("auto-fit-col") === "true";
|
|
4113
|
+
this.#t.toggleItemState("auto-fit-col", "on", n);
|
|
4114
|
+
let r = this.#e.getAttribute("show-title-bar") === "true";
|
|
4115
|
+
this.#t.toggleItemState("show-title-bar", "on", r);
|
|
4116
|
+
}
|
|
4117
|
+
#l(e, t, n) {
|
|
4118
|
+
let r = e.menuId, i = new CustomEvent("menu-click", {
|
|
4119
|
+
detail: {
|
|
4120
|
+
menuId: r,
|
|
4121
|
+
targetCell: t,
|
|
4122
|
+
targetTable: n,
|
|
4123
|
+
originalEvent: e
|
|
4124
|
+
},
|
|
4125
|
+
bubbles: !0,
|
|
4126
|
+
composed: !0
|
|
4127
|
+
});
|
|
4128
|
+
this.dispatchEvent(i);
|
|
4129
|
+
let a = parseInt(t.dataset.col, 10), o = this.#r(t);
|
|
4130
|
+
switch (r) {
|
|
4131
|
+
case "fix-column":
|
|
4132
|
+
case "unfix-column":
|
|
4133
|
+
this.#i(t)?.executeFixToggle(r, t);
|
|
4134
|
+
break;
|
|
4135
|
+
case "sort":
|
|
4136
|
+
isNaN(a) || o.sorting?.handleSortFromMenu?.(a, t);
|
|
4137
|
+
break;
|
|
4138
|
+
case "filtering":
|
|
4139
|
+
o?.filtering?.toggle();
|
|
4140
|
+
break;
|
|
4141
|
+
case "auto-fit-col":
|
|
4142
|
+
this.#e.setAttribute("auto-fit-col", this.#e.getAttribute("auto-fit-col") === "true" ? "false" : "true");
|
|
4143
|
+
break;
|
|
4144
|
+
case "show-title-bar": this.#e.setAttribute("show-title-bar", this.#e.getAttribute("show-title-bar") === "true" ? "false" : "true");
|
|
4145
|
+
}
|
|
4146
|
+
this.#t.close();
|
|
4147
|
+
}
|
|
4148
|
+
disconnectedCallback() {
|
|
4149
|
+
this.#e?.removeEventListener("contextmenu", this.#n);
|
|
4150
|
+
}
|
|
4151
|
+
};
|
|
4152
|
+
customElements.get("nine-table-menu") || customElements.define("nine-table-menu", Q);
|
|
4153
|
+
// src/menu/nine-table-menu-panel.js
|
|
4154
|
+
var $ = class extends HTMLElement {
|
|
4155
|
+
#e;
|
|
4156
|
+
#t = null;
|
|
4157
|
+
constructor() {
|
|
4158
|
+
super();
|
|
4159
|
+
}
|
|
4160
|
+
connectedCallback() {
|
|
4161
|
+
this.style.position = "fixed", this.style.display = "none", this.style.zIndex = "99999", this.innerHTML = "\n <div class=\"menu-wrapper\">\n <ul class=\"menu-container\"></ul>\n </div>\n ";
|
|
4162
|
+
}
|
|
4163
|
+
render(e, t) {
|
|
4164
|
+
this.#e = t;
|
|
4165
|
+
let n = this.querySelector(".menu-container");
|
|
4166
|
+
n && (n.innerHTML = "", this.#n(n, e), this.#r());
|
|
4167
|
+
}
|
|
4168
|
+
openAt(e, t, n = null) {
|
|
4169
|
+
if (this.style.display = "block", n) {
|
|
4170
|
+
let e = n.getBoundingClientRect(), r = e.right;
|
|
4171
|
+
requestAnimationFrame(() => {
|
|
4172
|
+
let n = this.querySelector(".menu-wrapper");
|
|
4173
|
+
if (!n) return;
|
|
4174
|
+
let i = n.getBoundingClientRect().width, a = r - i;
|
|
4175
|
+
a < 0 && (a = e.left);
|
|
4176
|
+
let o = n.getBoundingClientRect().height, s = t;
|
|
4177
|
+
t + o > window.innerHeight && (s = t - o), this.style.left = `${a}px`, this.style.top = `${s}px`;
|
|
4178
|
+
});
|
|
4179
|
+
} else this.style.left = `${e}px`, this.style.top = `${t}px`, requestAnimationFrame(() => {
|
|
4180
|
+
let n = this.querySelector(".menu-wrapper");
|
|
4181
|
+
if (!n) return;
|
|
4182
|
+
let r = n.getBoundingClientRect();
|
|
4183
|
+
e + r.width > window.innerWidth && (this.style.left = `${e - r.width}px`), t + r.height > window.innerHeight && (this.style.top = `${t - r.height}px`);
|
|
4184
|
+
});
|
|
4185
|
+
this.#t && window.removeEventListener("pointerdown", this.#t), this.#t = (e) => {
|
|
4186
|
+
!(e.composedPath ? e.composedPath() : []).includes(this) && !this.contains(e.target) && this.close();
|
|
4187
|
+
}, setTimeout(() => {
|
|
4188
|
+
window.addEventListener("pointerdown", this.#t);
|
|
4189
|
+
}, 0);
|
|
4190
|
+
}
|
|
4191
|
+
close() {
|
|
4192
|
+
this.style.display = "none", this.#t &&= (window.removeEventListener("pointerdown", this.#t), null);
|
|
4193
|
+
}
|
|
4194
|
+
toggleItemState(e, t, n) {
|
|
4195
|
+
let r = this.querySelector(`li[menu-id="${e}"]`);
|
|
4196
|
+
r && (n ? r.classList.add(t) : r.classList.remove(t));
|
|
4197
|
+
}
|
|
4198
|
+
#n(e, t) {
|
|
4199
|
+
t.forEach((t) => {
|
|
4200
|
+
if (t.type === "separator") {
|
|
4201
|
+
let t = document.createElement("li");
|
|
4202
|
+
t.className = "ng-menu-separator", e.appendChild(t);
|
|
4203
|
+
return;
|
|
4204
|
+
}
|
|
4205
|
+
let n = document.createElement("li");
|
|
4206
|
+
n.setAttribute("menu-id", t.menuId), n.className = `${t.className || ""} ${t.items ? "submenu" : ""} ${t.disabled ? "disabled" : ""}`.trim();
|
|
4207
|
+
let r = document.createElement("span");
|
|
4208
|
+
if (r.textContent = t.name, n.appendChild(r), t.items && t.items.length > 0) {
|
|
4209
|
+
let e = document.createElement("ul");
|
|
4210
|
+
e.className = "ng-menu-sublist", this.#n(e, t.items), n.appendChild(e);
|
|
4211
|
+
}
|
|
4212
|
+
e.appendChild(n);
|
|
4213
|
+
});
|
|
4214
|
+
}
|
|
4215
|
+
#r() {
|
|
4216
|
+
this.querySelectorAll("li[menu-id]").forEach((e) => {
|
|
4217
|
+
e.addEventListener("click", (t) => {
|
|
4218
|
+
if (t.stopPropagation(), e.classList.contains("disabled")) return;
|
|
4219
|
+
let n = e.getAttribute("menu-id");
|
|
4220
|
+
this.#e?.({
|
|
4221
|
+
menuId: n,
|
|
4222
|
+
target: e
|
|
4223
|
+
}), this.close();
|
|
4224
|
+
});
|
|
4225
|
+
});
|
|
4226
|
+
}
|
|
4227
|
+
disconnectedCallback() {
|
|
4228
|
+
this.close();
|
|
4229
|
+
}
|
|
4230
|
+
};
|
|
4231
|
+
customElements.get("nine-table-menu-panel") || customElements.define("nine-table-menu-panel", $);
|
|
4232
|
+
export { r as NINE_TABLE };
|
|
4233
|
+
|
|
4234
|
+
//# sourceMappingURL=nine-table.js.map
|