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