@nubisco/ui 5.59.0 → 5.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Spreadsheet-BwGhq9vm.cjs +4 -0
- package/dist/Spreadsheet-C9MeO5MD.js +1455 -0
- package/dist/all.cjs +1 -1
- package/dist/all.mjs +2 -2
- package/dist/components/Spreadsheet.cjs +1 -1
- package/dist/components/Spreadsheet.mjs +1 -1
- package/dist/components/Spreadsheet.vue.d.ts +1 -0
- package/dist/components/Spreadsheet.vue.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{main-bKOD32H3.cjs → main-I6bzKhGk.cjs} +1 -1
- package/dist/{main-DKTjcXpj.js → main-zCF9LQQU.js} +1 -1
- package/dist/styles/Spreadsheet.css +1 -1
- package/dist/ui.css +1 -1
- package/package.json +1 -1
- package/dist/Spreadsheet-BXRgUbej.cjs +0 -4
- package/dist/Spreadsheet-BmTeUxnu.js +0 -1427
|
@@ -0,0 +1,1455 @@
|
|
|
1
|
+
import { t as e } from "./_plugin-vue_export-helper-C6QCLu9I.js";
|
|
2
|
+
import { t } from "./Icon-B2tiGiqZ.js";
|
|
3
|
+
import { useStableId as n } from "./composables/useStableId.composable.mjs";
|
|
4
|
+
import { usePhoneLayout as r } from "./composables/usePhoneLayout.composable.mjs";
|
|
5
|
+
import { useNbStrings as i } from "./composables/useNbStrings.composable.mjs";
|
|
6
|
+
import { t as a } from "./Menu-CWxBEMC4.js";
|
|
7
|
+
import { t as o } from "./MenuItem-DMYDHaa0.js";
|
|
8
|
+
import { t as s } from "./MenuDivider-DdwhPon9.js";
|
|
9
|
+
import { Fragment as c, computed as l, createBlock as ee, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createTextVNode as te, createVNode as p, defineComponent as ne, mergeModels as re, nextTick as ie, normalizeClass as m, normalizeStyle as h, onBeforeUnmount as ae, onMounted as oe, openBlock as g, ref as _, renderList as se, renderSlot as ce, toDisplayString as le, unref as v, useModel as ue, useTemplateRef as de, vModelText as fe, watch as pe, withCtx as me, withDirectives as he, withModifiers as y } from "vue";
|
|
10
|
+
import * as ge from "@nubisco/ui/icons/arrow-down";
|
|
11
|
+
import * as _e from "@nubisco/ui/icons/arrow-up";
|
|
12
|
+
import * as ve from "@nubisco/ui/icons/arrows-down-up";
|
|
13
|
+
//#region src/components/Spreadsheet.vue?vue&type=script&setup=true&lang.ts
|
|
14
|
+
var ye = {
|
|
15
|
+
key: 0,
|
|
16
|
+
class: "nb-spreadsheet__toolbar"
|
|
17
|
+
}, be = [
|
|
18
|
+
"aria-label",
|
|
19
|
+
"aria-rowcount",
|
|
20
|
+
"aria-colcount",
|
|
21
|
+
"aria-activedescendant"
|
|
22
|
+
], xe = ["aria-rowindex"], Se = [
|
|
23
|
+
"aria-colindex",
|
|
24
|
+
"aria-sort",
|
|
25
|
+
"aria-label",
|
|
26
|
+
"data-header-col",
|
|
27
|
+
"data-header-row",
|
|
28
|
+
"onMousedown",
|
|
29
|
+
"onContextmenu"
|
|
30
|
+
], Ce = ["title"], we = ["title"], Te = [
|
|
31
|
+
"title",
|
|
32
|
+
"aria-label",
|
|
33
|
+
"onClick"
|
|
34
|
+
], Ee = ["title", "aria-label"], De = ["onMousedown"], Oe = ["aria-rowindex"], ke = ["onMousedown", "onContextmenu"], Ae = [
|
|
35
|
+
"title",
|
|
36
|
+
"aria-label",
|
|
37
|
+
"onClick"
|
|
38
|
+
], je = ["title", "aria-label"], Me = [
|
|
39
|
+
"id",
|
|
40
|
+
"aria-colindex",
|
|
41
|
+
"aria-selected",
|
|
42
|
+
"aria-readonly",
|
|
43
|
+
"title",
|
|
44
|
+
"data-cell",
|
|
45
|
+
"data-row",
|
|
46
|
+
"data-col",
|
|
47
|
+
"onMousedown",
|
|
48
|
+
"onMouseenter",
|
|
49
|
+
"onDblclick",
|
|
50
|
+
"onContextmenu"
|
|
51
|
+
], Ne = ["inputmode", "aria-label"], Pe = 9e3, Fe = 1e3, Ie = 100, Le = 26, Re = 20, ze = 50, Be = 8, b = /* @__PURE__ */ e(/* @__PURE__ */ ne({
|
|
52
|
+
__name: "Spreadsheet",
|
|
53
|
+
props: /* @__PURE__ */ re({
|
|
54
|
+
columns: { default: () => [] },
|
|
55
|
+
rows: { default: () => [] },
|
|
56
|
+
cellAttrs: {},
|
|
57
|
+
computed: {},
|
|
58
|
+
resizable: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: !0
|
|
61
|
+
},
|
|
62
|
+
rowReorderable: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: !1
|
|
65
|
+
},
|
|
66
|
+
showGutter: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: !0
|
|
69
|
+
},
|
|
70
|
+
gutterWidth: { default: 44 },
|
|
71
|
+
windowRows: { default: 80 },
|
|
72
|
+
locale: { default: "pt-PT" },
|
|
73
|
+
fit: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: !1
|
|
76
|
+
},
|
|
77
|
+
size: { default: "sm" },
|
|
78
|
+
ariaLabel: { default: void 0 },
|
|
79
|
+
columnHeaders: { default: "label" },
|
|
80
|
+
contextMenu: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: !1
|
|
83
|
+
},
|
|
84
|
+
extent: { default: "data" },
|
|
85
|
+
fillHandle: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: void 0
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
hiddenColumns: { default: () => [] },
|
|
91
|
+
hiddenColumnsModifiers: {},
|
|
92
|
+
hiddenRows: { default: () => [] },
|
|
93
|
+
hiddenRowsModifiers: {},
|
|
94
|
+
cells: {},
|
|
95
|
+
cellsModifiers: {}
|
|
96
|
+
}),
|
|
97
|
+
emits: /* @__PURE__ */ re([
|
|
98
|
+
"commit",
|
|
99
|
+
"change",
|
|
100
|
+
"selection",
|
|
101
|
+
"focus",
|
|
102
|
+
"row-reorder",
|
|
103
|
+
"column-resize"
|
|
104
|
+
], [
|
|
105
|
+
"update:hiddenColumns",
|
|
106
|
+
"update:hiddenRows",
|
|
107
|
+
"update:cells"
|
|
108
|
+
]),
|
|
109
|
+
setup(e, { expose: ne, emit: re }) {
|
|
110
|
+
let b = e, Ve = ue(e, "hiddenColumns"), He = ue(e, "hiddenRows"), Ue = ue(e, "cells"), x = re, S = i(), We = de("rootRef"), C = de("scrollerRef"), Ge = de("editorRef"), Ke = _({}), w = _(null), qe = n({}), T = _(null), E = _(null), Je = _(!1), D = _(null), Ye = _(0), Xe = _(0), Ze = "", Qe = _([]), $e = _([]), O = l(() => Ue.value !== void 0);
|
|
111
|
+
function et(e) {
|
|
112
|
+
let t = 0;
|
|
113
|
+
for (let n of e) t = t * 26 + (n.charCodeAt(0) - 64);
|
|
114
|
+
return t - 1;
|
|
115
|
+
}
|
|
116
|
+
let tt = l(() => {
|
|
117
|
+
let e = 0, t = 0;
|
|
118
|
+
for (let n of Object.keys(Ue.value ?? {})) {
|
|
119
|
+
let r = /^([A-Z]+)(\d+)$/.exec(n);
|
|
120
|
+
r && (e = Math.max(e, Number(r[2])), t = Math.max(t, et(r[1]) + 1));
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
rows: e,
|
|
124
|
+
columns: t
|
|
125
|
+
};
|
|
126
|
+
}), nt = _(Ie), rt = _(Le), it = l(() => {
|
|
127
|
+
let e = b.extent;
|
|
128
|
+
return typeof e == "object" ? {
|
|
129
|
+
rows: Math.min(Pe, e.maxRows ?? Pe),
|
|
130
|
+
columns: Math.min(Fe, e.maxColumns ?? Fe)
|
|
131
|
+
} : {
|
|
132
|
+
rows: Pe,
|
|
133
|
+
columns: Fe
|
|
134
|
+
};
|
|
135
|
+
}), at = l(() => {
|
|
136
|
+
let e = b.extent, t = tt.value, n = it.value, r = t.rows, i = t.columns;
|
|
137
|
+
return e === "infinite" ? (r = Math.max(r, nt.value), i = Math.max(i, rt.value)) : typeof e == "object" && (r = Math.max(r, e.minRows ?? 1), i = Math.max(i, e.minColumns ?? 1)), {
|
|
138
|
+
rows: Math.max(1, Math.min(n.rows, r)),
|
|
139
|
+
columns: Math.max(1, Math.min(n.columns, i))
|
|
140
|
+
};
|
|
141
|
+
}), ot = Object.freeze({}), k = l(() => O.value ? Array.from({ length: at.value.columns }, (e, t) => {
|
|
142
|
+
let n = pt(t);
|
|
143
|
+
return {
|
|
144
|
+
id: n,
|
|
145
|
+
label: n
|
|
146
|
+
};
|
|
147
|
+
}) : b.columns), A = l(() => O.value ? Array.from({ length: at.value.rows }, (e, t) => ({
|
|
148
|
+
id: String(t + 1),
|
|
149
|
+
values: ot
|
|
150
|
+
})) : b.rows);
|
|
151
|
+
function st(e, t) {
|
|
152
|
+
return `${t}${e}`;
|
|
153
|
+
}
|
|
154
|
+
let j = l(() => {
|
|
155
|
+
let e = k.value.filter((e) => e.pinned === "left"), t = k.value.filter((e) => e.pinned === "right"), n = k.value.filter((e) => !e.pinned);
|
|
156
|
+
return [
|
|
157
|
+
...e,
|
|
158
|
+
...n,
|
|
159
|
+
...t
|
|
160
|
+
];
|
|
161
|
+
}), ct = l(() => new Set(Ve.value)), lt = l(() => new Set(He.value)), M = l(() => j.value.filter((e) => !ct.value.has(e.id))), ut = l(() => j.value.filter((e) => ct.value.has(e.id)).map((e) => e.id)), dt = l(() => A.value.filter((e) => lt.value.has(e.id)).map((e) => e.id)), ft = l(() => new Map(j.value.map((e, t) => [e.id, pt(t)])));
|
|
162
|
+
function pt(e) {
|
|
163
|
+
let t = e + 1, n = "";
|
|
164
|
+
for (; t > 0;) {
|
|
165
|
+
let e = (t - 1) % 26;
|
|
166
|
+
n = String.fromCharCode(65 + e) + n, t = Math.floor((t - 1) / 26);
|
|
167
|
+
}
|
|
168
|
+
return n;
|
|
169
|
+
}
|
|
170
|
+
function mt(e) {
|
|
171
|
+
return ft.value.get(e) ?? "";
|
|
172
|
+
}
|
|
173
|
+
let N = l(() => {
|
|
174
|
+
let e = b.columnHeaders;
|
|
175
|
+
return O.value || e === "letters" ? ["letters"] : e === "both" ? ["letters", "label"] : ["label"];
|
|
176
|
+
}), ht = l(() => {
|
|
177
|
+
let e = /* @__PURE__ */ new Map(), t = [];
|
|
178
|
+
for (let n of j.value) ct.value.has(n.id) ? t.push(n.id) : t.length && (e.set(n.id, t), t = []);
|
|
179
|
+
return e;
|
|
180
|
+
}), gt = l(() => {
|
|
181
|
+
let e = [];
|
|
182
|
+
for (let t = j.value.length - 1; t >= 0; t--) {
|
|
183
|
+
let n = j.value[t];
|
|
184
|
+
if (!ct.value.has(n.id)) break;
|
|
185
|
+
e.unshift(n.id);
|
|
186
|
+
}
|
|
187
|
+
return e;
|
|
188
|
+
}), _t = l(() => b.showGutter ? 1 : 0), vt = l(() => new Map(A.value.map((e) => [e.id, e]))), P = l(() => new Map(k.value.map((e) => [e.id, e]))), F = l(() => new Map(M.value.map((e, t) => [e.id, t])));
|
|
189
|
+
function I(e) {
|
|
190
|
+
return Ke.value[e.id] ?? e.width ?? 120;
|
|
191
|
+
}
|
|
192
|
+
let yt = {
|
|
193
|
+
xs: 24,
|
|
194
|
+
sm: 32,
|
|
195
|
+
md: 40,
|
|
196
|
+
lg: 48
|
|
197
|
+
}, bt = l(() => yt[b.size] ?? yt.sm), { phoneTouch: xt } = r(), St = _(null), Ct = l(() => St.value ?? bt.value);
|
|
198
|
+
function wt() {
|
|
199
|
+
let e = We.value, t = C.value, n = H.value.length;
|
|
200
|
+
if (!b.fit || xt.value || !e || !t || !n) {
|
|
201
|
+
St.value = null;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
let r = e.querySelector(".nb-spreadsheet__toolbar"), i = t.offsetHeight - t.clientHeight, a = e.clientHeight - (r?.offsetHeight ?? 0) - i, o = Math.floor((a - kn()) / n);
|
|
205
|
+
St.value = Math.min(bt.value, Math.max(Re, o));
|
|
206
|
+
}
|
|
207
|
+
let Tt = null, Et = l(() => St.value === null ? void 0 : { "--nbss-row-height": `${St.value}px` }), Dt = l(() => ({
|
|
208
|
+
gridTemplateColumns: (b.showGutter ? `${b.gutterWidth}px ` : "") + M.value.map((e) => b.fit && !e.pinned ? `minmax(${I(e)}px, 1fr)` : `${I(e)}px`).join(" "),
|
|
209
|
+
gridTemplateRows: `${N.value.length === 2 ? "var(--nbss-letter-height) var(--nbss-header-height)" : "var(--nbss-header-height)"} repeat(${Math.max(1, H.value.length)}, var(--nbss-row-height))`
|
|
210
|
+
})), Ot = l(() => {
|
|
211
|
+
let e = M.value;
|
|
212
|
+
if (b.fit || e.length <= ze) return e;
|
|
213
|
+
let t = C.value?.clientWidth || 1200, n = Xe.value - t, r = Xe.value + t * 2, i = b.showGutter ? b.gutterWidth : 0, a = [];
|
|
214
|
+
for (let t of e) {
|
|
215
|
+
let e = I(t);
|
|
216
|
+
(t.pinned || i + e >= n && i <= r) && a.push(t), i += e;
|
|
217
|
+
}
|
|
218
|
+
return a;
|
|
219
|
+
});
|
|
220
|
+
function L(e) {
|
|
221
|
+
return F.value.get(e.id) ?? 0;
|
|
222
|
+
}
|
|
223
|
+
let kt = _(/* @__PURE__ */ new Set()), At = /* @__PURE__ */ new Map();
|
|
224
|
+
function jt() {
|
|
225
|
+
let e = C.value;
|
|
226
|
+
if (!e) return;
|
|
227
|
+
let t = [], n = !1, r = !1;
|
|
228
|
+
for (let i of k.value) {
|
|
229
|
+
if (!i.shortLabel) continue;
|
|
230
|
+
let a = e.querySelector(`[data-header-col="${Dn(i.id)}"] .nb-spreadsheet__header-label`);
|
|
231
|
+
if (!a) continue;
|
|
232
|
+
let o = `${i.id}::${i.label}`;
|
|
233
|
+
kt.value.has(i.id) || At.set(o, a.scrollWidth);
|
|
234
|
+
let s = At.get(o);
|
|
235
|
+
if (s === void 0) {
|
|
236
|
+
r = !0;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
t.push(i.id), s > a.clientWidth && (n = !0);
|
|
240
|
+
}
|
|
241
|
+
kt.value = new Set(n ? t : []), r && ie(jt);
|
|
242
|
+
}
|
|
243
|
+
pe(() => [b.columns, Ke.value], () => void ie(jt), { deep: !0 });
|
|
244
|
+
let R = l(() => {
|
|
245
|
+
let e = A.value.filter((e) => !e.pinned);
|
|
246
|
+
if (!w.value) return e;
|
|
247
|
+
let t = P.value.get(w.value.columnId);
|
|
248
|
+
if (!t) return e;
|
|
249
|
+
let n = w.value.direction === "asc" ? 1 : -1, r = (e, t) => e == null && t == null ? 0 : e == null ? -1 : t == null ? 1 : typeof e == "number" && typeof t == "number" ? (e - t) * n : String(e).localeCompare(String(t)) * n;
|
|
250
|
+
return [...e].sort((e, n) => r(e.values[t.id], n.values[t.id]));
|
|
251
|
+
}), Mt = l(() => new Map(R.value.map((e, t) => [e.id, t + 1]))), z = (e) => !lt.value.has(e.id), B = l(() => R.value.filter(z)), V = l(() => A.value.filter((e) => e.pinned === "top" && z(e))), Nt = l(() => A.value.filter((e) => e.pinned === "bottom" && z(e))), Pt = l(() => {
|
|
252
|
+
let e = /* @__PURE__ */ new Map(), t = [];
|
|
253
|
+
for (let n of R.value) z(n) ? t.length && (e.set(n.id, t), t = []) : t.push(n.id);
|
|
254
|
+
return e;
|
|
255
|
+
}), Ft = l(() => {
|
|
256
|
+
let e = [], t = R.value;
|
|
257
|
+
for (let n = t.length - 1; n >= 0 && !z(t[n]); n--) e.unshift(t[n].id);
|
|
258
|
+
return e;
|
|
259
|
+
}), It = l(() => B.value[B.value.length - 1]?.id), H = l(() => [
|
|
260
|
+
...V.value,
|
|
261
|
+
...B.value,
|
|
262
|
+
...Nt.value
|
|
263
|
+
]), U = l(() => new Map(H.value.map((e, t) => [e.id, t]))), Lt = l(() => {
|
|
264
|
+
let e = Math.max(1, Math.ceil((C.value?.clientHeight ?? 600) / Ct.value)), t = Math.max(10, Math.floor(b.windowRows / 4)), n = Math.floor(Ye.value / Ct.value) - V.value.length - t, r = Math.max(0, n), i = Math.min(B.value.length, r + e + t * 2), a = V.value.map((e, t) => ({
|
|
265
|
+
...e,
|
|
266
|
+
__virtualIndex: t,
|
|
267
|
+
gutterLabel: ""
|
|
268
|
+
})), o = B.value.slice(r, i).map((e, t) => ({
|
|
269
|
+
...e,
|
|
270
|
+
__virtualIndex: r + t + V.value.length
|
|
271
|
+
})), s = Nt.value.map((e, t) => ({
|
|
272
|
+
...e,
|
|
273
|
+
__virtualIndex: V.value.length + B.value.length + t,
|
|
274
|
+
gutterLabel: ""
|
|
275
|
+
}));
|
|
276
|
+
return [
|
|
277
|
+
...a,
|
|
278
|
+
...o,
|
|
279
|
+
...s
|
|
280
|
+
];
|
|
281
|
+
});
|
|
282
|
+
function Rt(e, t) {
|
|
283
|
+
if (t == null || t === "") return "";
|
|
284
|
+
if (e.type === "number") {
|
|
285
|
+
let e = typeof t == "number" ? t : Number(t);
|
|
286
|
+
return Number.isFinite(e) ? new Intl.NumberFormat(b.locale, { maximumFractionDigits: 4 }).format(e) : String(t);
|
|
287
|
+
}
|
|
288
|
+
if (e.type === "date") {
|
|
289
|
+
let e = t instanceof Date ? t : new Date(t);
|
|
290
|
+
return Number.isNaN(e.getTime()) ? String(t) : new Intl.DateTimeFormat(b.locale).format(e);
|
|
291
|
+
}
|
|
292
|
+
return String(t);
|
|
293
|
+
}
|
|
294
|
+
function zt(e, t) {
|
|
295
|
+
if (t === "") return null;
|
|
296
|
+
if (e.type === "number") {
|
|
297
|
+
let e = t.replace(/\s/g, "").replace(",", "."), n = Number(e);
|
|
298
|
+
if (!Number.isFinite(n)) throw Error("Invalid number");
|
|
299
|
+
return n;
|
|
300
|
+
}
|
|
301
|
+
if (e.type === "date") {
|
|
302
|
+
let e = new Date(t);
|
|
303
|
+
if (Number.isNaN(e.getTime())) throw Error("Invalid date");
|
|
304
|
+
return e.toISOString().slice(0, 10);
|
|
305
|
+
}
|
|
306
|
+
return t;
|
|
307
|
+
}
|
|
308
|
+
let Bt = l(() => new Intl.NumberFormat(b.locale).formatToParts(1.5).find((e) => e.type === "decimal")?.value ?? ".");
|
|
309
|
+
function Vt(e) {
|
|
310
|
+
let t = e.trim();
|
|
311
|
+
return t === "" ? null : /^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i.test(t) ? Number(t) : Bt.value === "," && /^[-+]?(\d+,?\d*|,\d+)$/.test(t) ? Number(t.replace(",", ".")) : e;
|
|
312
|
+
}
|
|
313
|
+
function Ht(e) {
|
|
314
|
+
return e == null ? "" : typeof e == "number" ? new Intl.NumberFormat(b.locale, { maximumFractionDigits: 10 }).format(e) : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : String(e);
|
|
315
|
+
}
|
|
316
|
+
function Ut(e, t) {
|
|
317
|
+
return e.parse ? e.parse(t) : O.value ? Vt(t) : zt(e, t);
|
|
318
|
+
}
|
|
319
|
+
function W(e, t) {
|
|
320
|
+
if (O.value) {
|
|
321
|
+
let n = Ue.value?.[st(e, t)];
|
|
322
|
+
return n === void 0 ? b.computed ? b.computed(e, t, W) : void 0 : n;
|
|
323
|
+
}
|
|
324
|
+
let n = vt.value.get(e);
|
|
325
|
+
if (!n) return;
|
|
326
|
+
let r = n.values[t];
|
|
327
|
+
if (r !== void 0) return r;
|
|
328
|
+
if (b.computed) return b.computed(e, t, W);
|
|
329
|
+
}
|
|
330
|
+
function Wt(e, t) {
|
|
331
|
+
return b.cellAttrs ? b.cellAttrs(e.id, t.id, e, t) ?? {} : {};
|
|
332
|
+
}
|
|
333
|
+
function Gt(e, t) {
|
|
334
|
+
let n = Wt(e, t);
|
|
335
|
+
if (n.display !== void 0) return n.display;
|
|
336
|
+
let r = W(e.id, t.id);
|
|
337
|
+
return t.format ? t.format(r, e) : O.value ? Ht(r) : Rt(t, r);
|
|
338
|
+
}
|
|
339
|
+
function Kt(e, t) {
|
|
340
|
+
let n = Wt(e, t), r = T.value?.rowId === e.id && T.value?.columnId === t.id, i = dn(e.id, t.id);
|
|
341
|
+
return {
|
|
342
|
+
[`nb-spreadsheet__cell--${t.align ?? (O.value ? typeof W(e.id, t.id) == "number" ? "right" : "left" : t.type === "number" || t.type === "date" ? "right" : "left")}`]: !0,
|
|
343
|
+
"nb-spreadsheet__cell--focused": r,
|
|
344
|
+
"nb-spreadsheet__cell--selected": i.selected,
|
|
345
|
+
"nb-spreadsheet__cell--edge-top": i.top,
|
|
346
|
+
"nb-spreadsheet__cell--edge-bottom": i.bottom,
|
|
347
|
+
"nb-spreadsheet__cell--edge-left": i.left,
|
|
348
|
+
"nb-spreadsheet__cell--edge-right": i.right,
|
|
349
|
+
"nb-spreadsheet__cell--readonly": G(e, t),
|
|
350
|
+
"nb-spreadsheet__cell--computed": !!n.computed || !!e.computed,
|
|
351
|
+
"nb-spreadsheet__cell--pinned-top": e.pinned === "top",
|
|
352
|
+
"nb-spreadsheet__cell--pinned-bottom": e.pinned === "bottom",
|
|
353
|
+
"nb-spreadsheet__cell--fill": nr(e.id, t.id),
|
|
354
|
+
"nb-spreadsheet__cell--fill-anchor": tr(e.id, t.id),
|
|
355
|
+
[n.className ?? ""]: !!n.className,
|
|
356
|
+
[e.className ?? ""]: !!e.className
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function G(e, t) {
|
|
360
|
+
if (e.computed || t.readOnly) return !0;
|
|
361
|
+
let n = Wt(e, t);
|
|
362
|
+
return !!n.readOnly || !!n.computed;
|
|
363
|
+
}
|
|
364
|
+
function qt(e, t) {
|
|
365
|
+
return Wt(e, t).tooltip ?? "";
|
|
366
|
+
}
|
|
367
|
+
function Jt(e, t) {
|
|
368
|
+
return `${qe}-r${U.value.get(e)}-c${F.value.get(t)}`;
|
|
369
|
+
}
|
|
370
|
+
let Yt = l(() => T.value ? Jt(T.value.rowId, T.value.columnId) : void 0);
|
|
371
|
+
function Xt(e, t, n) {
|
|
372
|
+
return {
|
|
373
|
+
"nb-spreadsheet__header--letters": n === "letters",
|
|
374
|
+
"nb-spreadsheet__header--stacked": N.value.length === 2,
|
|
375
|
+
"nb-spreadsheet__header--sortable": n === "label" && !!e.sortable,
|
|
376
|
+
"nb-spreadsheet__header--sorted": w.value?.columnId === e.id,
|
|
377
|
+
"nb-spreadsheet__header--selected": pn(t),
|
|
378
|
+
"nb-spreadsheet__header--pinned-left": e.pinned === "left",
|
|
379
|
+
"nb-spreadsheet__header--pinned-right": e.pinned === "right",
|
|
380
|
+
"nb-spreadsheet__header--last": t === M.value.length - 1
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function Zt(e) {
|
|
384
|
+
if (e.sortable) return w.value?.columnId === e.id ? w.value.direction === "asc" ? "ascending" : "descending" : "none";
|
|
385
|
+
}
|
|
386
|
+
function Qt(e) {
|
|
387
|
+
return w.value?.columnId === e.id ? w.value.direction === "asc" ? _e : ge : ve;
|
|
388
|
+
}
|
|
389
|
+
function $t(e) {
|
|
390
|
+
if (e.pinned !== "left") return 0;
|
|
391
|
+
let t = b.showGutter ? b.gutterWidth : 0;
|
|
392
|
+
for (let n of M.value) {
|
|
393
|
+
if (n.id === e.id) break;
|
|
394
|
+
n.pinned === "left" && (t += I(n));
|
|
395
|
+
}
|
|
396
|
+
return t;
|
|
397
|
+
}
|
|
398
|
+
function en(e) {
|
|
399
|
+
if (e.pinned !== "right") return 0;
|
|
400
|
+
let t = 0, n = [...M.value].reverse();
|
|
401
|
+
for (let r of n) {
|
|
402
|
+
if (r.id === e.id) break;
|
|
403
|
+
r.pinned === "right" && (t += I(r));
|
|
404
|
+
}
|
|
405
|
+
return t;
|
|
406
|
+
}
|
|
407
|
+
function tn(e, t, n) {
|
|
408
|
+
let r = _t.value + 1 + t, i = { top: n === 0 ? "0" : "var(--nbss-letter-height)" };
|
|
409
|
+
return e.pinned === "left" ? (i.position = "sticky", i.left = `${$t(e)}px`, i.zIndex = "3") : e.pinned === "right" && (i.position = "sticky", i.right = `${en(e)}px`, i.zIndex = "3"), {
|
|
410
|
+
gridRow: n + 1,
|
|
411
|
+
gridColumn: r,
|
|
412
|
+
...i
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function nn(e, t, n) {
|
|
416
|
+
let r = _t.value + 1 + n, i = e.__virtualIndex + 1 + N.value.length, a = {};
|
|
417
|
+
return t.pinned === "left" ? (a.position = "sticky", a.left = `${$t(t)}px`, a.zIndex = "2") : t.pinned === "right" && (a.position = "sticky", a.right = `${en(t)}px`, a.zIndex = "2"), (e.pinned === "top" || e.pinned === "bottom") && (a.position = "sticky", a.zIndex = String(Math.max(Number(a.zIndex ?? 0), 2)), Object.assign(a, rn(e))), {
|
|
418
|
+
gridRow: i,
|
|
419
|
+
gridColumn: r,
|
|
420
|
+
...a
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function rn(e) {
|
|
424
|
+
if (e.pinned === "top") {
|
|
425
|
+
let t = V.value.findIndex((t) => t.id === e.id);
|
|
426
|
+
return { top: `calc(var(--nbss-head-height) + var(--nbss-row-height) * ${Math.max(0, t)})` };
|
|
427
|
+
}
|
|
428
|
+
if (e.pinned === "bottom") {
|
|
429
|
+
let t = Nt.value, n = t.findIndex((t) => t.id === e.id);
|
|
430
|
+
return { bottom: `calc(var(--nbss-row-height) * ${Math.max(0, t.length - 1 - n)})` };
|
|
431
|
+
}
|
|
432
|
+
return {};
|
|
433
|
+
}
|
|
434
|
+
function an(e) {
|
|
435
|
+
return e.label === void 0 ? e.gutterLabel === void 0 ? String(Mt.value.get(e.id) ?? "") : e.gutterLabel : e.label;
|
|
436
|
+
}
|
|
437
|
+
function on(e) {
|
|
438
|
+
let t = {
|
|
439
|
+
position: "sticky",
|
|
440
|
+
left: "0",
|
|
441
|
+
zIndex: "2"
|
|
442
|
+
};
|
|
443
|
+
return e.pinned && (Object.assign(t, rn(e)), t.zIndex = "4"), {
|
|
444
|
+
gridRow: e.__virtualIndex + 1 + N.value.length,
|
|
445
|
+
gridColumn: 1,
|
|
446
|
+
...t
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
function sn(e) {
|
|
450
|
+
if (!e) return null;
|
|
451
|
+
let t = U.value.get(e.startRowId) ?? -1, n = U.value.get(e.endRowId) ?? -1, r = F.value.get(e.startColumnId) ?? -1, i = F.value.get(e.endColumnId) ?? -1;
|
|
452
|
+
return t < 0 || n < 0 || r < 0 || i < 0 ? null : {
|
|
453
|
+
r1: Math.min(t, n),
|
|
454
|
+
r2: Math.max(t, n),
|
|
455
|
+
c1: Math.min(r, i),
|
|
456
|
+
c2: Math.max(r, i)
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
let K = l(() => sn(E.value)), q = _([]), cn = l(() => {
|
|
460
|
+
let e = [];
|
|
461
|
+
for (let t of q.value) {
|
|
462
|
+
let n = sn(t);
|
|
463
|
+
n && e.push(n);
|
|
464
|
+
}
|
|
465
|
+
return K.value && e.push(K.value), e;
|
|
466
|
+
});
|
|
467
|
+
function ln(e, t) {
|
|
468
|
+
for (let n of cn.value) if (e >= n.r1 && e <= n.r2 && t >= n.c1 && t <= n.c2) return !0;
|
|
469
|
+
return !1;
|
|
470
|
+
}
|
|
471
|
+
function un(e, t) {
|
|
472
|
+
return ln(U.value.get(e) ?? -1, F.value.get(t) ?? -1);
|
|
473
|
+
}
|
|
474
|
+
function dn(e, t) {
|
|
475
|
+
let n = U.value.get(e) ?? -1, r = F.value.get(t) ?? -1, i = ln(n, r);
|
|
476
|
+
return {
|
|
477
|
+
selected: i,
|
|
478
|
+
right: i !== ln(n, r + 1),
|
|
479
|
+
bottom: i !== ln(n + 1, r),
|
|
480
|
+
left: i && r === 0,
|
|
481
|
+
top: i && n === 0
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function fn(e) {
|
|
485
|
+
let t = U.value.get(e) ?? -1;
|
|
486
|
+
return cn.value.some((e) => t >= e.r1 && t <= e.r2);
|
|
487
|
+
}
|
|
488
|
+
function pn(e) {
|
|
489
|
+
return cn.value.some((t) => e >= t.c1 && e <= t.c2);
|
|
490
|
+
}
|
|
491
|
+
function mn() {
|
|
492
|
+
E.value && (q.value = [...q.value, E.value]);
|
|
493
|
+
}
|
|
494
|
+
function J(e, t, n = !1, r = !1) {
|
|
495
|
+
r ? mn() : n || (q.value = []), T.value = {
|
|
496
|
+
rowId: e,
|
|
497
|
+
columnId: t
|
|
498
|
+
}, n && E.value ? E.value = {
|
|
499
|
+
...E.value,
|
|
500
|
+
endRowId: e,
|
|
501
|
+
endColumnId: t
|
|
502
|
+
} : E.value = {
|
|
503
|
+
startRowId: e,
|
|
504
|
+
startColumnId: t,
|
|
505
|
+
endRowId: e,
|
|
506
|
+
endColumnId: t
|
|
507
|
+
}, x("focus", T.value), x("selection", E.value);
|
|
508
|
+
}
|
|
509
|
+
function hn(e, t, n, r = "new") {
|
|
510
|
+
r === "add" ? mn() : r === "new" && (q.value = []), T.value = {
|
|
511
|
+
rowId: e,
|
|
512
|
+
columnId: t
|
|
513
|
+
}, E.value = n, x("focus", T.value), x("selection", E.value);
|
|
514
|
+
}
|
|
515
|
+
function gn(e, t = !1, n = !1) {
|
|
516
|
+
let r = H.value;
|
|
517
|
+
if (!r.length) return;
|
|
518
|
+
let i = t && E.value ? E.value.startColumnId : e;
|
|
519
|
+
hn(r[0].id, i, {
|
|
520
|
+
startRowId: r[0].id,
|
|
521
|
+
startColumnId: i,
|
|
522
|
+
endRowId: r[r.length - 1].id,
|
|
523
|
+
endColumnId: e
|
|
524
|
+
}, t ? "extend" : n ? "add" : "new");
|
|
525
|
+
}
|
|
526
|
+
function _n(e, t = !1, n = !1) {
|
|
527
|
+
let r = M.value;
|
|
528
|
+
if (!r.length) return;
|
|
529
|
+
let i = t && E.value ? E.value.startRowId : e;
|
|
530
|
+
hn(i, r[0].id, {
|
|
531
|
+
startRowId: i,
|
|
532
|
+
startColumnId: r[0].id,
|
|
533
|
+
endRowId: e,
|
|
534
|
+
endColumnId: r[r.length - 1].id
|
|
535
|
+
}, t ? "extend" : n ? "add" : "new");
|
|
536
|
+
}
|
|
537
|
+
function vn() {
|
|
538
|
+
let e = H.value, t = M.value;
|
|
539
|
+
!e.length || !t.length || hn(e[0].id, t[0].id, {
|
|
540
|
+
startRowId: e[0].id,
|
|
541
|
+
startColumnId: t[0].id,
|
|
542
|
+
endRowId: e[e.length - 1].id,
|
|
543
|
+
endColumnId: t[t.length - 1].id
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
function yn(e) {
|
|
547
|
+
Ze = e.pointerType;
|
|
548
|
+
}
|
|
549
|
+
function bn(e, t, n) {
|
|
550
|
+
if (e.button === 2) {
|
|
551
|
+
Ze = "";
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
let r = Ze === "touch" && !e.shiftKey && T.value?.rowId === t.id && T.value?.columnId === n.id;
|
|
555
|
+
if (Ze = "", D.value && Z(), Je.value = !0, J(t.id, n.id, e.shiftKey, !e.shiftKey && (e.metaKey || e.ctrlKey)), Y(), e.preventDefault(), document.addEventListener("mouseup", Sn, { once: !0 }), r && !G(t, n)) {
|
|
556
|
+
let e = W(t.id, n.id);
|
|
557
|
+
Rn(t, n, e == null ? "" : String(e), "edit");
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function xn(e, t) {
|
|
561
|
+
if ($.value) {
|
|
562
|
+
ir(e.id, t.id);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
!Je.value || !E.value || (E.value = {
|
|
566
|
+
...E.value,
|
|
567
|
+
endRowId: e.id,
|
|
568
|
+
endColumnId: t.id
|
|
569
|
+
}, x("selection", E.value));
|
|
570
|
+
}
|
|
571
|
+
function Sn() {
|
|
572
|
+
Je.value = !1;
|
|
573
|
+
}
|
|
574
|
+
function Cn(e, t) {
|
|
575
|
+
if (G(e, t)) return;
|
|
576
|
+
let n = W(e.id, t.id);
|
|
577
|
+
Rn(e, t, n == null ? "" : String(n), "edit");
|
|
578
|
+
}
|
|
579
|
+
function wn(e, t, n = "label") {
|
|
580
|
+
e.button === 0 && (e.preventDefault(), D.value && Z(), Y(), t.sortable && (n === "label" || N.value.length === 1) ? fr(t) : gn(t.id, e.shiftKey, e.metaKey || e.ctrlKey));
|
|
581
|
+
}
|
|
582
|
+
function Tn(e, t) {
|
|
583
|
+
e.button === 0 && (D.value && Z(), Y(), _n(t.id, e.shiftKey, e.metaKey || e.ctrlKey));
|
|
584
|
+
}
|
|
585
|
+
function En(e) {
|
|
586
|
+
e.button === 0 && (D.value && Z(), Y(), vn());
|
|
587
|
+
}
|
|
588
|
+
function Y() {
|
|
589
|
+
C.value?.focus({ preventScroll: !0 });
|
|
590
|
+
}
|
|
591
|
+
function X(e, t, n = !1) {
|
|
592
|
+
if (!T.value) {
|
|
593
|
+
let e = M.value[0], t = Lt.value[0];
|
|
594
|
+
e && t && J(t.id, e.id);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
let r = H.value, i = U.value.get(T.value.rowId) ?? 0, a = F.value.get(T.value.columnId) ?? 0, o = Math.max(0, Math.min(r.length - 1, i + e)), s = Math.max(0, Math.min(M.value.length - 1, a + t)), c = r[o].id, l = M.value[s].id;
|
|
598
|
+
J(c, l, n), Mn(c, l);
|
|
599
|
+
}
|
|
600
|
+
function Dn(e) {
|
|
601
|
+
return e.replace(/["\\]/g, "\\$&");
|
|
602
|
+
}
|
|
603
|
+
function On(e) {
|
|
604
|
+
let t = C.value?.querySelector(e);
|
|
605
|
+
return t ? t.offsetHeight : 0;
|
|
606
|
+
}
|
|
607
|
+
function kn() {
|
|
608
|
+
let e = 0;
|
|
609
|
+
return N.value.forEach((t, n) => {
|
|
610
|
+
e += On(`[data-header-row="${n}"]`) || (t === "letters" && n === 0 && N.value.length === 2 ? 24 : bt.value);
|
|
611
|
+
}), e;
|
|
612
|
+
}
|
|
613
|
+
function An(e) {
|
|
614
|
+
let t = 0;
|
|
615
|
+
for (let n of e) t += On(`[data-row="${Dn(n.id)}"]`);
|
|
616
|
+
return t;
|
|
617
|
+
}
|
|
618
|
+
function jn(e) {
|
|
619
|
+
let t = e === "left" && b.showGutter ? b.gutterWidth : 0;
|
|
620
|
+
for (let n of M.value) n.pinned === e && (t += I(n));
|
|
621
|
+
return t;
|
|
622
|
+
}
|
|
623
|
+
function Mn(e, t) {
|
|
624
|
+
let n = C.value;
|
|
625
|
+
if (!n) return;
|
|
626
|
+
let r = B.value.findIndex((t) => t.id === e);
|
|
627
|
+
if (r >= 0) {
|
|
628
|
+
let e = kn(), t = On(".nb-spreadsheet__cell") || Ct.value, i = e + (V.value.length + r) * t, a = e + An(V.value), o = An(Nt.value);
|
|
629
|
+
i - a < n.scrollTop ? n.scrollTop = i - a : i + t > n.scrollTop + n.clientHeight - o && (n.scrollTop = i + t - n.clientHeight + o);
|
|
630
|
+
}
|
|
631
|
+
let i = t ? P.value.get(t) : void 0;
|
|
632
|
+
if (i && !i.pinned) {
|
|
633
|
+
let e = b.showGutter ? b.gutterWidth : 0;
|
|
634
|
+
for (let t of M.value) {
|
|
635
|
+
if (t.id === i.id) break;
|
|
636
|
+
e += I(t);
|
|
637
|
+
}
|
|
638
|
+
let t = I(i), r = jn("left"), a = jn("right");
|
|
639
|
+
e - r < n.scrollLeft ? n.scrollLeft = e - r : e + t > n.scrollLeft + n.clientWidth - a && (n.scrollLeft = e + t - n.clientWidth + a);
|
|
640
|
+
}
|
|
641
|
+
Nn();
|
|
642
|
+
}
|
|
643
|
+
function Nn() {
|
|
644
|
+
let e = C.value;
|
|
645
|
+
Ye.value = e?.scrollTop ?? 0, Xe.value = e?.scrollLeft ?? 0, e && Pn(e);
|
|
646
|
+
}
|
|
647
|
+
function Pn(e) {
|
|
648
|
+
if (!O.value || b.extent !== "infinite") return;
|
|
649
|
+
let { rows: t, columns: n } = at.value;
|
|
650
|
+
e.clientHeight > 0 && e.scrollTop + e.clientHeight * 2 >= e.scrollHeight && t < Pe && (nt.value = Math.min(Pe, t + Ie)), e.clientWidth > 0 && e.scrollLeft + e.clientWidth * 2 >= e.scrollWidth && n < Fe && (rt.value = Math.min(Fe, n + Le));
|
|
651
|
+
}
|
|
652
|
+
function Fn() {
|
|
653
|
+
if (!T.value) return null;
|
|
654
|
+
let e = vt.value.get(T.value.rowId), t = P.value.get(T.value.columnId);
|
|
655
|
+
return e && t ? {
|
|
656
|
+
r: e,
|
|
657
|
+
c: t
|
|
658
|
+
} : null;
|
|
659
|
+
}
|
|
660
|
+
function In(e) {
|
|
661
|
+
return !e.metaKey && !e.ctrlKey && !e.altKey && e.key.length === 1;
|
|
662
|
+
}
|
|
663
|
+
function Ln(e) {
|
|
664
|
+
if (D.value) {
|
|
665
|
+
e.target !== Ge.value && (In(e) ? (e.preventDefault(), D.value.draft += e.key) : Hn(e));
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
let t = e.metaKey || e.ctrlKey;
|
|
669
|
+
if (t && e.key.toLowerCase() === "z") {
|
|
670
|
+
e.preventDefault(), e.shiftKey ? Ir() : Fr();
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
if (t && e.key.toLowerCase() === "a") {
|
|
674
|
+
e.preventDefault(), vn();
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
if (t && er.value && !e.shiftKey && !e.altKey && (e.key.toLowerCase() === "d" || e.key.toLowerCase() === "r")) {
|
|
678
|
+
e.preventDefault(), cr(e.key.toLowerCase() === "d" ? "down" : "right");
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (e.key === " " && (e.ctrlKey || e.shiftKey) && !e.metaKey && !e.altKey) {
|
|
682
|
+
let t = T.value;
|
|
683
|
+
if (!t) return;
|
|
684
|
+
e.preventDefault(), e.ctrlKey ? gn(t.columnId) : _n(t.rowId);
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
if (e.altKey && e.shiftKey && !t && (e.key === "ArrowLeft" || e.key === "ArrowRight")) {
|
|
688
|
+
let t = T.value ? P.value.get(T.value.columnId) : void 0;
|
|
689
|
+
if (!b.resizable || !t) return;
|
|
690
|
+
e.preventDefault();
|
|
691
|
+
let n = e.key === "ArrowRight" ? Be : -Be;
|
|
692
|
+
ur(t, I(t) + n);
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (e.key === "ContextMenu" || e.key === "F10" && e.shiftKey) {
|
|
696
|
+
if (!b.contextMenu || !T.value) return;
|
|
697
|
+
e.preventDefault(), kr();
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
switch (e.key) {
|
|
701
|
+
case "ArrowDown":
|
|
702
|
+
e.preventDefault(), X(1, 0, e.shiftKey);
|
|
703
|
+
break;
|
|
704
|
+
case "ArrowUp":
|
|
705
|
+
e.preventDefault(), X(-1, 0, e.shiftKey);
|
|
706
|
+
break;
|
|
707
|
+
case "ArrowLeft":
|
|
708
|
+
e.preventDefault(), X(0, -1, e.shiftKey);
|
|
709
|
+
break;
|
|
710
|
+
case "ArrowRight":
|
|
711
|
+
e.preventDefault(), X(0, 1, e.shiftKey);
|
|
712
|
+
break;
|
|
713
|
+
case "Tab":
|
|
714
|
+
e.preventDefault(), X(0, e.shiftKey ? -1 : 1);
|
|
715
|
+
break;
|
|
716
|
+
case "Enter":
|
|
717
|
+
e.preventDefault(), X(e.shiftKey ? -1 : 1, 0);
|
|
718
|
+
break;
|
|
719
|
+
case "Escape":
|
|
720
|
+
E.value = null, q.value = [], x("selection", null);
|
|
721
|
+
break;
|
|
722
|
+
case "Delete":
|
|
723
|
+
case "Backspace":
|
|
724
|
+
e.preventDefault(), Kn();
|
|
725
|
+
break;
|
|
726
|
+
case "F2": {
|
|
727
|
+
e.preventDefault();
|
|
728
|
+
let t = Fn();
|
|
729
|
+
if (t && !G(t.r, t.c)) {
|
|
730
|
+
let e = W(t.r.id, t.c.id);
|
|
731
|
+
Rn(t.r, t.c, e == null ? "" : String(e), "edit");
|
|
732
|
+
}
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
default: {
|
|
736
|
+
if (!In(e)) break;
|
|
737
|
+
let t = Fn();
|
|
738
|
+
t && !G(t.r, t.c) && (e.preventDefault(), Rn(t.r, t.c, e.key, "enter"));
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
function Rn(e, t, n, r) {
|
|
743
|
+
Mn(e.id, t.id), D.value = {
|
|
744
|
+
rowId: e.id,
|
|
745
|
+
columnId: t.id,
|
|
746
|
+
draft: n,
|
|
747
|
+
mode: r
|
|
748
|
+
}, ie(() => {
|
|
749
|
+
let e = Ge.value;
|
|
750
|
+
if (e) if (e.focus({ preventScroll: !0 }), r === "enter") {
|
|
751
|
+
let t = e.value.length;
|
|
752
|
+
e.setSelectionRange(t, t);
|
|
753
|
+
} else e.select();
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
let zn = l(() => {
|
|
757
|
+
if (D.value) return P.value.get(D.value.columnId)?.type === "number" ? "decimal" : "text";
|
|
758
|
+
}), Bn = l(() => {
|
|
759
|
+
if (!D.value) return;
|
|
760
|
+
if (O.value) return st(D.value.rowId, D.value.columnId);
|
|
761
|
+
let e = P.value.get(D.value.columnId), t = vt.value.get(D.value.rowId), n = t?.label ?? String(Mt.value.get(t?.id ?? "") ?? "");
|
|
762
|
+
return [e?.label, n].filter(Boolean).join(" ");
|
|
763
|
+
}), Vn = l(() => {
|
|
764
|
+
if (!D.value) return { display: "none" };
|
|
765
|
+
let e = C.value, t = e?.querySelector(`[data-cell="${Dn(`${D.value.rowId}::${D.value.columnId}`)}"]`);
|
|
766
|
+
if (!e || !t) return { display: "none" };
|
|
767
|
+
let n = t.getBoundingClientRect(), r = e.getBoundingClientRect();
|
|
768
|
+
return {
|
|
769
|
+
top: `${n.top - r.top - e.clientTop + Ye.value}px`,
|
|
770
|
+
left: `${n.left - r.left - e.clientLeft + Xe.value}px`,
|
|
771
|
+
width: `${n.width}px`,
|
|
772
|
+
height: `${n.height}px`
|
|
773
|
+
};
|
|
774
|
+
});
|
|
775
|
+
function Hn(e) {
|
|
776
|
+
let t = D.value?.mode, n = null;
|
|
777
|
+
switch (e.key) {
|
|
778
|
+
case "Enter":
|
|
779
|
+
n = [e.shiftKey ? -1 : 1, 0];
|
|
780
|
+
break;
|
|
781
|
+
case "Tab":
|
|
782
|
+
n = [0, e.shiftKey ? -1 : 1];
|
|
783
|
+
break;
|
|
784
|
+
case "ArrowDown":
|
|
785
|
+
n = [1, 0];
|
|
786
|
+
break;
|
|
787
|
+
case "ArrowUp":
|
|
788
|
+
n = [-1, 0];
|
|
789
|
+
break;
|
|
790
|
+
case "ArrowLeft":
|
|
791
|
+
t === "enter" && (n = [0, -1]);
|
|
792
|
+
break;
|
|
793
|
+
case "ArrowRight":
|
|
794
|
+
t === "enter" && (n = [0, 1]);
|
|
795
|
+
break;
|
|
796
|
+
case "Escape":
|
|
797
|
+
e.preventDefault(), D.value = null, Y();
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
n && (e.preventDefault(), Z(), X(n[0], n[1]));
|
|
801
|
+
}
|
|
802
|
+
function Z(e = !0) {
|
|
803
|
+
if (!D.value) return;
|
|
804
|
+
let { rowId: t, columnId: n, draft: r } = D.value;
|
|
805
|
+
D.value = null;
|
|
806
|
+
let i = P.value.get(n);
|
|
807
|
+
if (!i) return;
|
|
808
|
+
let a;
|
|
809
|
+
try {
|
|
810
|
+
a = Ut(i, r);
|
|
811
|
+
} catch {
|
|
812
|
+
e && Y();
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
let o = W(t, n);
|
|
816
|
+
if (!Un(o, a)) {
|
|
817
|
+
let e = Wn(t, n, o, a);
|
|
818
|
+
Pr([e]), Q([e]);
|
|
819
|
+
}
|
|
820
|
+
e && Y();
|
|
821
|
+
}
|
|
822
|
+
function Un(e, t) {
|
|
823
|
+
return e === t || e == null && t === null;
|
|
824
|
+
}
|
|
825
|
+
function Wn(e, t, n, r) {
|
|
826
|
+
let i = {
|
|
827
|
+
rowId: e,
|
|
828
|
+
columnId: t,
|
|
829
|
+
before: n,
|
|
830
|
+
after: r
|
|
831
|
+
};
|
|
832
|
+
return O.value && (i.cell = st(e, t)), i;
|
|
833
|
+
}
|
|
834
|
+
function Q(e) {
|
|
835
|
+
if (O.value) {
|
|
836
|
+
let t = { ...Ue.value };
|
|
837
|
+
for (let n of e) {
|
|
838
|
+
let e = st(n.rowId, n.columnId);
|
|
839
|
+
n.after === null || n.after === void 0 || n.after === "" ? delete t[e] : t[e] = n.after;
|
|
840
|
+
}
|
|
841
|
+
Ue.value = t;
|
|
842
|
+
}
|
|
843
|
+
for (let t of e) x("commit", t);
|
|
844
|
+
x("change", e);
|
|
845
|
+
}
|
|
846
|
+
function Gn() {
|
|
847
|
+
let e = H.value, t = M.value, n = /* @__PURE__ */ new Set(), r = [];
|
|
848
|
+
for (let i of cn.value) for (let a = i.r1; a <= i.r2; a++) for (let o = i.c1; o <= i.c2; o++) {
|
|
849
|
+
let i = `${a}:${o}`;
|
|
850
|
+
n.has(i) || (n.add(i), r.push({
|
|
851
|
+
rowId: e[a].id,
|
|
852
|
+
columnId: t[o].id
|
|
853
|
+
}));
|
|
854
|
+
}
|
|
855
|
+
return r;
|
|
856
|
+
}
|
|
857
|
+
function Kn() {
|
|
858
|
+
let e = Gn(), t = [];
|
|
859
|
+
for (let { rowId: n, columnId: r } of e) {
|
|
860
|
+
let e = vt.value.get(n), i = P.value.get(r);
|
|
861
|
+
if (!e || !i || G(e, i)) continue;
|
|
862
|
+
let a = W(n, r);
|
|
863
|
+
a == null || a === "" || t.push(Wn(n, r, a, null));
|
|
864
|
+
}
|
|
865
|
+
t.length !== 0 && (Pr(t), Q(t));
|
|
866
|
+
}
|
|
867
|
+
function qn() {
|
|
868
|
+
let e = K.value;
|
|
869
|
+
if (!e) return null;
|
|
870
|
+
let t = H.value.map((e) => e.id), n = M.value.map((e) => e.id), r = [];
|
|
871
|
+
for (let i = e.r1; i <= e.r2; i++) {
|
|
872
|
+
let a = [];
|
|
873
|
+
for (let r = e.c1; r <= e.c2; r++) {
|
|
874
|
+
let e = W(t[i], n[r]);
|
|
875
|
+
a.push(e == null ? "" : String(e));
|
|
876
|
+
}
|
|
877
|
+
r.push(a.join(" "));
|
|
878
|
+
}
|
|
879
|
+
return r.join("\n");
|
|
880
|
+
}
|
|
881
|
+
function Jn(e) {
|
|
882
|
+
let t = qn();
|
|
883
|
+
t !== null && (e.preventDefault(), e.clipboardData?.setData("text/plain", t));
|
|
884
|
+
}
|
|
885
|
+
function Yn(e) {
|
|
886
|
+
Jn(e), Kn();
|
|
887
|
+
}
|
|
888
|
+
function Xn(e) {
|
|
889
|
+
if (!T.value) return;
|
|
890
|
+
let t = e.clipboardData?.getData("text/plain") ?? "";
|
|
891
|
+
t && (e.preventDefault(), Zn(t));
|
|
892
|
+
}
|
|
893
|
+
function Zn(e) {
|
|
894
|
+
if (!T.value || !e) return;
|
|
895
|
+
let t = e.replace(/\r\n?/g, "\n").split("\n").map((e) => e.split(" ")), n = Math.max(...t.map((e) => e.length)), r = Qn(H.value.map((e) => e.id), (U.value.get(T.value.rowId) ?? 0) + t.length), i = $n(M.value.map((e) => e.id), (F.value.get(T.value.columnId) ?? 0) + n), a = U.value.get(T.value.rowId) ?? 0, o = F.value.get(T.value.columnId) ?? 0, s = [];
|
|
896
|
+
t.forEach((e, t) => {
|
|
897
|
+
e.forEach((e, n) => {
|
|
898
|
+
let c = r[a + t], l = i[o + n];
|
|
899
|
+
if (!c || !l) return;
|
|
900
|
+
let ee = vt.value.get(c) ?? {
|
|
901
|
+
id: c,
|
|
902
|
+
values: ot
|
|
903
|
+
}, u = P.value.get(l) ?? {
|
|
904
|
+
id: l,
|
|
905
|
+
label: l
|
|
906
|
+
};
|
|
907
|
+
if (G(ee, u)) return;
|
|
908
|
+
let d;
|
|
909
|
+
try {
|
|
910
|
+
d = Ut(u, e);
|
|
911
|
+
} catch {
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
let f = W(c, l);
|
|
915
|
+
Un(f, d) || s.push(Wn(c, l, f, d));
|
|
916
|
+
});
|
|
917
|
+
}), s.length !== 0 && (Pr(s), Q(s));
|
|
918
|
+
}
|
|
919
|
+
function Qn(e, t) {
|
|
920
|
+
if (!O.value || t <= e.length) return e;
|
|
921
|
+
let n = [...e], r = R.value, i = Number(r[r.length - 1]?.id ?? 0) + 1;
|
|
922
|
+
for (; n.length < t && i <= it.value.rows;) n.push(String(i++));
|
|
923
|
+
return n;
|
|
924
|
+
}
|
|
925
|
+
function $n(e, t) {
|
|
926
|
+
if (!O.value || t <= e.length) return e;
|
|
927
|
+
let n = [...e], r = j.value.length;
|
|
928
|
+
for (; n.length < t && r < it.value.columns;) n.push(pt(r++));
|
|
929
|
+
return n;
|
|
930
|
+
}
|
|
931
|
+
let er = l(() => (b.fillHandle ?? O.value) && q.value.length === 0), $ = _(null);
|
|
932
|
+
function tr(e, t) {
|
|
933
|
+
let n = K.value;
|
|
934
|
+
return !er.value || !n || D.value ? !1 : U.value.get(e) === n.r2 && F.value.get(t) === n.c2;
|
|
935
|
+
}
|
|
936
|
+
function nr(e, t) {
|
|
937
|
+
let n = $.value;
|
|
938
|
+
if (!n) return !1;
|
|
939
|
+
let r = U.value.get(e) ?? -1, i = F.value.get(t) ?? -1;
|
|
940
|
+
return r >= n.r1 && r <= n.r2 && i >= n.c1 && i <= n.c2 && !un(e, t);
|
|
941
|
+
}
|
|
942
|
+
function rr(e) {
|
|
943
|
+
e.button === 0 && ($.value = K.value ? { ...K.value } : null, document.addEventListener("mouseup", ar, { once: !0 }));
|
|
944
|
+
}
|
|
945
|
+
function ir(e, t) {
|
|
946
|
+
let n = K.value;
|
|
947
|
+
if (!n || !$.value) return;
|
|
948
|
+
let r = U.value.get(e) ?? -1, i = F.value.get(t) ?? -1, a = r > n.r2 ? r - n.r2 : r < n.r1 ? r - n.r1 : 0, o = i > n.c2 ? i - n.c2 : i < n.c1 ? i - n.c1 : 0;
|
|
949
|
+
Math.abs(a) >= Math.abs(o) ? $.value = {
|
|
950
|
+
...n,
|
|
951
|
+
r1: Math.min(n.r1, n.r1 + a),
|
|
952
|
+
r2: Math.max(n.r2, n.r2 + a)
|
|
953
|
+
} : $.value = {
|
|
954
|
+
...n,
|
|
955
|
+
c1: Math.min(n.c1, n.c1 + o),
|
|
956
|
+
c2: Math.max(n.c2, n.c2 + o)
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
function ar() {
|
|
960
|
+
let e = K.value, t = $.value;
|
|
961
|
+
if ($.value = null, !e || !t) return;
|
|
962
|
+
sr(e, t);
|
|
963
|
+
let n = H.value, r = M.value;
|
|
964
|
+
E.value = {
|
|
965
|
+
startRowId: n[t.r1].id,
|
|
966
|
+
startColumnId: r[t.c1].id,
|
|
967
|
+
endRowId: n[t.r2].id,
|
|
968
|
+
endColumnId: r[t.c2].id
|
|
969
|
+
}, x("selection", E.value);
|
|
970
|
+
}
|
|
971
|
+
function or(e, t, n) {
|
|
972
|
+
let r = e.length, i = r >= 2 && e.every((e) => typeof e == "number" && Number.isFinite(e)), a = e, o = i ? (a[r - 1] - a[0]) / (r - 1) : 0, s = i && a.every((e, t) => Math.abs(e - (a[0] + o * t)) < 1e-9);
|
|
973
|
+
return Array.from({ length: t }, (t, i) => {
|
|
974
|
+
if (s) {
|
|
975
|
+
let e = n ? a[0] - o * (i + 1) : a[r - 1] + o * (i + 1);
|
|
976
|
+
return Math.round(e * 1e10) / 1e10;
|
|
977
|
+
}
|
|
978
|
+
return n ? e[r - 1 - i % r] : e[i % r];
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
function sr(e, t) {
|
|
982
|
+
let n = H.value, r = M.value, i = [], a = (e, t, a) => {
|
|
983
|
+
let o = n[e], s = r[t];
|
|
984
|
+
if (!o || !s || G(o, s)) return;
|
|
985
|
+
let c = W(o.id, s.id), l = a === void 0 ? null : a;
|
|
986
|
+
Un(c, l) || i.push(Wn(o.id, s.id, c, l));
|
|
987
|
+
};
|
|
988
|
+
if (t.r1 !== e.r1 || t.r2 !== e.r2) {
|
|
989
|
+
let i = t.r1 < e.r1, o = i ? e.r1 - t.r1 : t.r2 - e.r2;
|
|
990
|
+
for (let t = e.c1; t <= e.c2; t++) {
|
|
991
|
+
let s = [];
|
|
992
|
+
for (let i = e.r1; i <= e.r2; i++) s.push(W(n[i].id, r[t].id));
|
|
993
|
+
or(s, o, i).forEach((n, r) => a(i ? e.r1 - 1 - r : e.r2 + 1 + r, t, n));
|
|
994
|
+
}
|
|
995
|
+
} else {
|
|
996
|
+
let i = t.c1 < e.c1, o = i ? e.c1 - t.c1 : t.c2 - e.c2;
|
|
997
|
+
if (o <= 0) return;
|
|
998
|
+
for (let t = e.r1; t <= e.r2; t++) {
|
|
999
|
+
let s = [];
|
|
1000
|
+
for (let i = e.c1; i <= e.c2; i++) s.push(W(n[t].id, r[i].id));
|
|
1001
|
+
or(s, o, i).forEach((n, r) => a(t, i ? e.c1 - 1 - r : e.c2 + 1 + r, n));
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
i.length && (Pr(i), Q(i));
|
|
1005
|
+
}
|
|
1006
|
+
function cr(e) {
|
|
1007
|
+
let t = K.value;
|
|
1008
|
+
if (t) if (e === "down") {
|
|
1009
|
+
let e = t.r1 === t.r2 ? t.r1 - 1 : t.r1;
|
|
1010
|
+
if (e < 0) return;
|
|
1011
|
+
sr({
|
|
1012
|
+
...t,
|
|
1013
|
+
r1: e,
|
|
1014
|
+
r2: e
|
|
1015
|
+
}, {
|
|
1016
|
+
...t,
|
|
1017
|
+
r1: e,
|
|
1018
|
+
r2: t.r2
|
|
1019
|
+
});
|
|
1020
|
+
} else {
|
|
1021
|
+
let e = t.c1 === t.c2 ? t.c1 - 1 : t.c1;
|
|
1022
|
+
if (e < 0) return;
|
|
1023
|
+
sr({
|
|
1024
|
+
...t,
|
|
1025
|
+
c1: e,
|
|
1026
|
+
c2: e
|
|
1027
|
+
}, {
|
|
1028
|
+
...t,
|
|
1029
|
+
c1: e,
|
|
1030
|
+
c2: t.c2
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
function lr(e, t) {
|
|
1035
|
+
let n = Math.max(e.minWidth ?? 60, Math.round(t));
|
|
1036
|
+
return Ke.value = {
|
|
1037
|
+
...Ke.value,
|
|
1038
|
+
[e.id]: n
|
|
1039
|
+
}, n;
|
|
1040
|
+
}
|
|
1041
|
+
function ur(e, t) {
|
|
1042
|
+
let n = I(e), r = lr(e, t);
|
|
1043
|
+
r !== n && x("column-resize", {
|
|
1044
|
+
columnId: e.id,
|
|
1045
|
+
width: r
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
function dr(e, t) {
|
|
1049
|
+
let n = e.clientX, r = I(t), i = (e) => {
|
|
1050
|
+
lr(t, r + (e.clientX - n));
|
|
1051
|
+
}, a = () => {
|
|
1052
|
+
window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", a);
|
|
1053
|
+
let e = I(t);
|
|
1054
|
+
e !== r && x("column-resize", {
|
|
1055
|
+
columnId: t.id,
|
|
1056
|
+
width: e
|
|
1057
|
+
});
|
|
1058
|
+
};
|
|
1059
|
+
window.addEventListener("mousemove", i), window.addEventListener("mouseup", a);
|
|
1060
|
+
}
|
|
1061
|
+
function fr(e) {
|
|
1062
|
+
w.value?.columnId === e.id ? w.value = w.value.direction === "asc" ? {
|
|
1063
|
+
columnId: e.id,
|
|
1064
|
+
direction: "desc"
|
|
1065
|
+
} : null : w.value = {
|
|
1066
|
+
columnId: e.id,
|
|
1067
|
+
direction: "asc"
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
function pr(e, t) {
|
|
1071
|
+
w.value = {
|
|
1072
|
+
columnId: e.id,
|
|
1073
|
+
direction: t
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
function mr(e) {
|
|
1077
|
+
M.value.filter((t) => !e.includes(t.id)).length && (Ve.value = [...new Set([...Ve.value, ...e])]);
|
|
1078
|
+
}
|
|
1079
|
+
function hr(e) {
|
|
1080
|
+
Ve.value = Ve.value.filter((t) => !e.includes(t));
|
|
1081
|
+
}
|
|
1082
|
+
function gr(e) {
|
|
1083
|
+
H.value.filter((t) => !e.includes(t.id)).length && (He.value = [...new Set([...He.value, ...e])]);
|
|
1084
|
+
}
|
|
1085
|
+
function _r(e) {
|
|
1086
|
+
He.value = He.value.filter((t) => !e.includes(t));
|
|
1087
|
+
}
|
|
1088
|
+
function vr(e, t, n) {
|
|
1089
|
+
let r = e.findIndex((e) => e.id === t);
|
|
1090
|
+
if (!(r < 0)) {
|
|
1091
|
+
for (let t = r + 1; t < e.length; t++) if (n(e[t])) return e[t].id;
|
|
1092
|
+
for (let t = r - 1; t >= 0; t--) if (n(e[t])) return e[t].id;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
pe([M, H], () => {
|
|
1096
|
+
let e = T.value;
|
|
1097
|
+
if (!e) return;
|
|
1098
|
+
let t = F.value.has(e.columnId), n = U.value.has(e.rowId);
|
|
1099
|
+
if (t && n) {
|
|
1100
|
+
let e = q.value.filter((e) => sn(e));
|
|
1101
|
+
e.length !== q.value.length && (q.value = e), E.value && !K.value && (E.value = null, x("selection", null));
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
let r = [
|
|
1105
|
+
...A.value.filter((e) => e.pinned === "top"),
|
|
1106
|
+
...R.value,
|
|
1107
|
+
...A.value.filter((e) => e.pinned === "bottom")
|
|
1108
|
+
], i = t ? e.columnId : vr(j.value, e.columnId, (e) => F.value.has(e.id)), a = n ? e.rowId : vr(r, e.rowId, (e) => U.value.has(e.id));
|
|
1109
|
+
i && a ? J(a, i) : (T.value = null, E.value = null, q.value = [], x("focus", null), x("selection", null));
|
|
1110
|
+
});
|
|
1111
|
+
let yr = de("menuRef"), br = _(!1), xr = _("cell"), Sr = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? "⌘" : "Ctrl+", Cr = typeof navigator < "u" && !!navigator.clipboard?.readText, wr = l(() => {
|
|
1112
|
+
let e = K.value;
|
|
1113
|
+
return e ? M.value.slice(e.c1, e.c2 + 1).map((e) => e.id) : [];
|
|
1114
|
+
}), Tr = l(() => {
|
|
1115
|
+
let e = K.value;
|
|
1116
|
+
return e ? H.value.slice(e.r1, e.r2 + 1).map((e) => e.id) : [];
|
|
1117
|
+
});
|
|
1118
|
+
function Er() {
|
|
1119
|
+
let e = K.value;
|
|
1120
|
+
if (!e) return "cell";
|
|
1121
|
+
let t = e.r1 === 0 && e.r2 === H.value.length - 1, n = e.c1 === 0 && e.c2 === M.value.length - 1;
|
|
1122
|
+
return t && !n ? "column" : n && !t ? "row" : "cell";
|
|
1123
|
+
}
|
|
1124
|
+
let Dr = l(() => {
|
|
1125
|
+
if (xr.value !== "column" || wr.value.length !== 1) return null;
|
|
1126
|
+
let e = P.value.get(wr.value[0]);
|
|
1127
|
+
return e?.sortable ? e : null;
|
|
1128
|
+
});
|
|
1129
|
+
function Or(e, t, n, r) {
|
|
1130
|
+
if (!b.contextMenu) return;
|
|
1131
|
+
e.preventDefault(), D.value && Z();
|
|
1132
|
+
let i = K.value;
|
|
1133
|
+
if (t === "column" && r) {
|
|
1134
|
+
let e = F.value.get(r) ?? -1;
|
|
1135
|
+
(Er() !== "column" || !i || e < i.c1 || e > i.c2) && gn(r);
|
|
1136
|
+
} else if (t === "row" && n) {
|
|
1137
|
+
let e = U.value.get(n) ?? -1;
|
|
1138
|
+
(Er() !== "row" || !i || e < i.r1 || e > i.r2) && _n(n);
|
|
1139
|
+
} else n && r ? un(n, r) || J(n, r) : vn();
|
|
1140
|
+
Y(), Ar(t, e.clientX, e.clientY);
|
|
1141
|
+
}
|
|
1142
|
+
function kr() {
|
|
1143
|
+
let e = T.value;
|
|
1144
|
+
if (!e) return;
|
|
1145
|
+
Mn(e.rowId, e.columnId);
|
|
1146
|
+
let t = (C.value?.querySelector(`[data-cell="${Dn(`${e.rowId}::${e.columnId}`)}"]`))?.getBoundingClientRect();
|
|
1147
|
+
Ar(Er(), t?.left ?? 0, t?.bottom ?? 0);
|
|
1148
|
+
}
|
|
1149
|
+
function Ar(e, t, n) {
|
|
1150
|
+
xr.value = e, yr.value?.setPositionXY(t, n), br.value = !0;
|
|
1151
|
+
}
|
|
1152
|
+
function jr() {
|
|
1153
|
+
let e = qn();
|
|
1154
|
+
e !== null && navigator.clipboard?.writeText(e).catch(() => {});
|
|
1155
|
+
}
|
|
1156
|
+
function Mr() {
|
|
1157
|
+
jr(), Kn();
|
|
1158
|
+
}
|
|
1159
|
+
function Nr() {
|
|
1160
|
+
navigator.clipboard?.readText().then(Zn).catch(() => {});
|
|
1161
|
+
}
|
|
1162
|
+
function Pr(e) {
|
|
1163
|
+
Qe.value.push(e), $e.value = [];
|
|
1164
|
+
}
|
|
1165
|
+
function Fr() {
|
|
1166
|
+
let e = Qe.value.pop();
|
|
1167
|
+
e && (Q(e.map((e) => ({
|
|
1168
|
+
...e,
|
|
1169
|
+
before: e.after,
|
|
1170
|
+
after: e.before
|
|
1171
|
+
}))), $e.value.push(e));
|
|
1172
|
+
}
|
|
1173
|
+
function Ir() {
|
|
1174
|
+
let e = $e.value.pop();
|
|
1175
|
+
e && (Q(e), Qe.value.push(e));
|
|
1176
|
+
}
|
|
1177
|
+
return pe(() => [
|
|
1178
|
+
b.fit,
|
|
1179
|
+
H.value.length,
|
|
1180
|
+
xt.value,
|
|
1181
|
+
b.size,
|
|
1182
|
+
b.columnHeaders
|
|
1183
|
+
], () => wt()), oe(() => {
|
|
1184
|
+
Y(), wt(), jt(), typeof ResizeObserver < "u" && C.value && (Tt = new ResizeObserver(() => {
|
|
1185
|
+
wt(), jt();
|
|
1186
|
+
}), Tt.observe(C.value), We.value && Tt.observe(We.value));
|
|
1187
|
+
}), ae(() => Tt?.disconnect()), ne({
|
|
1188
|
+
focus: (e, t) => J(e, t),
|
|
1189
|
+
undo: Fr,
|
|
1190
|
+
redo: Ir,
|
|
1191
|
+
getSelection: () => E.value,
|
|
1192
|
+
getSelections: () => [...q.value, E.value].filter((e) => !!e),
|
|
1193
|
+
selectAll: vn,
|
|
1194
|
+
selectColumn: (e) => gn(e),
|
|
1195
|
+
selectRow: (e) => _n(e),
|
|
1196
|
+
hideColumns: mr,
|
|
1197
|
+
showColumns: hr,
|
|
1198
|
+
hideRows: gr,
|
|
1199
|
+
showRows: _r
|
|
1200
|
+
}), (n, r) => (g(), d("div", {
|
|
1201
|
+
ref_key: "rootRef",
|
|
1202
|
+
ref: We,
|
|
1203
|
+
class: m(["nb-spreadsheet", [`nb-spreadsheet--${e.size}`, {
|
|
1204
|
+
"nb-spreadsheet--editing": !!D.value,
|
|
1205
|
+
"nb-spreadsheet--fit": e.fit,
|
|
1206
|
+
"nb-spreadsheet--two-headers": N.value.length === 2,
|
|
1207
|
+
"nb-spreadsheet--filling": !!$.value
|
|
1208
|
+
}]]),
|
|
1209
|
+
style: h(Et.value)
|
|
1210
|
+
}, [
|
|
1211
|
+
n.$slots.toolbar ? (g(), d("div", ye, [ce(n.$slots, "toolbar", {}, void 0, !0)])) : u("", !0),
|
|
1212
|
+
f("div", {
|
|
1213
|
+
ref_key: "scrollerRef",
|
|
1214
|
+
ref: C,
|
|
1215
|
+
class: m(["nb-spreadsheet__scroller", { "nb-spreadsheet__scroller--active": !!T.value }]),
|
|
1216
|
+
tabindex: "0",
|
|
1217
|
+
role: "grid",
|
|
1218
|
+
"aria-multiselectable": "true",
|
|
1219
|
+
"aria-label": e.ariaLabel,
|
|
1220
|
+
"aria-rowcount": H.value.length + 1,
|
|
1221
|
+
"aria-colcount": M.value.length + (e.showGutter ? 1 : 0),
|
|
1222
|
+
"aria-activedescendant": Yt.value,
|
|
1223
|
+
onKeydown: Ln,
|
|
1224
|
+
onCopy: Jn,
|
|
1225
|
+
onCut: Yn,
|
|
1226
|
+
onPaste: Xn,
|
|
1227
|
+
onScroll: Nn
|
|
1228
|
+
}, [f("div", {
|
|
1229
|
+
class: "nb-spreadsheet__grid",
|
|
1230
|
+
style: h(Dt.value)
|
|
1231
|
+
}, [(g(!0), d(c, null, se(N.value, (n, i) => (g(), d("div", {
|
|
1232
|
+
key: `hr-${n}`,
|
|
1233
|
+
class: "nb-spreadsheet__row",
|
|
1234
|
+
role: "row",
|
|
1235
|
+
"aria-rowindex": i + 1
|
|
1236
|
+
}, [e.showGutter && i === 0 ? (g(), d("div", {
|
|
1237
|
+
key: 0,
|
|
1238
|
+
class: "nb-spreadsheet__corner",
|
|
1239
|
+
role: "columnheader",
|
|
1240
|
+
"aria-colindex": "1",
|
|
1241
|
+
style: h({
|
|
1242
|
+
gridRow: `1 / span ${N.value.length}`,
|
|
1243
|
+
gridColumn: 1
|
|
1244
|
+
}),
|
|
1245
|
+
onMousedown: y(En, ["prevent"]),
|
|
1246
|
+
onContextmenu: r[0] ||= (e) => Or(e, "cell")
|
|
1247
|
+
}, null, 36)) : u("", !0), (g(!0), d(c, null, se(Ot.value, (a) => (g(), d("div", {
|
|
1248
|
+
key: `h-${n}-${a.id}`,
|
|
1249
|
+
class: m(["nb-spreadsheet__header", Xt(a, L(a), n)]),
|
|
1250
|
+
role: "columnheader",
|
|
1251
|
+
"aria-colindex": L(a) + _t.value + 1,
|
|
1252
|
+
"aria-sort": n === "label" ? Zt(a) : void 0,
|
|
1253
|
+
"aria-label": n === "letters" && N.value.length === 1 && a.label && !O.value ? `${mt(a.id)} ${a.label}` : void 0,
|
|
1254
|
+
"data-header-col": n === "label" ? a.id : void 0,
|
|
1255
|
+
"data-header-row": i,
|
|
1256
|
+
style: h(tn(a, L(a), i)),
|
|
1257
|
+
onMousedown: (e) => wn(e, a, n),
|
|
1258
|
+
onContextmenu: (e) => Or(e, "column", void 0, a.id)
|
|
1259
|
+
}, [
|
|
1260
|
+
n === "letters" ? (g(), d("span", {
|
|
1261
|
+
key: 0,
|
|
1262
|
+
class: "nb-spreadsheet__header-letter",
|
|
1263
|
+
title: N.value.length === 1 && !O.value ? a.label : void 0
|
|
1264
|
+
}, le(mt(a.id)), 9, Ce)) : (g(), d(c, { key: 1 }, [f("span", {
|
|
1265
|
+
class: "nb-spreadsheet__header-label",
|
|
1266
|
+
title: kt.value.has(a.id) ? a.label : void 0
|
|
1267
|
+
}, le(kt.value.has(a.id) ? a.shortLabel : a.label), 9, we), a.sortable ? (g(), ee(t, {
|
|
1268
|
+
key: 0,
|
|
1269
|
+
name: Qt(a),
|
|
1270
|
+
class: "nb-spreadsheet__sort",
|
|
1271
|
+
"aria-hidden": "true"
|
|
1272
|
+
}, null, 8, ["name"])) : u("", !0)], 64)),
|
|
1273
|
+
i === N.value.length - 1 ? (g(), d(c, { key: 2 }, [ht.value.has(a.id) ? (g(), d("button", {
|
|
1274
|
+
key: 0,
|
|
1275
|
+
type: "button",
|
|
1276
|
+
tabindex: "-1",
|
|
1277
|
+
class: "nb-spreadsheet__unhide nb-spreadsheet__unhide--col-start",
|
|
1278
|
+
title: v(S).spreadsheetShowColumns(ht.value.get(a.id).length),
|
|
1279
|
+
"aria-label": v(S).spreadsheetShowColumns(ht.value.get(a.id).length),
|
|
1280
|
+
onMousedown: r[1] ||= y(() => {}, ["stop", "prevent"]),
|
|
1281
|
+
onClick: (e) => hr(ht.value.get(a.id))
|
|
1282
|
+
}, null, 40, Te)) : u("", !0), L(a) === M.value.length - 1 && gt.value.length ? (g(), d("button", {
|
|
1283
|
+
key: 1,
|
|
1284
|
+
type: "button",
|
|
1285
|
+
tabindex: "-1",
|
|
1286
|
+
class: "nb-spreadsheet__unhide nb-spreadsheet__unhide--col-end",
|
|
1287
|
+
title: v(S).spreadsheetShowColumns(gt.value.length),
|
|
1288
|
+
"aria-label": v(S).spreadsheetShowColumns(gt.value.length),
|
|
1289
|
+
onMousedown: r[2] ||= y(() => {}, ["stop", "prevent"]),
|
|
1290
|
+
onClick: r[3] ||= (e) => hr(gt.value)
|
|
1291
|
+
}, null, 40, Ee)) : u("", !0)], 64)) : u("", !0),
|
|
1292
|
+
e.resizable ? (g(), d("span", {
|
|
1293
|
+
key: 3,
|
|
1294
|
+
class: "nb-spreadsheet__resize-handle",
|
|
1295
|
+
onMousedown: y((e) => dr(e, a), ["stop"])
|
|
1296
|
+
}, null, 40, De)) : u("", !0)
|
|
1297
|
+
], 46, Se))), 128))], 8, xe))), 128)), (g(!0), d(c, null, se(Lt.value, (t) => (g(), d("div", {
|
|
1298
|
+
key: `r-${t.id}`,
|
|
1299
|
+
class: "nb-spreadsheet__row",
|
|
1300
|
+
role: "row",
|
|
1301
|
+
"aria-rowindex": t.__virtualIndex + 1 + N.value.length
|
|
1302
|
+
}, [e.showGutter ? (g(), d("div", {
|
|
1303
|
+
key: 0,
|
|
1304
|
+
class: m(["nb-spreadsheet__gutter", {
|
|
1305
|
+
"nb-spreadsheet__gutter--pinned-top": t.pinned === "top",
|
|
1306
|
+
"nb-spreadsheet__gutter--pinned-bottom": t.pinned === "bottom",
|
|
1307
|
+
"nb-spreadsheet__gutter--selected": fn(t.id)
|
|
1308
|
+
}]),
|
|
1309
|
+
role: "rowheader",
|
|
1310
|
+
"aria-colindex": "1",
|
|
1311
|
+
style: h(on(t)),
|
|
1312
|
+
onMousedown: y((e) => Tn(e, t), ["prevent"]),
|
|
1313
|
+
onContextmenu: (e) => Or(e, "row", t.id)
|
|
1314
|
+
}, [
|
|
1315
|
+
te(le(an(t)) + " ", 1),
|
|
1316
|
+
Pt.value.has(t.id) ? (g(), d("button", {
|
|
1317
|
+
key: 0,
|
|
1318
|
+
type: "button",
|
|
1319
|
+
tabindex: "-1",
|
|
1320
|
+
class: "nb-spreadsheet__unhide nb-spreadsheet__unhide--row-start",
|
|
1321
|
+
title: v(S).spreadsheetShowRows(Pt.value.get(t.id).length),
|
|
1322
|
+
"aria-label": v(S).spreadsheetShowRows(Pt.value.get(t.id).length),
|
|
1323
|
+
onMousedown: r[4] ||= y(() => {}, ["stop", "prevent"]),
|
|
1324
|
+
onClick: (e) => _r(Pt.value.get(t.id))
|
|
1325
|
+
}, null, 40, Ae)) : u("", !0),
|
|
1326
|
+
t.id === It.value && Ft.value.length ? (g(), d("button", {
|
|
1327
|
+
key: 1,
|
|
1328
|
+
type: "button",
|
|
1329
|
+
tabindex: "-1",
|
|
1330
|
+
class: "nb-spreadsheet__unhide nb-spreadsheet__unhide--row-end",
|
|
1331
|
+
title: v(S).spreadsheetShowRows(Ft.value.length),
|
|
1332
|
+
"aria-label": v(S).spreadsheetShowRows(Ft.value.length),
|
|
1333
|
+
onMousedown: r[5] ||= y(() => {}, ["stop", "prevent"]),
|
|
1334
|
+
onClick: r[6] ||= (e) => _r(Ft.value)
|
|
1335
|
+
}, null, 40, je)) : u("", !0)
|
|
1336
|
+
], 46, ke)) : u("", !0), (g(!0), d(c, null, se(Ot.value, (e) => (g(), d("div", {
|
|
1337
|
+
id: Jt(t.id, e.id),
|
|
1338
|
+
key: `c-${t.id}-${e.id}`,
|
|
1339
|
+
class: m(["nb-spreadsheet__cell", Kt(t, e)]),
|
|
1340
|
+
role: "gridcell",
|
|
1341
|
+
"aria-colindex": L(e) + _t.value + 1,
|
|
1342
|
+
"aria-selected": un(t.id, e.id),
|
|
1343
|
+
"aria-readonly": G(t, e) || void 0,
|
|
1344
|
+
style: h(nn(t, e, L(e))),
|
|
1345
|
+
title: qt(t, e),
|
|
1346
|
+
"data-cell": `${t.id}::${e.id}`,
|
|
1347
|
+
"data-row": t.id,
|
|
1348
|
+
"data-col": e.id,
|
|
1349
|
+
onPointerdown: r[7] ||= (e) => yn(e),
|
|
1350
|
+
onMousedown: (n) => bn(n, t, e),
|
|
1351
|
+
onMouseenter: (n) => xn(t, e),
|
|
1352
|
+
onDblclick: (n) => Cn(t, e),
|
|
1353
|
+
onContextmenu: (n) => Or(n, "cell", t.id, e.id)
|
|
1354
|
+
}, [f("span", null, le(Gt(t, e)), 1), tr(t.id, e.id) ? (g(), d("span", {
|
|
1355
|
+
key: 0,
|
|
1356
|
+
class: "nb-spreadsheet__fill-handle",
|
|
1357
|
+
"aria-hidden": "true",
|
|
1358
|
+
onMousedown: y(rr, ["stop", "prevent"])
|
|
1359
|
+
}, null, 32)) : u("", !0)], 46, Me))), 128))], 8, Oe))), 128))], 4), D.value ? he((g(), d("input", {
|
|
1360
|
+
key: 0,
|
|
1361
|
+
ref_key: "editorRef",
|
|
1362
|
+
ref: Ge,
|
|
1363
|
+
"onUpdate:modelValue": r[8] ||= (e) => D.value.draft = e,
|
|
1364
|
+
class: "nb-spreadsheet__editor",
|
|
1365
|
+
style: h(Vn.value),
|
|
1366
|
+
inputmode: zn.value,
|
|
1367
|
+
"aria-label": Bn.value,
|
|
1368
|
+
enterkeyhint: "next",
|
|
1369
|
+
onBlur: r[9] ||= (e) => Z(!1),
|
|
1370
|
+
onKeydown: y(Hn, ["stop"])
|
|
1371
|
+
}, null, 44, Ne)), [[fe, D.value.draft]]) : u("", !0)], 42, be),
|
|
1372
|
+
e.contextMenu ? (g(), ee(a, {
|
|
1373
|
+
key: 1,
|
|
1374
|
+
ref_key: "menuRef",
|
|
1375
|
+
ref: yr,
|
|
1376
|
+
open: br.value,
|
|
1377
|
+
"onUpdate:open": r[16] ||= (e) => br.value = e,
|
|
1378
|
+
size: "sm"
|
|
1379
|
+
}, {
|
|
1380
|
+
default: me(() => [
|
|
1381
|
+
p(o, {
|
|
1382
|
+
label: v(S).spreadsheetCut,
|
|
1383
|
+
shortcut: `${v(Sr)}X`,
|
|
1384
|
+
onSelect: Mr
|
|
1385
|
+
}, null, 8, ["label", "shortcut"]),
|
|
1386
|
+
p(o, {
|
|
1387
|
+
label: v(S).spreadsheetCopy,
|
|
1388
|
+
shortcut: `${v(Sr)}C`,
|
|
1389
|
+
onSelect: jr
|
|
1390
|
+
}, null, 8, ["label", "shortcut"]),
|
|
1391
|
+
p(o, {
|
|
1392
|
+
label: v(S).spreadsheetPaste,
|
|
1393
|
+
shortcut: `${v(Sr)}V`,
|
|
1394
|
+
disabled: !v(Cr),
|
|
1395
|
+
"disabled-reason": v(S).spreadsheetPasteWithKeys,
|
|
1396
|
+
onSelect: Nr
|
|
1397
|
+
}, null, 8, [
|
|
1398
|
+
"label",
|
|
1399
|
+
"shortcut",
|
|
1400
|
+
"disabled",
|
|
1401
|
+
"disabled-reason"
|
|
1402
|
+
]),
|
|
1403
|
+
p(o, {
|
|
1404
|
+
label: v(S).spreadsheetClear,
|
|
1405
|
+
shortcut: "Delete",
|
|
1406
|
+
onSelect: Kn
|
|
1407
|
+
}, null, 8, ["label"]),
|
|
1408
|
+
Dr.value ? (g(), d(c, { key: 0 }, [
|
|
1409
|
+
p(s),
|
|
1410
|
+
p(o, {
|
|
1411
|
+
label: v(S).spreadsheetSortAscending,
|
|
1412
|
+
onSelect: r[10] ||= (e) => pr(Dr.value, "asc")
|
|
1413
|
+
}, null, 8, ["label"]),
|
|
1414
|
+
p(o, {
|
|
1415
|
+
label: v(S).spreadsheetSortDescending,
|
|
1416
|
+
onSelect: r[11] ||= (e) => pr(Dr.value, "desc")
|
|
1417
|
+
}, null, 8, ["label"])
|
|
1418
|
+
], 64)) : u("", !0),
|
|
1419
|
+
p(s),
|
|
1420
|
+
xr.value === "row" ? u("", !0) : (g(), d(c, { key: 1 }, [p(o, {
|
|
1421
|
+
label: v(S).spreadsheetHideColumns(wr.value.length),
|
|
1422
|
+
disabled: wr.value.length >= M.value.length,
|
|
1423
|
+
"disabled-reason": v(S).spreadsheetKeepOneColumn,
|
|
1424
|
+
onSelect: r[12] ||= (e) => mr(wr.value)
|
|
1425
|
+
}, null, 8, [
|
|
1426
|
+
"label",
|
|
1427
|
+
"disabled",
|
|
1428
|
+
"disabled-reason"
|
|
1429
|
+
]), ut.value.length ? (g(), ee(o, {
|
|
1430
|
+
key: 0,
|
|
1431
|
+
label: v(S).spreadsheetShowColumns(ut.value.length),
|
|
1432
|
+
onSelect: r[13] ||= (e) => hr(ut.value)
|
|
1433
|
+
}, null, 8, ["label"])) : u("", !0)], 64)),
|
|
1434
|
+
xr.value === "column" ? u("", !0) : (g(), d(c, { key: 2 }, [p(o, {
|
|
1435
|
+
label: v(S).spreadsheetHideRows(Tr.value.length),
|
|
1436
|
+
disabled: Tr.value.length >= H.value.length,
|
|
1437
|
+
"disabled-reason": v(S).spreadsheetKeepOneRow,
|
|
1438
|
+
onSelect: r[14] ||= (e) => gr(Tr.value)
|
|
1439
|
+
}, null, 8, [
|
|
1440
|
+
"label",
|
|
1441
|
+
"disabled",
|
|
1442
|
+
"disabled-reason"
|
|
1443
|
+
]), dt.value.length ? (g(), ee(o, {
|
|
1444
|
+
key: 0,
|
|
1445
|
+
label: v(S).spreadsheetShowRows(dt.value.length),
|
|
1446
|
+
onSelect: r[15] ||= (e) => _r(dt.value)
|
|
1447
|
+
}, null, 8, ["label"])) : u("", !0)], 64))
|
|
1448
|
+
]),
|
|
1449
|
+
_: 1
|
|
1450
|
+
}, 8, ["open"])) : u("", !0)
|
|
1451
|
+
], 6));
|
|
1452
|
+
}
|
|
1453
|
+
}), [["__scopeId", "data-v-44ef8680"]]);
|
|
1454
|
+
//#endregion
|
|
1455
|
+
export { b as t };
|