@nubisco/ui 5.60.0 → 5.61.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-Bg1gxM7t.cjs +4 -0
- package/dist/Spreadsheet-Cdl14I3Q.js +2326 -0
- package/dist/all.cjs +1 -1
- package/dist/all.mjs +2 -2
- package/dist/components/Spreadsheet.cjs +1 -1
- package/dist/components/Spreadsheet.d.ts +7 -0
- package/dist/components/Spreadsheet.mjs +1 -1
- package/dist/components/Spreadsheet.vue.d.ts.map +1 -1
- package/dist/components/spreadsheet/sheetLook.d.ts.map +1 -1
- package/dist/formula/criteria.d.ts.map +1 -1
- package/dist/formula/dates.d.ts +31 -0
- package/dist/formula/dates.d.ts.map +1 -0
- package/dist/formula/evaluator.d.ts.map +1 -1
- package/dist/formula/format.d.ts +7 -0
- package/dist/formula/format.d.ts.map +1 -0
- package/dist/formula/functions/date.d.ts +3 -0
- package/dist/formula/functions/date.d.ts.map +1 -0
- package/dist/formula/functions/index.d.ts.map +1 -1
- package/dist/formula/functions/text.d.ts.map +1 -1
- package/dist/formula/index.cjs +1 -1
- package/dist/formula/index.d.ts +2 -0
- package/dist/formula/index.d.ts.map +1 -1
- package/dist/formula/index.mjs +2 -2
- package/dist/formula/parser.d.ts.map +1 -1
- package/dist/formula/syntax.d.ts.map +1 -1
- package/dist/formula/tokenizer.d.ts +2 -0
- package/dist/formula/tokenizer.d.ts.map +1 -1
- package/dist/formula/types.d.ts +7 -2
- package/dist/formula/types.d.ts.map +1 -1
- package/dist/formula/values.d.ts.map +1 -1
- package/dist/formula-Co-gRJ5f.cjs +1 -0
- package/dist/{formula-Bic1LaPK.js → formula-QEIwkjmo.js} +1042 -434
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{main-wtHGDDYS.js → main-DJ43_gPi.js} +1 -1
- package/dist/{main-vJqUlyCN.cjs → main-NxnoNUx0.cjs} +1 -1
- package/dist/styles/Spreadsheet.css +1 -1
- package/dist/ui.css +1 -1
- package/package.json +1 -1
- package/dist/Spreadsheet-DD0OS-sF.cjs +0 -4
- package/dist/Spreadsheet-DN8_9s4Q.js +0 -2215
- package/dist/formula-CoCixvl3.cjs +0 -1
|
@@ -0,0 +1,2326 @@
|
|
|
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 { parseCsv as c, toCsv as l } from "./utils/csv.helper.mjs";
|
|
10
|
+
import { _ as u, a as d, b as f, c as p, f as m, h as ee, i as te, l as ne, m as re, n as ie, o as ae, p as oe, r as se, s as ce, t as le, y as h } from "./formula-QEIwkjmo.js";
|
|
11
|
+
import { Fragment as g, computed as _, createBlock as ue, createCommentVNode as v, createElementBlock as y, createElementVNode as b, createTextVNode as de, createVNode as x, defineComponent as fe, getCurrentInstance as pe, mergeModels as me, mergeProps as he, nextTick as ge, normalizeClass as S, normalizeStyle as C, onBeforeUnmount as _e, onMounted as ve, openBlock as w, ref as T, renderList as ye, renderSlot as be, toDisplayString as E, unref as D, useModel as xe, useTemplateRef as Se, vModelDynamic as Ce, watch as we, withCtx as Te, withDirectives as Ee, withModifiers as O } from "vue";
|
|
12
|
+
import * as De from "@nubisco/ui/icons/arrow-down";
|
|
13
|
+
import * as Oe from "@nubisco/ui/icons/arrow-up";
|
|
14
|
+
import * as ke from "@nubisco/ui/icons/arrows-down-up";
|
|
15
|
+
//#region src/components/spreadsheet/sheetLook.ts
|
|
16
|
+
function Ae(e) {
|
|
17
|
+
let t = e.trim();
|
|
18
|
+
if (t.includes(":")) return h(t);
|
|
19
|
+
let n = f(t);
|
|
20
|
+
return n ? {
|
|
21
|
+
r1: n.row,
|
|
22
|
+
c1: n.col,
|
|
23
|
+
r2: n.row,
|
|
24
|
+
c2: n.col
|
|
25
|
+
} : null;
|
|
26
|
+
}
|
|
27
|
+
function je(e) {
|
|
28
|
+
let t = u(e.r1, e.c1), n = u(e.r2, e.c2);
|
|
29
|
+
return t === n ? t : `${t}:${n}`;
|
|
30
|
+
}
|
|
31
|
+
function Me(e, t) {
|
|
32
|
+
return e.r1 <= t.r2 && t.r1 <= e.r2 && e.c1 <= t.c2 && t.c1 <= e.c2;
|
|
33
|
+
}
|
|
34
|
+
function Ne(e, t, n) {
|
|
35
|
+
let r = (e, t) => e === void 0 ? { maximumFractionDigits: t } : {
|
|
36
|
+
minimumFractionDigits: e,
|
|
37
|
+
maximumFractionDigits: e
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
if (t?.type === "date" || t?.type === "time" || t?.type === "datetime") return Pe(e, t, n);
|
|
41
|
+
if (t?.type === "percent") return new Intl.NumberFormat(n, {
|
|
42
|
+
style: "percent",
|
|
43
|
+
...r(t.decimals, 10)
|
|
44
|
+
}).format(e);
|
|
45
|
+
if (t?.type === "currency") return new Intl.NumberFormat(n, {
|
|
46
|
+
style: "currency",
|
|
47
|
+
currency: t.currency,
|
|
48
|
+
...t.decimals === void 0 ? {} : r(t.decimals, 2)
|
|
49
|
+
}).format(e);
|
|
50
|
+
if (t?.type === "number") return new Intl.NumberFormat(n, {
|
|
51
|
+
useGrouping: t.grouping ?? !0,
|
|
52
|
+
...r(t.decimals, 10)
|
|
53
|
+
}).format(e);
|
|
54
|
+
} catch {}
|
|
55
|
+
return new Intl.NumberFormat(n, {
|
|
56
|
+
maximumFractionDigits: 10,
|
|
57
|
+
useGrouping: !1
|
|
58
|
+
}).format(e);
|
|
59
|
+
}
|
|
60
|
+
function Pe(e, t, n) {
|
|
61
|
+
let r = oe(e), i = new Date(Date.UTC(r.year, r.month - 1, r.day, r.hours, r.minutes, r.seconds));
|
|
62
|
+
i.setUTCFullYear(r.year);
|
|
63
|
+
let a = { timeZone: "UTC" };
|
|
64
|
+
return t.type === "date" ? a.dateStyle = t.style ?? "short" : t.type === "time" ? a.timeStyle = t.style ?? "short" : (a.dateStyle = t.style ?? "medium", a.timeStyle = "short"), new Intl.DateTimeFormat(n, a).format(i);
|
|
65
|
+
}
|
|
66
|
+
function Fe(e) {
|
|
67
|
+
return typeof e == "object" && !!e && typeof e.error == "string";
|
|
68
|
+
}
|
|
69
|
+
function k(e, t) {
|
|
70
|
+
if (typeof t == "number") {
|
|
71
|
+
let n = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
|
|
72
|
+
return Number.isFinite(n) ? n - t : null;
|
|
73
|
+
}
|
|
74
|
+
return e == null ? null : String(e).toLowerCase().localeCompare(t.toLowerCase());
|
|
75
|
+
}
|
|
76
|
+
function Ie(e, t, n) {
|
|
77
|
+
if (Fe(t)) return e.when === "error";
|
|
78
|
+
let r = t == null || t === "";
|
|
79
|
+
switch (e.when) {
|
|
80
|
+
case "error": return !1;
|
|
81
|
+
case "empty": return r;
|
|
82
|
+
case "notEmpty": return !r;
|
|
83
|
+
case "formula": return n === !0 || typeof n == "number" && n !== 0;
|
|
84
|
+
case "between":
|
|
85
|
+
case "notBetween": {
|
|
86
|
+
let n = typeof t == "number" ? t : NaN;
|
|
87
|
+
if (!Number.isFinite(n)) return !1;
|
|
88
|
+
let r = Math.min(e.min, e.max), i = Math.max(e.min, e.max), a = n >= r && n <= i;
|
|
89
|
+
return e.when === "between" ? a : !a;
|
|
90
|
+
}
|
|
91
|
+
case "contains":
|
|
92
|
+
case "notContains":
|
|
93
|
+
case "startsWith":
|
|
94
|
+
case "endsWith": {
|
|
95
|
+
if (r) return e.when === "notContains";
|
|
96
|
+
let n = String(t).toLowerCase(), i = e.text.toLowerCase();
|
|
97
|
+
return e.when === "contains" ? n.includes(i) : e.when === "notContains" ? !n.includes(i) : e.when === "startsWith" ? n.startsWith(i) : n.endsWith(i);
|
|
98
|
+
}
|
|
99
|
+
default: {
|
|
100
|
+
if (r) return !1;
|
|
101
|
+
let n = k(t, e.value);
|
|
102
|
+
if (n === null) return e.when === "notEqual";
|
|
103
|
+
switch (e.when) {
|
|
104
|
+
case "greaterThan": return n > 0;
|
|
105
|
+
case "lessThan": return n < 0;
|
|
106
|
+
case "greaterOrEqual": return n >= 0;
|
|
107
|
+
case "lessOrEqual": return n <= 0;
|
|
108
|
+
case "equal": return n === 0;
|
|
109
|
+
case "notEqual": return n !== 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return !1;
|
|
114
|
+
}
|
|
115
|
+
function Le(e, t) {
|
|
116
|
+
return t ? e ? {
|
|
117
|
+
...e,
|
|
118
|
+
...t
|
|
119
|
+
} : t : e;
|
|
120
|
+
}
|
|
121
|
+
function Re(e) {
|
|
122
|
+
let t = {};
|
|
123
|
+
for (let [n, r] of Object.entries(e)) r !== void 0 && r !== !1 && (t[n] = r);
|
|
124
|
+
return Object.keys(t).length ? t : void 0;
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/components/Spreadsheet.vue?vue&type=script&setup=true&lang.ts
|
|
128
|
+
var ze = {
|
|
129
|
+
key: 0,
|
|
130
|
+
class: "nb-spreadsheet__toolbar"
|
|
131
|
+
}, Be = {
|
|
132
|
+
key: 1,
|
|
133
|
+
class: "nb-spreadsheet__formula-bar"
|
|
134
|
+
}, Ve = { class: "nb-spreadsheet__name-box" }, He = { class: "nb-spreadsheet__bar-field" }, Ue = {
|
|
135
|
+
key: 0,
|
|
136
|
+
class: "nb-spreadsheet__mirror nb-spreadsheet__mirror--bar",
|
|
137
|
+
"aria-hidden": "true"
|
|
138
|
+
}, We = [
|
|
139
|
+
"value",
|
|
140
|
+
"readonly",
|
|
141
|
+
"aria-label"
|
|
142
|
+
], Ge = [
|
|
143
|
+
"aria-label",
|
|
144
|
+
"aria-rowcount",
|
|
145
|
+
"aria-colcount",
|
|
146
|
+
"aria-activedescendant"
|
|
147
|
+
], Ke = ["aria-rowindex"], qe = [
|
|
148
|
+
"aria-colindex",
|
|
149
|
+
"aria-sort",
|
|
150
|
+
"aria-label",
|
|
151
|
+
"data-header-col",
|
|
152
|
+
"data-header-row",
|
|
153
|
+
"onMousedown",
|
|
154
|
+
"onContextmenu"
|
|
155
|
+
], Je = ["title"], Ye = ["title"], Xe = [
|
|
156
|
+
"title",
|
|
157
|
+
"aria-label",
|
|
158
|
+
"onClick"
|
|
159
|
+
], Ze = ["title", "aria-label"], Qe = ["onMousedown"], $e = ["aria-rowindex"], et = ["onMousedown", "onContextmenu"], tt = [
|
|
160
|
+
"title",
|
|
161
|
+
"aria-label",
|
|
162
|
+
"onClick"
|
|
163
|
+
], nt = ["title", "aria-label"], rt = [
|
|
164
|
+
"id",
|
|
165
|
+
"aria-colindex",
|
|
166
|
+
"aria-selected",
|
|
167
|
+
"aria-readonly",
|
|
168
|
+
"title",
|
|
169
|
+
"data-cell",
|
|
170
|
+
"data-row",
|
|
171
|
+
"data-col",
|
|
172
|
+
"onMousedown",
|
|
173
|
+
"onMouseenter",
|
|
174
|
+
"onDblclick",
|
|
175
|
+
"onContextmenu"
|
|
176
|
+
], it = ["inputmode", "aria-label"], at = ["aria-label"], ot = [
|
|
177
|
+
"id",
|
|
178
|
+
"aria-selected",
|
|
179
|
+
"onMousedown"
|
|
180
|
+
], st = { class: "nb-spreadsheet__assist-name" }, ct = { class: "nb-spreadsheet__assist-description" }, lt = ["id"], ut = { class: "nb-spreadsheet__signature-call" }, dt = { key: 0 }, ft = { class: "nb-spreadsheet__assist-description" }, pt = 9e3, mt = 1e3, ht = 100, gt = 26, _t = 20, vt = 50, yt = 8, bt = 8, xt = /* @__PURE__ */ e(/* @__PURE__ */ fe({
|
|
181
|
+
__name: "Spreadsheet",
|
|
182
|
+
props: /* @__PURE__ */ me({
|
|
183
|
+
columns: { default: () => [] },
|
|
184
|
+
rows: { default: () => [] },
|
|
185
|
+
cellAttrs: {},
|
|
186
|
+
computed: {},
|
|
187
|
+
resizable: {
|
|
188
|
+
type: Boolean,
|
|
189
|
+
default: !0
|
|
190
|
+
},
|
|
191
|
+
rowReorderable: {
|
|
192
|
+
type: Boolean,
|
|
193
|
+
default: !1
|
|
194
|
+
},
|
|
195
|
+
showGutter: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
default: !0
|
|
198
|
+
},
|
|
199
|
+
gutterWidth: { default: 44 },
|
|
200
|
+
windowRows: { default: 80 },
|
|
201
|
+
locale: { default: "pt-PT" },
|
|
202
|
+
fit: {
|
|
203
|
+
type: Boolean,
|
|
204
|
+
default: !1
|
|
205
|
+
},
|
|
206
|
+
size: { default: "sm" },
|
|
207
|
+
ariaLabel: { default: void 0 },
|
|
208
|
+
columnHeaders: { default: "label" },
|
|
209
|
+
contextMenu: {
|
|
210
|
+
type: Boolean,
|
|
211
|
+
default: !1
|
|
212
|
+
},
|
|
213
|
+
extent: { default: "data" },
|
|
214
|
+
fillHandle: {
|
|
215
|
+
type: Boolean,
|
|
216
|
+
default: void 0
|
|
217
|
+
},
|
|
218
|
+
conditionalFormats: { default: void 0 },
|
|
219
|
+
formulas: {
|
|
220
|
+
type: Boolean,
|
|
221
|
+
default: !0
|
|
222
|
+
},
|
|
223
|
+
formulaBar: {
|
|
224
|
+
type: Boolean,
|
|
225
|
+
default: void 0
|
|
226
|
+
}
|
|
227
|
+
}, {
|
|
228
|
+
hiddenColumns: { default: () => [] },
|
|
229
|
+
hiddenColumnsModifiers: {},
|
|
230
|
+
hiddenRows: { default: () => [] },
|
|
231
|
+
hiddenRowsModifiers: {},
|
|
232
|
+
cells: {},
|
|
233
|
+
cellsModifiers: {},
|
|
234
|
+
styles: { default: () => ({}) },
|
|
235
|
+
stylesModifiers: {},
|
|
236
|
+
merges: { default: () => [] },
|
|
237
|
+
mergesModifiers: {}
|
|
238
|
+
}),
|
|
239
|
+
emits: /* @__PURE__ */ me([
|
|
240
|
+
"commit",
|
|
241
|
+
"change",
|
|
242
|
+
"selection",
|
|
243
|
+
"focus",
|
|
244
|
+
"row-reorder",
|
|
245
|
+
"column-resize"
|
|
246
|
+
], [
|
|
247
|
+
"update:hiddenColumns",
|
|
248
|
+
"update:hiddenRows",
|
|
249
|
+
"update:cells",
|
|
250
|
+
"update:styles",
|
|
251
|
+
"update:merges"
|
|
252
|
+
]),
|
|
253
|
+
setup(e, { expose: u, emit: f }) {
|
|
254
|
+
let h = e, fe = xe(e, "hiddenColumns"), me = xe(e, "hiddenRows"), Pe = xe(e, "cells"), k = xe(e, "styles"), xt = xe(e, "merges"), A = f, j = i(), St = Se("rootRef"), M = Se("scrollerRef"), Ct = Se("editorRef"), wt = T({}), N = T(null), Tt = n({}), P = T(null), F = T(null), Et = T(!1), I = T(null), Dt = T(0), Ot = T(0), kt = "", At = T([]), jt = T([]), L = _(() => Pe.value !== void 0);
|
|
255
|
+
function Mt(e) {
|
|
256
|
+
let t = 0;
|
|
257
|
+
for (let n of e) t = t * 26 + (n.charCodeAt(0) - 64);
|
|
258
|
+
return t - 1;
|
|
259
|
+
}
|
|
260
|
+
let Nt = _(() => {
|
|
261
|
+
let e = 0, t = 0;
|
|
262
|
+
for (let n of Object.keys(Pe.value ?? {})) {
|
|
263
|
+
let r = /^([A-Z]+)(\d+)$/.exec(n);
|
|
264
|
+
r && (e = Math.max(e, Number(r[2])), t = Math.max(t, Mt(r[1]) + 1));
|
|
265
|
+
}
|
|
266
|
+
for (let n of Ht.value) e = Math.max(e, n.r2 + 1), t = Math.max(t, n.c2 + 1);
|
|
267
|
+
return {
|
|
268
|
+
rows: e,
|
|
269
|
+
columns: t
|
|
270
|
+
};
|
|
271
|
+
}), Pt = T(ht), Ft = T(gt), It = _(() => {
|
|
272
|
+
let e = h.extent;
|
|
273
|
+
return typeof e == "object" ? {
|
|
274
|
+
rows: Math.min(pt, e.maxRows ?? pt),
|
|
275
|
+
columns: Math.min(mt, e.maxColumns ?? mt)
|
|
276
|
+
} : {
|
|
277
|
+
rows: pt,
|
|
278
|
+
columns: mt
|
|
279
|
+
};
|
|
280
|
+
}), Lt = _(() => {
|
|
281
|
+
let e = h.extent, t = Nt.value, n = It.value, r = t.rows, i = t.columns;
|
|
282
|
+
return e === "infinite" ? (r = Math.max(r, Pt.value), i = Math.max(i, Ft.value)) : typeof e == "object" && (r = Math.max(r, e.minRows ?? 1), i = Math.max(i, e.minColumns ?? 1)), {
|
|
283
|
+
rows: Math.max(1, Math.min(n.rows, r)),
|
|
284
|
+
columns: Math.max(1, Math.min(n.columns, i))
|
|
285
|
+
};
|
|
286
|
+
}), Rt = Object.freeze({}), zt = _(() => L.value ? Array.from({ length: Lt.value.columns }, (e, t) => {
|
|
287
|
+
let n = vn(t);
|
|
288
|
+
return {
|
|
289
|
+
id: n,
|
|
290
|
+
label: n
|
|
291
|
+
};
|
|
292
|
+
}) : h.columns), Bt = _(() => L.value ? Array.from({ length: Lt.value.rows }, (e, t) => ({
|
|
293
|
+
id: String(t + 1),
|
|
294
|
+
values: Rt
|
|
295
|
+
})) : h.rows);
|
|
296
|
+
function R(e, t) {
|
|
297
|
+
return `${t}${e}`;
|
|
298
|
+
}
|
|
299
|
+
function Vt(e, t) {
|
|
300
|
+
return {
|
|
301
|
+
r: Number(e) - 1,
|
|
302
|
+
c: Mt(t)
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
let Ht = _(() => {
|
|
306
|
+
if (!L.value) return [];
|
|
307
|
+
let e = [];
|
|
308
|
+
for (let t of xt.value) {
|
|
309
|
+
let n = Ae(t);
|
|
310
|
+
!n || !Number.isFinite(n.r2) || !Number.isFinite(n.c2) || n.r1 === n.r2 && n.c1 === n.c2 || e.push(n);
|
|
311
|
+
}
|
|
312
|
+
return e;
|
|
313
|
+
}), Ut = _(() => {
|
|
314
|
+
let e = [];
|
|
315
|
+
for (let t of Ht.value) {
|
|
316
|
+
let n = -1, r = -1, i = -1, a = -1;
|
|
317
|
+
for (let e = t.r1; e <= t.r2; e++) {
|
|
318
|
+
let t = G.value.get(String(e + 1));
|
|
319
|
+
t !== void 0 && (n < 0 && (n = t), r = t);
|
|
320
|
+
}
|
|
321
|
+
for (let e = t.c1; e <= t.c2; e++) {
|
|
322
|
+
let t = H.value.get(vn(e));
|
|
323
|
+
t !== void 0 && (i < 0 && (i = t), a = t);
|
|
324
|
+
}
|
|
325
|
+
n < 0 || i < 0 || n === r && i === a || e.push({
|
|
326
|
+
r1: n,
|
|
327
|
+
r2: r,
|
|
328
|
+
c1: i,
|
|
329
|
+
c2: a
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
return e;
|
|
333
|
+
}), Wt = _(() => {
|
|
334
|
+
let e = /* @__PURE__ */ new Map();
|
|
335
|
+
for (let t of Ut.value) for (let n = t.r1; n <= t.r2; n++) for (let r = t.c1; r <= t.c2; r++) e.set(`${n}:${r}`, t);
|
|
336
|
+
return e;
|
|
337
|
+
});
|
|
338
|
+
function Gt(e, t) {
|
|
339
|
+
return Wt.value.get(`${e}:${t}`);
|
|
340
|
+
}
|
|
341
|
+
function Kt(e, t) {
|
|
342
|
+
if (!Ut.value.length) return !1;
|
|
343
|
+
let n = G.value.get(e) ?? -1, r = H.value.get(t) ?? -1, i = Gt(n, r);
|
|
344
|
+
return !!i && (i.r1 !== n || i.c1 !== r);
|
|
345
|
+
}
|
|
346
|
+
function qt(e) {
|
|
347
|
+
if (!Ut.value.length) return e;
|
|
348
|
+
let t = { ...e }, n = !0;
|
|
349
|
+
for (; n;) {
|
|
350
|
+
n = !1;
|
|
351
|
+
for (let e of Ut.value) Me(t, e) && (e.r1 < t.r1 || e.r2 > t.r2 || e.c1 < t.c1 || e.c2 > t.c2) && (t.r1 = Math.min(t.r1, e.r1), t.r2 = Math.max(t.r2, e.r2), t.c1 = Math.min(t.c1, e.c1), t.c2 = Math.max(t.c2, e.c2), n = !0);
|
|
352
|
+
}
|
|
353
|
+
return t;
|
|
354
|
+
}
|
|
355
|
+
function Jt(e) {
|
|
356
|
+
let t = W.value, n = z.value, r = Vt(t[e.r1].id, n[e.c1].id), i = Vt(t[e.r2].id, n[e.c2].id);
|
|
357
|
+
return {
|
|
358
|
+
r1: r.r,
|
|
359
|
+
c1: r.c,
|
|
360
|
+
r2: i.r,
|
|
361
|
+
c2: i.c
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function Yt() {
|
|
365
|
+
let e = Y.value;
|
|
366
|
+
if (!L.value || !e || e.r1 === e.r2 && e.c1 === e.c2) return;
|
|
367
|
+
let t = Jt(e), n = xt.value, r = [...n.filter((e) => {
|
|
368
|
+
let n = Ae(e);
|
|
369
|
+
return !n || !Me(n, t);
|
|
370
|
+
}), je(t)];
|
|
371
|
+
Ga([], { merges: [n, r] }), xt.value = r;
|
|
372
|
+
}
|
|
373
|
+
function Xt() {
|
|
374
|
+
if (!L.value || !Mr.value.length) return;
|
|
375
|
+
let e = Mr.value.map(Jt), t = xt.value, n = t.filter((t) => {
|
|
376
|
+
let n = Ae(t);
|
|
377
|
+
return !n || !e.some((e) => Me(n, e));
|
|
378
|
+
});
|
|
379
|
+
n.length !== t.length && (Ga([], { merges: [t, n] }), xt.value = n);
|
|
380
|
+
}
|
|
381
|
+
let Zt = _(() => {
|
|
382
|
+
let e = Y.value;
|
|
383
|
+
return !!e && (e.r1 !== e.r2 || e.c1 !== e.c2);
|
|
384
|
+
}), Qt = _(() => Mr.value.some((e) => Ut.value.some((t) => Me(t, e)))), $t = _(() => {
|
|
385
|
+
if (!L.value || !h.conditionalFormats?.length) return [];
|
|
386
|
+
let e = [];
|
|
387
|
+
for (let t of h.conditionalFormats) {
|
|
388
|
+
let n = Ae(t.range);
|
|
389
|
+
n && e.push({
|
|
390
|
+
range: n,
|
|
391
|
+
format: t
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
return e;
|
|
395
|
+
}), en = pe()?.vnode.props ?? {}, tn = "styles" in en || "onUpdate:styles" in en, nn = _(() => L.value || tn);
|
|
396
|
+
function rn(e, t) {
|
|
397
|
+
return L.value ? R(e, t) : `${e}:${t}`;
|
|
398
|
+
}
|
|
399
|
+
function an(e, t) {
|
|
400
|
+
return e === t || JSON.stringify(e ?? {}) === JSON.stringify(t ?? {});
|
|
401
|
+
}
|
|
402
|
+
function on(e, t) {
|
|
403
|
+
if (!nn.value) return;
|
|
404
|
+
let n = k.value[rn(e, t)];
|
|
405
|
+
if (!L.value || !$t.value.length) return n;
|
|
406
|
+
let { r, c: i } = Vt(e, t);
|
|
407
|
+
for (let { range: a, format: o } of $t.value) {
|
|
408
|
+
if (r < a.r1 || r > a.r2 || i < a.c1 || i > a.c2) continue;
|
|
409
|
+
let s = o.rule.when === "formula" ? rr(o.rule.formula, r - a.r1, i - a.c1) : void 0;
|
|
410
|
+
Ie(o.rule, nr(e, t), s) && (n = Le(n, o.style));
|
|
411
|
+
}
|
|
412
|
+
return n;
|
|
413
|
+
}
|
|
414
|
+
function sn(e) {
|
|
415
|
+
if (!nn.value) return;
|
|
416
|
+
let t = k.value, n = { ...t };
|
|
417
|
+
for (let { rowId: r, columnId: i } of bi()) {
|
|
418
|
+
let a = rn(r, i), o = Re({
|
|
419
|
+
...t[a],
|
|
420
|
+
...e
|
|
421
|
+
});
|
|
422
|
+
o ? n[a] = o : delete n[a];
|
|
423
|
+
}
|
|
424
|
+
Ga([], { styles: [t, n] }), k.value = n;
|
|
425
|
+
}
|
|
426
|
+
function cn(e) {
|
|
427
|
+
let t = P.value;
|
|
428
|
+
if (!t) return;
|
|
429
|
+
let n = !k.value[rn(t.rowId, t.columnId)]?.[e];
|
|
430
|
+
sn({ [e]: n });
|
|
431
|
+
}
|
|
432
|
+
function ln() {
|
|
433
|
+
sn({
|
|
434
|
+
bold: void 0,
|
|
435
|
+
italic: void 0,
|
|
436
|
+
underline: void 0,
|
|
437
|
+
strike: void 0,
|
|
438
|
+
align: void 0,
|
|
439
|
+
intent: void 0,
|
|
440
|
+
format: void 0
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
function un(e = {}) {
|
|
444
|
+
let t = e.values === "display", n = fn.value, r = [];
|
|
445
|
+
if (L.value) {
|
|
446
|
+
let { rows: e, columns: n } = Nt.value;
|
|
447
|
+
for (let i = 0; i < e; i++) {
|
|
448
|
+
let e = [];
|
|
449
|
+
for (let r = 0; r < n; r++) {
|
|
450
|
+
let n = String(i + 1), a = vn(r);
|
|
451
|
+
e.push(t ? ir(n, a) : q(n, a));
|
|
452
|
+
}
|
|
453
|
+
r.push(e);
|
|
454
|
+
}
|
|
455
|
+
} else {
|
|
456
|
+
r.push(n.map((e) => e.label));
|
|
457
|
+
for (let e of [
|
|
458
|
+
...Bt.value.filter((e) => e.pinned === "top"),
|
|
459
|
+
...Rn.value,
|
|
460
|
+
...Bt.value.filter((e) => e.pinned === "bottom")
|
|
461
|
+
]) r.push(n.map((n) => t ? gr(e, n) : q(e.id, n.id)));
|
|
462
|
+
}
|
|
463
|
+
return l(r, e.delimiter ?? ",");
|
|
464
|
+
}
|
|
465
|
+
function dn(e, t) {
|
|
466
|
+
if (!L.value) return;
|
|
467
|
+
let n = {}, r = [];
|
|
468
|
+
c(e, t).forEach((e, t) => {
|
|
469
|
+
e.forEach((e, i) => {
|
|
470
|
+
let a = `${vn(i)}${t + 1}`, o = Zn(e);
|
|
471
|
+
if (o === null) return;
|
|
472
|
+
n[a] = o;
|
|
473
|
+
let s = typeof o == "number" ? fr(e) : null;
|
|
474
|
+
s && r.push({
|
|
475
|
+
key: a,
|
|
476
|
+
format: s.format
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
let i = pr(r), a = Pe.value ?? {}, o = [];
|
|
481
|
+
for (let e of new Set([...Object.keys(a), ...Object.keys(n)])) {
|
|
482
|
+
let t = /^([A-Z]+)(\d+)$/.exec(e);
|
|
483
|
+
if (!t) continue;
|
|
484
|
+
let r = a[e] ?? null, i = n[e] ?? null;
|
|
485
|
+
_i(r, i) || o.push(vi(t[2], t[1], r, i));
|
|
486
|
+
}
|
|
487
|
+
!o.length && !i || (Ga(o, i ? { styles: [k.value, i] } : {}), o.length && yi(o), i && (k.value = i));
|
|
488
|
+
}
|
|
489
|
+
let fn = _(() => {
|
|
490
|
+
let e = zt.value.filter((e) => e.pinned === "left"), t = zt.value.filter((e) => e.pinned === "right"), n = zt.value.filter((e) => !e.pinned);
|
|
491
|
+
return [
|
|
492
|
+
...e,
|
|
493
|
+
...n,
|
|
494
|
+
...t
|
|
495
|
+
];
|
|
496
|
+
}), pn = _(() => new Set(fe.value)), mn = _(() => new Set(me.value)), z = _(() => fn.value.filter((e) => !pn.value.has(e.id))), hn = _(() => fn.value.filter((e) => pn.value.has(e.id)).map((e) => e.id)), gn = _(() => Bt.value.filter((e) => mn.value.has(e.id)).map((e) => e.id)), _n = _(() => new Map(fn.value.map((e, t) => [e.id, vn(t)])));
|
|
497
|
+
function vn(e) {
|
|
498
|
+
let t = e + 1, n = "";
|
|
499
|
+
for (; t > 0;) {
|
|
500
|
+
let e = (t - 1) % 26;
|
|
501
|
+
n = String.fromCharCode(65 + e) + n, t = Math.floor((t - 1) / 26);
|
|
502
|
+
}
|
|
503
|
+
return n;
|
|
504
|
+
}
|
|
505
|
+
function yn(e) {
|
|
506
|
+
return _n.value.get(e) ?? "";
|
|
507
|
+
}
|
|
508
|
+
let B = _(() => {
|
|
509
|
+
let e = h.columnHeaders;
|
|
510
|
+
return L.value || e === "letters" ? ["letters"] : e === "both" ? ["letters", "label"] : ["label"];
|
|
511
|
+
}), bn = _(() => {
|
|
512
|
+
let e = /* @__PURE__ */ new Map(), t = [];
|
|
513
|
+
for (let n of fn.value) pn.value.has(n.id) ? t.push(n.id) : t.length && (e.set(n.id, t), t = []);
|
|
514
|
+
return e;
|
|
515
|
+
}), xn = _(() => {
|
|
516
|
+
let e = [];
|
|
517
|
+
for (let t = fn.value.length - 1; t >= 0; t--) {
|
|
518
|
+
let n = fn.value[t];
|
|
519
|
+
if (!pn.value.has(n.id)) break;
|
|
520
|
+
e.unshift(n.id);
|
|
521
|
+
}
|
|
522
|
+
return e;
|
|
523
|
+
}), Sn = _(() => h.showGutter ? 1 : 0), Cn = _(() => new Map(Bt.value.map((e) => [e.id, e]))), V = _(() => new Map(zt.value.map((e) => [e.id, e]))), H = _(() => new Map(z.value.map((e, t) => [e.id, t])));
|
|
524
|
+
function U(e) {
|
|
525
|
+
return wt.value[e.id] ?? e.width ?? 120;
|
|
526
|
+
}
|
|
527
|
+
let wn = {
|
|
528
|
+
xs: 24,
|
|
529
|
+
sm: 32,
|
|
530
|
+
md: 40,
|
|
531
|
+
lg: 48
|
|
532
|
+
}, Tn = _(() => wn[h.size] ?? wn.sm), { phoneTouch: En } = r(), Dn = T(null), On = _(() => Dn.value ?? Tn.value);
|
|
533
|
+
function kn() {
|
|
534
|
+
let e = St.value, t = M.value, n = W.value.length;
|
|
535
|
+
if (!h.fit || En.value || !e || !t || !n) {
|
|
536
|
+
Dn.value = null;
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
let r = e.querySelector(".nb-spreadsheet__toolbar"), i = t.offsetHeight - t.clientHeight, a = e.clientHeight - (r?.offsetHeight ?? 0) - i, o = Math.floor((a - ni()) / n);
|
|
540
|
+
Dn.value = Math.min(Tn.value, Math.max(_t, o));
|
|
541
|
+
}
|
|
542
|
+
let An = null, jn = _(() => Dn.value === null ? void 0 : { "--nbss-row-height": `${Dn.value}px` }), Mn = _(() => ({
|
|
543
|
+
gridTemplateColumns: (h.showGutter ? `${h.gutterWidth}px ` : "") + z.value.map((e) => h.fit && !e.pinned ? `minmax(${U(e)}px, 1fr)` : `${U(e)}px`).join(" "),
|
|
544
|
+
gridTemplateRows: `${B.value.length === 2 ? "var(--nbss-letter-height) var(--nbss-header-height)" : "var(--nbss-header-height)"} repeat(${Math.max(1, W.value.length)}, var(--nbss-row-height))`
|
|
545
|
+
})), Nn = _(() => {
|
|
546
|
+
let e = z.value;
|
|
547
|
+
if (h.fit || e.length <= vt) return e;
|
|
548
|
+
let t = M.value?.clientWidth || 1200, n = Ot.value - t, r = Ot.value + t * 2, i = h.showGutter ? h.gutterWidth : 0, a = /* @__PURE__ */ new Set();
|
|
549
|
+
e.forEach((e, t) => {
|
|
550
|
+
let o = U(e);
|
|
551
|
+
(e.pinned || i + o >= n && i <= r) && a.add(t), i += o;
|
|
552
|
+
});
|
|
553
|
+
for (let e of Ut.value) for (let t = e.c1 + 1; t <= e.c2; t++) if (a.has(t)) {
|
|
554
|
+
a.add(e.c1);
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
return e.filter((e, t) => a.has(t));
|
|
558
|
+
});
|
|
559
|
+
function Pn(e) {
|
|
560
|
+
return H.value.get(e.id) ?? 0;
|
|
561
|
+
}
|
|
562
|
+
let Fn = T(/* @__PURE__ */ new Set()), In = /* @__PURE__ */ new Map();
|
|
563
|
+
function Ln() {
|
|
564
|
+
let e = M.value;
|
|
565
|
+
if (!e) return;
|
|
566
|
+
let t = [], n = !1, r = !1;
|
|
567
|
+
for (let i of zt.value) {
|
|
568
|
+
if (!i.shortLabel) continue;
|
|
569
|
+
let a = e.querySelector(`[data-header-col="${ei(i.id)}"] .nb-spreadsheet__header-label`);
|
|
570
|
+
if (!a) continue;
|
|
571
|
+
let o = `${i.id}::${i.label}`;
|
|
572
|
+
Fn.value.has(i.id) || In.set(o, a.scrollWidth);
|
|
573
|
+
let s = In.get(o);
|
|
574
|
+
if (s === void 0) {
|
|
575
|
+
r = !0;
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
t.push(i.id), s > a.clientWidth && (n = !0);
|
|
579
|
+
}
|
|
580
|
+
Fn.value = new Set(n ? t : []), r && ge(Ln);
|
|
581
|
+
}
|
|
582
|
+
we(() => [h.columns, wt.value], () => void ge(Ln), { deep: !0 });
|
|
583
|
+
let Rn = _(() => {
|
|
584
|
+
let e = Bt.value.filter((e) => !e.pinned);
|
|
585
|
+
if (!N.value) return e;
|
|
586
|
+
let t = V.value.get(N.value.columnId);
|
|
587
|
+
if (!t) return e;
|
|
588
|
+
let n = N.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;
|
|
589
|
+
return [...e].sort((e, n) => r(e.values[t.id], n.values[t.id]));
|
|
590
|
+
}), zn = _(() => new Map(Rn.value.map((e, t) => [e.id, t + 1]))), Bn = (e) => !mn.value.has(e.id), Vn = _(() => Rn.value.filter(Bn)), Hn = _(() => Bt.value.filter((e) => e.pinned === "top" && Bn(e))), Un = _(() => Bt.value.filter((e) => e.pinned === "bottom" && Bn(e))), Wn = _(() => {
|
|
591
|
+
let e = /* @__PURE__ */ new Map(), t = [];
|
|
592
|
+
for (let n of Rn.value) Bn(n) ? t.length && (e.set(n.id, t), t = []) : t.push(n.id);
|
|
593
|
+
return e;
|
|
594
|
+
}), Gn = _(() => {
|
|
595
|
+
let e = [], t = Rn.value;
|
|
596
|
+
for (let n = t.length - 1; n >= 0 && !Bn(t[n]); n--) e.unshift(t[n].id);
|
|
597
|
+
return e;
|
|
598
|
+
}), Kn = _(() => Vn.value[Vn.value.length - 1]?.id), W = _(() => [
|
|
599
|
+
...Hn.value,
|
|
600
|
+
...Vn.value,
|
|
601
|
+
...Un.value
|
|
602
|
+
]), G = _(() => new Map(W.value.map((e, t) => [e.id, t]))), qn = _(() => {
|
|
603
|
+
let e = Math.max(1, Math.ceil((M.value?.clientHeight ?? 600) / On.value)), t = Math.max(10, Math.floor(h.windowRows / 4)), n = Math.floor(Dt.value / On.value) - Hn.value.length - t, r = Math.max(0, n), i = Math.min(Vn.value.length, r + e + t * 2), a = Hn.value.map((e, t) => ({
|
|
604
|
+
...e,
|
|
605
|
+
__virtualIndex: t,
|
|
606
|
+
gutterLabel: ""
|
|
607
|
+
})), o = Vn.value.slice(r, i).map((e, t) => ({
|
|
608
|
+
...e,
|
|
609
|
+
__virtualIndex: r + t + Hn.value.length
|
|
610
|
+
})), s = r + Hn.value.length;
|
|
611
|
+
for (let e of Ut.value) {
|
|
612
|
+
if (e.r1 >= s || e.r2 < s) continue;
|
|
613
|
+
let t = W.value[e.r1];
|
|
614
|
+
t && !o.some((e) => e.id === t.id) && o.unshift({
|
|
615
|
+
...t,
|
|
616
|
+
__virtualIndex: e.r1
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
let c = Un.value.map((e, t) => ({
|
|
620
|
+
...e,
|
|
621
|
+
__virtualIndex: Hn.value.length + Vn.value.length + t,
|
|
622
|
+
gutterLabel: ""
|
|
623
|
+
}));
|
|
624
|
+
return [
|
|
625
|
+
...a,
|
|
626
|
+
...o,
|
|
627
|
+
...c
|
|
628
|
+
];
|
|
629
|
+
});
|
|
630
|
+
function Jn(e, t) {
|
|
631
|
+
if (t == null || t === "") return "";
|
|
632
|
+
if (e.type === "number") {
|
|
633
|
+
let e = typeof t == "number" ? t : Number(t);
|
|
634
|
+
return Number.isFinite(e) ? new Intl.NumberFormat(h.locale, { maximumFractionDigits: 4 }).format(e) : String(t);
|
|
635
|
+
}
|
|
636
|
+
if (e.type === "date") {
|
|
637
|
+
let e = t instanceof Date ? t : new Date(t);
|
|
638
|
+
return Number.isNaN(e.getTime()) ? String(t) : new Intl.DateTimeFormat(h.locale).format(e);
|
|
639
|
+
}
|
|
640
|
+
return String(t);
|
|
641
|
+
}
|
|
642
|
+
function Yn(e, t) {
|
|
643
|
+
if (t === "") return null;
|
|
644
|
+
if (e.type === "number") {
|
|
645
|
+
let e = t.replace(/\s/g, "").replace(",", "."), n = Number(e);
|
|
646
|
+
if (!Number.isFinite(n)) throw Error("Invalid number");
|
|
647
|
+
return n;
|
|
648
|
+
}
|
|
649
|
+
if (e.type === "date") {
|
|
650
|
+
let e = new Date(t);
|
|
651
|
+
if (Number.isNaN(e.getTime())) throw Error("Invalid date");
|
|
652
|
+
return e.toISOString().slice(0, 10);
|
|
653
|
+
}
|
|
654
|
+
return t;
|
|
655
|
+
}
|
|
656
|
+
let Xn = _(() => new Intl.NumberFormat(h.locale).formatToParts(1.5).find((e) => e.type === "decimal")?.value ?? ".");
|
|
657
|
+
function Zn(e) {
|
|
658
|
+
let t = e.trim();
|
|
659
|
+
if (t === "") return null;
|
|
660
|
+
if (/^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i.test(t)) return Number(t);
|
|
661
|
+
if (Xn.value === "," && /^[-+]?(\d+,?\d*|,\d+)$/.test(t)) return Number(t.replace(",", "."));
|
|
662
|
+
let n = fr(t);
|
|
663
|
+
return n ? n.value : e;
|
|
664
|
+
}
|
|
665
|
+
function Qn(e) {
|
|
666
|
+
return e == null ? "" : typeof e == "number" ? new Intl.NumberFormat(h.locale, {
|
|
667
|
+
maximumFractionDigits: 10,
|
|
668
|
+
useGrouping: !1
|
|
669
|
+
}).format(e) : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : String(e);
|
|
670
|
+
}
|
|
671
|
+
let $n = le(), er = /* @__PURE__ */ new Map(), K = _(() => L.value && h.formulas), tr = _(() => K.value ? $n.compute(Pe.value ?? {}) : er);
|
|
672
|
+
function nr(e, t) {
|
|
673
|
+
let n = q(e, t);
|
|
674
|
+
return K.value && ne(n) ? tr.value.get(R(e, t)) ?? null : n;
|
|
675
|
+
}
|
|
676
|
+
function rr(e, t, n) {
|
|
677
|
+
if (!L.value) return;
|
|
678
|
+
tr.value;
|
|
679
|
+
let r = e.startsWith("=") ? e : `=${e}`;
|
|
680
|
+
return $n.evaluate(d(r, t, n));
|
|
681
|
+
}
|
|
682
|
+
function ir(e, t) {
|
|
683
|
+
let n = nr(e, t);
|
|
684
|
+
return Fe(n) ? n.error : typeof n == "number" ? Ne(n, k.value[R(e, t)]?.format ?? cr(q(e, t)), h.locale) : Qn(n);
|
|
685
|
+
}
|
|
686
|
+
let ar = /^=\s*(DATE|TODAY|EDATE|EOMONTH|WORKDAY|DATEVALUE)\s*\(/i, or = /^=\s*(TIME|TIMEVALUE)\s*\(/i, sr = /^=\s*NOW\s*\(/i;
|
|
687
|
+
function cr(e) {
|
|
688
|
+
if (!K.value || !ne(e)) return;
|
|
689
|
+
if (ar.test(e)) return { type: "date" };
|
|
690
|
+
if (or.test(e)) return { type: "time" };
|
|
691
|
+
if (sr.test(e)) return { type: "datetime" };
|
|
692
|
+
let t = lr.exec(e), n = t ? k.value[`${t[1]}${t[2]}`]?.format : void 0;
|
|
693
|
+
if (n?.type === "date" || n?.type === "datetime") return n;
|
|
694
|
+
}
|
|
695
|
+
let lr = /^=\s*\$?([A-Z]+)\$?(\d+)\s*[+-]\s*[\d.]+\s*$/, ur = _(() => new Intl.DateTimeFormat(h.locale, { timeZone: "UTC" }).formatToParts(new Date(Date.UTC(2006, 0, 2))).filter((e) => e.type === "day" || e.type === "month" || e.type === "year").map((e) => e.type)), dr = /^(\d{1,4})[./-](\d{1,2})[./-](\d{1,4})(?:[ T](\d{1,2}):(\d{2})(?::(\d{2}))?)?$/;
|
|
696
|
+
function fr(e) {
|
|
697
|
+
let t = e.trim(), n = re(t);
|
|
698
|
+
if (n !== null) {
|
|
699
|
+
let e = /^\d{4}-/.test(t), r = t.includes(":");
|
|
700
|
+
return {
|
|
701
|
+
value: n,
|
|
702
|
+
format: { type: e && r ? "datetime" : r ? "time" : "date" }
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
let r = dr.exec(t);
|
|
706
|
+
if (!r || ur.value.length !== 3) return null;
|
|
707
|
+
let i = {};
|
|
708
|
+
ur.value.forEach((e, t) => i[e] = Number(r[t + 1]));
|
|
709
|
+
let { year: a } = i, { month: o, day: s } = i;
|
|
710
|
+
if (a < 100 && (a += 2e3), o < 1 || o > 12 || s < 1 || s > 31) return null;
|
|
711
|
+
let c = ee(a, o, s, Number(r[4] ?? 0), Number(r[5] ?? 0), Number(r[6] ?? 0));
|
|
712
|
+
return oe(c).day === s ? {
|
|
713
|
+
value: c,
|
|
714
|
+
format: { type: r[4] ? "datetime" : "date" }
|
|
715
|
+
} : null;
|
|
716
|
+
}
|
|
717
|
+
function pr(e) {
|
|
718
|
+
let t = null;
|
|
719
|
+
for (let { key: n, format: r } of e) k.value[n]?.format || (t ??= { ...k.value }, t[n] = {
|
|
720
|
+
...k.value[n],
|
|
721
|
+
format: r
|
|
722
|
+
});
|
|
723
|
+
return t;
|
|
724
|
+
}
|
|
725
|
+
function mr(e, t, n = !1) {
|
|
726
|
+
if (e.parse) return e.parse(t);
|
|
727
|
+
let r = t.trim();
|
|
728
|
+
return n && K.value && r.length > 1 && r.startsWith("=") ? ce(r, fa.value) : L.value ? Zn(t) : Yn(e, t);
|
|
729
|
+
}
|
|
730
|
+
function q(e, t) {
|
|
731
|
+
if (L.value) {
|
|
732
|
+
let n = Pe.value?.[R(e, t)];
|
|
733
|
+
return n === void 0 ? h.computed ? h.computed(e, t, q) : void 0 : n;
|
|
734
|
+
}
|
|
735
|
+
let n = Cn.value.get(e);
|
|
736
|
+
if (!n) return;
|
|
737
|
+
let r = n.values[t];
|
|
738
|
+
if (r !== void 0) return r;
|
|
739
|
+
if (h.computed) return h.computed(e, t, q);
|
|
740
|
+
}
|
|
741
|
+
function hr(e, t) {
|
|
742
|
+
return h.cellAttrs ? h.cellAttrs(e.id, t.id, e, t) ?? {} : {};
|
|
743
|
+
}
|
|
744
|
+
function gr(e, t) {
|
|
745
|
+
let n = hr(e, t);
|
|
746
|
+
if (n.display !== void 0) return n.display;
|
|
747
|
+
let r = q(e.id, t.id);
|
|
748
|
+
if (t.format) return t.format(r, e);
|
|
749
|
+
if (L.value) return ir(e.id, t.id);
|
|
750
|
+
let i = nn.value ? k.value[rn(e.id, t.id)]?.format : void 0;
|
|
751
|
+
return i && typeof r == "number" ? Ne(r, i, h.locale) : Jn(t, r);
|
|
752
|
+
}
|
|
753
|
+
function _r(e, t) {
|
|
754
|
+
let n = hr(e, t), r = P.value?.rowId === e.id && P.value?.columnId === t.id, i = Fr(e.id, t.id), a = on(e.id, t.id);
|
|
755
|
+
return {
|
|
756
|
+
[`nb-spreadsheet__cell--${a?.align ?? t.align ?? (L.value ? typeof nr(e.id, t.id) == "number" ? "right" : "left" : t.type === "number" || t.type === "date" ? "right" : "left")}`]: !0,
|
|
757
|
+
"nb-spreadsheet__cell--focused": r,
|
|
758
|
+
"nb-spreadsheet__cell--selected": i.selected,
|
|
759
|
+
"nb-spreadsheet__cell--edge-top": i.top,
|
|
760
|
+
"nb-spreadsheet__cell--edge-bottom": i.bottom,
|
|
761
|
+
"nb-spreadsheet__cell--edge-left": i.left,
|
|
762
|
+
"nb-spreadsheet__cell--edge-right": i.right,
|
|
763
|
+
"nb-spreadsheet__cell--readonly": J(e, t),
|
|
764
|
+
"nb-spreadsheet__cell--computed": !!n.computed || !!e.computed,
|
|
765
|
+
"nb-spreadsheet__cell--pinned-top": e.pinned === "top",
|
|
766
|
+
"nb-spreadsheet__cell--pinned-bottom": e.pinned === "bottom",
|
|
767
|
+
"nb-spreadsheet__cell--fill": Ni(e.id, t.id),
|
|
768
|
+
"nb-spreadsheet__cell--fill-anchor": Mi(e.id, t.id),
|
|
769
|
+
"nb-spreadsheet__cell--bold": !!a?.bold,
|
|
770
|
+
"nb-spreadsheet__cell--italic": !!a?.italic,
|
|
771
|
+
"nb-spreadsheet__cell--underline": !!a?.underline,
|
|
772
|
+
"nb-spreadsheet__cell--strike": !!a?.strike,
|
|
773
|
+
[`nb-spreadsheet__cell--intent-${a?.intent}`]: !!a?.intent,
|
|
774
|
+
"nb-spreadsheet__cell--error": L.value && Fe(nr(e.id, t.id)),
|
|
775
|
+
[n.className ?? ""]: !!n.className,
|
|
776
|
+
[e.className ?? ""]: !!e.className
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function J(e, t) {
|
|
780
|
+
if (e.computed || t.readOnly) return !0;
|
|
781
|
+
let n = hr(e, t);
|
|
782
|
+
return !!n.readOnly || !!n.computed;
|
|
783
|
+
}
|
|
784
|
+
function vr(e, t) {
|
|
785
|
+
let n = hr(e, t).tooltip;
|
|
786
|
+
if (n !== void 0) return n;
|
|
787
|
+
let r = L.value ? nr(e.id, t.id) : void 0;
|
|
788
|
+
return Fe(r) ? r.message : "";
|
|
789
|
+
}
|
|
790
|
+
function yr(e, t) {
|
|
791
|
+
return `${Tt}-r${G.value.get(e)}-c${H.value.get(t)}`;
|
|
792
|
+
}
|
|
793
|
+
let br = _(() => P.value ? yr(P.value.rowId, P.value.columnId) : void 0);
|
|
794
|
+
function xr(e, t, n) {
|
|
795
|
+
return {
|
|
796
|
+
"nb-spreadsheet__header--letters": n === "letters",
|
|
797
|
+
"nb-spreadsheet__header--stacked": B.value.length === 2,
|
|
798
|
+
"nb-spreadsheet__header--sortable": n === "label" && !!e.sortable,
|
|
799
|
+
"nb-spreadsheet__header--sorted": N.value?.columnId === e.id,
|
|
800
|
+
"nb-spreadsheet__header--selected": Lr(t),
|
|
801
|
+
"nb-spreadsheet__header--pinned-left": e.pinned === "left",
|
|
802
|
+
"nb-spreadsheet__header--pinned-right": e.pinned === "right",
|
|
803
|
+
"nb-spreadsheet__header--last": t === z.value.length - 1
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
function Sr(e) {
|
|
807
|
+
if (e.sortable) return N.value?.columnId === e.id ? N.value.direction === "asc" ? "ascending" : "descending" : "none";
|
|
808
|
+
}
|
|
809
|
+
function Cr(e) {
|
|
810
|
+
return N.value?.columnId === e.id ? N.value.direction === "asc" ? Oe : De : ke;
|
|
811
|
+
}
|
|
812
|
+
function wr(e) {
|
|
813
|
+
if (e.pinned !== "left") return 0;
|
|
814
|
+
let t = h.showGutter ? h.gutterWidth : 0;
|
|
815
|
+
for (let n of z.value) {
|
|
816
|
+
if (n.id === e.id) break;
|
|
817
|
+
n.pinned === "left" && (t += U(n));
|
|
818
|
+
}
|
|
819
|
+
return t;
|
|
820
|
+
}
|
|
821
|
+
function Tr(e) {
|
|
822
|
+
if (e.pinned !== "right") return 0;
|
|
823
|
+
let t = 0, n = [...z.value].reverse();
|
|
824
|
+
for (let r of n) {
|
|
825
|
+
if (r.id === e.id) break;
|
|
826
|
+
r.pinned === "right" && (t += U(r));
|
|
827
|
+
}
|
|
828
|
+
return t;
|
|
829
|
+
}
|
|
830
|
+
function Er(e, t, n) {
|
|
831
|
+
let r = Sn.value + 1 + t, i = { top: n === 0 ? "0" : "var(--nbss-letter-height)" };
|
|
832
|
+
return e.pinned === "left" ? (i.position = "sticky", i.left = `${wr(e)}px`, i.zIndex = "3") : e.pinned === "right" && (i.position = "sticky", i.right = `${Tr(e)}px`, i.zIndex = "3"), {
|
|
833
|
+
gridRow: n + 1,
|
|
834
|
+
gridColumn: r,
|
|
835
|
+
...i
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
function Dr(e, t, n) {
|
|
839
|
+
let r = Sn.value + 1 + n, i = e.__virtualIndex + 1 + B.value.length, a = {};
|
|
840
|
+
t.pinned === "left" ? (a.position = "sticky", a.left = `${wr(t)}px`, a.zIndex = "2") : t.pinned === "right" && (a.position = "sticky", a.right = `${Tr(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, Or(e)));
|
|
841
|
+
let o = Ut.value.length ? Gt(e.__virtualIndex, n) : void 0;
|
|
842
|
+
return o ? {
|
|
843
|
+
gridRow: `${i} / span ${o.r2 - o.r1 + 1}`,
|
|
844
|
+
gridColumn: `${r} / span ${o.c2 - o.c1 + 1}`,
|
|
845
|
+
...a
|
|
846
|
+
} : {
|
|
847
|
+
gridRow: i,
|
|
848
|
+
gridColumn: r,
|
|
849
|
+
...a
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
function Or(e) {
|
|
853
|
+
if (e.pinned === "top") {
|
|
854
|
+
let t = Hn.value.findIndex((t) => t.id === e.id);
|
|
855
|
+
return { top: `calc(var(--nbss-head-height) + var(--nbss-row-height) * ${Math.max(0, t)})` };
|
|
856
|
+
}
|
|
857
|
+
if (e.pinned === "bottom") {
|
|
858
|
+
let t = Un.value, n = t.findIndex((t) => t.id === e.id);
|
|
859
|
+
return { bottom: `calc(var(--nbss-row-height) * ${Math.max(0, t.length - 1 - n)})` };
|
|
860
|
+
}
|
|
861
|
+
return {};
|
|
862
|
+
}
|
|
863
|
+
function kr(e) {
|
|
864
|
+
return e.label === void 0 ? e.gutterLabel === void 0 ? String(zn.value.get(e.id) ?? "") : e.gutterLabel : e.label;
|
|
865
|
+
}
|
|
866
|
+
function Ar(e) {
|
|
867
|
+
let t = {
|
|
868
|
+
position: "sticky",
|
|
869
|
+
left: "0",
|
|
870
|
+
zIndex: "2"
|
|
871
|
+
};
|
|
872
|
+
return e.pinned && (Object.assign(t, Or(e)), t.zIndex = "4"), {
|
|
873
|
+
gridRow: e.__virtualIndex + 1 + B.value.length,
|
|
874
|
+
gridColumn: 1,
|
|
875
|
+
...t
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
function jr(e) {
|
|
879
|
+
if (!e) return null;
|
|
880
|
+
let t = G.value.get(e.startRowId) ?? -1, n = G.value.get(e.endRowId) ?? -1, r = H.value.get(e.startColumnId) ?? -1, i = H.value.get(e.endColumnId) ?? -1;
|
|
881
|
+
return t < 0 || n < 0 || r < 0 || i < 0 ? null : qt({
|
|
882
|
+
r1: Math.min(t, n),
|
|
883
|
+
r2: Math.max(t, n),
|
|
884
|
+
c1: Math.min(r, i),
|
|
885
|
+
c2: Math.max(r, i)
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
let Y = _(() => jr(F.value)), X = T([]), Mr = _(() => {
|
|
889
|
+
let e = [];
|
|
890
|
+
for (let t of X.value) {
|
|
891
|
+
let n = jr(t);
|
|
892
|
+
n && e.push(n);
|
|
893
|
+
}
|
|
894
|
+
return Y.value && e.push(Y.value), e;
|
|
895
|
+
});
|
|
896
|
+
function Nr(e, t) {
|
|
897
|
+
for (let n of Mr.value) if (e >= n.r1 && e <= n.r2 && t >= n.c1 && t <= n.c2) return !0;
|
|
898
|
+
return !1;
|
|
899
|
+
}
|
|
900
|
+
function Pr(e, t) {
|
|
901
|
+
return Nr(G.value.get(e) ?? -1, H.value.get(t) ?? -1);
|
|
902
|
+
}
|
|
903
|
+
function Fr(e, t) {
|
|
904
|
+
let n = G.value.get(e) ?? -1, r = H.value.get(t) ?? -1, i = Nr(n, r), a = Gt(n, r), o = a ? a.c2 : r, s = a ? a.r2 : n;
|
|
905
|
+
return {
|
|
906
|
+
selected: i,
|
|
907
|
+
right: i !== Nr(n, o + 1),
|
|
908
|
+
bottom: i !== Nr(s + 1, r),
|
|
909
|
+
left: i && r === 0,
|
|
910
|
+
top: i && n === 0
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
function Ir(e) {
|
|
914
|
+
let t = G.value.get(e) ?? -1;
|
|
915
|
+
return Mr.value.some((e) => t >= e.r1 && t <= e.r2);
|
|
916
|
+
}
|
|
917
|
+
function Lr(e) {
|
|
918
|
+
return Mr.value.some((t) => e >= t.c1 && e <= t.c2);
|
|
919
|
+
}
|
|
920
|
+
function Rr() {
|
|
921
|
+
F.value && (X.value = [...X.value, F.value]);
|
|
922
|
+
}
|
|
923
|
+
function zr(e, t, n = !1, r = !1) {
|
|
924
|
+
r ? Rr() : n || (X.value = []), P.value = {
|
|
925
|
+
rowId: e,
|
|
926
|
+
columnId: t
|
|
927
|
+
}, n && F.value ? F.value = {
|
|
928
|
+
...F.value,
|
|
929
|
+
endRowId: e,
|
|
930
|
+
endColumnId: t
|
|
931
|
+
} : F.value = {
|
|
932
|
+
startRowId: e,
|
|
933
|
+
startColumnId: t,
|
|
934
|
+
endRowId: e,
|
|
935
|
+
endColumnId: t
|
|
936
|
+
}, A("focus", P.value), A("selection", F.value);
|
|
937
|
+
}
|
|
938
|
+
function Br(e, t, n, r = "new") {
|
|
939
|
+
r === "add" ? Rr() : r === "new" && (X.value = []), P.value = {
|
|
940
|
+
rowId: e,
|
|
941
|
+
columnId: t
|
|
942
|
+
}, F.value = n, A("focus", P.value), A("selection", F.value);
|
|
943
|
+
}
|
|
944
|
+
function Vr(e, t = !1, n = !1) {
|
|
945
|
+
let r = W.value;
|
|
946
|
+
if (!r.length) return;
|
|
947
|
+
let i = t && F.value ? F.value.startColumnId : e;
|
|
948
|
+
Br(r[0].id, i, {
|
|
949
|
+
startRowId: r[0].id,
|
|
950
|
+
startColumnId: i,
|
|
951
|
+
endRowId: r[r.length - 1].id,
|
|
952
|
+
endColumnId: e
|
|
953
|
+
}, t ? "extend" : n ? "add" : "new");
|
|
954
|
+
}
|
|
955
|
+
function Hr(e, t = !1, n = !1) {
|
|
956
|
+
let r = z.value;
|
|
957
|
+
if (!r.length) return;
|
|
958
|
+
let i = t && F.value ? F.value.startRowId : e;
|
|
959
|
+
Br(i, r[0].id, {
|
|
960
|
+
startRowId: i,
|
|
961
|
+
startColumnId: r[0].id,
|
|
962
|
+
endRowId: e,
|
|
963
|
+
endColumnId: r[r.length - 1].id
|
|
964
|
+
}, t ? "extend" : n ? "add" : "new");
|
|
965
|
+
}
|
|
966
|
+
function Ur() {
|
|
967
|
+
let e = W.value, t = z.value;
|
|
968
|
+
!e.length || !t.length || Br(e[0].id, t[0].id, {
|
|
969
|
+
startRowId: e[0].id,
|
|
970
|
+
startColumnId: t[0].id,
|
|
971
|
+
endRowId: e[e.length - 1].id,
|
|
972
|
+
endColumnId: t[t.length - 1].id
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
function Wr(e) {
|
|
976
|
+
kt = e.pointerType;
|
|
977
|
+
}
|
|
978
|
+
function Gr(e, t, n) {
|
|
979
|
+
if (e.button === 2) {
|
|
980
|
+
kt = "";
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
if (I.value && Ta()) {
|
|
984
|
+
e.preventDefault(), ka(t, n, e);
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
let r = kt === "touch" && !e.shiftKey && P.value?.rowId === t.id && P.value?.columnId === n.id;
|
|
988
|
+
kt = "", I.value && gi(), Et.value = !0, zr(t.id, n.id, e.shiftKey, !e.shiftKey && (e.metaKey || e.ctrlKey)), Qr(), e.preventDefault(), document.addEventListener("mouseup", qr, { once: !0 }), r && !J(t, n) && di(t, n, ma(t.id, n.id), "edit");
|
|
989
|
+
}
|
|
990
|
+
function Kr(e, t) {
|
|
991
|
+
if (ji.value) {
|
|
992
|
+
Fi(e.id, t.id);
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
if (Z.value?.dragging) {
|
|
996
|
+
Da({
|
|
997
|
+
ri: G.value.get(e.id) ?? 0,
|
|
998
|
+
ci: H.value.get(t.id) ?? 0
|
|
999
|
+
}, !0);
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
!Et.value || !F.value || (F.value = {
|
|
1003
|
+
...F.value,
|
|
1004
|
+
endRowId: e.id,
|
|
1005
|
+
endColumnId: t.id
|
|
1006
|
+
}, A("selection", F.value));
|
|
1007
|
+
}
|
|
1008
|
+
function qr() {
|
|
1009
|
+
Et.value = !1;
|
|
1010
|
+
}
|
|
1011
|
+
function Jr(e, t) {
|
|
1012
|
+
J(e, t) || di(e, t, ma(e.id, t.id), "edit");
|
|
1013
|
+
}
|
|
1014
|
+
function Yr(e, t, n = "label") {
|
|
1015
|
+
e.button === 0 && (e.preventDefault(), I.value && gi(), Qr(), t.sortable && (n === "label" || B.value.length === 1) ? Wi(t) : Vr(t.id, e.shiftKey, e.metaKey || e.ctrlKey));
|
|
1016
|
+
}
|
|
1017
|
+
function Xr(e, t) {
|
|
1018
|
+
e.button === 0 && (I.value && gi(), Qr(), Hr(t.id, e.shiftKey, e.metaKey || e.ctrlKey));
|
|
1019
|
+
}
|
|
1020
|
+
function Zr(e) {
|
|
1021
|
+
e.button === 0 && (I.value && gi(), Qr(), Ur());
|
|
1022
|
+
}
|
|
1023
|
+
function Qr() {
|
|
1024
|
+
M.value?.focus({ preventScroll: !0 });
|
|
1025
|
+
}
|
|
1026
|
+
function $r(e, t, n = !1) {
|
|
1027
|
+
if (!P.value) {
|
|
1028
|
+
let e = z.value[0], t = qn.value[0];
|
|
1029
|
+
e && t && zr(t.id, e.id);
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
let r = W.value, i = G.value.get(P.value.rowId) ?? 0, a = H.value.get(P.value.columnId) ?? 0, o = Gt(i, a);
|
|
1033
|
+
o && (e > 0 && (i = o.r2), t > 0 && (a = o.c2));
|
|
1034
|
+
let s = Math.max(0, Math.min(r.length - 1, i + e)), c = Math.max(0, Math.min(z.value.length - 1, a + t)), l = Gt(s, c);
|
|
1035
|
+
l && (s = l.r1, c = l.c1);
|
|
1036
|
+
let u = r[s].id, d = z.value[c].id;
|
|
1037
|
+
zr(u, d, n), ai(u, d);
|
|
1038
|
+
}
|
|
1039
|
+
function ei(e) {
|
|
1040
|
+
return e.replace(/["\\]/g, "\\$&");
|
|
1041
|
+
}
|
|
1042
|
+
function ti(e) {
|
|
1043
|
+
let t = M.value?.querySelector(e);
|
|
1044
|
+
return t ? t.offsetHeight : 0;
|
|
1045
|
+
}
|
|
1046
|
+
function ni() {
|
|
1047
|
+
let e = 0;
|
|
1048
|
+
return B.value.forEach((t, n) => {
|
|
1049
|
+
e += ti(`[data-header-row="${n}"]`) || (t === "letters" && n === 0 && B.value.length === 2 ? 24 : Tn.value);
|
|
1050
|
+
}), e;
|
|
1051
|
+
}
|
|
1052
|
+
function ri(e) {
|
|
1053
|
+
let t = 0;
|
|
1054
|
+
for (let n of e) t += ti(`[data-row="${ei(n.id)}"]`);
|
|
1055
|
+
return t;
|
|
1056
|
+
}
|
|
1057
|
+
function ii(e) {
|
|
1058
|
+
let t = e === "left" && h.showGutter ? h.gutterWidth : 0;
|
|
1059
|
+
for (let n of z.value) n.pinned === e && (t += U(n));
|
|
1060
|
+
return t;
|
|
1061
|
+
}
|
|
1062
|
+
function ai(e, t) {
|
|
1063
|
+
let n = M.value;
|
|
1064
|
+
if (!n) return;
|
|
1065
|
+
let r = Vn.value.findIndex((t) => t.id === e);
|
|
1066
|
+
if (r >= 0) {
|
|
1067
|
+
let e = ni(), t = ti(".nb-spreadsheet__cell") || On.value, i = e + (Hn.value.length + r) * t, a = e + ri(Hn.value), o = ri(Un.value);
|
|
1068
|
+
i - a < n.scrollTop ? n.scrollTop = i - a : i + t > n.scrollTop + n.clientHeight - o && (n.scrollTop = i + t - n.clientHeight + o);
|
|
1069
|
+
}
|
|
1070
|
+
let i = t ? V.value.get(t) : void 0;
|
|
1071
|
+
if (i && !i.pinned) {
|
|
1072
|
+
let e = h.showGutter ? h.gutterWidth : 0;
|
|
1073
|
+
for (let t of z.value) {
|
|
1074
|
+
if (t.id === i.id) break;
|
|
1075
|
+
e += U(t);
|
|
1076
|
+
}
|
|
1077
|
+
let t = U(i), r = ii("left"), a = ii("right");
|
|
1078
|
+
e - r < n.scrollLeft ? n.scrollLeft = e - r : e + t > n.scrollLeft + n.clientWidth - a && (n.scrollLeft = e + t - n.clientWidth + a);
|
|
1079
|
+
}
|
|
1080
|
+
oi();
|
|
1081
|
+
}
|
|
1082
|
+
function oi() {
|
|
1083
|
+
let e = M.value;
|
|
1084
|
+
Dt.value = e?.scrollTop ?? 0, Ot.value = e?.scrollLeft ?? 0, e && si(e);
|
|
1085
|
+
}
|
|
1086
|
+
function si(e) {
|
|
1087
|
+
if (!L.value || h.extent !== "infinite") return;
|
|
1088
|
+
let { rows: t, columns: n } = Lt.value;
|
|
1089
|
+
e.clientHeight > 0 && e.scrollTop + e.clientHeight * 2 >= e.scrollHeight && t < pt && (Pt.value = Math.min(pt, t + ht)), e.clientWidth > 0 && e.scrollLeft + e.clientWidth * 2 >= e.scrollWidth && n < mt && (Ft.value = Math.min(mt, n + gt));
|
|
1090
|
+
}
|
|
1091
|
+
function ci() {
|
|
1092
|
+
if (!P.value) return null;
|
|
1093
|
+
let e = Cn.value.get(P.value.rowId), t = V.value.get(P.value.columnId);
|
|
1094
|
+
return e && t ? {
|
|
1095
|
+
r: e,
|
|
1096
|
+
c: t
|
|
1097
|
+
} : null;
|
|
1098
|
+
}
|
|
1099
|
+
function li(e) {
|
|
1100
|
+
return !e.metaKey && !e.ctrlKey && !e.altKey && e.key.length === 1;
|
|
1101
|
+
}
|
|
1102
|
+
function ui(e) {
|
|
1103
|
+
if (I.value) {
|
|
1104
|
+
e.target !== Ct.value && (li(e) ? (e.preventDefault(), I.value.draft += e.key) : hi(e));
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
let t = e.metaKey || e.ctrlKey;
|
|
1108
|
+
if (t && e.key.toLowerCase() === "z") {
|
|
1109
|
+
e.preventDefault(), e.shiftKey ? qa() : Ka();
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
if (t && e.key.toLowerCase() === "a") {
|
|
1113
|
+
e.preventDefault(), Ur();
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
let n = {
|
|
1117
|
+
b: "bold",
|
|
1118
|
+
i: "italic",
|
|
1119
|
+
u: "underline"
|
|
1120
|
+
}, r = e.key.toLowerCase();
|
|
1121
|
+
if (t && nn.value && !e.shiftKey && !e.altKey && (r === "b" || r === "i" || r === "u")) {
|
|
1122
|
+
e.preventDefault(), cn(n[r]);
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
if (t && Ai.value && !e.shiftKey && !e.altKey && (e.key.toLowerCase() === "d" || e.key.toLowerCase() === "r")) {
|
|
1126
|
+
e.preventDefault(), Bi(e.key.toLowerCase() === "d" ? "down" : "right");
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
if (e.key === " " && (e.ctrlKey || e.shiftKey) && !e.metaKey && !e.altKey) {
|
|
1130
|
+
let t = P.value;
|
|
1131
|
+
if (!t) return;
|
|
1132
|
+
e.preventDefault(), e.ctrlKey ? Vr(t.columnId) : Hr(t.rowId);
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
if (e.altKey && e.shiftKey && !t && (e.key === "ArrowLeft" || e.key === "ArrowRight")) {
|
|
1136
|
+
let t = P.value ? V.value.get(P.value.columnId) : void 0;
|
|
1137
|
+
if (!h.resizable || !t) return;
|
|
1138
|
+
e.preventDefault();
|
|
1139
|
+
let n = e.key === "ArrowRight" ? yt : -yt;
|
|
1140
|
+
Hi(t, U(t) + n);
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
if (e.key === "ContextMenu" || e.key === "F10" && e.shiftKey) {
|
|
1144
|
+
if (!h.contextMenu || !P.value) return;
|
|
1145
|
+
e.preventDefault(), sa();
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
switch (e.key) {
|
|
1149
|
+
case "ArrowDown":
|
|
1150
|
+
e.preventDefault(), $r(1, 0, e.shiftKey);
|
|
1151
|
+
break;
|
|
1152
|
+
case "ArrowUp":
|
|
1153
|
+
e.preventDefault(), $r(-1, 0, e.shiftKey);
|
|
1154
|
+
break;
|
|
1155
|
+
case "ArrowLeft":
|
|
1156
|
+
e.preventDefault(), $r(0, -1, e.shiftKey);
|
|
1157
|
+
break;
|
|
1158
|
+
case "ArrowRight":
|
|
1159
|
+
e.preventDefault(), $r(0, 1, e.shiftKey);
|
|
1160
|
+
break;
|
|
1161
|
+
case "Tab":
|
|
1162
|
+
e.preventDefault(), $r(0, e.shiftKey ? -1 : 1);
|
|
1163
|
+
break;
|
|
1164
|
+
case "Enter":
|
|
1165
|
+
e.preventDefault(), $r(e.shiftKey ? -1 : 1, 0);
|
|
1166
|
+
break;
|
|
1167
|
+
case "Escape":
|
|
1168
|
+
F.value = null, X.value = [], A("selection", null);
|
|
1169
|
+
break;
|
|
1170
|
+
case "Delete":
|
|
1171
|
+
case "Backspace":
|
|
1172
|
+
e.preventDefault(), xi();
|
|
1173
|
+
break;
|
|
1174
|
+
case "F2": {
|
|
1175
|
+
e.preventDefault();
|
|
1176
|
+
let t = ci();
|
|
1177
|
+
t && !J(t.r, t.c) && di(t.r, t.c, ma(t.r.id, t.c.id), "edit");
|
|
1178
|
+
break;
|
|
1179
|
+
}
|
|
1180
|
+
default: {
|
|
1181
|
+
if (!li(e)) break;
|
|
1182
|
+
let t = ci();
|
|
1183
|
+
t && !J(t.r, t.c) && (e.preventDefault(), di(t.r, t.c, e.key, "enter"));
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
function di(e, t, n, r) {
|
|
1188
|
+
ai(e.id, t.id), I.value = {
|
|
1189
|
+
rowId: e.id,
|
|
1190
|
+
columnId: t.id,
|
|
1191
|
+
draft: n,
|
|
1192
|
+
mode: r,
|
|
1193
|
+
source: "cell"
|
|
1194
|
+
}, Z.value = null, Q.value = null, $.value = null, ge(() => {
|
|
1195
|
+
let e = Ct.value;
|
|
1196
|
+
if (e) if (ge(Ma), e.focus({ preventScroll: !0 }), r === "enter") {
|
|
1197
|
+
let t = e.value.length;
|
|
1198
|
+
e.setSelectionRange(t, t);
|
|
1199
|
+
} else e.select();
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
let fi = _(() => {
|
|
1203
|
+
if (I.value) return V.value.get(I.value.columnId)?.type === "number" ? "decimal" : "text";
|
|
1204
|
+
}), pi = _(() => {
|
|
1205
|
+
if (!I.value) return;
|
|
1206
|
+
if (L.value) return R(I.value.rowId, I.value.columnId);
|
|
1207
|
+
let e = V.value.get(I.value.columnId), t = Cn.value.get(I.value.rowId), n = t?.label ?? String(zn.value.get(t?.id ?? "") ?? "");
|
|
1208
|
+
return [e?.label, n].filter(Boolean).join(" ");
|
|
1209
|
+
}), mi = _(() => {
|
|
1210
|
+
if (!I.value) return { display: "none" };
|
|
1211
|
+
let e = M.value, t = e?.querySelector(`[data-cell="${ei(`${I.value.rowId}::${I.value.columnId}`)}"]`);
|
|
1212
|
+
if (!e || !t) return { display: "none" };
|
|
1213
|
+
let n = t.getBoundingClientRect(), r = e.getBoundingClientRect();
|
|
1214
|
+
return {
|
|
1215
|
+
top: `${n.top - r.top - e.clientTop + Dt.value}px`,
|
|
1216
|
+
left: `${n.left - r.left - e.clientLeft + Ot.value}px`,
|
|
1217
|
+
width: `${n.width}px`,
|
|
1218
|
+
height: `${n.height}px`
|
|
1219
|
+
};
|
|
1220
|
+
});
|
|
1221
|
+
function hi(e) {
|
|
1222
|
+
if (Pa(e)) return;
|
|
1223
|
+
let t = I.value?.mode, n = null;
|
|
1224
|
+
switch (e.key) {
|
|
1225
|
+
case "Enter":
|
|
1226
|
+
n = [e.shiftKey ? -1 : 1, 0];
|
|
1227
|
+
break;
|
|
1228
|
+
case "Tab":
|
|
1229
|
+
n = [0, e.shiftKey ? -1 : 1];
|
|
1230
|
+
break;
|
|
1231
|
+
case "ArrowDown":
|
|
1232
|
+
n = [1, 0];
|
|
1233
|
+
break;
|
|
1234
|
+
case "ArrowUp":
|
|
1235
|
+
n = [-1, 0];
|
|
1236
|
+
break;
|
|
1237
|
+
case "ArrowLeft":
|
|
1238
|
+
t === "enter" && (n = [0, -1]);
|
|
1239
|
+
break;
|
|
1240
|
+
case "ArrowRight":
|
|
1241
|
+
t === "enter" && (n = [0, 1]);
|
|
1242
|
+
break;
|
|
1243
|
+
case "Escape":
|
|
1244
|
+
e.preventDefault(), I.value = null, Qr();
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
n && (e.preventDefault(), gi(), $r(n[0], n[1]));
|
|
1248
|
+
}
|
|
1249
|
+
function gi(e = !0) {
|
|
1250
|
+
if (!I.value) return;
|
|
1251
|
+
let { rowId: t, columnId: n, draft: r } = I.value;
|
|
1252
|
+
I.value = null;
|
|
1253
|
+
let i = V.value.get(n);
|
|
1254
|
+
if (!i) return;
|
|
1255
|
+
Z.value = null, Q.value = null, $.value = null;
|
|
1256
|
+
let a;
|
|
1257
|
+
try {
|
|
1258
|
+
a = mr(i, r, !0);
|
|
1259
|
+
} catch {
|
|
1260
|
+
e && Qr();
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
let o = q(t, n), s = L.value && typeof a == "number" ? fr(r) : null, c = s ? pr([{
|
|
1264
|
+
key: R(t, n),
|
|
1265
|
+
format: s.format
|
|
1266
|
+
}]) : null;
|
|
1267
|
+
if (!_i(o, a) || c) {
|
|
1268
|
+
let e = vi(t, n, o, a), r = _i(o, a) ? [] : [e];
|
|
1269
|
+
Ga(r, c ? { styles: [k.value, c] } : {}), r.length && yi(r), c && (k.value = c);
|
|
1270
|
+
}
|
|
1271
|
+
e && Qr();
|
|
1272
|
+
}
|
|
1273
|
+
function _i(e, t) {
|
|
1274
|
+
return e === t || e == null && t === null;
|
|
1275
|
+
}
|
|
1276
|
+
function vi(e, t, n, r) {
|
|
1277
|
+
let i = {
|
|
1278
|
+
rowId: e,
|
|
1279
|
+
columnId: t,
|
|
1280
|
+
before: n,
|
|
1281
|
+
after: r
|
|
1282
|
+
};
|
|
1283
|
+
return L.value && (i.cell = R(e, t)), i;
|
|
1284
|
+
}
|
|
1285
|
+
function yi(e) {
|
|
1286
|
+
if (L.value) {
|
|
1287
|
+
let t = { ...Pe.value };
|
|
1288
|
+
for (let n of e) {
|
|
1289
|
+
let e = R(n.rowId, n.columnId);
|
|
1290
|
+
n.after === null || n.after === void 0 || n.after === "" ? delete t[e] : t[e] = n.after;
|
|
1291
|
+
}
|
|
1292
|
+
Pe.value = t;
|
|
1293
|
+
}
|
|
1294
|
+
for (let t of e) A("commit", t);
|
|
1295
|
+
A("change", e);
|
|
1296
|
+
}
|
|
1297
|
+
function bi() {
|
|
1298
|
+
let e = W.value, t = z.value, n = /* @__PURE__ */ new Set(), r = [];
|
|
1299
|
+
for (let i of Mr.value) for (let a = i.r1; a <= i.r2; a++) for (let o = i.c1; o <= i.c2; o++) {
|
|
1300
|
+
let i = `${a}:${o}`;
|
|
1301
|
+
n.has(i) || (n.add(i), r.push({
|
|
1302
|
+
rowId: e[a].id,
|
|
1303
|
+
columnId: t[o].id
|
|
1304
|
+
}));
|
|
1305
|
+
}
|
|
1306
|
+
return r;
|
|
1307
|
+
}
|
|
1308
|
+
function xi() {
|
|
1309
|
+
let e = bi(), t = [];
|
|
1310
|
+
for (let { rowId: n, columnId: r } of e) {
|
|
1311
|
+
let e = Cn.value.get(n), i = V.value.get(r);
|
|
1312
|
+
if (!e || !i || J(e, i)) continue;
|
|
1313
|
+
let a = q(n, r);
|
|
1314
|
+
a == null || a === "" || t.push(vi(n, r, a, null));
|
|
1315
|
+
}
|
|
1316
|
+
t.length !== 0 && (Ga(t), yi(t));
|
|
1317
|
+
}
|
|
1318
|
+
function Si() {
|
|
1319
|
+
let e = Y.value;
|
|
1320
|
+
if (!e) return null;
|
|
1321
|
+
let t = W.value.map((e) => e.id), n = z.value.map((e) => e.id), r = [];
|
|
1322
|
+
for (let i = e.r1; i <= e.r2; i++) {
|
|
1323
|
+
let a = [];
|
|
1324
|
+
for (let r = e.c1; r <= e.c2; r++) {
|
|
1325
|
+
let e = q(t[i], n[r]);
|
|
1326
|
+
a.push(e == null ? "" : String(e));
|
|
1327
|
+
}
|
|
1328
|
+
r.push(a.join(" "));
|
|
1329
|
+
}
|
|
1330
|
+
return r.join("\n");
|
|
1331
|
+
}
|
|
1332
|
+
let Ci = null;
|
|
1333
|
+
function wi(e) {
|
|
1334
|
+
let t = Si();
|
|
1335
|
+
if (t === null) return;
|
|
1336
|
+
e.preventDefault(), e.clipboardData?.setData("text/plain", t);
|
|
1337
|
+
let n = Y.value;
|
|
1338
|
+
if (!n || !L.value && !nn.value) return;
|
|
1339
|
+
let r = W.value, i = z.value, a = L.value ? Vt(r[n.r1].id, i[n.c1].id) : {
|
|
1340
|
+
r: 0,
|
|
1341
|
+
c: 0
|
|
1342
|
+
}, o = [], s = [];
|
|
1343
|
+
for (let e = n.r1; e <= n.r2; e++) {
|
|
1344
|
+
let t = [];
|
|
1345
|
+
for (let a = n.c1; a <= n.c2; a++) {
|
|
1346
|
+
let n = rn(r[e].id, i[a].id);
|
|
1347
|
+
s.push(n), t.push(nn.value ? k.value[n] : void 0);
|
|
1348
|
+
}
|
|
1349
|
+
o.push(t);
|
|
1350
|
+
}
|
|
1351
|
+
Ci = {
|
|
1352
|
+
text: t,
|
|
1353
|
+
r: a.r,
|
|
1354
|
+
c: a.c,
|
|
1355
|
+
cut: !1,
|
|
1356
|
+
styles: o,
|
|
1357
|
+
keys: s
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
function Ti(e) {
|
|
1361
|
+
wi(e), Ci && (Ci.cut = !0), xi();
|
|
1362
|
+
}
|
|
1363
|
+
function Ei(e) {
|
|
1364
|
+
if (!P.value) return;
|
|
1365
|
+
let t = e.clipboardData?.getData("text/plain") ?? "";
|
|
1366
|
+
t && (e.preventDefault(), Di(t));
|
|
1367
|
+
}
|
|
1368
|
+
function Di(e) {
|
|
1369
|
+
if (!P.value || !e) return;
|
|
1370
|
+
let t = e.replace(/\r\n?/g, "\n").split("\n").map((e) => e.split(" ")), n = Math.max(...t.map((e) => e.length)), r = Oi(W.value.map((e) => e.id), (G.value.get(P.value.rowId) ?? 0) + t.length), i = ki(z.value.map((e) => e.id), (H.value.get(P.value.columnId) ?? 0) + n), a = G.value.get(P.value.rowId) ?? 0, o = H.value.get(P.value.columnId) ?? 0, s = [], c = L.value ? Vt(P.value.rowId, P.value.columnId) : null, l = Ci && Ci.text === e ? Ci : null, u = c && l && !l.cut ? {
|
|
1371
|
+
r: c.r - l.r,
|
|
1372
|
+
c: c.c - l.c
|
|
1373
|
+
} : null, f = null;
|
|
1374
|
+
if (l?.cut && nn.value) for (let e of l.keys) k.value[e] && (f ??= { ...k.value }, delete f[e]);
|
|
1375
|
+
let p = [];
|
|
1376
|
+
if (t.forEach((e, t) => {
|
|
1377
|
+
e.forEach((e, n) => {
|
|
1378
|
+
let c = r[a + t], m = i[o + n];
|
|
1379
|
+
if (!c || !m) return;
|
|
1380
|
+
let ee = Cn.value.get(c) ?? {
|
|
1381
|
+
id: c,
|
|
1382
|
+
values: Rt
|
|
1383
|
+
}, te = V.value.get(m) ?? {
|
|
1384
|
+
id: m,
|
|
1385
|
+
label: m
|
|
1386
|
+
};
|
|
1387
|
+
if (J(ee, te)) return;
|
|
1388
|
+
let re;
|
|
1389
|
+
try {
|
|
1390
|
+
re = mr(te, e);
|
|
1391
|
+
} catch {
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
if (u && K.value && ne(re) && (re = d(re, u.r, u.c)), l && nn.value) {
|
|
1395
|
+
let e = rn(c, m), r = l.styles[t]?.[n], i = (f ?? k.value)[e];
|
|
1396
|
+
an(i, r) || (f ??= { ...k.value }, r ? f[e] = r : delete f[e]);
|
|
1397
|
+
} else if (L.value && typeof re == "number") {
|
|
1398
|
+
let t = fr(e);
|
|
1399
|
+
t && p.push({
|
|
1400
|
+
key: R(c, m),
|
|
1401
|
+
format: t.format
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
let ie = q(c, m);
|
|
1405
|
+
_i(ie, re) || s.push(vi(c, m, ie, re));
|
|
1406
|
+
});
|
|
1407
|
+
}), p.length) {
|
|
1408
|
+
let e = f ?? k.value;
|
|
1409
|
+
for (let { key: t, format: n } of p) e[t]?.format || (f ??= { ...k.value }, f[t] = {
|
|
1410
|
+
...e[t],
|
|
1411
|
+
format: n
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
s.length === 0 && !f || (Ga(s, f ? { styles: [k.value, f] } : {}), s.length && yi(s), f && (k.value = f), l?.cut && (Ci = null));
|
|
1415
|
+
}
|
|
1416
|
+
function Oi(e, t) {
|
|
1417
|
+
if (!L.value || t <= e.length) return e;
|
|
1418
|
+
let n = [...e], r = Rn.value, i = Number(r[r.length - 1]?.id ?? 0) + 1;
|
|
1419
|
+
for (; n.length < t && i <= It.value.rows;) n.push(String(i++));
|
|
1420
|
+
return n;
|
|
1421
|
+
}
|
|
1422
|
+
function ki(e, t) {
|
|
1423
|
+
if (!L.value || t <= e.length) return e;
|
|
1424
|
+
let n = [...e], r = fn.value.length;
|
|
1425
|
+
for (; n.length < t && r < It.value.columns;) n.push(vn(r++));
|
|
1426
|
+
return n;
|
|
1427
|
+
}
|
|
1428
|
+
let Ai = _(() => (h.fillHandle ?? L.value) && X.value.length === 0), ji = T(null);
|
|
1429
|
+
function Mi(e, t) {
|
|
1430
|
+
let n = Y.value;
|
|
1431
|
+
return !Ai.value || !n || I.value ? !1 : G.value.get(e) === n.r2 && H.value.get(t) === n.c2;
|
|
1432
|
+
}
|
|
1433
|
+
function Ni(e, t) {
|
|
1434
|
+
let n = ji.value;
|
|
1435
|
+
if (!n) return !1;
|
|
1436
|
+
let r = G.value.get(e) ?? -1, i = H.value.get(t) ?? -1;
|
|
1437
|
+
return r >= n.r1 && r <= n.r2 && i >= n.c1 && i <= n.c2 && !Pr(e, t);
|
|
1438
|
+
}
|
|
1439
|
+
function Pi(e) {
|
|
1440
|
+
e.button === 0 && (ji.value = Y.value ? { ...Y.value } : null, document.addEventListener("mouseup", Ii, { once: !0 }));
|
|
1441
|
+
}
|
|
1442
|
+
function Fi(e, t) {
|
|
1443
|
+
let n = Y.value;
|
|
1444
|
+
if (!n || !ji.value) return;
|
|
1445
|
+
let r = G.value.get(e) ?? -1, i = H.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;
|
|
1446
|
+
Math.abs(a) >= Math.abs(o) ? ji.value = {
|
|
1447
|
+
...n,
|
|
1448
|
+
r1: Math.min(n.r1, n.r1 + a),
|
|
1449
|
+
r2: Math.max(n.r2, n.r2 + a)
|
|
1450
|
+
} : ji.value = {
|
|
1451
|
+
...n,
|
|
1452
|
+
c1: Math.min(n.c1, n.c1 + o),
|
|
1453
|
+
c2: Math.max(n.c2, n.c2 + o)
|
|
1454
|
+
};
|
|
1455
|
+
}
|
|
1456
|
+
function Ii() {
|
|
1457
|
+
let e = Y.value, t = ji.value;
|
|
1458
|
+
if (ji.value = null, !e || !t) return;
|
|
1459
|
+
zi(e, t);
|
|
1460
|
+
let n = W.value, r = z.value;
|
|
1461
|
+
F.value = {
|
|
1462
|
+
startRowId: n[t.r1].id,
|
|
1463
|
+
startColumnId: r[t.c1].id,
|
|
1464
|
+
endRowId: n[t.r2].id,
|
|
1465
|
+
endColumnId: r[t.c2].id
|
|
1466
|
+
}, A("selection", F.value);
|
|
1467
|
+
}
|
|
1468
|
+
function Li(e, t, n) {
|
|
1469
|
+
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);
|
|
1470
|
+
return Array.from({ length: t }, (t, i) => {
|
|
1471
|
+
if (s) {
|
|
1472
|
+
let e = n ? a[0] - o * (i + 1) : a[r - 1] + o * (i + 1);
|
|
1473
|
+
return Math.round(e * 1e10) / 1e10;
|
|
1474
|
+
}
|
|
1475
|
+
return n ? e[r - 1 - i % r] : e[i % r];
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
function Ri(e, t, n, r, i) {
|
|
1479
|
+
if (!K.value || !ne(e)) return e;
|
|
1480
|
+
let a = W.value, o = z.value;
|
|
1481
|
+
if (!a[t] || !a[r] || !o[n] || !o[i]) return e;
|
|
1482
|
+
let s = Vt(a[t].id, o[n].id), c = Vt(a[r].id, o[i].id);
|
|
1483
|
+
return d(e, c.r - s.r, c.c - s.c);
|
|
1484
|
+
}
|
|
1485
|
+
function zi(e, t) {
|
|
1486
|
+
let n = W.value, r = z.value, i = [], a = null, o = (e, t, o, s, c) => {
|
|
1487
|
+
let l = n[e], u = r[t];
|
|
1488
|
+
if (!l || !u || J(l, u)) return;
|
|
1489
|
+
let d = q(l.id, u.id), f = o === void 0 ? null : o;
|
|
1490
|
+
if (_i(d, f) || i.push(vi(l.id, u.id, d, f)), !nn.value) return;
|
|
1491
|
+
let p = k.value[rn(n[s].id, r[c].id)], m = rn(l.id, u.id);
|
|
1492
|
+
an(k.value[m], p) || (a ??= { ...k.value }, p ? a[m] = p : delete a[m]);
|
|
1493
|
+
};
|
|
1494
|
+
if (t.r1 !== e.r1 || t.r2 !== e.r2) {
|
|
1495
|
+
let i = t.r1 < e.r1, a = i ? e.r1 - t.r1 : t.r2 - e.r2;
|
|
1496
|
+
for (let t = e.c1; t <= e.c2; t++) {
|
|
1497
|
+
let s = [];
|
|
1498
|
+
for (let i = e.r1; i <= e.r2; i++) s.push(q(n[i].id, r[t].id));
|
|
1499
|
+
let c = e.r2 - e.r1 + 1;
|
|
1500
|
+
Li(s, a, i).forEach((n, r) => {
|
|
1501
|
+
let a = i ? e.r1 - 1 - r : e.r2 + 1 + r, s = i ? e.r2 - r % c : e.r1 + r % c;
|
|
1502
|
+
o(a, t, Ri(n, s, t, a, t), s, t);
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
} else {
|
|
1506
|
+
let i = t.c1 < e.c1, a = i ? e.c1 - t.c1 : t.c2 - e.c2;
|
|
1507
|
+
if (a <= 0) return;
|
|
1508
|
+
for (let t = e.r1; t <= e.r2; t++) {
|
|
1509
|
+
let s = [];
|
|
1510
|
+
for (let i = e.c1; i <= e.c2; i++) s.push(q(n[t].id, r[i].id));
|
|
1511
|
+
let c = e.c2 - e.c1 + 1;
|
|
1512
|
+
Li(s, a, i).forEach((n, r) => {
|
|
1513
|
+
let a = i ? e.c1 - 1 - r : e.c2 + 1 + r, s = i ? e.c2 - r % c : e.c1 + r % c;
|
|
1514
|
+
o(t, a, Ri(n, t, s, t, a), t, s);
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
let s = a;
|
|
1519
|
+
!i.length && !s || (Ga(i, s ? { styles: [k.value, s] } : {}), i.length && yi(i), s && (k.value = s));
|
|
1520
|
+
}
|
|
1521
|
+
function Bi(e) {
|
|
1522
|
+
let t = Y.value;
|
|
1523
|
+
if (t) if (e === "down") {
|
|
1524
|
+
let e = t.r1 === t.r2 ? t.r1 - 1 : t.r1;
|
|
1525
|
+
if (e < 0) return;
|
|
1526
|
+
zi({
|
|
1527
|
+
...t,
|
|
1528
|
+
r1: e,
|
|
1529
|
+
r2: e
|
|
1530
|
+
}, {
|
|
1531
|
+
...t,
|
|
1532
|
+
r1: e,
|
|
1533
|
+
r2: t.r2
|
|
1534
|
+
});
|
|
1535
|
+
} else {
|
|
1536
|
+
let e = t.c1 === t.c2 ? t.c1 - 1 : t.c1;
|
|
1537
|
+
if (e < 0) return;
|
|
1538
|
+
zi({
|
|
1539
|
+
...t,
|
|
1540
|
+
c1: e,
|
|
1541
|
+
c2: e
|
|
1542
|
+
}, {
|
|
1543
|
+
...t,
|
|
1544
|
+
c1: e,
|
|
1545
|
+
c2: t.c2
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
function Vi(e, t) {
|
|
1550
|
+
let n = Math.max(e.minWidth ?? 60, Math.round(t));
|
|
1551
|
+
return wt.value = {
|
|
1552
|
+
...wt.value,
|
|
1553
|
+
[e.id]: n
|
|
1554
|
+
}, n;
|
|
1555
|
+
}
|
|
1556
|
+
function Hi(e, t) {
|
|
1557
|
+
let n = U(e), r = Vi(e, t);
|
|
1558
|
+
r !== n && A("column-resize", {
|
|
1559
|
+
columnId: e.id,
|
|
1560
|
+
width: r
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
function Ui(e, t) {
|
|
1564
|
+
let n = e.clientX, r = U(t), i = (e) => {
|
|
1565
|
+
Vi(t, r + (e.clientX - n));
|
|
1566
|
+
}, a = () => {
|
|
1567
|
+
window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", a);
|
|
1568
|
+
let e = U(t);
|
|
1569
|
+
e !== r && A("column-resize", {
|
|
1570
|
+
columnId: t.id,
|
|
1571
|
+
width: e
|
|
1572
|
+
});
|
|
1573
|
+
};
|
|
1574
|
+
window.addEventListener("mousemove", i), window.addEventListener("mouseup", a);
|
|
1575
|
+
}
|
|
1576
|
+
function Wi(e) {
|
|
1577
|
+
N.value?.columnId === e.id ? N.value = N.value.direction === "asc" ? {
|
|
1578
|
+
columnId: e.id,
|
|
1579
|
+
direction: "desc"
|
|
1580
|
+
} : null : N.value = {
|
|
1581
|
+
columnId: e.id,
|
|
1582
|
+
direction: "asc"
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
function Gi(e, t) {
|
|
1586
|
+
N.value = {
|
|
1587
|
+
columnId: e.id,
|
|
1588
|
+
direction: t
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
function Ki(e) {
|
|
1592
|
+
z.value.filter((t) => !e.includes(t.id)).length && (fe.value = [...new Set([...fe.value, ...e])]);
|
|
1593
|
+
}
|
|
1594
|
+
function qi(e) {
|
|
1595
|
+
fe.value = fe.value.filter((t) => !e.includes(t));
|
|
1596
|
+
}
|
|
1597
|
+
function Ji(e) {
|
|
1598
|
+
W.value.filter((t) => !e.includes(t.id)).length && (me.value = [...new Set([...me.value, ...e])]);
|
|
1599
|
+
}
|
|
1600
|
+
function Yi(e) {
|
|
1601
|
+
me.value = me.value.filter((t) => !e.includes(t));
|
|
1602
|
+
}
|
|
1603
|
+
function Xi(e, t, n) {
|
|
1604
|
+
let r = e.findIndex((e) => e.id === t);
|
|
1605
|
+
if (!(r < 0)) {
|
|
1606
|
+
for (let t = r + 1; t < e.length; t++) if (n(e[t])) return e[t].id;
|
|
1607
|
+
for (let t = r - 1; t >= 0; t--) if (n(e[t])) return e[t].id;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
we([z, W], () => {
|
|
1611
|
+
let e = P.value;
|
|
1612
|
+
if (!e) return;
|
|
1613
|
+
let t = H.value.has(e.columnId), n = G.value.has(e.rowId);
|
|
1614
|
+
if (t && n) {
|
|
1615
|
+
let e = X.value.filter((e) => jr(e));
|
|
1616
|
+
e.length !== X.value.length && (X.value = e), F.value && !Y.value && (F.value = null, A("selection", null));
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
let r = [
|
|
1620
|
+
...Bt.value.filter((e) => e.pinned === "top"),
|
|
1621
|
+
...Rn.value,
|
|
1622
|
+
...Bt.value.filter((e) => e.pinned === "bottom")
|
|
1623
|
+
], i = t ? e.columnId : Xi(fn.value, e.columnId, (e) => H.value.has(e.id)), a = n ? e.rowId : Xi(r, e.rowId, (e) => G.value.has(e.id));
|
|
1624
|
+
i && a ? zr(a, i) : (P.value = null, F.value = null, X.value = [], A("focus", null), A("selection", null));
|
|
1625
|
+
});
|
|
1626
|
+
let Zi = Se("menuRef"), Qi = T(!1), $i = T("cell"), ea = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? "⌘" : "Ctrl+", ta = typeof navigator < "u" && !!navigator.clipboard?.readText, na = _(() => {
|
|
1627
|
+
let e = Y.value;
|
|
1628
|
+
return e ? z.value.slice(e.c1, e.c2 + 1).map((e) => e.id) : [];
|
|
1629
|
+
}), ra = _(() => {
|
|
1630
|
+
let e = Y.value;
|
|
1631
|
+
return e ? W.value.slice(e.r1, e.r2 + 1).map((e) => e.id) : [];
|
|
1632
|
+
});
|
|
1633
|
+
function ia() {
|
|
1634
|
+
let e = Y.value;
|
|
1635
|
+
if (!e) return "cell";
|
|
1636
|
+
let t = e.r1 === 0 && e.r2 === W.value.length - 1, n = e.c1 === 0 && e.c2 === z.value.length - 1;
|
|
1637
|
+
return t && !n ? "column" : n && !t ? "row" : "cell";
|
|
1638
|
+
}
|
|
1639
|
+
let aa = _(() => {
|
|
1640
|
+
if ($i.value !== "column" || na.value.length !== 1) return null;
|
|
1641
|
+
let e = V.value.get(na.value[0]);
|
|
1642
|
+
return e?.sortable ? e : null;
|
|
1643
|
+
});
|
|
1644
|
+
function oa(e, t, n, r) {
|
|
1645
|
+
if (!h.contextMenu) return;
|
|
1646
|
+
e.preventDefault(), I.value && gi();
|
|
1647
|
+
let i = Y.value;
|
|
1648
|
+
if (t === "column" && r) {
|
|
1649
|
+
let e = H.value.get(r) ?? -1;
|
|
1650
|
+
(ia() !== "column" || !i || e < i.c1 || e > i.c2) && Vr(r);
|
|
1651
|
+
} else if (t === "row" && n) {
|
|
1652
|
+
let e = G.value.get(n) ?? -1;
|
|
1653
|
+
(ia() !== "row" || !i || e < i.r1 || e > i.r2) && Hr(n);
|
|
1654
|
+
} else n && r ? Pr(n, r) || zr(n, r) : Ur();
|
|
1655
|
+
Qr(), ca(t, e.clientX, e.clientY);
|
|
1656
|
+
}
|
|
1657
|
+
function sa() {
|
|
1658
|
+
let e = P.value;
|
|
1659
|
+
if (!e) return;
|
|
1660
|
+
ai(e.rowId, e.columnId);
|
|
1661
|
+
let t = (M.value?.querySelector(`[data-cell="${ei(`${e.rowId}::${e.columnId}`)}"]`))?.getBoundingClientRect();
|
|
1662
|
+
ca(ia(), t?.left ?? 0, t?.bottom ?? 0);
|
|
1663
|
+
}
|
|
1664
|
+
function ca(e, t, n) {
|
|
1665
|
+
$i.value = e, Zi.value?.setPositionXY(t, n), Qi.value = !0;
|
|
1666
|
+
}
|
|
1667
|
+
function la() {
|
|
1668
|
+
let e = Si();
|
|
1669
|
+
e !== null && navigator.clipboard?.writeText(e).catch(() => {});
|
|
1670
|
+
}
|
|
1671
|
+
function ua() {
|
|
1672
|
+
la(), xi();
|
|
1673
|
+
}
|
|
1674
|
+
function da() {
|
|
1675
|
+
navigator.clipboard?.readText().then(Di).catch(() => {});
|
|
1676
|
+
}
|
|
1677
|
+
let fa = _(() => ae(h.locale)), pa = _(() => L.value && (h.formulaBar ?? K.value));
|
|
1678
|
+
function ma(e, t) {
|
|
1679
|
+
let n = q(e, t);
|
|
1680
|
+
return n == null ? "" : K.value && ne(n) ? p(n, fa.value) : String(n);
|
|
1681
|
+
}
|
|
1682
|
+
let ha = _(() => K.value && !!I.value?.draft.startsWith("="));
|
|
1683
|
+
function ga() {
|
|
1684
|
+
return I.value ? I.value.source === "bar" ? La.value : Ct.value : null;
|
|
1685
|
+
}
|
|
1686
|
+
let _a = _(() => {
|
|
1687
|
+
if (!ha.value || !I.value) return [];
|
|
1688
|
+
let e = /* @__PURE__ */ new Map();
|
|
1689
|
+
return te(I.value.draft, fa.value).map((t) => {
|
|
1690
|
+
let n = t.text.replace(/\$/g, "").toUpperCase();
|
|
1691
|
+
return e.has(n) || e.set(n, e.size % bt + 1), {
|
|
1692
|
+
...t,
|
|
1693
|
+
colour: e.get(n)
|
|
1694
|
+
};
|
|
1695
|
+
});
|
|
1696
|
+
}), va = _(() => {
|
|
1697
|
+
if (!ha.value || !I.value) return [];
|
|
1698
|
+
let e = I.value.draft, t = [], n = 0;
|
|
1699
|
+
for (let r of _a.value) r.start > n && t.push({
|
|
1700
|
+
text: e.slice(n, r.start),
|
|
1701
|
+
colour: 0
|
|
1702
|
+
}), t.push({
|
|
1703
|
+
text: e.slice(r.start, r.end),
|
|
1704
|
+
colour: r.colour
|
|
1705
|
+
}), n = r.end;
|
|
1706
|
+
return n < e.length && t.push({
|
|
1707
|
+
text: e.slice(n),
|
|
1708
|
+
colour: 0
|
|
1709
|
+
}), t;
|
|
1710
|
+
});
|
|
1711
|
+
function ya(e, t, n, r) {
|
|
1712
|
+
let i = Math.min(t, n - 1), a, o;
|
|
1713
|
+
for (let t = e; t <= i && a === void 0; t++) a = r(t);
|
|
1714
|
+
for (let t = i; t >= e && o === void 0; t--) o = r(t);
|
|
1715
|
+
return a === void 0 || o === void 0 ? null : [a, o];
|
|
1716
|
+
}
|
|
1717
|
+
let ba = _(() => {
|
|
1718
|
+
let e = [], t = B.value.length;
|
|
1719
|
+
for (let n of _a.value) {
|
|
1720
|
+
let r = ya(n.range.r1, n.range.r2, Lt.value.rows, (e) => G.value.get(String(e + 1))), i = ya(n.range.c1, n.range.c2, Lt.value.columns, (e) => H.value.get(vn(e)));
|
|
1721
|
+
!r || !i || e.push({
|
|
1722
|
+
key: `${n.start}`,
|
|
1723
|
+
colour: n.colour,
|
|
1724
|
+
style: {
|
|
1725
|
+
gridRow: `${r[0] + 1 + t} / span ${r[1] - r[0] + 1}`,
|
|
1726
|
+
gridColumn: `${Sn.value + 1 + i[0]} / span ${i[1] - i[0] + 1}`
|
|
1727
|
+
}
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
return e;
|
|
1731
|
+
}), xa = T({
|
|
1732
|
+
cell: 0,
|
|
1733
|
+
bar: 0
|
|
1734
|
+
});
|
|
1735
|
+
function Sa(e) {
|
|
1736
|
+
let t = e.target;
|
|
1737
|
+
xa.value = {
|
|
1738
|
+
...xa.value,
|
|
1739
|
+
[t === La.value ? "bar" : "cell"]: t.scrollLeft
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
let Ca = _(() => K.value ? {
|
|
1743
|
+
role: "combobox",
|
|
1744
|
+
"aria-autocomplete": "list",
|
|
1745
|
+
"aria-expanded": !!Q.value,
|
|
1746
|
+
"aria-controls": Q.value ? ja : void 0,
|
|
1747
|
+
"aria-activedescendant": Q.value ? `${ja}-${Q.value.active}` : void 0,
|
|
1748
|
+
"aria-describedby": $.value ? `${ja}-signature` : void 0
|
|
1749
|
+
} : {}), Z = T(null);
|
|
1750
|
+
function wa(e, t) {
|
|
1751
|
+
let n = e.slice(0, t).trimEnd();
|
|
1752
|
+
if (!n.startsWith("=")) return !1;
|
|
1753
|
+
let r = n[n.length - 1];
|
|
1754
|
+
return "=(+-*/^&<>,;:".includes(r) || r === fa.value.separator;
|
|
1755
|
+
}
|
|
1756
|
+
function Ta() {
|
|
1757
|
+
let e = ga();
|
|
1758
|
+
if (!ha.value || !e || !I.value) return !1;
|
|
1759
|
+
let t = e.selectionStart ?? I.value.draft.length;
|
|
1760
|
+
return Z.value && t === Z.value.end ? !0 : wa(I.value.draft, t);
|
|
1761
|
+
}
|
|
1762
|
+
function Ea(e, t) {
|
|
1763
|
+
let n = W.value[e], r = z.value[t];
|
|
1764
|
+
return n && r ? R(n.id, r.id) : "";
|
|
1765
|
+
}
|
|
1766
|
+
function Da(e, t) {
|
|
1767
|
+
let n = ga();
|
|
1768
|
+
if (!I.value || !n) return;
|
|
1769
|
+
let r = I.value.draft, i = n.selectionStart ?? r.length, a = Z.value && i === Z.value.end, o = a ? Z.value.start : i, s = a ? Z.value.end : i, c = t && a ? Z.value.anchor : e, l = Ea(c.ri, c.ci), u = Ea(e.ri, e.ci);
|
|
1770
|
+
if (!l || !u) return;
|
|
1771
|
+
let d = Math.min(c.ri, e.ri), f = Math.max(c.ri, e.ri), p = Math.min(c.ci, e.ci), m = Math.max(c.ci, e.ci), ee = d === f && p === m ? Ea(d, p) : `${Ea(d, p)}:${Ea(f, m)}`;
|
|
1772
|
+
I.value.draft = r.slice(0, o) + ee + r.slice(s);
|
|
1773
|
+
let te = o + ee.length;
|
|
1774
|
+
Z.value = {
|
|
1775
|
+
start: o,
|
|
1776
|
+
end: te,
|
|
1777
|
+
anchor: c,
|
|
1778
|
+
cursor: e,
|
|
1779
|
+
dragging: Z.value?.dragging ?? !1
|
|
1780
|
+
}, ge(() => {
|
|
1781
|
+
n.setSelectionRange(te, te), Ma();
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
function Oa(e, t, n) {
|
|
1785
|
+
if (!Ta() || !I.value) return !1;
|
|
1786
|
+
let r = Z.value?.cursor ?? {
|
|
1787
|
+
ri: G.value.get(I.value.rowId) ?? 0,
|
|
1788
|
+
ci: H.value.get(I.value.columnId) ?? 0
|
|
1789
|
+
};
|
|
1790
|
+
return Da({
|
|
1791
|
+
ri: Math.max(0, Math.min(W.value.length - 1, r.ri + e)),
|
|
1792
|
+
ci: Math.max(0, Math.min(z.value.length - 1, r.ci + t))
|
|
1793
|
+
}, n), !0;
|
|
1794
|
+
}
|
|
1795
|
+
function ka(e, t, n) {
|
|
1796
|
+
Da({
|
|
1797
|
+
ri: G.value.get(e.id) ?? 0,
|
|
1798
|
+
ci: H.value.get(t.id) ?? 0
|
|
1799
|
+
}, n.shiftKey), Z.value && (Z.value.dragging = !0), document.addEventListener("mouseup", () => {
|
|
1800
|
+
Z.value && (Z.value.dragging = !1);
|
|
1801
|
+
}, { once: !0 });
|
|
1802
|
+
}
|
|
1803
|
+
let Q = T(null), $ = T(null), Aa = T(null), ja = `${Tt}-functions`;
|
|
1804
|
+
function Ma() {
|
|
1805
|
+
let e = ga();
|
|
1806
|
+
if (!e || !ha.value || !I.value) {
|
|
1807
|
+
Q.value = null, $.value = null;
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
let t = I.value.draft, n = e.selectionStart ?? t.length, r = m(t, fa.value), i = r.find((e) => e.end === n && (e.type === "name" || e.type === "function")), a = i && /^[A-Za-z][A-Za-z0-9.]*$/.test(i.text) ? se(i.text).slice(0, 8) : [];
|
|
1811
|
+
Q.value = a.length && !(a.length === 1 && a[0].name === i.text.toUpperCase() && t[n] === "(") ? {
|
|
1812
|
+
items: a,
|
|
1813
|
+
active: Math.min(Q.value?.active ?? 0, a.length - 1),
|
|
1814
|
+
start: i.start,
|
|
1815
|
+
end: i.end
|
|
1816
|
+
} : null;
|
|
1817
|
+
let o = [], s, c = 0;
|
|
1818
|
+
for (let e of r) {
|
|
1819
|
+
if (e.start >= n) break;
|
|
1820
|
+
if (e.text === "{") c++;
|
|
1821
|
+
else if (e.text === "}") c = Math.max(0, c - 1);
|
|
1822
|
+
else if (c) continue;
|
|
1823
|
+
else e.type === "paren" && e.text === "(" ? o.push({
|
|
1824
|
+
name: s?.type === "function" ? s.text.toUpperCase() : null,
|
|
1825
|
+
arg: 0
|
|
1826
|
+
}) : e.type === "paren" && e.text === ")" ? o.pop() : e.type === "separator" && o.length && o[o.length - 1].arg++;
|
|
1827
|
+
e.type !== "whitespace" && (s = e);
|
|
1828
|
+
}
|
|
1829
|
+
let l = o[o.length - 1], u = l?.name ? ie.find((e) => e.name === l.name) : void 0;
|
|
1830
|
+
$.value = u && !Q.value ? {
|
|
1831
|
+
fn: u,
|
|
1832
|
+
arg: l.arg
|
|
1833
|
+
} : null;
|
|
1834
|
+
let d = e.getBoundingClientRect();
|
|
1835
|
+
Aa.value = {
|
|
1836
|
+
left: d.left,
|
|
1837
|
+
top: d.bottom + 2
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
function Na(e = Q.value?.active ?? 0) {
|
|
1841
|
+
let t = Q.value, n = ga();
|
|
1842
|
+
if (!t || !I.value || !n) return;
|
|
1843
|
+
let r = t.items[e].name, i = I.value.draft, a = i.slice(t.end), o = a.startsWith("(") ? r : `${r}(`;
|
|
1844
|
+
I.value.draft = i.slice(0, t.start) + o + a;
|
|
1845
|
+
let s = t.start + o.length + (a.startsWith("(") ? 1 : 0);
|
|
1846
|
+
Q.value = null, ge(() => {
|
|
1847
|
+
n.focus({ preventScroll: !0 }), n.setSelectionRange(s, s), Ma();
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
function Pa(e) {
|
|
1851
|
+
let t = Q.value;
|
|
1852
|
+
if (t) {
|
|
1853
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
1854
|
+
e.preventDefault();
|
|
1855
|
+
let n = e.key === "ArrowDown" ? 1 : -1;
|
|
1856
|
+
return t.active = (t.active + n + t.items.length) % t.items.length, !0;
|
|
1857
|
+
}
|
|
1858
|
+
if (e.key === "Enter" || e.key === "Tab") return e.preventDefault(), Na(), !0;
|
|
1859
|
+
if (e.key === "Escape") return e.preventDefault(), Q.value = null, !0;
|
|
1860
|
+
}
|
|
1861
|
+
let n = {
|
|
1862
|
+
ArrowUp: [-1, 0],
|
|
1863
|
+
ArrowDown: [1, 0],
|
|
1864
|
+
ArrowLeft: [0, -1],
|
|
1865
|
+
ArrowRight: [0, 1]
|
|
1866
|
+
}[e.key];
|
|
1867
|
+
return n && I.value?.mode === "enter" && !e.altKey && !e.metaKey && !e.ctrlKey && Oa(n[0], n[1], e.shiftKey) ? (e.preventDefault(), !0) : !1;
|
|
1868
|
+
}
|
|
1869
|
+
function Fa() {
|
|
1870
|
+
Z.value = null, ge(Ma);
|
|
1871
|
+
}
|
|
1872
|
+
function Ia(e, t) {
|
|
1873
|
+
let n = e.syntax.indexOf("("), r = e.syntax.lastIndexOf(")");
|
|
1874
|
+
if (n < 0 || r < n) return [{
|
|
1875
|
+
text: e.syntax,
|
|
1876
|
+
current: !1
|
|
1877
|
+
}];
|
|
1878
|
+
let i = e.syntax.slice(n + 1, r).split(/,\s*/), a = Math.min(t, i.length - 1), o = [{
|
|
1879
|
+
text: e.syntax.slice(0, n + 1),
|
|
1880
|
+
current: !1
|
|
1881
|
+
}];
|
|
1882
|
+
return i.forEach((e, t) => {
|
|
1883
|
+
t && o.push({
|
|
1884
|
+
text: `${fa.value.separator} `,
|
|
1885
|
+
current: !1
|
|
1886
|
+
}), o.push({
|
|
1887
|
+
text: e,
|
|
1888
|
+
current: t === a
|
|
1889
|
+
});
|
|
1890
|
+
}), o.push({
|
|
1891
|
+
text: e.syntax.slice(r),
|
|
1892
|
+
current: !1
|
|
1893
|
+
}), o;
|
|
1894
|
+
}
|
|
1895
|
+
let La = Se("barRef"), Ra = _(() => {
|
|
1896
|
+
let e = Y.value;
|
|
1897
|
+
return !e || !P.value ? "" : e.r1 === e.r2 && e.c1 === e.c2 ? R(P.value.rowId, P.value.columnId) : `${Ea(e.r1, e.c1)}:${Ea(e.r2, e.c2)}`;
|
|
1898
|
+
}), za = _(() => {
|
|
1899
|
+
if (I.value) return I.value.draft;
|
|
1900
|
+
let e = P.value;
|
|
1901
|
+
return e ? ma(e.rowId, e.columnId) : "";
|
|
1902
|
+
}), Ba = _(() => {
|
|
1903
|
+
let e = ci();
|
|
1904
|
+
return !!e && !J(e.r, e.c);
|
|
1905
|
+
});
|
|
1906
|
+
function Va() {
|
|
1907
|
+
if (I.value) {
|
|
1908
|
+
I.value.source = "bar";
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1911
|
+
let e = ci();
|
|
1912
|
+
!e || J(e.r, e.c) || (I.value = {
|
|
1913
|
+
rowId: e.r.id,
|
|
1914
|
+
columnId: e.c.id,
|
|
1915
|
+
draft: ma(e.r.id, e.c.id),
|
|
1916
|
+
mode: "edit",
|
|
1917
|
+
source: "bar"
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
function Ha(e) {
|
|
1921
|
+
I.value && (I.value.draft = e.target.value, Fa());
|
|
1922
|
+
}
|
|
1923
|
+
function Ua(e) {
|
|
1924
|
+
let t = e.relatedTarget;
|
|
1925
|
+
t && (t === La.value || t === Ct.value) || (Q.value = null, $.value = null, gi(!1));
|
|
1926
|
+
}
|
|
1927
|
+
function Wa(e) {
|
|
1928
|
+
I.value && (I.value.source = e);
|
|
1929
|
+
}
|
|
1930
|
+
function Ga(e, t = {}) {
|
|
1931
|
+
At.value.push({
|
|
1932
|
+
changes: e,
|
|
1933
|
+
...t
|
|
1934
|
+
}), jt.value = [];
|
|
1935
|
+
}
|
|
1936
|
+
function Ka() {
|
|
1937
|
+
let e = At.value.pop();
|
|
1938
|
+
e && (e.changes.length && yi(e.changes.map((e) => ({
|
|
1939
|
+
...e,
|
|
1940
|
+
before: e.after,
|
|
1941
|
+
after: e.before
|
|
1942
|
+
}))), e.styles && (k.value = e.styles[0]), e.merges && (xt.value = e.merges[0]), jt.value.push(e));
|
|
1943
|
+
}
|
|
1944
|
+
function qa() {
|
|
1945
|
+
let e = jt.value.pop();
|
|
1946
|
+
e && (e.changes.length && yi(e.changes), e.styles && (k.value = e.styles[1]), e.merges && (xt.value = e.merges[1]), At.value.push(e));
|
|
1947
|
+
}
|
|
1948
|
+
return we(() => [
|
|
1949
|
+
h.fit,
|
|
1950
|
+
W.value.length,
|
|
1951
|
+
En.value,
|
|
1952
|
+
h.size,
|
|
1953
|
+
h.columnHeaders
|
|
1954
|
+
], () => kn()), ve(() => {
|
|
1955
|
+
kn(), Ln(), typeof ResizeObserver < "u" && M.value && (An = new ResizeObserver(() => {
|
|
1956
|
+
kn(), Ln();
|
|
1957
|
+
}), An.observe(M.value), St.value && An.observe(St.value));
|
|
1958
|
+
}), _e(() => An?.disconnect()), u({
|
|
1959
|
+
focus: (e, t) => {
|
|
1960
|
+
zr(e, t), Qr();
|
|
1961
|
+
},
|
|
1962
|
+
undo: Ka,
|
|
1963
|
+
redo: qa,
|
|
1964
|
+
getSelection: () => F.value,
|
|
1965
|
+
getSelections: () => [...X.value, F.value].filter((e) => !!e),
|
|
1966
|
+
selectAll: Ur,
|
|
1967
|
+
selectColumn: (e) => Vr(e),
|
|
1968
|
+
selectRow: (e) => Hr(e),
|
|
1969
|
+
hideColumns: Ki,
|
|
1970
|
+
showColumns: qi,
|
|
1971
|
+
hideRows: Ji,
|
|
1972
|
+
showRows: Yi,
|
|
1973
|
+
applyStyle: sn,
|
|
1974
|
+
clearStyles: ln,
|
|
1975
|
+
merge: Yt,
|
|
1976
|
+
unmerge: Xt,
|
|
1977
|
+
exportCsv: un,
|
|
1978
|
+
importCsv: dn
|
|
1979
|
+
}), (n, r) => (w(), y("div", {
|
|
1980
|
+
ref_key: "rootRef",
|
|
1981
|
+
ref: St,
|
|
1982
|
+
class: S(["nb-spreadsheet", [`nb-spreadsheet--${e.size}`, {
|
|
1983
|
+
"nb-spreadsheet--editing": !!I.value,
|
|
1984
|
+
"nb-spreadsheet--fit": e.fit,
|
|
1985
|
+
"nb-spreadsheet--two-headers": B.value.length === 2,
|
|
1986
|
+
"nb-spreadsheet--filling": !!ji.value
|
|
1987
|
+
}]]),
|
|
1988
|
+
style: C(jn.value)
|
|
1989
|
+
}, [
|
|
1990
|
+
n.$slots.toolbar ? (w(), y("div", ze, [be(n.$slots, "toolbar", {}, void 0, !0)])) : v("", !0),
|
|
1991
|
+
pa.value ? (w(), y("div", Be, [
|
|
1992
|
+
b("span", Ve, E(Ra.value), 1),
|
|
1993
|
+
r[18] ||= b("span", {
|
|
1994
|
+
class: "nb-spreadsheet__fx",
|
|
1995
|
+
"aria-hidden": "true"
|
|
1996
|
+
}, "fx", -1),
|
|
1997
|
+
b("div", He, [ha.value ? (w(), y("div", Ue, [b("span", { style: C({ transform: `translateX(${-xa.value.bar}px)` }) }, [(w(!0), y(g, null, ye(va.value, (e, t) => (w(), y("span", {
|
|
1998
|
+
key: t,
|
|
1999
|
+
class: S(e.colour ? `nb-spreadsheet__ref--${e.colour}` : "")
|
|
2000
|
+
}, E(e.text), 3))), 128))], 4)])) : v("", !0), b("input", he({
|
|
2001
|
+
ref_key: "barRef",
|
|
2002
|
+
ref: La,
|
|
2003
|
+
class: ["nb-spreadsheet__bar-input", { "nb-spreadsheet__input--formula": ha.value }],
|
|
2004
|
+
value: za.value,
|
|
2005
|
+
readonly: !Ba.value,
|
|
2006
|
+
"aria-label": D(j).spreadsheetFormulaBar
|
|
2007
|
+
}, Ca.value, {
|
|
2008
|
+
autocomplete: "off",
|
|
2009
|
+
spellcheck: "false",
|
|
2010
|
+
onFocus: Va,
|
|
2011
|
+
onInput: Ha,
|
|
2012
|
+
onKeydown: r[0] ||= O((e) => I.value && hi(e), ["stop"]),
|
|
2013
|
+
onKeyup: Ma,
|
|
2014
|
+
onClick: Ma,
|
|
2015
|
+
onBlur: Ua,
|
|
2016
|
+
onScroll: Sa
|
|
2017
|
+
}), null, 16, We)])
|
|
2018
|
+
])) : v("", !0),
|
|
2019
|
+
b("div", {
|
|
2020
|
+
ref_key: "scrollerRef",
|
|
2021
|
+
ref: M,
|
|
2022
|
+
class: S(["nb-spreadsheet__scroller", { "nb-spreadsheet__scroller--active": !!P.value }]),
|
|
2023
|
+
tabindex: "0",
|
|
2024
|
+
role: "grid",
|
|
2025
|
+
"aria-multiselectable": "true",
|
|
2026
|
+
"aria-label": e.ariaLabel,
|
|
2027
|
+
"aria-rowcount": W.value.length + 1,
|
|
2028
|
+
"aria-colcount": z.value.length + (e.showGutter ? 1 : 0),
|
|
2029
|
+
"aria-activedescendant": br.value,
|
|
2030
|
+
onKeydown: ui,
|
|
2031
|
+
onCopy: wi,
|
|
2032
|
+
onCut: Ti,
|
|
2033
|
+
onPaste: Ei,
|
|
2034
|
+
onScroll: oi
|
|
2035
|
+
}, [
|
|
2036
|
+
b("div", {
|
|
2037
|
+
class: "nb-spreadsheet__grid",
|
|
2038
|
+
style: C(Mn.value)
|
|
2039
|
+
}, [
|
|
2040
|
+
(w(!0), y(g, null, ye(B.value, (n, i) => (w(), y("div", {
|
|
2041
|
+
key: `hr-${n}`,
|
|
2042
|
+
class: "nb-spreadsheet__row",
|
|
2043
|
+
role: "row",
|
|
2044
|
+
"aria-rowindex": i + 1
|
|
2045
|
+
}, [e.showGutter && i === 0 ? (w(), y("div", {
|
|
2046
|
+
key: 0,
|
|
2047
|
+
class: "nb-spreadsheet__corner",
|
|
2048
|
+
role: "columnheader",
|
|
2049
|
+
"aria-colindex": "1",
|
|
2050
|
+
style: C({
|
|
2051
|
+
gridRow: `1 / span ${B.value.length}`,
|
|
2052
|
+
gridColumn: 1
|
|
2053
|
+
}),
|
|
2054
|
+
onMousedown: O(Zr, ["prevent"]),
|
|
2055
|
+
onContextmenu: r[1] ||= (e) => oa(e, "cell")
|
|
2056
|
+
}, null, 36)) : v("", !0), (w(!0), y(g, null, ye(Nn.value, (a) => (w(), y("div", {
|
|
2057
|
+
key: `h-${n}-${a.id}`,
|
|
2058
|
+
class: S(["nb-spreadsheet__header", xr(a, Pn(a), n)]),
|
|
2059
|
+
role: "columnheader",
|
|
2060
|
+
"aria-colindex": Pn(a) + Sn.value + 1,
|
|
2061
|
+
"aria-sort": n === "label" ? Sr(a) : void 0,
|
|
2062
|
+
"aria-label": n === "letters" && B.value.length === 1 && a.label && !L.value ? `${yn(a.id)} ${a.label}` : void 0,
|
|
2063
|
+
"data-header-col": n === "label" ? a.id : void 0,
|
|
2064
|
+
"data-header-row": i,
|
|
2065
|
+
style: C(Er(a, Pn(a), i)),
|
|
2066
|
+
onMousedown: (e) => Yr(e, a, n),
|
|
2067
|
+
onContextmenu: (e) => oa(e, "column", void 0, a.id)
|
|
2068
|
+
}, [
|
|
2069
|
+
n === "letters" ? (w(), y("span", {
|
|
2070
|
+
key: 0,
|
|
2071
|
+
class: "nb-spreadsheet__header-letter",
|
|
2072
|
+
title: B.value.length === 1 && !L.value ? a.label : void 0
|
|
2073
|
+
}, E(yn(a.id)), 9, Je)) : (w(), y(g, { key: 1 }, [b("span", {
|
|
2074
|
+
class: "nb-spreadsheet__header-label",
|
|
2075
|
+
title: Fn.value.has(a.id) ? a.label : void 0
|
|
2076
|
+
}, E(Fn.value.has(a.id) ? a.shortLabel : a.label), 9, Ye), a.sortable ? (w(), ue(t, {
|
|
2077
|
+
key: 0,
|
|
2078
|
+
name: Cr(a),
|
|
2079
|
+
class: "nb-spreadsheet__sort",
|
|
2080
|
+
"aria-hidden": "true"
|
|
2081
|
+
}, null, 8, ["name"])) : v("", !0)], 64)),
|
|
2082
|
+
i === B.value.length - 1 ? (w(), y(g, { key: 2 }, [bn.value.has(a.id) ? (w(), y("button", {
|
|
2083
|
+
key: 0,
|
|
2084
|
+
type: "button",
|
|
2085
|
+
tabindex: "-1",
|
|
2086
|
+
class: "nb-spreadsheet__unhide nb-spreadsheet__unhide--col-start",
|
|
2087
|
+
title: D(j).spreadsheetShowColumns(bn.value.get(a.id).length),
|
|
2088
|
+
"aria-label": D(j).spreadsheetShowColumns(bn.value.get(a.id).length),
|
|
2089
|
+
onMousedown: r[2] ||= O(() => {}, ["stop", "prevent"]),
|
|
2090
|
+
onClick: (e) => qi(bn.value.get(a.id))
|
|
2091
|
+
}, null, 40, Xe)) : v("", !0), Pn(a) === z.value.length - 1 && xn.value.length ? (w(), y("button", {
|
|
2092
|
+
key: 1,
|
|
2093
|
+
type: "button",
|
|
2094
|
+
tabindex: "-1",
|
|
2095
|
+
class: "nb-spreadsheet__unhide nb-spreadsheet__unhide--col-end",
|
|
2096
|
+
title: D(j).spreadsheetShowColumns(xn.value.length),
|
|
2097
|
+
"aria-label": D(j).spreadsheetShowColumns(xn.value.length),
|
|
2098
|
+
onMousedown: r[3] ||= O(() => {}, ["stop", "prevent"]),
|
|
2099
|
+
onClick: r[4] ||= (e) => qi(xn.value)
|
|
2100
|
+
}, null, 40, Ze)) : v("", !0)], 64)) : v("", !0),
|
|
2101
|
+
e.resizable ? (w(), y("span", {
|
|
2102
|
+
key: 3,
|
|
2103
|
+
class: "nb-spreadsheet__resize-handle",
|
|
2104
|
+
onMousedown: O((e) => Ui(e, a), ["stop"])
|
|
2105
|
+
}, null, 40, Qe)) : v("", !0)
|
|
2106
|
+
], 46, qe))), 128))], 8, Ke))), 128)),
|
|
2107
|
+
(w(!0), y(g, null, ye(qn.value, (t) => (w(), y("div", {
|
|
2108
|
+
key: `r-${t.id}`,
|
|
2109
|
+
class: "nb-spreadsheet__row",
|
|
2110
|
+
role: "row",
|
|
2111
|
+
"aria-rowindex": t.__virtualIndex + 1 + B.value.length
|
|
2112
|
+
}, [e.showGutter ? (w(), y("div", {
|
|
2113
|
+
key: 0,
|
|
2114
|
+
class: S(["nb-spreadsheet__gutter", {
|
|
2115
|
+
"nb-spreadsheet__gutter--pinned-top": t.pinned === "top",
|
|
2116
|
+
"nb-spreadsheet__gutter--pinned-bottom": t.pinned === "bottom",
|
|
2117
|
+
"nb-spreadsheet__gutter--selected": Ir(t.id)
|
|
2118
|
+
}]),
|
|
2119
|
+
role: "rowheader",
|
|
2120
|
+
"aria-colindex": "1",
|
|
2121
|
+
style: C(Ar(t)),
|
|
2122
|
+
onMousedown: O((e) => Xr(e, t), ["prevent"]),
|
|
2123
|
+
onContextmenu: (e) => oa(e, "row", t.id)
|
|
2124
|
+
}, [
|
|
2125
|
+
de(E(kr(t)) + " ", 1),
|
|
2126
|
+
Wn.value.has(t.id) ? (w(), y("button", {
|
|
2127
|
+
key: 0,
|
|
2128
|
+
type: "button",
|
|
2129
|
+
tabindex: "-1",
|
|
2130
|
+
class: "nb-spreadsheet__unhide nb-spreadsheet__unhide--row-start",
|
|
2131
|
+
title: D(j).spreadsheetShowRows(Wn.value.get(t.id).length),
|
|
2132
|
+
"aria-label": D(j).spreadsheetShowRows(Wn.value.get(t.id).length),
|
|
2133
|
+
onMousedown: r[5] ||= O(() => {}, ["stop", "prevent"]),
|
|
2134
|
+
onClick: (e) => Yi(Wn.value.get(t.id))
|
|
2135
|
+
}, null, 40, tt)) : v("", !0),
|
|
2136
|
+
t.id === Kn.value && Gn.value.length ? (w(), y("button", {
|
|
2137
|
+
key: 1,
|
|
2138
|
+
type: "button",
|
|
2139
|
+
tabindex: "-1",
|
|
2140
|
+
class: "nb-spreadsheet__unhide nb-spreadsheet__unhide--row-end",
|
|
2141
|
+
title: D(j).spreadsheetShowRows(Gn.value.length),
|
|
2142
|
+
"aria-label": D(j).spreadsheetShowRows(Gn.value.length),
|
|
2143
|
+
onMousedown: r[6] ||= O(() => {}, ["stop", "prevent"]),
|
|
2144
|
+
onClick: r[7] ||= (e) => Yi(Gn.value)
|
|
2145
|
+
}, null, 40, nt)) : v("", !0)
|
|
2146
|
+
], 46, et)) : v("", !0), (w(!0), y(g, null, ye(Nn.value, (e) => (w(), y(g, { key: `c-${t.id}-${e.id}` }, [Kt(t.id, e.id) ? v("", !0) : (w(), y("div", {
|
|
2147
|
+
key: 0,
|
|
2148
|
+
id: yr(t.id, e.id),
|
|
2149
|
+
class: S(["nb-spreadsheet__cell", _r(t, e)]),
|
|
2150
|
+
role: "gridcell",
|
|
2151
|
+
"aria-colindex": Pn(e) + Sn.value + 1,
|
|
2152
|
+
"aria-selected": Pr(t.id, e.id),
|
|
2153
|
+
"aria-readonly": J(t, e) || void 0,
|
|
2154
|
+
style: C(Dr(t, e, Pn(e))),
|
|
2155
|
+
title: vr(t, e),
|
|
2156
|
+
"data-cell": `${t.id}::${e.id}`,
|
|
2157
|
+
"data-row": t.id,
|
|
2158
|
+
"data-col": e.id,
|
|
2159
|
+
onPointerdown: r[8] ||= (e) => Wr(e),
|
|
2160
|
+
onMousedown: (n) => Gr(n, t, e),
|
|
2161
|
+
onMouseenter: (n) => Kr(t, e),
|
|
2162
|
+
onDblclick: (n) => Jr(t, e),
|
|
2163
|
+
onContextmenu: (n) => oa(n, "cell", t.id, e.id)
|
|
2164
|
+
}, [b("span", null, E(gr(t, e)), 1), Mi(t.id, e.id) ? (w(), y("span", {
|
|
2165
|
+
key: 0,
|
|
2166
|
+
class: "nb-spreadsheet__fill-handle",
|
|
2167
|
+
"aria-hidden": "true",
|
|
2168
|
+
onMousedown: O(Pi, ["stop", "prevent"])
|
|
2169
|
+
}, null, 32)) : v("", !0)], 46, rt))], 64))), 128))], 8, $e))), 128)),
|
|
2170
|
+
(w(!0), y(g, null, ye(ba.value, (e) => (w(), y("div", {
|
|
2171
|
+
key: e.key,
|
|
2172
|
+
class: S(["nb-spreadsheet__ref-box", `nb-spreadsheet__ref--${e.colour}`]),
|
|
2173
|
+
style: C(e.style),
|
|
2174
|
+
"aria-hidden": "true"
|
|
2175
|
+
}, null, 6))), 128))
|
|
2176
|
+
], 4),
|
|
2177
|
+
I.value && ha.value ? (w(), y("div", {
|
|
2178
|
+
key: 0,
|
|
2179
|
+
class: "nb-spreadsheet__editor nb-spreadsheet__mirror",
|
|
2180
|
+
style: C(mi.value),
|
|
2181
|
+
"aria-hidden": "true"
|
|
2182
|
+
}, [b("span", { style: C({ transform: `translateX(${-xa.value.cell}px)` }) }, [(w(!0), y(g, null, ye(va.value, (e, t) => (w(), y("span", {
|
|
2183
|
+
key: t,
|
|
2184
|
+
class: S(e.colour ? `nb-spreadsheet__ref--${e.colour}` : "")
|
|
2185
|
+
}, E(e.text), 3))), 128))], 4)], 4)) : v("", !0),
|
|
2186
|
+
I.value ? Ee((w(), y("input", he({
|
|
2187
|
+
key: 1,
|
|
2188
|
+
ref_key: "editorRef",
|
|
2189
|
+
ref: Ct,
|
|
2190
|
+
"onUpdate:modelValue": r[9] ||= (e) => I.value.draft = e,
|
|
2191
|
+
class: ["nb-spreadsheet__editor", { "nb-spreadsheet__input--formula": ha.value }],
|
|
2192
|
+
style: mi.value,
|
|
2193
|
+
inputmode: fi.value,
|
|
2194
|
+
"aria-label": pi.value
|
|
2195
|
+
}, Ca.value, {
|
|
2196
|
+
autocomplete: "off",
|
|
2197
|
+
spellcheck: "false",
|
|
2198
|
+
enterkeyhint: "next",
|
|
2199
|
+
onFocus: r[10] ||= (e) => Wa("cell"),
|
|
2200
|
+
onBlur: Ua,
|
|
2201
|
+
onInput: Fa,
|
|
2202
|
+
onKeyup: Ma,
|
|
2203
|
+
onClick: Ma,
|
|
2204
|
+
onScroll: Sa,
|
|
2205
|
+
onKeydown: O(hi, ["stop"])
|
|
2206
|
+
}), null, 16, it)), [[Ce, I.value.draft]]) : v("", !0)
|
|
2207
|
+
], 42, Ge),
|
|
2208
|
+
I.value && (Q.value || $.value) && Aa.value ? (w(), y("div", {
|
|
2209
|
+
key: 2,
|
|
2210
|
+
class: "nb-spreadsheet__assist",
|
|
2211
|
+
style: C({
|
|
2212
|
+
left: `${Aa.value.left}px`,
|
|
2213
|
+
top: `${Aa.value.top}px`
|
|
2214
|
+
})
|
|
2215
|
+
}, [Q.value ? (w(), y("ul", {
|
|
2216
|
+
key: 0,
|
|
2217
|
+
id: ja,
|
|
2218
|
+
class: "nb-spreadsheet__assist-list",
|
|
2219
|
+
role: "listbox",
|
|
2220
|
+
"aria-label": D(j).spreadsheetFunctions
|
|
2221
|
+
}, [(w(!0), y(g, null, ye(Q.value.items, (e, t) => (w(), y("li", {
|
|
2222
|
+
id: `${ja}-${t}`,
|
|
2223
|
+
key: e.name,
|
|
2224
|
+
class: S(["nb-spreadsheet__assist-option", { "nb-spreadsheet__assist-option--active": t === Q.value.active }]),
|
|
2225
|
+
role: "option",
|
|
2226
|
+
"aria-selected": t === Q.value.active,
|
|
2227
|
+
onMousedown: O((e) => Na(t), ["prevent"])
|
|
2228
|
+
}, [b("span", st, E(e.name), 1), b("span", ct, E(e.description), 1)], 42, ot))), 128))], 8, at)) : $.value ? (w(), y("div", {
|
|
2229
|
+
key: 1,
|
|
2230
|
+
id: `${ja}-signature`,
|
|
2231
|
+
class: "nb-spreadsheet__signature"
|
|
2232
|
+
}, [b("span", ut, [(w(!0), y(g, null, ye(Ia($.value.fn, $.value.arg), (e, t) => (w(), y(g, { key: t }, [e.current ? (w(), y("strong", dt, E(e.text), 1)) : (w(), y(g, { key: 1 }, [de(E(e.text), 1)], 64))], 64))), 128))]), b("span", ft, E($.value.fn.description), 1)], 8, lt)) : v("", !0)], 4)) : v("", !0),
|
|
2233
|
+
e.contextMenu ? (w(), ue(a, {
|
|
2234
|
+
key: 3,
|
|
2235
|
+
ref_key: "menuRef",
|
|
2236
|
+
ref: Zi,
|
|
2237
|
+
open: Qi.value,
|
|
2238
|
+
"onUpdate:open": r[17] ||= (e) => Qi.value = e,
|
|
2239
|
+
size: "sm"
|
|
2240
|
+
}, {
|
|
2241
|
+
default: Te(() => [
|
|
2242
|
+
x(o, {
|
|
2243
|
+
label: D(j).spreadsheetCut,
|
|
2244
|
+
shortcut: `${D(ea)}X`,
|
|
2245
|
+
onSelect: ua
|
|
2246
|
+
}, null, 8, ["label", "shortcut"]),
|
|
2247
|
+
x(o, {
|
|
2248
|
+
label: D(j).spreadsheetCopy,
|
|
2249
|
+
shortcut: `${D(ea)}C`,
|
|
2250
|
+
onSelect: la
|
|
2251
|
+
}, null, 8, ["label", "shortcut"]),
|
|
2252
|
+
x(o, {
|
|
2253
|
+
label: D(j).spreadsheetPaste,
|
|
2254
|
+
shortcut: `${D(ea)}V`,
|
|
2255
|
+
disabled: !D(ta),
|
|
2256
|
+
"disabled-reason": D(j).spreadsheetPasteWithKeys,
|
|
2257
|
+
onSelect: da
|
|
2258
|
+
}, null, 8, [
|
|
2259
|
+
"label",
|
|
2260
|
+
"shortcut",
|
|
2261
|
+
"disabled",
|
|
2262
|
+
"disabled-reason"
|
|
2263
|
+
]),
|
|
2264
|
+
x(o, {
|
|
2265
|
+
label: D(j).spreadsheetClear,
|
|
2266
|
+
shortcut: "Delete",
|
|
2267
|
+
onSelect: xi
|
|
2268
|
+
}, null, 8, ["label"]),
|
|
2269
|
+
L.value ? (w(), y(g, { key: 0 }, [x(s), Qt.value ? (w(), ue(o, {
|
|
2270
|
+
key: 0,
|
|
2271
|
+
label: D(j).spreadsheetUnmerge,
|
|
2272
|
+
onSelect: Xt
|
|
2273
|
+
}, null, 8, ["label"])) : (w(), ue(o, {
|
|
2274
|
+
key: 1,
|
|
2275
|
+
label: D(j).spreadsheetMerge,
|
|
2276
|
+
disabled: !Zt.value,
|
|
2277
|
+
onSelect: Yt
|
|
2278
|
+
}, null, 8, ["label", "disabled"]))], 64)) : v("", !0),
|
|
2279
|
+
aa.value ? (w(), y(g, { key: 1 }, [
|
|
2280
|
+
x(s),
|
|
2281
|
+
x(o, {
|
|
2282
|
+
label: D(j).spreadsheetSortAscending,
|
|
2283
|
+
onSelect: r[11] ||= (e) => Gi(aa.value, "asc")
|
|
2284
|
+
}, null, 8, ["label"]),
|
|
2285
|
+
x(o, {
|
|
2286
|
+
label: D(j).spreadsheetSortDescending,
|
|
2287
|
+
onSelect: r[12] ||= (e) => Gi(aa.value, "desc")
|
|
2288
|
+
}, null, 8, ["label"])
|
|
2289
|
+
], 64)) : v("", !0),
|
|
2290
|
+
x(s),
|
|
2291
|
+
$i.value === "row" ? v("", !0) : (w(), y(g, { key: 2 }, [x(o, {
|
|
2292
|
+
label: D(j).spreadsheetHideColumns(na.value.length),
|
|
2293
|
+
disabled: na.value.length >= z.value.length,
|
|
2294
|
+
"disabled-reason": D(j).spreadsheetKeepOneColumn,
|
|
2295
|
+
onSelect: r[13] ||= (e) => Ki(na.value)
|
|
2296
|
+
}, null, 8, [
|
|
2297
|
+
"label",
|
|
2298
|
+
"disabled",
|
|
2299
|
+
"disabled-reason"
|
|
2300
|
+
]), hn.value.length ? (w(), ue(o, {
|
|
2301
|
+
key: 0,
|
|
2302
|
+
label: D(j).spreadsheetShowColumns(hn.value.length),
|
|
2303
|
+
onSelect: r[14] ||= (e) => qi(hn.value)
|
|
2304
|
+
}, null, 8, ["label"])) : v("", !0)], 64)),
|
|
2305
|
+
$i.value === "column" ? v("", !0) : (w(), y(g, { key: 3 }, [x(o, {
|
|
2306
|
+
label: D(j).spreadsheetHideRows(ra.value.length),
|
|
2307
|
+
disabled: ra.value.length >= W.value.length,
|
|
2308
|
+
"disabled-reason": D(j).spreadsheetKeepOneRow,
|
|
2309
|
+
onSelect: r[15] ||= (e) => Ji(ra.value)
|
|
2310
|
+
}, null, 8, [
|
|
2311
|
+
"label",
|
|
2312
|
+
"disabled",
|
|
2313
|
+
"disabled-reason"
|
|
2314
|
+
]), gn.value.length ? (w(), ue(o, {
|
|
2315
|
+
key: 0,
|
|
2316
|
+
label: D(j).spreadsheetShowRows(gn.value.length),
|
|
2317
|
+
onSelect: r[16] ||= (e) => Yi(gn.value)
|
|
2318
|
+
}, null, 8, ["label"])) : v("", !0)], 64))
|
|
2319
|
+
]),
|
|
2320
|
+
_: 1
|
|
2321
|
+
}, 8, ["open"])) : v("", !0)
|
|
2322
|
+
], 6));
|
|
2323
|
+
}
|
|
2324
|
+
}), [["__scopeId", "data-v-332e4a41"]]);
|
|
2325
|
+
//#endregion
|
|
2326
|
+
export { xt as t };
|