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