@medyat/vue-data-table 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/LICENSE +21 -0
- package/README.md +179 -2
- package/dist/ColumnsDialog-dngip-aF.js +251 -0
- package/dist/ColumnsDialog-dngip-aF.js.map +1 -0
- package/dist/DateEditor-C2zzyoPQ.js +224 -0
- package/dist/DateEditor-C2zzyoPQ.js.map +1 -0
- package/dist/FiltersSheet-C3zOlbkN.js +284 -0
- package/dist/FiltersSheet-C3zOlbkN.js.map +1 -0
- package/dist/Layer-Di-tPd8b.js +106 -0
- package/dist/Layer-Di-tPd8b.js.map +1 -0
- package/dist/PhoneMoreSheet-66OdIZrl.js +266 -0
- package/dist/PhoneMoreSheet-66OdIZrl.js.map +1 -0
- package/dist/TextEditor-CHLM6u-l.js +330 -0
- package/dist/TextEditor-CHLM6u-l.js.map +1 -0
- package/dist/index.d.ts +716 -0
- package/dist/index.js +3186 -0
- package/dist/index.js.map +1 -0
- package/dist/query-CGNWUi2E.js +2904 -0
- package/dist/query-CGNWUi2E.js.map +1 -0
- package/dist/shadcn-bridge-hsl.css +22 -0
- package/dist/shadcn-bridge.css +23 -0
- package/dist/sheet.d.ts +623 -0
- package/dist/sheet.js +3721 -0
- package/dist/sheet.js.map +1 -0
- package/dist/style.css +2 -0
- package/package.json +93 -4
package/dist/sheet.js
ADDED
|
@@ -0,0 +1,3721 @@
|
|
|
1
|
+
import { $ as e, B as t, I as n, J as r, K as i, Q as a, R as o, S as s, W as c, X as l, Y as u, Z as d, _ as f, a as p, at as m, b as h, c as g, d as _, et as v, g as y, i as b, it as x, k as S, l as C, m as ee, n as w, nt as T, o as te, p as ne, q as E, r as re, rt as ie, s as ae, t as D, tt as oe, v as se, w as O, x as k, y as ce, z as le } from "./query-CGNWUi2E.js";
|
|
2
|
+
import { Fragment as A, computed as j, createBlock as M, createCommentVNode as N, createElementBlock as P, createElementVNode as F, createSlots as ue, createTextVNode as I, createVNode as L, defineComponent as R, getCurrentInstance as de, h as z, inject as fe, mergeModels as pe, mergeProps as me, nextTick as he, normalizeClass as ge, normalizeStyle as _e, onBeforeUnmount as ve, onMounted as ye, openBlock as B, provide as be, ref as V, renderList as xe, renderSlot as Se, shallowReactive as Ce, shallowRef as H, toDisplayString as U, toHandlers as we, toRaw as W, toValue as Te, unref as G, useId as K, useModel as Ee, useTemplateRef as De, vModelCheckbox as Oe, vModelSelect as ke, vShow as Ae, watch as je, watchEffect as Me, withCtx as q, withDirectives as Ne, withModifiers as Pe } from "vue";
|
|
3
|
+
import { PhArrowLeft as Fe, PhArrowRight as Ie, PhArrowUUpLeft as Le, PhArrowUUpRight as Re, PhArrowUp as ze, PhCalendarBlank as J, PhCaretDown as Be, PhCaretLeft as Y, PhCaretRight as X, PhCaretUp as Ve, PhCheck as He, PhCircleNotch as Ue, PhCopy as We, PhDownloadSimple as Ge, PhExport as Ke, PhInfo as qe, PhLink as Je, PhLock as Ye, PhMonitor as Xe, PhPlus as Ze, PhTable as Z, PhUploadSimple as Qe, PhWarning as $e, PhWarningCircle as et, PhX as tt } from "@phosphor-icons/vue";
|
|
4
|
+
import { cellSelectionFeature as nt, tableFeatures as rt, useTable as it } from "@tanstack/vue-table";
|
|
5
|
+
import { AlertDialogCancel as Q, AlertDialogContent as at, AlertDialogDescription as $, AlertDialogOverlay as ot, AlertDialogPortal as st, AlertDialogRoot as ct, AlertDialogTitle as lt, CalendarCell as ut, CalendarCellTrigger as dt, CalendarGrid as ft, CalendarGridBody as pt, CalendarGridHead as mt, CalendarGridRow as ht, CalendarHeadCell as gt, CalendarHeader as _t, CalendarHeading as vt, CalendarNext as yt, CalendarPrev as bt, CalendarRoot as xt, ComboboxAnchor as St, ComboboxContent as Ct, ComboboxEmpty as wt, ComboboxInput as Tt, ComboboxItem as Et, ComboboxItemIndicator as Dt, ComboboxPortal as Ot, ComboboxRoot as kt, ComboboxViewport as At, ContextMenuContent as jt, ContextMenuItem as Mt, ContextMenuPortal as Nt, ContextMenuRoot as Pt, ContextMenuSeparator as Ft, ContextMenuTrigger as It, DialogClose as Lt, DialogContent as Rt, DialogDescription as zt, DialogOverlay as Bt, DialogPortal as Vt, DialogRoot as Ht, DialogTitle as Ut, DropdownMenuContent as Wt, DropdownMenuItem as Gt, DropdownMenuPortal as Kt, DropdownMenuRoot as qt, DropdownMenuSub as Jt, DropdownMenuSubContent as Yt, DropdownMenuSubTrigger as Xt, DropdownMenuTrigger as Zt, PopoverContent as Qt, PopoverPortal as $t, PopoverRoot as en, PopoverTrigger as tn, ToggleGroupItem as nn, ToggleGroupRoot as rn } from "reka-ui";
|
|
6
|
+
import { useVirtualizer as an } from "@tanstack/vue-virtual";
|
|
7
|
+
import { getDayOfWeek as on, getLocalTimeZone as sn, parseDate as cn, startOfWeek as ln, today as un } from "@internationalized/date";
|
|
8
|
+
//#region src/sheet/clipboard.ts
|
|
9
|
+
var dn = (e) => /[\t\n\r"]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e, fn = (e) => e.map((e) => e.map(dn).join(" ")).join("\n"), pn = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, "<br>"), mn = (e) => `<table><tbody>${e.map((e) => `<tr>${e.map((e) => `<td>${pn(e)}</td>`).join("")}</tr>`).join("")}</tbody></table>`;
|
|
10
|
+
function hn(e, t = " ") {
|
|
11
|
+
let n = [], r = [], i = "", a = !1;
|
|
12
|
+
for (let o = 0; o < e.length; o++) {
|
|
13
|
+
let s = e[o];
|
|
14
|
+
a ? s === "\"" ? e[o + 1] === "\"" ? (i += "\"", o++) : a = !1 : i += s : s === "\"" && i === "" ? a = !0 : s === t ? (r.push(i), i = "") : s === "\n" || s === "\r" ? (s === "\r" && e[o + 1] === "\n" && o++, r.push(i), n.push(r), r = [], i = "") : i += s;
|
|
15
|
+
}
|
|
16
|
+
return (i !== "" || r.length) && (r.push(i), n.push(r)), n.length > 1 && n[n.length - 1].every((e) => e === "") && n.pop(), n;
|
|
17
|
+
}
|
|
18
|
+
function gn(e) {
|
|
19
|
+
return typeof DOMParser > "u" ? [] : [...new DOMParser().parseFromString(e, "text/html").querySelectorAll("tr")].map((e) => [...e.querySelectorAll("td, th")].map((e) => (e.textContent ?? "").replace(/\u00a0/g, " ").trim()));
|
|
20
|
+
}
|
|
21
|
+
function _n(e) {
|
|
22
|
+
let t = e?.getData("text/plain") ?? "";
|
|
23
|
+
if (t) return hn(t);
|
|
24
|
+
let n = e?.getData("text/html") ?? "";
|
|
25
|
+
return n ? gn(n) : [];
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/sheet/parse.ts
|
|
29
|
+
var vn = (e, t, n) => {
|
|
30
|
+
let r = e.find((e) => xn(e.label, n) === xn(t, n) || String(e.value) === t.trim());
|
|
31
|
+
return r ? r.value : t.trim();
|
|
32
|
+
}, yn = (e) => e.split(/[;,]/).map((e) => e.trim()).filter(Boolean);
|
|
33
|
+
function bn(e) {
|
|
34
|
+
for (let t of e) {
|
|
35
|
+
let e = t.replace(/[\s%\u00a0A-Za-z₺€$£]/g, ""), n = e.lastIndexOf(","), r = e.lastIndexOf(".");
|
|
36
|
+
if (n >= 0 && r >= 0) return n > r ? "," : ".";
|
|
37
|
+
if (n >= 0 && /,\d{1,2}$/.test(e) && !/^\d{1,3}(,\d{3})+$/.test(e)) return ",";
|
|
38
|
+
if (r >= 0 && /\.\d{1,2}$/.test(e) && !/^\d{1,3}(\.\d{3})+$/.test(e)) return ".";
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
var xn = (e, t) => e.trim().toLocaleLowerCase(t).replace(/ı|i̇/g, "i"), Sn = (e, t, n) => {
|
|
43
|
+
let r = new Date(e, t - 1, n);
|
|
44
|
+
return r.getFullYear() === e && r.getMonth() === t - 1 && r.getDate() === n ? S(r) : null;
|
|
45
|
+
};
|
|
46
|
+
function Cn(e, t) {
|
|
47
|
+
let n = e.trim();
|
|
48
|
+
if (!n) return null;
|
|
49
|
+
let r = xn(n, t.locale);
|
|
50
|
+
if (r === "today" || r === xn(t.todayWord, t.locale)) return S(t.today);
|
|
51
|
+
let i = /^([+-])(\d+)d$/i.exec(n);
|
|
52
|
+
if (i) {
|
|
53
|
+
let e = new Date(t.today);
|
|
54
|
+
return e.setDate(e.getDate() + (i[1] === "-" ? -1 : 1) * Number(i[2])), S(e);
|
|
55
|
+
}
|
|
56
|
+
let a = /^(\d{4})-(\d{2})-(\d{2})/.exec(n);
|
|
57
|
+
if (a) return Sn(+a[1], +a[2], +a[3]);
|
|
58
|
+
let o = /^(\d{1,2})[./](\d{1,2})(?:[./](\d{2}|\d{4}))?$/.exec(n);
|
|
59
|
+
return o ? Sn(o[3] ? o[3].length === 2 ? 2e3 + +o[3] : +o[3] : t.today.getFullYear(), +o[2], +o[1]) : null;
|
|
60
|
+
}
|
|
61
|
+
function wn(e, t, r) {
|
|
62
|
+
let i = t.trim();
|
|
63
|
+
if (i === "") return null;
|
|
64
|
+
if (l[e.type].numeric || e.type === "star") return i.startsWith("=") ? i : n(r.locale, i) ?? i;
|
|
65
|
+
switch (e.type) {
|
|
66
|
+
case "date":
|
|
67
|
+
case "datetime": return Cn(i, r) ?? i;
|
|
68
|
+
case "select": return vn(e.options, i, r.locale);
|
|
69
|
+
case "multiselect": return yn(i).map((t) => vn(e.options, t, r.locale));
|
|
70
|
+
case "boolean": {
|
|
71
|
+
let e = xn(i, r.locale);
|
|
72
|
+
return [
|
|
73
|
+
"true",
|
|
74
|
+
"1",
|
|
75
|
+
"yes",
|
|
76
|
+
xn(r.yesWord, r.locale)
|
|
77
|
+
].includes(e) ? !0 : ![
|
|
78
|
+
"false",
|
|
79
|
+
"0",
|
|
80
|
+
"no",
|
|
81
|
+
xn(r.noWord, r.locale)
|
|
82
|
+
].includes(e) && i;
|
|
83
|
+
}
|
|
84
|
+
case "uppercase": return i.toLocaleUpperCase(r.locale);
|
|
85
|
+
case "lowercase": return i.toLocaleLowerCase(r.locale);
|
|
86
|
+
default: return i;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function Tn(e, t) {
|
|
90
|
+
return t == null ? "" : e.type === "select" ? ie(e.options, t) : Array.isArray(t) ? t.join(", ") : typeof t == "object" ? JSON.stringify(t) : String(t);
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/sheet/editors/useParseEnv.ts
|
|
94
|
+
function En() {
|
|
95
|
+
let { i18n: e, locale: t } = c();
|
|
96
|
+
return () => ({
|
|
97
|
+
locale: t,
|
|
98
|
+
today: /* @__PURE__ */ new Date(),
|
|
99
|
+
todayWord: e.t("date.today"),
|
|
100
|
+
yesWord: e.t("common.yes"),
|
|
101
|
+
noWord: e.t("common.no")
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function Dn(e) {
|
|
105
|
+
if (!e) return;
|
|
106
|
+
e.focus({ preventScroll: !0 });
|
|
107
|
+
let t = e.value.length;
|
|
108
|
+
e.setSelectionRange(t, t);
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/sheet/editors/NumberCell.vue?vue&type=script&setup=true&lang.ts
|
|
112
|
+
var On = { class: "dt-cell-editor is-number" }, kn = ["value", "aria-label"], An = {
|
|
113
|
+
key: 0,
|
|
114
|
+
class: "dt-ccy",
|
|
115
|
+
"aria-hidden": "true"
|
|
116
|
+
}, jn = /* @__PURE__ */ R({
|
|
117
|
+
__name: "NumberCell",
|
|
118
|
+
props: {
|
|
119
|
+
modelValue: {},
|
|
120
|
+
row: {},
|
|
121
|
+
column: {}
|
|
122
|
+
},
|
|
123
|
+
emits: ["update:modelValue"],
|
|
124
|
+
setup(e, { emit: t }) {
|
|
125
|
+
let n = e, r = t, i = En(), a = V(null), o = V(Tn(n.column, n.modelValue)), s = j(() => {
|
|
126
|
+
let e = n.column;
|
|
127
|
+
return e.type === "currency" && typeof e.currency == "string" ? e.currency : e.type === "percentage" ? "%" : "";
|
|
128
|
+
});
|
|
129
|
+
ye(() => Dn(a.value));
|
|
130
|
+
let c = () => {
|
|
131
|
+
o.value = a.value.value, r("update:modelValue", wn(n.column, o.value, i()));
|
|
132
|
+
};
|
|
133
|
+
return (t, n) => (B(), P("span", On, [F("input", {
|
|
134
|
+
ref_key: "el",
|
|
135
|
+
ref: a,
|
|
136
|
+
class: "dt-cell-input is-right",
|
|
137
|
+
type: "text",
|
|
138
|
+
inputmode: "decimal",
|
|
139
|
+
value: o.value,
|
|
140
|
+
"aria-label": e.column.header,
|
|
141
|
+
autocomplete: "off",
|
|
142
|
+
onInput: c
|
|
143
|
+
}, null, 40, kn), s.value ? (B(), P("span", An, U(s.value), 1)) : N("", !0)]));
|
|
144
|
+
}
|
|
145
|
+
}), Mn = /* @__PURE__ */ R({
|
|
146
|
+
__name: "OptionCell",
|
|
147
|
+
props: {
|
|
148
|
+
modelValue: {},
|
|
149
|
+
row: {},
|
|
150
|
+
column: {}
|
|
151
|
+
},
|
|
152
|
+
emits: ["update:modelValue"],
|
|
153
|
+
setup(e, { emit: t }) {
|
|
154
|
+
let n = e, r = t, { i18n: i } = c(), a = En(), s = j(() => n.column), l = j(() => {
|
|
155
|
+
let e = s.value;
|
|
156
|
+
return e.optionEnabled ? e.options.filter((t) => e.optionEnabled(t, n.row)) : e.options;
|
|
157
|
+
}), u = V(!0), d = V();
|
|
158
|
+
je(u, (e) => {
|
|
159
|
+
e && he(() => {
|
|
160
|
+
d.value = document.querySelector(".dt-cell-list[role=\"listbox\"]")?.id || void 0;
|
|
161
|
+
});
|
|
162
|
+
}, { immediate: !0 });
|
|
163
|
+
let f = V(Tn(n.column, n.modelValue)), p = V(null), m = () => p.value?.$el ?? null;
|
|
164
|
+
ye(() => void he(() => Dn(m())));
|
|
165
|
+
let h = (e) => {
|
|
166
|
+
f.value = e, r("update:modelValue", wn(n.column, e, a()));
|
|
167
|
+
}, g = (e) => {
|
|
168
|
+
e != null && (r("update:modelValue", e), f.value = ie(s.value.options, e), u.value = !1, he(() => Dn(m())));
|
|
169
|
+
}, _ = (e) => {
|
|
170
|
+
e.altKey && e.key === "ArrowDown" && (e.preventDefault(), u.value = !0);
|
|
171
|
+
}, v = (e) => o(e.o.tone, e.o.label);
|
|
172
|
+
return (t, n) => (B(), M(G(kt), {
|
|
173
|
+
open: u.value,
|
|
174
|
+
"onUpdate:open": n[0] ||= (e) => u.value = e,
|
|
175
|
+
class: "dt-cell-editor is-option",
|
|
176
|
+
"model-value": e.modelValue ?? void 0,
|
|
177
|
+
"reset-search-term-on-blur": !1,
|
|
178
|
+
"onUpdate:modelValue": g
|
|
179
|
+
}, {
|
|
180
|
+
default: q(() => [L(G(St), { class: "dt-cell-anchor" }, {
|
|
181
|
+
default: q(() => [L(G(Tt), {
|
|
182
|
+
ref_key: "input",
|
|
183
|
+
ref: p,
|
|
184
|
+
class: "dt-cell-input",
|
|
185
|
+
autocomplete: "off",
|
|
186
|
+
"aria-label": e.column.header,
|
|
187
|
+
"aria-controls": d.value,
|
|
188
|
+
"model-value": f.value,
|
|
189
|
+
"display-value": () => f.value,
|
|
190
|
+
"onUpdate:modelValue": h,
|
|
191
|
+
onKeydown: _
|
|
192
|
+
}, null, 8, [
|
|
193
|
+
"aria-label",
|
|
194
|
+
"aria-controls",
|
|
195
|
+
"model-value",
|
|
196
|
+
"display-value"
|
|
197
|
+
])]),
|
|
198
|
+
_: 1
|
|
199
|
+
}), L(G(Ot), null, {
|
|
200
|
+
default: q(() => [L(G(Ct), {
|
|
201
|
+
class: "dt-pop dt-cell-list dt-sheet-layer",
|
|
202
|
+
position: "popper",
|
|
203
|
+
align: "end",
|
|
204
|
+
"side-offset": 2,
|
|
205
|
+
"aria-label": e.column.header
|
|
206
|
+
}, {
|
|
207
|
+
default: q(() => [L(G(At), null, {
|
|
208
|
+
default: q(() => [(B(!0), P(A, null, xe(l.value, (e) => (B(), M(G(Et), {
|
|
209
|
+
key: String(e.value),
|
|
210
|
+
class: "dt-pop-item dt-cell-option",
|
|
211
|
+
value: e.value,
|
|
212
|
+
"text-value": e.label
|
|
213
|
+
}, {
|
|
214
|
+
default: q(() => [L(v, { o: e }, null, 8, ["o"]), n[1] ||= F("kbd", {
|
|
215
|
+
class: "dt-kbd dt-cell-option-enter",
|
|
216
|
+
"aria-hidden": "true"
|
|
217
|
+
}, "↵", -1)]),
|
|
218
|
+
_: 2
|
|
219
|
+
}, 1032, ["value", "text-value"]))), 128)), L(G(wt), { class: "dt-options-empty" }, {
|
|
220
|
+
default: q(() => [I(U(G(i).t("picker.noMatch")), 1)]),
|
|
221
|
+
_: 1
|
|
222
|
+
})]),
|
|
223
|
+
_: 1
|
|
224
|
+
})]),
|
|
225
|
+
_: 1
|
|
226
|
+
}, 8, ["aria-label"])]),
|
|
227
|
+
_: 1
|
|
228
|
+
})]),
|
|
229
|
+
_: 1
|
|
230
|
+
}, 8, ["open", "model-value"]));
|
|
231
|
+
}
|
|
232
|
+
}), Nn = ["value", "aria-label"], Pn = ["value", "aria-label"], Fn = /* @__PURE__ */ R({
|
|
233
|
+
__name: "TextCell",
|
|
234
|
+
props: {
|
|
235
|
+
modelValue: {},
|
|
236
|
+
row: {},
|
|
237
|
+
column: {}
|
|
238
|
+
},
|
|
239
|
+
emits: ["update:modelValue"],
|
|
240
|
+
setup(e, { emit: t }) {
|
|
241
|
+
let n = e, r = t, i = En(), a = V(null), o = V(Tn(n.column, n.modelValue));
|
|
242
|
+
ye(() => Dn(a.value));
|
|
243
|
+
let s = () => {
|
|
244
|
+
o.value = a.value.value, r("update:modelValue", wn(n.column, o.value, i()));
|
|
245
|
+
};
|
|
246
|
+
return (t, n) => e.column.type === "text" ? (B(), P("textarea", {
|
|
247
|
+
key: 0,
|
|
248
|
+
ref_key: "el",
|
|
249
|
+
ref: a,
|
|
250
|
+
class: "dt-cell-input is-multiline",
|
|
251
|
+
value: o.value,
|
|
252
|
+
"aria-label": e.column.header,
|
|
253
|
+
rows: "3",
|
|
254
|
+
onInput: s
|
|
255
|
+
}, null, 40, Nn)) : (B(), P("input", {
|
|
256
|
+
key: 1,
|
|
257
|
+
ref_key: "el",
|
|
258
|
+
ref: a,
|
|
259
|
+
class: "dt-cell-input",
|
|
260
|
+
type: "text",
|
|
261
|
+
value: o.value,
|
|
262
|
+
"aria-label": e.column.header,
|
|
263
|
+
autocomplete: "off",
|
|
264
|
+
onInput: s
|
|
265
|
+
}, null, 40, Pn));
|
|
266
|
+
}
|
|
267
|
+
}), In = { class: "dt-cell-editor is-date" }, Ln = ["value", "aria-label"], Rn = ["aria-label"], zn = {
|
|
268
|
+
key: 0,
|
|
269
|
+
class: "dt-cell-date-head"
|
|
270
|
+
}, Bn = /* @__PURE__ */ R({
|
|
271
|
+
__name: "DateCell",
|
|
272
|
+
props: {
|
|
273
|
+
modelValue: {},
|
|
274
|
+
row: {},
|
|
275
|
+
column: {}
|
|
276
|
+
},
|
|
277
|
+
emits: ["update:modelValue"],
|
|
278
|
+
setup(e, { emit: t }) {
|
|
279
|
+
let n = e, r = t, { i18n: i, locale: a } = c(), o = En(), s = x(a), l = new Intl.DateTimeFormat(a, {
|
|
280
|
+
weekday: "short",
|
|
281
|
+
month: "short",
|
|
282
|
+
day: "numeric"
|
|
283
|
+
}), u = V(null), d = V(!1), f = V(Tn(n.column, n.modelValue));
|
|
284
|
+
ye(() => Dn(u.value));
|
|
285
|
+
let p = sn(), h = un(p), g = on(ln(h, a), "en-US"), _ = (e) => {
|
|
286
|
+
try {
|
|
287
|
+
return typeof e == "string" && e ? cn(e.slice(0, 10)) : void 0;
|
|
288
|
+
} catch {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
}, v = j(() => _(n.modelValue)), y = j(() => {
|
|
292
|
+
let e = n.modelValue;
|
|
293
|
+
if (typeof e != "string" || !v.value) return null;
|
|
294
|
+
let t = m(e.slice(0, 10));
|
|
295
|
+
return {
|
|
296
|
+
day: l.format(t),
|
|
297
|
+
relative: s.relative(t)
|
|
298
|
+
};
|
|
299
|
+
}), b = () => {
|
|
300
|
+
f.value = u.value.value, r("update:modelValue", wn(n.column, f.value, o()));
|
|
301
|
+
}, S = (e) => {
|
|
302
|
+
if (!e) return;
|
|
303
|
+
let t = e.toString();
|
|
304
|
+
f.value = t, r("update:modelValue", t), d.value = !1;
|
|
305
|
+
}, C = (e) => {
|
|
306
|
+
e.preventDefault(), he(() => Dn(u.value));
|
|
307
|
+
}, ee = (e) => {
|
|
308
|
+
e.altKey && e.key === "ArrowDown" && (e.preventDefault(), d.value = !0);
|
|
309
|
+
};
|
|
310
|
+
return (t, n) => (B(), P("span", In, [F("input", {
|
|
311
|
+
ref_key: "el",
|
|
312
|
+
ref: u,
|
|
313
|
+
class: "dt-cell-input",
|
|
314
|
+
type: "text",
|
|
315
|
+
value: f.value,
|
|
316
|
+
"aria-label": e.column.header,
|
|
317
|
+
autocomplete: "off",
|
|
318
|
+
onInput: b,
|
|
319
|
+
onKeydown: ee
|
|
320
|
+
}, null, 40, Ln), L(G(en), {
|
|
321
|
+
open: d.value,
|
|
322
|
+
"onUpdate:open": n[1] ||= (e) => d.value = e
|
|
323
|
+
}, {
|
|
324
|
+
default: q(() => [L(G(tn), { "as-child": "" }, {
|
|
325
|
+
default: q(() => [F("button", {
|
|
326
|
+
type: "button",
|
|
327
|
+
class: "dt-cell-editor-btn",
|
|
328
|
+
tabindex: "-1",
|
|
329
|
+
"aria-label": G(i).t("type.date")
|
|
330
|
+
}, [L(G(J), {
|
|
331
|
+
size: 14,
|
|
332
|
+
"aria-hidden": "true"
|
|
333
|
+
})], 8, Rn)]),
|
|
334
|
+
_: 1
|
|
335
|
+
}), L(G($t), null, {
|
|
336
|
+
default: q(() => [L(G(Qt), {
|
|
337
|
+
class: "dt-pop dt-cell-date dt-sheet-layer",
|
|
338
|
+
align: "start",
|
|
339
|
+
"side-offset": 4,
|
|
340
|
+
onCloseAutoFocus: C
|
|
341
|
+
}, {
|
|
342
|
+
default: q(() => [y.value ? (B(), P("div", zn, [F("strong", null, U(y.value.day), 1), F("span", null, U(y.value.relative), 1)])) : N("", !0), L(G(xt), {
|
|
343
|
+
class: "dt-calendar",
|
|
344
|
+
"model-value": v.value,
|
|
345
|
+
locale: G(a),
|
|
346
|
+
"week-starts-on": G(g),
|
|
347
|
+
placeholder: v.value ?? G(h),
|
|
348
|
+
"onUpdate:modelValue": n[0] ||= (e) => S(e)
|
|
349
|
+
}, {
|
|
350
|
+
default: q(({ weekDays: e, grid: t }) => [L(G(_t), { class: "dt-cal-head" }, {
|
|
351
|
+
default: q(() => [
|
|
352
|
+
L(G(bt), { class: "dt-icon-btn-sm" }, {
|
|
353
|
+
default: q(() => [L(G(Y), {
|
|
354
|
+
size: 16,
|
|
355
|
+
"aria-hidden": "true"
|
|
356
|
+
})]),
|
|
357
|
+
_: 1
|
|
358
|
+
}),
|
|
359
|
+
L(G(vt), { class: "dt-cal-title" }),
|
|
360
|
+
L(G(yt), { class: "dt-icon-btn-sm" }, {
|
|
361
|
+
default: q(() => [L(G(X), {
|
|
362
|
+
size: 16,
|
|
363
|
+
"aria-hidden": "true"
|
|
364
|
+
})]),
|
|
365
|
+
_: 1
|
|
366
|
+
})
|
|
367
|
+
]),
|
|
368
|
+
_: 1
|
|
369
|
+
}), (B(!0), P(A, null, xe(t, (t) => (B(), M(G(ft), {
|
|
370
|
+
key: t.value.toString(),
|
|
371
|
+
class: "dt-cal-grid"
|
|
372
|
+
}, {
|
|
373
|
+
default: q(() => [L(G(mt), null, {
|
|
374
|
+
default: q(() => [L(G(ht), null, {
|
|
375
|
+
default: q(() => [(B(!0), P(A, null, xe(e, (e) => (B(), M(G(gt), {
|
|
376
|
+
key: e,
|
|
377
|
+
class: "dt-cal-dow"
|
|
378
|
+
}, {
|
|
379
|
+
default: q(() => [I(U(e), 1)]),
|
|
380
|
+
_: 2
|
|
381
|
+
}, 1024))), 128))]),
|
|
382
|
+
_: 2
|
|
383
|
+
}, 1024)]),
|
|
384
|
+
_: 2
|
|
385
|
+
}, 1024), L(G(pt), null, {
|
|
386
|
+
default: q(() => [(B(!0), P(A, null, xe(t.rows, (e, n) => (B(), M(G(ht), { key: n }, {
|
|
387
|
+
default: q(() => [(B(!0), P(A, null, xe(e, (e) => (B(), M(G(ut), {
|
|
388
|
+
key: e.toString(),
|
|
389
|
+
date: e,
|
|
390
|
+
class: "dt-cal-cell"
|
|
391
|
+
}, {
|
|
392
|
+
default: q(() => [L(G(dt), {
|
|
393
|
+
day: e,
|
|
394
|
+
month: t.value,
|
|
395
|
+
class: "dt-cal-day"
|
|
396
|
+
}, null, 8, ["day", "month"])]),
|
|
397
|
+
_: 2
|
|
398
|
+
}, 1032, ["date"]))), 128))]),
|
|
399
|
+
_: 2
|
|
400
|
+
}, 1024))), 128))]),
|
|
401
|
+
_: 2
|
|
402
|
+
}, 1024)]),
|
|
403
|
+
_: 2
|
|
404
|
+
}, 1024))), 128))]),
|
|
405
|
+
_: 1
|
|
406
|
+
}, 8, [
|
|
407
|
+
"model-value",
|
|
408
|
+
"locale",
|
|
409
|
+
"week-starts-on",
|
|
410
|
+
"placeholder"
|
|
411
|
+
])]),
|
|
412
|
+
_: 1
|
|
413
|
+
})]),
|
|
414
|
+
_: 1
|
|
415
|
+
})]),
|
|
416
|
+
_: 1
|
|
417
|
+
}, 8, ["open"])]));
|
|
418
|
+
}
|
|
419
|
+
}), Vn = Symbol("dt-sheet-editor"), Hn = () => fe(Vn, { seed: () => void 0 }), Un = /* @__PURE__ */ R({
|
|
420
|
+
__name: "MultiCell",
|
|
421
|
+
props: {
|
|
422
|
+
modelValue: {},
|
|
423
|
+
row: {},
|
|
424
|
+
column: {}
|
|
425
|
+
},
|
|
426
|
+
emits: ["update:modelValue"],
|
|
427
|
+
setup(e, { emit: t }) {
|
|
428
|
+
let n = e, r = t, { locale: i } = c(), a = (e) => e.toLocaleLowerCase(i), s = Hn(), l = j(() => n.column), u = j(() => Array.isArray(n.modelValue) ? n.modelValue : []), d = j(() => {
|
|
429
|
+
let e = l.value;
|
|
430
|
+
return e.options.filter((t) => u.value.includes(t.value) || !e.optionEnabled || e.optionEnabled(t, n.row));
|
|
431
|
+
}), f = V(s.seed() ?? ""), p = j(() => {
|
|
432
|
+
let e = a(f.value.trim());
|
|
433
|
+
return e ? d.value.filter((t) => a(t.label).includes(e)) : d.value;
|
|
434
|
+
}), m = V(!0), h = j({
|
|
435
|
+
get: () => m.value && p.value.length > 0,
|
|
436
|
+
set: (e) => m.value = e
|
|
437
|
+
}), g = V();
|
|
438
|
+
je(h, (e) => {
|
|
439
|
+
e && he(() => {
|
|
440
|
+
g.value = document.querySelector(".dt-cell-list[role=\"listbox\"]")?.id || void 0;
|
|
441
|
+
});
|
|
442
|
+
}, { immediate: !0 });
|
|
443
|
+
let _ = (e) => {
|
|
444
|
+
Array.isArray(e) && (r("update:modelValue", e.length ? e : null), f.value = "", he(b));
|
|
445
|
+
}, v = (e) => {
|
|
446
|
+
e.altKey && e.key === "ArrowDown" && (e.preventDefault(), h.value = !0);
|
|
447
|
+
}, y = V(null), b = () => Dn(y.value?.$el ?? null);
|
|
448
|
+
ye(() => void he(b));
|
|
449
|
+
let x = (e) => o(e.o.tone, e.o.label);
|
|
450
|
+
return (t, n) => (B(), M(G(kt), {
|
|
451
|
+
open: h.value,
|
|
452
|
+
"onUpdate:open": n[1] ||= (e) => h.value = e,
|
|
453
|
+
class: "dt-cell-editor is-multi",
|
|
454
|
+
multiple: "",
|
|
455
|
+
"model-value": u.value,
|
|
456
|
+
"reset-search-term-on-blur": !1,
|
|
457
|
+
"reset-search-term-on-select": !1,
|
|
458
|
+
"ignore-filter": "",
|
|
459
|
+
"onUpdate:modelValue": _
|
|
460
|
+
}, {
|
|
461
|
+
default: q(() => [L(G(St), { class: "dt-cell-anchor" }, {
|
|
462
|
+
default: q(() => [L(G(Tt), {
|
|
463
|
+
ref_key: "input",
|
|
464
|
+
ref: y,
|
|
465
|
+
modelValue: f.value,
|
|
466
|
+
"onUpdate:modelValue": n[0] ||= (e) => f.value = e,
|
|
467
|
+
class: "dt-cell-input",
|
|
468
|
+
"display-value": () => f.value,
|
|
469
|
+
autocomplete: "off",
|
|
470
|
+
"aria-label": e.column.header,
|
|
471
|
+
"aria-controls": g.value,
|
|
472
|
+
onKeydown: v
|
|
473
|
+
}, null, 8, [
|
|
474
|
+
"modelValue",
|
|
475
|
+
"display-value",
|
|
476
|
+
"aria-label",
|
|
477
|
+
"aria-controls"
|
|
478
|
+
])]),
|
|
479
|
+
_: 1
|
|
480
|
+
}), L(G(Ot), null, {
|
|
481
|
+
default: q(() => [L(G(Ct), {
|
|
482
|
+
class: "dt-pop dt-cell-list dt-sheet-layer",
|
|
483
|
+
position: "popper",
|
|
484
|
+
align: "start",
|
|
485
|
+
"side-offset": 2,
|
|
486
|
+
"aria-label": e.column.header
|
|
487
|
+
}, {
|
|
488
|
+
default: q(() => [L(G(At), null, {
|
|
489
|
+
default: q(() => [(B(!0), P(A, null, xe(p.value, (e) => (B(), M(G(Et), {
|
|
490
|
+
key: String(e.value),
|
|
491
|
+
class: "dt-pop-item dt-cell-option",
|
|
492
|
+
value: e.value,
|
|
493
|
+
"text-value": e.label
|
|
494
|
+
}, {
|
|
495
|
+
default: q(() => [
|
|
496
|
+
L(x, { o: e }, null, 8, ["o"]),
|
|
497
|
+
L(G(Dt), { class: "dt-cell-option-check" }, {
|
|
498
|
+
default: q(() => [L(G(He), {
|
|
499
|
+
size: 14,
|
|
500
|
+
"aria-hidden": "true"
|
|
501
|
+
})]),
|
|
502
|
+
_: 1
|
|
503
|
+
}),
|
|
504
|
+
n[2] ||= F("kbd", {
|
|
505
|
+
class: "dt-kbd dt-cell-option-enter",
|
|
506
|
+
"aria-hidden": "true"
|
|
507
|
+
}, "↵", -1)
|
|
508
|
+
]),
|
|
509
|
+
_: 2
|
|
510
|
+
}, 1032, ["value", "text-value"]))), 128))]),
|
|
511
|
+
_: 1
|
|
512
|
+
})]),
|
|
513
|
+
_: 1
|
|
514
|
+
}, 8, ["aria-label"])]),
|
|
515
|
+
_: 1
|
|
516
|
+
})]),
|
|
517
|
+
_: 1
|
|
518
|
+
}, 8, ["open", "model-value"]));
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/sheet/fill.ts
|
|
523
|
+
function Wn(e, t, n = !1) {
|
|
524
|
+
if (!e.length || t <= 0) return [];
|
|
525
|
+
let r = e.every((e) => typeof e == "number") ? e : null;
|
|
526
|
+
if (r && r.length >= 2) {
|
|
527
|
+
let e = r[1] - r[0];
|
|
528
|
+
if (r.every((t, n) => n === 0 || Math.abs(t - r[n - 1] - e) < 1e-9)) {
|
|
529
|
+
let i = n ? r[0] : r[r.length - 1], a = n ? -1 : 1;
|
|
530
|
+
return Array.from({ length: t }, (t, n) => Gn(i + a * e * (n + 1)));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
let i = e.length;
|
|
534
|
+
return Array.from({ length: t }, (t, r) => n ? e[(i - 1 - r % i + i) % i] : e[r % i]);
|
|
535
|
+
}
|
|
536
|
+
var Gn = (e) => Number(e.toPrecision(10));
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/sheet/import/model.ts
|
|
539
|
+
function Kn(e) {
|
|
540
|
+
return e == null ? "" : e instanceof Date ? Number.isNaN(e.getTime()) ? "" : S(e) : String(e).trim();
|
|
541
|
+
}
|
|
542
|
+
var qn = {
|
|
543
|
+
ı: "i",
|
|
544
|
+
i̇: "i",
|
|
545
|
+
ş: "s",
|
|
546
|
+
ğ: "g",
|
|
547
|
+
ç: "c",
|
|
548
|
+
ö: "o",
|
|
549
|
+
ü: "u",
|
|
550
|
+
â: "a",
|
|
551
|
+
î: "i",
|
|
552
|
+
û: "u"
|
|
553
|
+
}, Jn = (e) => e.toLocaleLowerCase("tr").replace(/ı|i̇|ş|ğ|ç|ö|ü|â|î|û/g, (e) => qn[e] ?? e).replace(/[^a-z0-9]+/g, " ").trim(), Yn = (e) => /^[-+]?[\d.,\s]*\d[\d.,\s]*%?$/.test(e);
|
|
554
|
+
function Xn(e) {
|
|
555
|
+
let t = -1, n = -1;
|
|
556
|
+
for (let r = 0; r < Math.min(e.length, 20); r++) {
|
|
557
|
+
let i = (e[r] ?? []).map(Kn).filter(Boolean);
|
|
558
|
+
i.length && (i.filter((e) => !Yn(e)).length * 2 < i.length || i.length > n && (n = i.length, t = r));
|
|
559
|
+
}
|
|
560
|
+
if (t >= 0) return t;
|
|
561
|
+
let r = e.findIndex((e) => (e ?? []).some((e) => Kn(e) !== ""));
|
|
562
|
+
return r < 0 ? 0 : r;
|
|
563
|
+
}
|
|
564
|
+
function Zn(e, t) {
|
|
565
|
+
let n = {}, r = t.map((e) => new Set([
|
|
566
|
+
e.header,
|
|
567
|
+
String(e.id),
|
|
568
|
+
...e.importAliases ?? []
|
|
569
|
+
].map(Jn)));
|
|
570
|
+
return e.forEach((e, i) => {
|
|
571
|
+
let a = Jn(e);
|
|
572
|
+
if (!a) return;
|
|
573
|
+
let o = t.filter((e, t) => r[t].has(a));
|
|
574
|
+
o.length === 1 && (n[i] = String(o[0].id));
|
|
575
|
+
}), n;
|
|
576
|
+
}
|
|
577
|
+
//#endregion
|
|
578
|
+
//#region src/sheet/ImportDialog.vue?vue&type=script&setup=true&lang.ts
|
|
579
|
+
var Qn = { class: "dt-import-head" }, $n = { class: "dt-import-body" }, er = ["aria-busy"], tr = { class: "dt-import-drop-icon" }, nr = { class: "dt-import-file" }, rr = { class: "dt-import-file-icon" }, ir = { class: "dt-import-file-text" }, ar = {
|
|
580
|
+
key: 0,
|
|
581
|
+
class: "dt-select dt-import-sheet"
|
|
582
|
+
}, or = ["aria-label"], sr = ["value"], cr = {
|
|
583
|
+
key: 1,
|
|
584
|
+
class: "dt-import-sheet-info"
|
|
585
|
+
}, lr = { class: "dt-import-match" }, ur = { class: "dt-import-match-label" }, dr = { class: "dt-import-key" }, fr = { class: "dt-mono" }, pr = ["value", "aria-label"], mr = { value: "" }, hr = ["value", "disabled"], gr = { class: "dt-select dt-import-headerrow" }, _r = { class: "dt-import-match-label" }, vr = ["value"], yr = ["value"], br = {
|
|
586
|
+
key: 0,
|
|
587
|
+
class: "dt-import-warn"
|
|
588
|
+
}, xr = { class: "dt-import-table" }, Sr = ["title"], Cr = { class: "dt-mono" }, wr = { class: "dt-import-muted" }, Tr = {
|
|
589
|
+
key: 1,
|
|
590
|
+
class: "dt-select dt-import-field"
|
|
591
|
+
}, Er = [
|
|
592
|
+
"value",
|
|
593
|
+
"aria-label",
|
|
594
|
+
"onChange"
|
|
595
|
+
], Dr = {
|
|
596
|
+
value: "",
|
|
597
|
+
disabled: ""
|
|
598
|
+
}, Or = ["value", "disabled"], kr = { class: "dt-import-preview" }, Ar = {
|
|
599
|
+
key: 0,
|
|
600
|
+
class: "dt-mono"
|
|
601
|
+
}, jr = { class: "dt-import-muted" }, Mr = {
|
|
602
|
+
key: 1,
|
|
603
|
+
class: "dt-import-summary"
|
|
604
|
+
}, Nr = { class: "dt-import-summary-line" }, Pr = {
|
|
605
|
+
key: 0,
|
|
606
|
+
class: "dt-import-newlist dt-mono"
|
|
607
|
+
}, Fr = {
|
|
608
|
+
key: 1,
|
|
609
|
+
class: "dt-check-row"
|
|
610
|
+
}, Ir = {
|
|
611
|
+
key: 2,
|
|
612
|
+
class: "dt-import-warn"
|
|
613
|
+
}, Lr = {
|
|
614
|
+
key: 2,
|
|
615
|
+
class: "dt-import-error",
|
|
616
|
+
role: "alert"
|
|
617
|
+
}, Rr = { class: "dt-import-foot" }, zr = ["disabled"], Br = "__skip__", Vr = /* @__PURE__ */ R({
|
|
618
|
+
__name: "ImportDialog",
|
|
619
|
+
props: /*@__PURE__*/ pe({
|
|
620
|
+
parseFile: { type: Function },
|
|
621
|
+
columns: {},
|
|
622
|
+
keyColumn: {},
|
|
623
|
+
entity: {},
|
|
624
|
+
maxRows: {},
|
|
625
|
+
rowCount: {},
|
|
626
|
+
inList: { type: Function },
|
|
627
|
+
parseEnv: { type: Function },
|
|
628
|
+
fmtEnv: {}
|
|
629
|
+
}, {
|
|
630
|
+
open: {
|
|
631
|
+
type: Boolean,
|
|
632
|
+
default: !1
|
|
633
|
+
},
|
|
634
|
+
openModifiers: {}
|
|
635
|
+
}),
|
|
636
|
+
emits: /*@__PURE__*/ pe(["apply"], ["update:open"]),
|
|
637
|
+
setup(e, { emit: t }) {
|
|
638
|
+
let n = e, r = t, i = Ee(e, "open"), { i18n: a, locale: o } = c(), s = j(() => n.columns.find((e) => e.id === n.keyColumn)), u = j(() => s.value?.header ?? n.keyColumn), d = j(() => n.columns.filter((e) => e.id !== n.keyColumn).map((e) => ({
|
|
639
|
+
id: e.id,
|
|
640
|
+
def: e,
|
|
641
|
+
editable: !!e.editable
|
|
642
|
+
}))), f = H(null), p = H(null), m = V(!1), h = V(!1), g = V(""), _ = V(0), v = V(0), y = V({}), b = V(null), x = V(!0), S = V(!1), C = V(!1), ee = V(null), w = j(() => p.value?.sheets[_.value]?.rows ?? []), T = j(() => (w.value[v.value] ?? []).map(Kn)), te = j(() => w.value.slice(v.value + 1).filter((e) => (e ?? []).some((e) => Kn(e) !== ""))), ne = j(() => Math.min(w.value.length, 20)), E = () => {
|
|
643
|
+
let e = Zn(T.value, n.columns), t = {}, r = null;
|
|
644
|
+
for (let [i, a] of Object.entries(e)) a === n.keyColumn ? r ??= Number(i) : d.value.find((e) => e.id === a)?.editable && (t[Number(i)] = a);
|
|
645
|
+
y.value = t, b.value = r, S.value = !1;
|
|
646
|
+
}, re = async (e) => {
|
|
647
|
+
f.value = e, h.value = !1, m.value = !0;
|
|
648
|
+
try {
|
|
649
|
+
let t = await n.parseFile(e);
|
|
650
|
+
p.value = t, _.value = 0, v.value = Xn(t.sheets[0]?.rows ?? []), E();
|
|
651
|
+
} catch (e) {
|
|
652
|
+
p.value = null, h.value = !0, g.value = e instanceof Error ? e.message : "";
|
|
653
|
+
} finally {
|
|
654
|
+
m.value = !1;
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
je(_, () => {
|
|
658
|
+
v.value = Xn(w.value), E();
|
|
659
|
+
});
|
|
660
|
+
let ie = (e) => {
|
|
661
|
+
v.value = e, E();
|
|
662
|
+
}, ae = (e) => {
|
|
663
|
+
let t = e.target.files?.[0];
|
|
664
|
+
t && re(t), e.target.value = "";
|
|
665
|
+
}, D = (e) => {
|
|
666
|
+
C.value = !1;
|
|
667
|
+
let t = e.dataTransfer?.files?.[0];
|
|
668
|
+
t && re(t);
|
|
669
|
+
}, se = () => {
|
|
670
|
+
f.value = null, p.value = null, h.value = !1, y.value = {}, b.value = null;
|
|
671
|
+
};
|
|
672
|
+
je(i, (e) => {
|
|
673
|
+
e || se();
|
|
674
|
+
});
|
|
675
|
+
let O = j(() => b.value === null ? [] : te.value.map((e) => Kn(e?.[b.value])).filter(Boolean)), k = j(() => {
|
|
676
|
+
if (!O.value.length) return null;
|
|
677
|
+
let e = /* @__PURE__ */ new Set(), t = 0, r = [];
|
|
678
|
+
for (let i of O.value) e.has(i) || (e.add(i), n.inList(i) ? t++ : r.push(i));
|
|
679
|
+
return {
|
|
680
|
+
updates: t,
|
|
681
|
+
news: r
|
|
682
|
+
};
|
|
683
|
+
}), ce = j(() => {
|
|
684
|
+
let e = k.value;
|
|
685
|
+
return !!e && x.value && n.rowCount + e.news.length > n.maxRows;
|
|
686
|
+
}), le = j(() => !!p.value && b.value !== null && !!k.value && !ce.value), ue = (e, t) => {
|
|
687
|
+
if (!l[t.type].numeric) return o;
|
|
688
|
+
let n = bn(te.value.slice(0, 50).map((t) => Kn(t?.[e])));
|
|
689
|
+
return n === "," ? "de" : n === "." ? "en" : o;
|
|
690
|
+
}, R = (e, t, r) => {
|
|
691
|
+
if (typeof r == "number" || typeof r == "boolean") return r;
|
|
692
|
+
if (r instanceof Date) return Kn(r);
|
|
693
|
+
let i = Kn(r);
|
|
694
|
+
return i === "" ? null : wn(t, i, n.parseEnv(ue(e, t)));
|
|
695
|
+
}, de = (e) => {
|
|
696
|
+
let t = te.value[0], r = Kn(t?.[e]), i = y.value[e], a = i ? n.columns.find((e) => e.id === i) : void 0;
|
|
697
|
+
if (!a || !r) return {
|
|
698
|
+
raw: r,
|
|
699
|
+
shown: null
|
|
700
|
+
};
|
|
701
|
+
let o = R(e, a, t?.[e]), s = oe(a, {}, o, n.fmtEnv);
|
|
702
|
+
return {
|
|
703
|
+
raw: r,
|
|
704
|
+
shown: s === r ? null : s
|
|
705
|
+
};
|
|
706
|
+
}, z = () => {
|
|
707
|
+
if (!le.value || b.value === null) return;
|
|
708
|
+
let e = [];
|
|
709
|
+
for (let t of te.value) {
|
|
710
|
+
let r = Kn(t?.[b.value]);
|
|
711
|
+
if (!r) continue;
|
|
712
|
+
let i = {};
|
|
713
|
+
for (let [e, r] of Object.entries(y.value)) {
|
|
714
|
+
if (!r || r === Br) continue;
|
|
715
|
+
let a = n.columns.find((e) => e.id === r), o = t?.[Number(e)];
|
|
716
|
+
a && Kn(o) !== "" && (i[r] = R(Number(e), a, o));
|
|
717
|
+
}
|
|
718
|
+
e.push({
|
|
719
|
+
key: r,
|
|
720
|
+
values: i
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
r("apply", {
|
|
724
|
+
rows: e,
|
|
725
|
+
addNew: x.value
|
|
726
|
+
}), i.value = !1;
|
|
727
|
+
}, fe = j(() => {
|
|
728
|
+
let e = p.value?.sheets[_.value];
|
|
729
|
+
return e ? a.t("import.sheetInfo", {
|
|
730
|
+
sheet: e.name,
|
|
731
|
+
count: te.value.length
|
|
732
|
+
}) : "";
|
|
733
|
+
});
|
|
734
|
+
return (t, n) => (B(), M(G(Ht), {
|
|
735
|
+
open: i.value,
|
|
736
|
+
"onUpdate:open": n[9] ||= (e) => i.value = e
|
|
737
|
+
}, {
|
|
738
|
+
default: q(() => [L(G(Vt), null, {
|
|
739
|
+
default: q(() => [L(G(Bt), { class: "dt-scrim" }), L(G(Rt), { class: "dt-dialog dt-import" }, {
|
|
740
|
+
default: q(() => [
|
|
741
|
+
F("div", Qn, [F("div", null, [L(G(Ut), { class: "dt-dialog-title" }, {
|
|
742
|
+
default: q(() => [I(U(G(a).t("import.title")), 1)]),
|
|
743
|
+
_: 1
|
|
744
|
+
}), L(G(zt), { class: "dt-dialog-body" }, {
|
|
745
|
+
default: q(() => [I(U(G(a).t("import.body", {
|
|
746
|
+
key: u.value,
|
|
747
|
+
entity: e.entity
|
|
748
|
+
})), 1)]),
|
|
749
|
+
_: 1
|
|
750
|
+
})]), L(G(Lt), {
|
|
751
|
+
class: "dt-btn dt-btn-icon dt-btn-ghost",
|
|
752
|
+
"aria-label": G(a).t("common.close")
|
|
753
|
+
}, {
|
|
754
|
+
default: q(() => [L(G(tt), {
|
|
755
|
+
size: 16,
|
|
756
|
+
"aria-hidden": "true"
|
|
757
|
+
})]),
|
|
758
|
+
_: 1
|
|
759
|
+
}, 8, ["aria-label"])]),
|
|
760
|
+
F("div", $n, [
|
|
761
|
+
F("input", {
|
|
762
|
+
ref_key: "input",
|
|
763
|
+
ref: ee,
|
|
764
|
+
type: "file",
|
|
765
|
+
class: "dt-sr-only",
|
|
766
|
+
accept: ".xlsx,.xls,.csv",
|
|
767
|
+
tabindex: "-1",
|
|
768
|
+
onChange: ae
|
|
769
|
+
}, null, 544),
|
|
770
|
+
p.value ? (B(), P(A, { key: 1 }, [
|
|
771
|
+
F("div", nr, [
|
|
772
|
+
F("span", rr, [L(G(Z), {
|
|
773
|
+
size: 18,
|
|
774
|
+
"aria-hidden": "true"
|
|
775
|
+
})]),
|
|
776
|
+
F("span", ir, [F("strong", null, U(f.value?.name), 1), p.value.sheets.length > 1 ? (B(), P("label", ar, [Ne(F("select", {
|
|
777
|
+
"onUpdate:modelValue": n[3] ||= (e) => _.value = e,
|
|
778
|
+
"aria-label": G(a).t("import.sheetInfo", {
|
|
779
|
+
sheet: "",
|
|
780
|
+
count: 0
|
|
781
|
+
})
|
|
782
|
+
}, [(B(!0), P(A, null, xe(p.value.sheets, (e, t) => (B(), P("option", {
|
|
783
|
+
key: t,
|
|
784
|
+
value: t
|
|
785
|
+
}, U(G(a).t("import.sheetInfo", {
|
|
786
|
+
sheet: e.name,
|
|
787
|
+
count: e.rows.length
|
|
788
|
+
})), 9, sr))), 128))], 8, or), [[ke, _.value]])])) : (B(), P("span", cr, U(fe.value), 1))]),
|
|
789
|
+
F("button", {
|
|
790
|
+
type: "button",
|
|
791
|
+
class: "dt-btn dt-btn-sm",
|
|
792
|
+
onClick: n[4] ||= (e) => ee.value?.click()
|
|
793
|
+
}, U(G(a).t("import.replace")), 1)
|
|
794
|
+
]),
|
|
795
|
+
F("div", lr, [
|
|
796
|
+
F("span", ur, U(G(a).t("import.matchBy")), 1),
|
|
797
|
+
F("span", dr, [L(G(Ye), {
|
|
798
|
+
size: 12,
|
|
799
|
+
"aria-hidden": "true"
|
|
800
|
+
}), F("span", fr, U(u.value), 1)]),
|
|
801
|
+
L(G(Fe), {
|
|
802
|
+
size: 14,
|
|
803
|
+
"aria-hidden": "true"
|
|
804
|
+
}),
|
|
805
|
+
F("label", { class: ge(["dt-select dt-import-keysel", { "is-missing": b.value === null }]) }, [F("select", {
|
|
806
|
+
value: b.value ?? "",
|
|
807
|
+
"aria-label": G(a).t("import.excelColumn"),
|
|
808
|
+
onChange: n[5] ||= (e) => b.value = e.target.value === "" ? null : Number(e.target.value)
|
|
809
|
+
}, [F("option", mr, U(G(a).t("import.excelColumn")), 1), (B(!0), P(A, null, xe(T.value, (e, t) => (B(), P("option", {
|
|
810
|
+
key: t,
|
|
811
|
+
value: t,
|
|
812
|
+
disabled: !e
|
|
813
|
+
}, U(e), 9, hr))), 128))], 40, pr)], 2),
|
|
814
|
+
n[10] ||= F("span", { class: "dt-import-spacer" }, null, -1),
|
|
815
|
+
F("label", gr, [F("span", _r, U(G(a).t("import.headerRow")), 1), F("select", {
|
|
816
|
+
value: v.value,
|
|
817
|
+
onChange: n[6] ||= (e) => ie(Number(e.target.value))
|
|
818
|
+
}, [(B(!0), P(A, null, xe(ne.value, (e) => (B(), P("option", {
|
|
819
|
+
key: e,
|
|
820
|
+
value: e - 1
|
|
821
|
+
}, U(G(a).t("import.headerRowN", { n: e })), 9, yr))), 128))], 40, vr)])
|
|
822
|
+
]),
|
|
823
|
+
b.value === null ? (B(), P("p", br, [L(G(et), {
|
|
824
|
+
size: 14,
|
|
825
|
+
"aria-hidden": "true"
|
|
826
|
+
}), I(" " + U(G(a).t("import.keyRequired", { key: u.value })), 1)])) : N("", !0),
|
|
827
|
+
F("table", xr, [
|
|
828
|
+
n[12] ||= F("colgroup", null, [
|
|
829
|
+
F("col", { class: "dt-import-col-excel" }),
|
|
830
|
+
F("col", { class: "dt-import-col-arrow" }),
|
|
831
|
+
F("col", { class: "dt-import-col-field" }),
|
|
832
|
+
F("col")
|
|
833
|
+
], -1),
|
|
834
|
+
F("thead", null, [F("tr", null, [
|
|
835
|
+
F("th", null, U(G(a).t("import.excelColumn")), 1),
|
|
836
|
+
n[11] ||= F("th", null, null, -1),
|
|
837
|
+
F("th", null, U(G(a).t("import.field")), 1),
|
|
838
|
+
F("th", null, U(G(a).t("import.firstValue")), 1)
|
|
839
|
+
])]),
|
|
840
|
+
F("tbody", null, [(B(!0), P(A, null, xe(T.value, (e, t) => (B(), P("tr", {
|
|
841
|
+
key: t,
|
|
842
|
+
class: ge({ "is-skipped": t !== b.value && (y.value[t] ?? "") === Br })
|
|
843
|
+
}, [
|
|
844
|
+
F("td", {
|
|
845
|
+
class: "dt-import-col",
|
|
846
|
+
title: e
|
|
847
|
+
}, U(e), 9, Sr),
|
|
848
|
+
F("td", null, [L(G(Ie), {
|
|
849
|
+
size: 14,
|
|
850
|
+
"aria-hidden": "true"
|
|
851
|
+
})]),
|
|
852
|
+
F("td", null, [t === b.value ? (B(), P(A, { key: 0 }, [F("span", Cr, U(u.value), 1), F("span", wr, U(G(a).t("import.matchKey")), 1)], 64)) : (B(), P("label", Tr, [F("select", {
|
|
853
|
+
value: y.value[t] ?? "",
|
|
854
|
+
"aria-label": G(a).t("import.field"),
|
|
855
|
+
onChange: (e) => y.value = {
|
|
856
|
+
...y.value,
|
|
857
|
+
[t]: e.target.value
|
|
858
|
+
}
|
|
859
|
+
}, [
|
|
860
|
+
F("option", Dr, U(G(a).t("import.chooseField")), 1),
|
|
861
|
+
F("option", { value: Br }, U(G(a).t("import.skip")), 1),
|
|
862
|
+
(B(!0), P(A, null, xe(d.value, (e) => (B(), P("option", {
|
|
863
|
+
key: e.id,
|
|
864
|
+
value: e.id,
|
|
865
|
+
disabled: !e.editable
|
|
866
|
+
}, U(e.def.header) + U(e.editable ? "" : ` · ${G(a).t("sheet.readOnly.badge")}`), 9, Or))), 128))
|
|
867
|
+
], 40, Er)]))]),
|
|
868
|
+
F("td", kr, [t === b.value ? (B(), P("span", Ar, U(de(t).raw), 1)) : de(t).shown ? (B(), P(A, { key: 1 }, [
|
|
869
|
+
F("span", jr, U(de(t).raw), 1),
|
|
870
|
+
L(G(Ie), {
|
|
871
|
+
size: 12,
|
|
872
|
+
"aria-hidden": "true"
|
|
873
|
+
}),
|
|
874
|
+
F("strong", null, U(de(t).shown), 1)
|
|
875
|
+
], 64)) : (B(), P("span", {
|
|
876
|
+
key: 2,
|
|
877
|
+
class: ge({ "dt-import-muted": !y.value[t] || y.value[t] === Br })
|
|
878
|
+
}, U(de(t).raw), 3))])
|
|
879
|
+
], 2))), 128))])
|
|
880
|
+
]),
|
|
881
|
+
k.value && b.value !== null ? (B(), P("div", Mr, [
|
|
882
|
+
F("div", Nr, [
|
|
883
|
+
L(G(qe), {
|
|
884
|
+
size: 16,
|
|
885
|
+
"aria-hidden": "true"
|
|
886
|
+
}),
|
|
887
|
+
F("span", null, U(G(a).t("import.summary", {
|
|
888
|
+
updates: k.value.updates,
|
|
889
|
+
news: k.value.news.length,
|
|
890
|
+
key: u.value
|
|
891
|
+
})), 1),
|
|
892
|
+
k.value.news.length ? (B(), P("button", {
|
|
893
|
+
key: 0,
|
|
894
|
+
type: "button",
|
|
895
|
+
class: "dt-link dt-import-link",
|
|
896
|
+
onClick: n[7] ||= (e) => S.value = !S.value
|
|
897
|
+
}, U(G(a).t("import.seeNew", { key: u.value })), 1)) : N("", !0)
|
|
898
|
+
]),
|
|
899
|
+
S.value ? (B(), P("div", Pr, U(k.value.news.join(", ")), 1)) : N("", !0),
|
|
900
|
+
k.value.news.length ? (B(), P("label", Fr, [Ne(F("input", {
|
|
901
|
+
"onUpdate:modelValue": n[8] ||= (e) => x.value = e,
|
|
902
|
+
type: "checkbox",
|
|
903
|
+
class: "dt-checkbox"
|
|
904
|
+
}, null, 512), [[Oe, x.value]]), I(" " + U(G(a).t("import.addNew", {
|
|
905
|
+
count: k.value.news.length,
|
|
906
|
+
key: u.value
|
|
907
|
+
})), 1)])) : N("", !0),
|
|
908
|
+
ce.value ? (B(), P("p", Ir, [L(G(et), {
|
|
909
|
+
size: 14,
|
|
910
|
+
"aria-hidden": "true"
|
|
911
|
+
}), I(" " + U(G(a).t("sheet.limitFile", {
|
|
912
|
+
count: e.rowCount + k.value.news.length,
|
|
913
|
+
max: e.maxRows
|
|
914
|
+
})), 1)])) : N("", !0)
|
|
915
|
+
])) : N("", !0)
|
|
916
|
+
], 64)) : (B(), P("button", {
|
|
917
|
+
key: 0,
|
|
918
|
+
type: "button",
|
|
919
|
+
class: ge(["dt-import-drop", {
|
|
920
|
+
"is-over": C.value,
|
|
921
|
+
"is-failed": h.value
|
|
922
|
+
}]),
|
|
923
|
+
"aria-busy": m.value ? "true" : void 0,
|
|
924
|
+
onClick: n[0] ||= (e) => ee.value?.click(),
|
|
925
|
+
onDragover: n[1] ||= Pe((e) => C.value = !0, ["prevent"]),
|
|
926
|
+
onDragleave: n[2] ||= (e) => C.value = !1,
|
|
927
|
+
onDrop: Pe(D, ["prevent"])
|
|
928
|
+
}, [F("span", tr, [L(G(Qe), {
|
|
929
|
+
size: 20,
|
|
930
|
+
"aria-hidden": "true"
|
|
931
|
+
})]), F("span", null, U(G(a).t("import.drop")), 1)], 42, er)),
|
|
932
|
+
h.value && !p.value ? (B(), P("p", Lr, [I(U(G(a).t("import.failed")) + " ", 1), g.value ? (B(), P(A, { key: 0 }, [I("· " + U(g.value), 1)], 64)) : N("", !0)])) : N("", !0)
|
|
933
|
+
]),
|
|
934
|
+
F("div", Rr, [L(G(Lt), { class: "dt-btn" }, {
|
|
935
|
+
default: q(() => [I(U(G(a).t("common.cancel")), 1)]),
|
|
936
|
+
_: 1
|
|
937
|
+
}), F("button", {
|
|
938
|
+
type: "button",
|
|
939
|
+
class: "dt-btn dt-btn-primary",
|
|
940
|
+
disabled: !le.value,
|
|
941
|
+
onClick: z
|
|
942
|
+
}, U(G(a).t("import.apply")), 9, zr)])
|
|
943
|
+
]),
|
|
944
|
+
_: 1
|
|
945
|
+
})]),
|
|
946
|
+
_: 1
|
|
947
|
+
})]),
|
|
948
|
+
_: 1
|
|
949
|
+
}, 8, ["open"]));
|
|
950
|
+
}
|
|
951
|
+
}), Hr = (e) => new Date(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate(), e.getUTCHours(), e.getUTCMinutes(), e.getUTCSeconds());
|
|
952
|
+
async function Ur(e, t) {
|
|
953
|
+
if (/\.csv$/i.test(e.name)) {
|
|
954
|
+
let t = (await e.text()).replace(/^\uFEFF/, ""), n = t.slice(0, t.search(/\r?\n|$/)), r = n.split(";").length > n.split(",").length ? ";" : ",";
|
|
955
|
+
return { sheets: [{
|
|
956
|
+
name: e.name.replace(/\.csv$/i, ""),
|
|
957
|
+
rows: hn(t, r)
|
|
958
|
+
}] };
|
|
959
|
+
}
|
|
960
|
+
if (!/\.xlsx$/i.test(e.name)) throw Error(t.t("import.xlsxOnly"));
|
|
961
|
+
let { default: n } = await import("read-excel-file/browser");
|
|
962
|
+
return { sheets: (await n(e)).map((e) => ({
|
|
963
|
+
name: e.sheet,
|
|
964
|
+
rows: e.data.map((e) => e.map((e) => e instanceof Date ? Hr(e) : e))
|
|
965
|
+
})) };
|
|
966
|
+
}
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/sheet/SaveErrorsDialog.vue?vue&type=script&setup=true&lang.ts
|
|
969
|
+
var Wr = { class: "dt-error-list" }, Gr = { class: "dt-error-no" }, Kr = { class: "dt-mono" }, qr = { class: "dt-error-msg" }, Jr = { class: "dt-dialog-actions" }, Yr = ["disabled"], Xr = /* @__PURE__ */ R({
|
|
970
|
+
__name: "SaveErrorsDialog",
|
|
971
|
+
props: /*@__PURE__*/ pe({
|
|
972
|
+
errors: {},
|
|
973
|
+
okRows: {}
|
|
974
|
+
}, {
|
|
975
|
+
open: {
|
|
976
|
+
type: Boolean,
|
|
977
|
+
default: !1
|
|
978
|
+
},
|
|
979
|
+
openModifiers: {}
|
|
980
|
+
}),
|
|
981
|
+
emits: /*@__PURE__*/ pe(["fix", "save"], ["update:open"]),
|
|
982
|
+
setup(e, { emit: t }) {
|
|
983
|
+
let n = t, r = Ee(e, "open"), { i18n: i } = c(), a = () => {
|
|
984
|
+
n("save"), r.value = !1;
|
|
985
|
+
};
|
|
986
|
+
return (t, o) => (B(), M(G(ct), {
|
|
987
|
+
open: r.value,
|
|
988
|
+
"onUpdate:open": o[1] ||= (e) => r.value = e
|
|
989
|
+
}, {
|
|
990
|
+
default: q(() => [L(G(st), null, {
|
|
991
|
+
default: q(() => [L(G(ot), { class: "dt-scrim" }), L(G(at), { class: "dt-dialog dt-dialog-errors" }, {
|
|
992
|
+
default: q(() => [
|
|
993
|
+
L(G(lt), { class: "dt-dialog-title" }, {
|
|
994
|
+
default: q(() => [I(U(G(i).t("sheet.errDialog.title", { count: e.errors.length })), 1)]),
|
|
995
|
+
_: 1
|
|
996
|
+
}),
|
|
997
|
+
L(G($), { class: "dt-dialog-body" }, {
|
|
998
|
+
default: q(() => [I(U(G(i).t("sheet.errDialog.body", { count: e.okRows })), 1)]),
|
|
999
|
+
_: 1
|
|
1000
|
+
}),
|
|
1001
|
+
F("ul", Wr, [(B(!0), P(A, null, xe(e.errors.slice(0, 8), (e) => (B(), P("li", {
|
|
1002
|
+
key: e.rowNo,
|
|
1003
|
+
class: "dt-error-row"
|
|
1004
|
+
}, [
|
|
1005
|
+
L(G(et), {
|
|
1006
|
+
size: 14,
|
|
1007
|
+
"aria-hidden": "true"
|
|
1008
|
+
}),
|
|
1009
|
+
F("span", Gr, U(e.rowNo), 1),
|
|
1010
|
+
F("span", Kr, U(e.key), 1),
|
|
1011
|
+
F("span", qr, U(e.message), 1)
|
|
1012
|
+
]))), 128))]),
|
|
1013
|
+
F("div", Jr, [L(G(Q), {
|
|
1014
|
+
class: "dt-btn",
|
|
1015
|
+
onClick: o[0] ||= (e) => n("fix")
|
|
1016
|
+
}, {
|
|
1017
|
+
default: q(() => [I(U(G(i).t("sheet.errDialog.fix")), 1)]),
|
|
1018
|
+
_: 1
|
|
1019
|
+
}), F("button", {
|
|
1020
|
+
type: "button",
|
|
1021
|
+
class: "dt-btn dt-btn-primary",
|
|
1022
|
+
disabled: !e.okRows,
|
|
1023
|
+
onClick: a
|
|
1024
|
+
}, U(G(i).t("sheet.errDialog.save", { count: e.okRows })), 9, Yr)])
|
|
1025
|
+
]),
|
|
1026
|
+
_: 1
|
|
1027
|
+
})]),
|
|
1028
|
+
_: 1
|
|
1029
|
+
})]),
|
|
1030
|
+
_: 1
|
|
1031
|
+
}, 8, ["open"]));
|
|
1032
|
+
}
|
|
1033
|
+
}), Zr = { class: "dt-kbd" }, Qr = { class: "dt-kbd" }, $r = { class: "dt-kbd" }, ei = { class: "dt-kbd" }, ti = { class: "dt-kbd" }, ni = { class: "dt-kbd" }, ri = ["href"], ii = /* @__PURE__ */ R({
|
|
1034
|
+
__name: "SheetMenu",
|
|
1035
|
+
props: {
|
|
1036
|
+
sheet: {},
|
|
1037
|
+
entity: {},
|
|
1038
|
+
href: {},
|
|
1039
|
+
readOnly: { type: Boolean }
|
|
1040
|
+
},
|
|
1041
|
+
setup(e) {
|
|
1042
|
+
let { i18n: t } = c(), n = {
|
|
1043
|
+
cut: h ? "⌘X" : "Ctrl+X",
|
|
1044
|
+
copy: h ? "⌘C" : "Ctrl+C",
|
|
1045
|
+
paste: h ? "⌘V" : "Ctrl+V",
|
|
1046
|
+
clear: "Del"
|
|
1047
|
+
};
|
|
1048
|
+
return (r, i) => (B(), M(G(Nt), null, {
|
|
1049
|
+
default: q(() => [L(G(jt), { class: "dt-menu dt-sheet-menu" }, {
|
|
1050
|
+
default: q(() => [
|
|
1051
|
+
L(G(Mt), {
|
|
1052
|
+
class: "dt-menu-item",
|
|
1053
|
+
disabled: e.readOnly,
|
|
1054
|
+
onSelect: i[0] ||= (t) => e.sheet.copyToClipboard(!0)
|
|
1055
|
+
}, {
|
|
1056
|
+
default: q(() => [I(U(G(t).t("sheet.menu.cut")) + " ", 1), F("kbd", Zr, U(n.cut), 1)]),
|
|
1057
|
+
_: 1
|
|
1058
|
+
}, 8, ["disabled"]),
|
|
1059
|
+
L(G(Mt), {
|
|
1060
|
+
class: "dt-menu-item",
|
|
1061
|
+
onSelect: i[1] ||= (t) => e.sheet.copyToClipboard(!1)
|
|
1062
|
+
}, {
|
|
1063
|
+
default: q(() => [I(U(G(t).t("sheet.menu.copy")) + " ", 1), F("kbd", Qr, U(n.copy), 1)]),
|
|
1064
|
+
_: 1
|
|
1065
|
+
}),
|
|
1066
|
+
L(G(Mt), {
|
|
1067
|
+
class: "dt-menu-item",
|
|
1068
|
+
disabled: e.readOnly,
|
|
1069
|
+
onSelect: i[2] ||= (t) => e.sheet.pasteFromClipboard()
|
|
1070
|
+
}, {
|
|
1071
|
+
default: q(() => [I(U(G(t).t("sheet.menu.paste")) + " ", 1), F("kbd", $r, U(n.paste), 1)]),
|
|
1072
|
+
_: 1
|
|
1073
|
+
}, 8, ["disabled"]),
|
|
1074
|
+
L(G(Mt), {
|
|
1075
|
+
class: "dt-menu-item",
|
|
1076
|
+
disabled: e.readOnly,
|
|
1077
|
+
onSelect: i[3] ||= (t) => e.sheet.fillDown()
|
|
1078
|
+
}, {
|
|
1079
|
+
default: q(() => [I(U(G(t).t("sheet.menu.fillDown")) + " ", 1), F("kbd", ei, U(G(ne)), 1)]),
|
|
1080
|
+
_: 1
|
|
1081
|
+
}, 8, ["disabled"]),
|
|
1082
|
+
L(G(Mt), {
|
|
1083
|
+
class: "dt-menu-item",
|
|
1084
|
+
disabled: e.readOnly,
|
|
1085
|
+
onSelect: i[4] ||= (t) => e.sheet.clearCells()
|
|
1086
|
+
}, {
|
|
1087
|
+
default: q(() => [I(U(G(t).t("sheet.menu.clear")) + " ", 1), F("kbd", ti, U(n.clear), 1)]),
|
|
1088
|
+
_: 1
|
|
1089
|
+
}, 8, ["disabled"]),
|
|
1090
|
+
L(G(Ft), { class: "dt-menu-sep" }),
|
|
1091
|
+
L(G(Mt), {
|
|
1092
|
+
class: "dt-menu-item",
|
|
1093
|
+
disabled: e.readOnly,
|
|
1094
|
+
onSelect: i[5] ||= (t) => e.sheet.insertRow("above")
|
|
1095
|
+
}, {
|
|
1096
|
+
default: q(() => [I(U(G(t).t("sheet.menu.insertAbove")), 1)]),
|
|
1097
|
+
_: 1
|
|
1098
|
+
}, 8, ["disabled"]),
|
|
1099
|
+
L(G(Mt), {
|
|
1100
|
+
class: "dt-menu-item",
|
|
1101
|
+
disabled: e.readOnly,
|
|
1102
|
+
onSelect: i[6] ||= (t) => e.sheet.insertRow("below")
|
|
1103
|
+
}, {
|
|
1104
|
+
default: q(() => [I(U(G(t).t("sheet.menu.insertBelow")), 1)]),
|
|
1105
|
+
_: 1
|
|
1106
|
+
}, 8, ["disabled"]),
|
|
1107
|
+
L(G(Mt), {
|
|
1108
|
+
class: "dt-menu-item",
|
|
1109
|
+
disabled: e.readOnly,
|
|
1110
|
+
onSelect: i[7] ||= (t) => e.sheet.removeSelectedRows()
|
|
1111
|
+
}, {
|
|
1112
|
+
default: q(() => [I(U(G(t).t("sheet.menu.remove")) + " ", 1), F("kbd", ni, U(G(f)), 1)]),
|
|
1113
|
+
_: 1
|
|
1114
|
+
}, 8, ["disabled"]),
|
|
1115
|
+
e.href ? (B(), P(A, { key: 0 }, [L(G(Ft), { class: "dt-menu-sep" }), L(G(Mt), {
|
|
1116
|
+
"as-child": "",
|
|
1117
|
+
class: "dt-menu-item"
|
|
1118
|
+
}, {
|
|
1119
|
+
default: q(() => [F("a", {
|
|
1120
|
+
href: e.href,
|
|
1121
|
+
target: "_blank",
|
|
1122
|
+
rel: "noopener"
|
|
1123
|
+
}, U(G(t).t("sheet.menu.open", { entity: e.entity })), 9, ri)]),
|
|
1124
|
+
_: 1
|
|
1125
|
+
})], 64)) : N("", !0)
|
|
1126
|
+
]),
|
|
1127
|
+
_: 1
|
|
1128
|
+
})]),
|
|
1129
|
+
_: 1
|
|
1130
|
+
}));
|
|
1131
|
+
}
|
|
1132
|
+
}), ai = /* @__PURE__ */ new WeakMap(), oi = (e) => {
|
|
1133
|
+
if (!e.href) return e;
|
|
1134
|
+
let t = ai.get(e);
|
|
1135
|
+
return t || ai.set(e, t = {
|
|
1136
|
+
...e,
|
|
1137
|
+
href: void 0
|
|
1138
|
+
}), t;
|
|
1139
|
+
}, si = R({
|
|
1140
|
+
name: "DtSheetRow",
|
|
1141
|
+
props: {
|
|
1142
|
+
row: {
|
|
1143
|
+
type: Object,
|
|
1144
|
+
required: !0
|
|
1145
|
+
},
|
|
1146
|
+
index: {
|
|
1147
|
+
type: Number,
|
|
1148
|
+
required: !0
|
|
1149
|
+
},
|
|
1150
|
+
rowNo: {
|
|
1151
|
+
type: Number,
|
|
1152
|
+
required: !0
|
|
1153
|
+
},
|
|
1154
|
+
columns: {
|
|
1155
|
+
type: Array,
|
|
1156
|
+
required: !0
|
|
1157
|
+
},
|
|
1158
|
+
env: {
|
|
1159
|
+
type: Object,
|
|
1160
|
+
required: !0
|
|
1161
|
+
},
|
|
1162
|
+
keyColumn: {
|
|
1163
|
+
type: String,
|
|
1164
|
+
required: !0
|
|
1165
|
+
},
|
|
1166
|
+
read: {
|
|
1167
|
+
type: Function,
|
|
1168
|
+
required: !0
|
|
1169
|
+
},
|
|
1170
|
+
original: {
|
|
1171
|
+
type: Function,
|
|
1172
|
+
required: !0
|
|
1173
|
+
},
|
|
1174
|
+
canEdit: {
|
|
1175
|
+
type: Function,
|
|
1176
|
+
required: !0
|
|
1177
|
+
},
|
|
1178
|
+
current: {
|
|
1179
|
+
type: Function,
|
|
1180
|
+
required: !0
|
|
1181
|
+
},
|
|
1182
|
+
editorFor: {
|
|
1183
|
+
type: Function,
|
|
1184
|
+
required: !0
|
|
1185
|
+
},
|
|
1186
|
+
draft: {
|
|
1187
|
+
type: Map,
|
|
1188
|
+
default: void 0
|
|
1189
|
+
},
|
|
1190
|
+
issues: {
|
|
1191
|
+
type: Map,
|
|
1192
|
+
default: void 0
|
|
1193
|
+
},
|
|
1194
|
+
isNew: {
|
|
1195
|
+
type: Boolean,
|
|
1196
|
+
default: !1
|
|
1197
|
+
},
|
|
1198
|
+
rowError: {
|
|
1199
|
+
type: String,
|
|
1200
|
+
default: void 0
|
|
1201
|
+
},
|
|
1202
|
+
active: {
|
|
1203
|
+
type: String,
|
|
1204
|
+
default: null
|
|
1205
|
+
},
|
|
1206
|
+
selection: {
|
|
1207
|
+
type: Object,
|
|
1208
|
+
default: null
|
|
1209
|
+
},
|
|
1210
|
+
handleAt: {
|
|
1211
|
+
type: String,
|
|
1212
|
+
default: null
|
|
1213
|
+
},
|
|
1214
|
+
fill: {
|
|
1215
|
+
type: Object,
|
|
1216
|
+
default: null
|
|
1217
|
+
},
|
|
1218
|
+
found: {
|
|
1219
|
+
type: Set,
|
|
1220
|
+
default: void 0
|
|
1221
|
+
},
|
|
1222
|
+
editing: {
|
|
1223
|
+
type: Object,
|
|
1224
|
+
default: null
|
|
1225
|
+
},
|
|
1226
|
+
tipBelow: {
|
|
1227
|
+
type: Boolean,
|
|
1228
|
+
default: !1
|
|
1229
|
+
},
|
|
1230
|
+
gutter: {
|
|
1231
|
+
type: Boolean,
|
|
1232
|
+
default: !0
|
|
1233
|
+
},
|
|
1234
|
+
uid: {
|
|
1235
|
+
type: String,
|
|
1236
|
+
default: "dt"
|
|
1237
|
+
},
|
|
1238
|
+
style: {
|
|
1239
|
+
type: Object,
|
|
1240
|
+
default: void 0
|
|
1241
|
+
}
|
|
1242
|
+
},
|
|
1243
|
+
emits: ["edit-value", "use-suggestion"],
|
|
1244
|
+
setup(e, { emit: n }) {
|
|
1245
|
+
let r = (t, n) => e.env.i18n.t(t, n), i = (i, o) => {
|
|
1246
|
+
let s = i.def, c = i.id, l = e.read(e.row, s), u = e.canEdit(e.row, s), f = e.issues?.get(c), p = e.draft?.has(c) ?? !1, m = e.active === c, h = e.selection, g = !!h && o >= h.from && o <= h.to, _ = e.fill, v = !!_ && o >= _.from && o <= _.to, y = e.editing?.columnId === c ? e.editing : null, b = c === e.keyColumn, x;
|
|
1247
|
+
if (y?.inCell) {
|
|
1248
|
+
let t = e.editorFor(s);
|
|
1249
|
+
x = z(t, {
|
|
1250
|
+
modelValue: y.value,
|
|
1251
|
+
row: e.current(e.row),
|
|
1252
|
+
column: s,
|
|
1253
|
+
"onUpdate:modelValue": (e) => n("edit-value", e)
|
|
1254
|
+
});
|
|
1255
|
+
} else x = y ? z("span", { class: "dt-cell-content" }, Tn(s, y.value)) : f?.level === "error" && T(l) && f.message === r("sheet.required") ? z("span", { class: "dt-cell-content dt-cell-required" }, f.message) : z("span", { class: "dt-cell-content" }, [t(oi(s), e.row, l, e.env)]);
|
|
1256
|
+
let S = [x];
|
|
1257
|
+
b && e.rowError && !y && S.push(z("span", {
|
|
1258
|
+
class: "dt-cell-tip is-error",
|
|
1259
|
+
role: "tooltip"
|
|
1260
|
+
}, e.rowError)), !u && !b && S.push(z(Ye, {
|
|
1261
|
+
size: 12,
|
|
1262
|
+
class: "dt-cell-lock",
|
|
1263
|
+
role: "img",
|
|
1264
|
+
"aria-label": r("sheet.readOnly.badge")
|
|
1265
|
+
}));
|
|
1266
|
+
let C = f ? `${e.uid}-${e.rowNo}-${o}` : void 0;
|
|
1267
|
+
return f && S.push(z("span", {
|
|
1268
|
+
id: C,
|
|
1269
|
+
class: ["dt-cell-tip", `is-${f.level}`],
|
|
1270
|
+
role: "tooltip"
|
|
1271
|
+
}, [f.message, f.suggest ? z("button", {
|
|
1272
|
+
type: "button",
|
|
1273
|
+
class: "dt-cell-tip-btn",
|
|
1274
|
+
tabindex: -1,
|
|
1275
|
+
onClick: () => n("use-suggestion", s, f.suggest.value)
|
|
1276
|
+
}, r("sheet.useOption", { option: f.suggest.label })) : null])), e.handleAt === c && !y && S.push(z("span", {
|
|
1277
|
+
class: "dt-fill-handle",
|
|
1278
|
+
"aria-hidden": "true"
|
|
1279
|
+
})), z("div", {
|
|
1280
|
+
class: [
|
|
1281
|
+
"dt-cell",
|
|
1282
|
+
`is-${d(s)}`,
|
|
1283
|
+
{
|
|
1284
|
+
"is-numeric": a(s.type),
|
|
1285
|
+
"is-key": b,
|
|
1286
|
+
"is-new": b && e.isNew,
|
|
1287
|
+
"is-readonly": !u,
|
|
1288
|
+
"is-active": m,
|
|
1289
|
+
"is-selected": g,
|
|
1290
|
+
"is-edge-l": g && o === h.from,
|
|
1291
|
+
"is-edge-r": g && o === h.to,
|
|
1292
|
+
"is-edge-t": g && h.top,
|
|
1293
|
+
"is-edge-b": g && h.bottom,
|
|
1294
|
+
"is-fill": v,
|
|
1295
|
+
"is-fill-end": v && _.last,
|
|
1296
|
+
"is-match": e.found?.has(c) ?? !1,
|
|
1297
|
+
"is-editing": !!y,
|
|
1298
|
+
"is-changed": p,
|
|
1299
|
+
"is-error": f?.level === "error" || b && !!e.rowError,
|
|
1300
|
+
"is-warning": f?.level === "warning",
|
|
1301
|
+
"is-tip-below": e.tipBelow,
|
|
1302
|
+
"is-pinned-start": i.pinned === "start",
|
|
1303
|
+
"is-pinned-end": i.pinned === "end",
|
|
1304
|
+
"is-pin-edge": i.pinEdge
|
|
1305
|
+
}
|
|
1306
|
+
],
|
|
1307
|
+
style: {
|
|
1308
|
+
...i.pinned === "start" ? { left: `var(${i.offsetVar})` } : i.pinned === "end" ? { right: `var(${i.offsetVar})` } : null,
|
|
1309
|
+
...le(s, l)
|
|
1310
|
+
},
|
|
1311
|
+
role: "gridcell",
|
|
1312
|
+
tabindex: m ? 0 : -1,
|
|
1313
|
+
"aria-readonly": u ? void 0 : "true",
|
|
1314
|
+
"aria-selected": g ? "true" : void 0,
|
|
1315
|
+
"aria-describedby": C,
|
|
1316
|
+
"aria-invalid": f?.level === "error" ? "true" : void 0,
|
|
1317
|
+
"data-col": c,
|
|
1318
|
+
"data-dt-tip": p && !f && !y && !e.isNew ? r("sheet.was", { value: oe(s, e.row, e.original(e.row, s), e.env) }) : void 0
|
|
1319
|
+
}, S);
|
|
1320
|
+
}, o = () => {
|
|
1321
|
+
let t = !!e.rowError;
|
|
1322
|
+
for (let n of e.issues?.values() ?? []) n.level === "error" && (t = !0);
|
|
1323
|
+
let n = !!e.draft?.size;
|
|
1324
|
+
return z("div", {
|
|
1325
|
+
class: [
|
|
1326
|
+
"dt-cell",
|
|
1327
|
+
"dt-gutter",
|
|
1328
|
+
"is-pinned-start"
|
|
1329
|
+
],
|
|
1330
|
+
style: { left: "0px" },
|
|
1331
|
+
role: "rowheader",
|
|
1332
|
+
"data-dt-tip": e.rowError
|
|
1333
|
+
}, [t ? z(et, {
|
|
1334
|
+
size: 13,
|
|
1335
|
+
class: "dt-mark is-error",
|
|
1336
|
+
role: "img",
|
|
1337
|
+
"aria-label": r("sheet.hasErrors")
|
|
1338
|
+
}) : e.isNew ? z(Ze, {
|
|
1339
|
+
size: 13,
|
|
1340
|
+
class: "dt-mark is-new",
|
|
1341
|
+
role: "img",
|
|
1342
|
+
"aria-label": r("sheet.addedRow")
|
|
1343
|
+
}) : n ? z("span", {
|
|
1344
|
+
class: "dt-mark is-changed",
|
|
1345
|
+
role: "img",
|
|
1346
|
+
"aria-label": r("sheet.changed")
|
|
1347
|
+
}) : null, z("span", { class: "dt-gutter-no" }, String(e.rowNo))]);
|
|
1348
|
+
};
|
|
1349
|
+
return () => {
|
|
1350
|
+
let t = new Map(e.columns.map((e, t) => [e.id, t]));
|
|
1351
|
+
return z("div", {
|
|
1352
|
+
class: ["dt-row", { "is-active-row": e.active !== null }],
|
|
1353
|
+
role: "row",
|
|
1354
|
+
"aria-rowindex": e.index + 2,
|
|
1355
|
+
"data-index": e.index,
|
|
1356
|
+
style: e.style
|
|
1357
|
+
}, [e.gutter ? o() : null, ..._(e.columns, (e) => i(e, t.get(e.id)))]);
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
}), ci = [
|
|
1361
|
+
"aria-label",
|
|
1362
|
+
"aria-rowcount",
|
|
1363
|
+
"aria-colcount",
|
|
1364
|
+
"aria-busy",
|
|
1365
|
+
"aria-readonly",
|
|
1366
|
+
"data-density"
|
|
1367
|
+
], li = {
|
|
1368
|
+
class: "dt-head",
|
|
1369
|
+
role: "row",
|
|
1370
|
+
"aria-rowindex": "1"
|
|
1371
|
+
}, ui = {
|
|
1372
|
+
key: 0,
|
|
1373
|
+
class: "dt-head-cell dt-gutter is-pinned-start",
|
|
1374
|
+
style: { left: "0px" },
|
|
1375
|
+
role: "columnheader"
|
|
1376
|
+
}, di = ["aria-sort", "data-col"], fi = [
|
|
1377
|
+
"data-dt-tip",
|
|
1378
|
+
"aria-describedby",
|
|
1379
|
+
"onClick"
|
|
1380
|
+
], pi = { class: "dt-head-text" }, mi = ["aria-label"], hi = {
|
|
1381
|
+
key: 1,
|
|
1382
|
+
class: "dt-head-unit"
|
|
1383
|
+
}, gi = {
|
|
1384
|
+
key: 2,
|
|
1385
|
+
class: "dt-head-sort",
|
|
1386
|
+
"aria-hidden": "true"
|
|
1387
|
+
}, _i = {
|
|
1388
|
+
key: 0,
|
|
1389
|
+
class: "dt-head-sort-index"
|
|
1390
|
+
}, vi = ["id"], yi = ["onMousedown", "onTouchstartPassive"], bi = {
|
|
1391
|
+
key: 0,
|
|
1392
|
+
class: "dt-resize-badge"
|
|
1393
|
+
}, xi = ["data-index"], Si = {
|
|
1394
|
+
key: 1,
|
|
1395
|
+
class: "dt-body-state"
|
|
1396
|
+
}, Ci = 56, wi = 24, Ti = 12, Ei = /* @__PURE__ */ R({
|
|
1397
|
+
__name: "SheetGrid",
|
|
1398
|
+
props: {
|
|
1399
|
+
sheet: {},
|
|
1400
|
+
layout: {},
|
|
1401
|
+
rows: {},
|
|
1402
|
+
density: { default: "compact" },
|
|
1403
|
+
label: {},
|
|
1404
|
+
loading: {
|
|
1405
|
+
type: Boolean,
|
|
1406
|
+
default: !1
|
|
1407
|
+
},
|
|
1408
|
+
skeleton: {
|
|
1409
|
+
type: Boolean,
|
|
1410
|
+
default: !1
|
|
1411
|
+
},
|
|
1412
|
+
verticalLines: {
|
|
1413
|
+
type: Boolean,
|
|
1414
|
+
default: !0
|
|
1415
|
+
},
|
|
1416
|
+
keyColumn: {},
|
|
1417
|
+
found: { default: null },
|
|
1418
|
+
readOnly: {
|
|
1419
|
+
type: Boolean,
|
|
1420
|
+
default: !1
|
|
1421
|
+
},
|
|
1422
|
+
sort: {},
|
|
1423
|
+
entity: {},
|
|
1424
|
+
phone: {
|
|
1425
|
+
type: Boolean,
|
|
1426
|
+
default: !1
|
|
1427
|
+
}
|
|
1428
|
+
},
|
|
1429
|
+
setup(e, { expose: t }) {
|
|
1430
|
+
let n = e, r = c(), i = K(), o = V(null), l = V(null), u = n.layout, f = n.sheet, p = f.table, m = f.store, h = m.keyOf, g = typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches, _ = j(() => g && n.density === "compact" ? "standard" : n.density), y = j(() => n.phone ? 0 : Ci);
|
|
1431
|
+
Me(() => {
|
|
1432
|
+
let e = o.value;
|
|
1433
|
+
if (!e) return;
|
|
1434
|
+
let t = y.value;
|
|
1435
|
+
e.style.setProperty("--cols", `${t ? `${t}px ` : ""}${u.colsVar.value}`), e.style.setProperty("--dt-min-w", `${u.minWidth.value + t}px`);
|
|
1436
|
+
let n = new Set(u.start.value.map((e) => e.offsetVar));
|
|
1437
|
+
for (let [r, i] of Object.entries(u.offsetVars.value)) e.style.setProperty(r, n.has(r) ? `${parseFloat(i) + t}px` : i);
|
|
1438
|
+
}, { flush: "sync" });
|
|
1439
|
+
let b = V(32), S = V(32), ee = V(0), w = () => {
|
|
1440
|
+
let e = l.value;
|
|
1441
|
+
ee.value = e ? Math.max(0, e.offsetHeight - e.clientHeight) : 0;
|
|
1442
|
+
}, T = () => {
|
|
1443
|
+
let e = o.value ? parseFloat(getComputedStyle(o.value).getPropertyValue("--dt-row-h")) : NaN;
|
|
1444
|
+
b.value = Number.isFinite(e) ? e : 32, S.value = o.value?.querySelector(".dt-head")?.offsetHeight ?? S.value, w();
|
|
1445
|
+
};
|
|
1446
|
+
ye(T), je(_, () => requestAnimationFrame(T));
|
|
1447
|
+
let te = new v(), ne = j(() => ({
|
|
1448
|
+
fmt: x(r.locale),
|
|
1449
|
+
i18n: r.i18n,
|
|
1450
|
+
today: /* @__PURE__ */ new Date(),
|
|
1451
|
+
labels: te,
|
|
1452
|
+
density: _.value,
|
|
1453
|
+
coarse: g
|
|
1454
|
+
})), E = j(() => u.columns.value), re = j(() => new Map(E.value.map((e) => [e.id, e.def]))), ie = j(() => {
|
|
1455
|
+
let e = /* @__PURE__ */ new Map();
|
|
1456
|
+
return n.rows.forEach((t, n) => e.set(h(t), n)), e;
|
|
1457
|
+
}), ae = p.active, D = j(() => ae.value ? ie.value.get(ae.value.rowId) ?? -1 : -1), oe = j(() => {
|
|
1458
|
+
let e = p.bounds.value;
|
|
1459
|
+
return !!e && (e.maxRowIndex > e.minRowIndex || e.maxColumnIndex > e.minColumnIndex);
|
|
1460
|
+
}), se = (e) => {
|
|
1461
|
+
let t = p.bounds.value;
|
|
1462
|
+
return !t || !oe.value || e < t.minRowIndex || e > t.maxRowIndex ? null : {
|
|
1463
|
+
from: t.minColumnIndex,
|
|
1464
|
+
to: t.maxColumnIndex,
|
|
1465
|
+
top: e === t.minRowIndex,
|
|
1466
|
+
bottom: e === t.maxRowIndex
|
|
1467
|
+
};
|
|
1468
|
+
}, ce = (e) => {
|
|
1469
|
+
let t = p.bounds.value;
|
|
1470
|
+
return !t || J.value || n.phone ? null : oe.value ? e === t.maxRowIndex ? E.value[t.maxColumnIndex]?.id ?? null : null : e === D.value ? ae.value?.columnId ?? null : null;
|
|
1471
|
+
}, le = (e) => {
|
|
1472
|
+
let t = f.edit.editing.value, r = n.rows[e];
|
|
1473
|
+
return t && r && h(t.row) === h(r) ? {
|
|
1474
|
+
columnId: t.def.id,
|
|
1475
|
+
value: t.value,
|
|
1476
|
+
inCell: t.inCell
|
|
1477
|
+
} : null;
|
|
1478
|
+
}, ue = (e) => {
|
|
1479
|
+
let t = n.rows[e];
|
|
1480
|
+
return t ? n.found?.get(h(t)) : void 0;
|
|
1481
|
+
}, I = j(() => n.skeleton ? 24 : n.rows.length), R = an(j(() => ({
|
|
1482
|
+
count: I.value,
|
|
1483
|
+
getScrollElement: () => l.value,
|
|
1484
|
+
estimateSize: () => b.value + 1,
|
|
1485
|
+
scrollMargin: S.value,
|
|
1486
|
+
scrollPaddingStart: S.value,
|
|
1487
|
+
scrollPaddingEnd: ee.value,
|
|
1488
|
+
overscan: 10,
|
|
1489
|
+
getItemKey: (e) => n.skeleton ? `sk-${e}` : h(n.rows[e]),
|
|
1490
|
+
rangeExtractor: (e) => {
|
|
1491
|
+
let t = Math.max(0, e.startIndex - e.overscan), r = Math.min(e.count - 1, e.endIndex + e.overscan), i = [], a = n.skeleton ? -1 : D.value;
|
|
1492
|
+
a >= 0 && a < t && i.push(a);
|
|
1493
|
+
for (let e = t; e <= r; e++) i.push(e);
|
|
1494
|
+
return a > r && a < e.count && i.push(a), i;
|
|
1495
|
+
}
|
|
1496
|
+
}))), de = j(() => R.value.getVirtualItems()), z = j(() => R.value.getTotalSize());
|
|
1497
|
+
je(b, () => R.value.measure());
|
|
1498
|
+
let fe = H(!1), pe = () => {
|
|
1499
|
+
w(), fe.value = (l.value?.scrollLeft ?? 0) > 0;
|
|
1500
|
+
}, me = (e, t) => {
|
|
1501
|
+
let n = o.value?.querySelector(`.dt-row[data-index="${e}"]`);
|
|
1502
|
+
if (!n) return null;
|
|
1503
|
+
for (let e of n.querySelectorAll(".dt-cell[data-col]")) if (e.dataset.col === t) return e;
|
|
1504
|
+
return null;
|
|
1505
|
+
}, be = () => {
|
|
1506
|
+
let e = 0;
|
|
1507
|
+
for (let t of o.value?.querySelectorAll(".dt-head .is-pinned-start") ?? []) e += t.offsetWidth;
|
|
1508
|
+
return e;
|
|
1509
|
+
}, Ce = (e) => {
|
|
1510
|
+
let t = l.value;
|
|
1511
|
+
if (!t || e.classList.contains("is-pinned-start")) return;
|
|
1512
|
+
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = r.left + be();
|
|
1513
|
+
n.left < i ? t.scrollLeft -= i - n.left : n.right > r.right && (t.scrollLeft += n.right - r.right);
|
|
1514
|
+
}, we = () => {
|
|
1515
|
+
let e = p.rangeEnd.value, t = e ? ie.value.get(e.rowId) : void 0;
|
|
1516
|
+
e && t !== void 0 && (R.value.scrollToIndex(t, { align: "auto" }), requestAnimationFrame(() => {
|
|
1517
|
+
let n = me(t, e.columnId);
|
|
1518
|
+
n && Ce(n);
|
|
1519
|
+
}));
|
|
1520
|
+
}, W = () => void he(() => Te(0)), Te = (e) => {
|
|
1521
|
+
let t = ae.value;
|
|
1522
|
+
if (!t || f.edit.editing.value?.inCell) return;
|
|
1523
|
+
let n = ie.value.get(t.rowId);
|
|
1524
|
+
if (n === void 0) {
|
|
1525
|
+
e < 3 && requestAnimationFrame(() => Te(e + 1));
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
R.value.scrollToIndex(n, { align: "auto" });
|
|
1529
|
+
let r = (e) => {
|
|
1530
|
+
let i = me(n, t.columnId);
|
|
1531
|
+
i ? (i.focus({ preventScroll: !0 }), Ce(i)) : e < 3 && requestAnimationFrame(() => r(e + 1));
|
|
1532
|
+
};
|
|
1533
|
+
r(0);
|
|
1534
|
+
}, Ee = (e, t) => {
|
|
1535
|
+
let r = n.rows[Math.max(0, Math.min(n.rows.length - 1, e))];
|
|
1536
|
+
r && (p.focus(h(r), t), W());
|
|
1537
|
+
}, De = (e) => {
|
|
1538
|
+
let t = ae.value;
|
|
1539
|
+
if (!t) return;
|
|
1540
|
+
let r = E.value, i = r.findIndex((e) => e.id === t.columnId), a = D.value;
|
|
1541
|
+
e === "right" ? i < r.length - 1 ? p.move("right") : a < n.rows.length - 1 && p.focus(h(n.rows[a + 1]), r[0].id) : i > 0 ? p.move("left") : a > 0 && p.focus(h(n.rows[a - 1]), r[r.length - 1].id), W();
|
|
1542
|
+
}, Oe = (e) => {
|
|
1543
|
+
let t = ae.value, r = E.value;
|
|
1544
|
+
if (e === "left") p.focus(t.rowId, r[0].id);
|
|
1545
|
+
else if (e === "right") p.focus(t.rowId, r[r.length - 1].id);
|
|
1546
|
+
else {
|
|
1547
|
+
let r = n.rows[e === "up" ? 0 : n.rows.length - 1];
|
|
1548
|
+
r && p.focus(h(r), t.columnId);
|
|
1549
|
+
}
|
|
1550
|
+
}, ke = () => Math.max(1, Math.floor((l.value?.clientHeight ?? 0) / (b.value + 1)) - 1), Ae = {
|
|
1551
|
+
ArrowUp: "up",
|
|
1552
|
+
ArrowDown: "down",
|
|
1553
|
+
ArrowLeft: "left",
|
|
1554
|
+
ArrowRight: "right"
|
|
1555
|
+
}, Ne = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform), Pe = (e) => {
|
|
1556
|
+
let t = e.target, r = f.edit.editing.value;
|
|
1557
|
+
if (r?.inCell) {
|
|
1558
|
+
if (e.key === "Tab") {
|
|
1559
|
+
e.preventDefault(), f.edit.commit(), De(e.shiftKey ? "left" : "right");
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
if (e.key === "Escape" && r.def.type === "multiselect" && !r.def.editor) {
|
|
1563
|
+
e.preventDefault(), f.edit.commit(), W();
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
if (e.defaultPrevented || t.getAttribute("aria-expanded") === "true" || t.tagName === "BUTTON") return;
|
|
1567
|
+
e.key === "Enter" && !(e.shiftKey && t.tagName === "TEXTAREA") ? (e.preventDefault(), f.edit.commit(), p.move("down"), W()) : e.key === "Escape" && (e.preventDefault(), f.edit.cancel(), W());
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1570
|
+
let i = t.closest(".dt-cell[data-col]");
|
|
1571
|
+
if (!i) return;
|
|
1572
|
+
if (t !== i) {
|
|
1573
|
+
e.key === "Escape" && (e.preventDefault(), i.focus());
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
let a = ae.value, o = n.rows[D.value], s = a ? re.value.get(a.columnId) : void 0;
|
|
1577
|
+
if (!a || !o || !s) return;
|
|
1578
|
+
let c = f.canEdit(o, s), l = e.metaKey || e.ctrlKey, u = Ae[e.key];
|
|
1579
|
+
if (u) {
|
|
1580
|
+
if (e.preventDefault(), e.shiftKey) {
|
|
1581
|
+
p.extend(u), he(we);
|
|
1582
|
+
return;
|
|
1583
|
+
}
|
|
1584
|
+
l ? Oe(u) : p.move(u), W();
|
|
1585
|
+
} else {
|
|
1586
|
+
switch (e.key) {
|
|
1587
|
+
case "Tab":
|
|
1588
|
+
e.preventDefault(), De(e.shiftKey ? "left" : "right");
|
|
1589
|
+
return;
|
|
1590
|
+
case "Enter": {
|
|
1591
|
+
e.preventDefault();
|
|
1592
|
+
let t = c ? null : i.querySelector(k);
|
|
1593
|
+
t ? t.focus() : (p.move("down"), W());
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
case "F2":
|
|
1597
|
+
e.preventDefault(), f.edit.start(o, s, { inCell: !0 });
|
|
1598
|
+
return;
|
|
1599
|
+
case "Escape":
|
|
1600
|
+
e.preventDefault(), p.focus(a.rowId, a.columnId);
|
|
1601
|
+
return;
|
|
1602
|
+
case " ":
|
|
1603
|
+
e.preventDefault(), s.type === "boolean" && c && f.toggle(o, s);
|
|
1604
|
+
return;
|
|
1605
|
+
case "Delete":
|
|
1606
|
+
case "Backspace":
|
|
1607
|
+
e.preventDefault(), f.clearCells();
|
|
1608
|
+
return;
|
|
1609
|
+
case "Home":
|
|
1610
|
+
e.preventDefault(), Ee(l ? 0 : D.value, E.value[0].id);
|
|
1611
|
+
return;
|
|
1612
|
+
case "End":
|
|
1613
|
+
e.preventDefault(), Ee(l ? n.rows.length - 1 : D.value, E.value[E.value.length - 1].id);
|
|
1614
|
+
return;
|
|
1615
|
+
case "PageDown":
|
|
1616
|
+
e.preventDefault(), Ee(D.value + ke(), a.columnId);
|
|
1617
|
+
return;
|
|
1618
|
+
case "PageUp":
|
|
1619
|
+
e.preventDefault(), Ee(D.value - ke(), a.columnId);
|
|
1620
|
+
return;
|
|
1621
|
+
case "F8":
|
|
1622
|
+
e.preventDefault(), f.goToError(e.shiftKey ? -1 : 1);
|
|
1623
|
+
return;
|
|
1624
|
+
case "ContextMenu":
|
|
1625
|
+
case "F10":
|
|
1626
|
+
if (e.key === "F10" && !e.shiftKey) return;
|
|
1627
|
+
e.preventDefault(), Qe(i);
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
if (l) {
|
|
1631
|
+
let t = e.key.toLowerCase();
|
|
1632
|
+
t === "a" && !e.shiftKey ? (e.preventDefault(), p.selectAll()) : t === "s" ? (e.preventDefault(), f.save()) : t === "d" && !e.shiftKey ? (e.preventDefault(), f.fillDown()) : t === "z" && !e.shiftKey ? (e.preventDefault(), f.undo()) : t === "z" && e.shiftKey || t === "y" && !Ne ? (e.preventDefault(), f.redo()) : (e.key === "-" || e.key === "Subtract") && (e.preventDefault(), f.removeSelectedRows());
|
|
1633
|
+
} else e.key.length === 1 && !e.altKey && c && (e.preventDefault(), f.edit.start(o, s, {
|
|
1634
|
+
inCell: !0,
|
|
1635
|
+
replace: e.key
|
|
1636
|
+
}));
|
|
1637
|
+
}
|
|
1638
|
+
}, Fe = (e, t) => {
|
|
1639
|
+
f.edit.editing.value?.inCell || O(e.target) || e.target.closest(".dt-cell[data-col]") && f[t](e.clipboardData) && e.preventDefault();
|
|
1640
|
+
}, Ie = (e) => {
|
|
1641
|
+
let t = e?.closest(".dt-cell[data-col]"), r = e?.closest(".dt-row[data-index]");
|
|
1642
|
+
if (!t || !r || n.skeleton) return null;
|
|
1643
|
+
let i = Number(r.dataset.index), a = n.rows[i];
|
|
1644
|
+
return a ? {
|
|
1645
|
+
index: i,
|
|
1646
|
+
row: a,
|
|
1647
|
+
columnId: t.dataset.col,
|
|
1648
|
+
cell: t,
|
|
1649
|
+
target: e
|
|
1650
|
+
} : null;
|
|
1651
|
+
}, Le = (e) => Ie(e.target), Re = H(null), J = H(null), Be = H(null), Y = {
|
|
1652
|
+
x: 0,
|
|
1653
|
+
y: 0
|
|
1654
|
+
}, X = 0, Ve = (e) => {
|
|
1655
|
+
if (e) {
|
|
1656
|
+
if (Re.value === "fill") {
|
|
1657
|
+
let t = J.value, n = e.index > t.toRow || e.index < t.fromRow ? e.index : t.toRow;
|
|
1658
|
+
n !== t.target && (J.value = {
|
|
1659
|
+
...t,
|
|
1660
|
+
target: n
|
|
1661
|
+
}, We());
|
|
1662
|
+
} else p.extendHandler(h(e.row), e.columnId)?.(new MouseEvent("mouseover"));
|
|
1663
|
+
}
|
|
1664
|
+
}, He = () => {
|
|
1665
|
+
X = 0;
|
|
1666
|
+
let e = l.value;
|
|
1667
|
+
if (!Re.value || !e) return;
|
|
1668
|
+
let t = e.getBoundingClientRect(), n = 0;
|
|
1669
|
+
Y.y < t.top + wi ? n = -12 : Y.y > t.bottom - wi && (n = Ti);
|
|
1670
|
+
let r = 0;
|
|
1671
|
+
Re.value === "select" && (Y.x < t.left + be() + wi ? r = -12 : Y.x > t.right - wi && (r = Ti)), (n || r) && (e.scrollTop += n, e.scrollLeft += r, Ve(Ie(document.elementFromPoint(Y.x, Y.y))), X = requestAnimationFrame(He));
|
|
1672
|
+
}, Ue = (e) => {
|
|
1673
|
+
Re.value && (Y = {
|
|
1674
|
+
x: e.clientX,
|
|
1675
|
+
y: e.clientY
|
|
1676
|
+
}, Re.value === "fill" && Ve(Le(e)), X ||= requestAnimationFrame(He));
|
|
1677
|
+
}, We = () => {
|
|
1678
|
+
let e = J.value;
|
|
1679
|
+
if (!e || e.target === e.toRow) {
|
|
1680
|
+
Be.value = null;
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
let t = (e.target, e.toRow, e.target), n = me(t, E.value[e.cols[1]].id), r = o.value?.getBoundingClientRect();
|
|
1684
|
+
if (!n || !r) {
|
|
1685
|
+
Be.value = null;
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
let i = n.getBoundingClientRect();
|
|
1689
|
+
Be.value = {
|
|
1690
|
+
left: i.right - r.left + 10,
|
|
1691
|
+
top: i.bottom - r.top - 13,
|
|
1692
|
+
text: f.fillLabel(e.fromRow, e.toRow, e.cols, e.target)
|
|
1693
|
+
};
|
|
1694
|
+
}, Ge = () => {
|
|
1695
|
+
if (Re.value === "fill" && J.value) {
|
|
1696
|
+
let e = J.value;
|
|
1697
|
+
e.target !== e.toRow && f.fill(e.fromRow, e.toRow, e.cols, e.target), J.value = null, Be.value = null, W();
|
|
1698
|
+
}
|
|
1699
|
+
Re.value = null, cancelAnimationFrame(X), X = 0;
|
|
1700
|
+
};
|
|
1701
|
+
ye(() => document.addEventListener("mouseup", Ge)), ve(() => {
|
|
1702
|
+
document.removeEventListener("mouseup", Ge), cancelAnimationFrame(X);
|
|
1703
|
+
});
|
|
1704
|
+
let Ke = -1, qe = (e) => {
|
|
1705
|
+
if (e.button !== 0) return;
|
|
1706
|
+
let t = e.target, r = (o.value?.querySelector(".dt-fill-handle"))?.getBoundingClientRect();
|
|
1707
|
+
if (r && e.clientX >= r.left - 2 && e.clientX <= r.right + 2 && e.clientY >= r.top - 2 && e.clientY <= r.bottom + 2) {
|
|
1708
|
+
let t = p.bounds.value;
|
|
1709
|
+
if (!t) return;
|
|
1710
|
+
e.preventDefault(), f.edit.commit(), J.value = {
|
|
1711
|
+
fromRow: t.minRowIndex,
|
|
1712
|
+
toRow: t.maxRowIndex,
|
|
1713
|
+
cols: [t.minColumnIndex, t.maxColumnIndex],
|
|
1714
|
+
target: t.maxRowIndex
|
|
1715
|
+
}, Re.value = "fill", Y = {
|
|
1716
|
+
x: e.clientX,
|
|
1717
|
+
y: e.clientY
|
|
1718
|
+
};
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
let i = t.closest(".dt-row[data-index]");
|
|
1722
|
+
if (t.closest(".dt-gutter") && i && !n.skeleton) {
|
|
1723
|
+
e.preventDefault();
|
|
1724
|
+
let t = Number(i.dataset.index), r = E.value, a = e.shiftKey && Ke >= 0 ? Ke : t;
|
|
1725
|
+
Ke = a, f.edit.commit(), p.selectRange({
|
|
1726
|
+
anchorRowId: h(n.rows[a]),
|
|
1727
|
+
anchorColumnId: r[0].id,
|
|
1728
|
+
focusRowId: h(n.rows[t]),
|
|
1729
|
+
focusColumnId: r[r.length - 1].id
|
|
1730
|
+
}), W();
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
let a = Le(e);
|
|
1734
|
+
a && (Ke = -1, !(f.edit.editing.value?.inCell && a.cell.classList.contains("is-editing")) && (f.edit.commit(), n.phone ? p.focus(h(a.row), a.columnId) : (s(a.target, a.cell) || e.preventDefault(), p.startHandler(h(a.row), a.columnId)?.(e), Re.value = "select", Y = {
|
|
1735
|
+
x: e.clientX,
|
|
1736
|
+
y: e.clientY
|
|
1737
|
+
}, a.cell.focus({ preventScroll: !0 }))));
|
|
1738
|
+
}, Je = (e) => {
|
|
1739
|
+
if (Re.value === "fill") return;
|
|
1740
|
+
let t = Le(e);
|
|
1741
|
+
t && p.extendHandler(h(t.row), t.columnId)?.(e);
|
|
1742
|
+
}, Xe = (e) => {
|
|
1743
|
+
let t = Le(e);
|
|
1744
|
+
if (!t || s(t.target, t.cell)) return;
|
|
1745
|
+
let n = re.value.get(t.columnId);
|
|
1746
|
+
n && (n.type === "boolean" && !n.editor ? f.canEdit(t.row, n) && f.toggle(t.row, n) : f.edit.start(t.row, n, { inCell: !0 }));
|
|
1747
|
+
}, Ze = (e) => {
|
|
1748
|
+
let t = J.value;
|
|
1749
|
+
if (!t || t.target === t.toRow) return null;
|
|
1750
|
+
let n = t.target > t.toRow;
|
|
1751
|
+
return (n ? e > t.toRow && e <= t.target : e < t.fromRow && e >= t.target) ? {
|
|
1752
|
+
from: t.cols[0],
|
|
1753
|
+
to: t.cols[1],
|
|
1754
|
+
last: n ? e === t.target : e === t.fromRow - 1
|
|
1755
|
+
} : null;
|
|
1756
|
+
}, Z = (e) => {
|
|
1757
|
+
let t = Le(e);
|
|
1758
|
+
if (!t || n.skeleton) {
|
|
1759
|
+
e.stopPropagation();
|
|
1760
|
+
return;
|
|
1761
|
+
}
|
|
1762
|
+
let r = p.bounds.value, i = E.value.findIndex((e) => e.id === t.columnId);
|
|
1763
|
+
r && t.index >= r.minRowIndex && t.index <= r.maxRowIndex && i >= r.minColumnIndex && i <= r.maxColumnIndex || (f.edit.commit(), p.focus(h(t.row), t.columnId), t.cell.focus({ preventScroll: !0 }));
|
|
1764
|
+
}, Qe = (e) => {
|
|
1765
|
+
let t = e.getBoundingClientRect();
|
|
1766
|
+
e.dispatchEvent(new MouseEvent("contextmenu", {
|
|
1767
|
+
bubbles: !0,
|
|
1768
|
+
cancelable: !0,
|
|
1769
|
+
clientX: t.left + 8,
|
|
1770
|
+
clientY: t.bottom - 4
|
|
1771
|
+
}));
|
|
1772
|
+
}, $e = j(() => {
|
|
1773
|
+
let e = n.rows[D.value];
|
|
1774
|
+
return e ? f.openHref(e) : void 0;
|
|
1775
|
+
}), et = (e) => n.sort?.get(e), tt = (e) => typeof e.unit == "string" ? e.unit : void 0, nt = (e) => {
|
|
1776
|
+
let t = e.id === n.keyColumn ? r.i18n.t("sheet.keyTooltip", { key: e.def.header }) : void 0;
|
|
1777
|
+
return e.def.description ? `${t ?? e.def.header}\n${e.def.description}` : t;
|
|
1778
|
+
}, rt = (e, t) => {
|
|
1779
|
+
let n = t.currentTarget.parentElement;
|
|
1780
|
+
u.setWidth(e.id, n.getBoundingClientRect().width), e.header.getResizeHandler()(t);
|
|
1781
|
+
}, it = r.i18n.t("sheet.required").toLocaleLowerCase(r.locale);
|
|
1782
|
+
return t({
|
|
1783
|
+
focusActive: W,
|
|
1784
|
+
scrollToIndex: (e) => R.value.scrollToIndex(e)
|
|
1785
|
+
}), (t, n) => (B(), M(G(Pt), null, {
|
|
1786
|
+
default: q(() => [L(G(It), { "as-child": "" }, {
|
|
1787
|
+
default: q(() => [F("div", {
|
|
1788
|
+
ref_key: "root",
|
|
1789
|
+
ref: o,
|
|
1790
|
+
class: ge(["dt-grid dt-sheet-grid", {
|
|
1791
|
+
"is-scrolled-start": fe.value,
|
|
1792
|
+
"is-skeleton": e.skeleton,
|
|
1793
|
+
"has-vlines": e.verticalLines,
|
|
1794
|
+
"is-filling": Re.value === "fill",
|
|
1795
|
+
"is-phone": e.phone
|
|
1796
|
+
}]),
|
|
1797
|
+
role: "grid",
|
|
1798
|
+
"aria-label": e.label,
|
|
1799
|
+
"aria-rowcount": e.skeleton ? -1 : e.rows.length,
|
|
1800
|
+
"aria-colcount": E.value.length + +!e.phone,
|
|
1801
|
+
"aria-busy": e.loading || e.readOnly ? "true" : void 0,
|
|
1802
|
+
"aria-readonly": e.readOnly ? "true" : void 0,
|
|
1803
|
+
"data-density": _.value,
|
|
1804
|
+
onKeydown: Pe,
|
|
1805
|
+
onMousedown: qe,
|
|
1806
|
+
onMousemove: Ue,
|
|
1807
|
+
onMouseover: Je,
|
|
1808
|
+
onDblclick: Xe,
|
|
1809
|
+
onContextmenuCapture: Z,
|
|
1810
|
+
onCopy: n[1] ||= (e) => Fe(e, "copy"),
|
|
1811
|
+
onCut: n[2] ||= (e) => Fe(e, "cut"),
|
|
1812
|
+
onPaste: n[3] ||= (e) => Fe(e, "paste")
|
|
1813
|
+
}, [
|
|
1814
|
+
F("div", {
|
|
1815
|
+
ref_key: "scrollEl",
|
|
1816
|
+
ref: l,
|
|
1817
|
+
class: "dt-scroll",
|
|
1818
|
+
onScrollPassive: pe
|
|
1819
|
+
}, [F("div", li, [
|
|
1820
|
+
e.phone ? N("", !0) : (B(), P("div", ui, U(G(r).i18n.t("sheet.err.row")), 1)),
|
|
1821
|
+
(B(!0), P(A, null, xe(E.value, (t) => (B(), P("div", {
|
|
1822
|
+
key: t.id,
|
|
1823
|
+
class: ge(["dt-head-cell", [`is-${G(d)(t.def)}`, {
|
|
1824
|
+
"is-numeric": G(a)(t.def.type),
|
|
1825
|
+
"is-key": t.id === e.keyColumn,
|
|
1826
|
+
"is-pinned-start": t.pinned === "start",
|
|
1827
|
+
"is-pin-edge": t.pinEdge,
|
|
1828
|
+
"is-resizing": G(u).resizing.value?.id === t.id
|
|
1829
|
+
}]]),
|
|
1830
|
+
style: _e(t.pinned === "start" ? { left: `var(${t.offsetVar})` } : void 0),
|
|
1831
|
+
role: "columnheader",
|
|
1832
|
+
"aria-sort": et(t.id)?.dir === "asc" ? "ascending" : et(t.id)?.dir === "desc" ? "descending" : void 0,
|
|
1833
|
+
"data-col": t.id
|
|
1834
|
+
}, [
|
|
1835
|
+
t.id === e.keyColumn ? (B(), M(G(Ye), {
|
|
1836
|
+
key: 0,
|
|
1837
|
+
size: 12,
|
|
1838
|
+
class: "dt-head-lock",
|
|
1839
|
+
"aria-hidden": "true"
|
|
1840
|
+
})) : N("", !0),
|
|
1841
|
+
F("button", {
|
|
1842
|
+
type: "button",
|
|
1843
|
+
class: "dt-head-label",
|
|
1844
|
+
tabindex: "-1",
|
|
1845
|
+
"data-dt-tip": nt(t),
|
|
1846
|
+
"aria-describedby": t.def.description ? `${G(i)}-desc-${t.id}` : void 0,
|
|
1847
|
+
onClick: (e) => G(f).sort(t.id, e.shiftKey)
|
|
1848
|
+
}, [
|
|
1849
|
+
F("span", pi, U(t.def.header), 1),
|
|
1850
|
+
t.def.required ? (B(), P("span", {
|
|
1851
|
+
key: 0,
|
|
1852
|
+
class: "dt-head-required",
|
|
1853
|
+
"aria-label": G(it)
|
|
1854
|
+
}, "*", 8, mi)) : N("", !0),
|
|
1855
|
+
tt(t.def) ? (B(), P("span", hi, U(tt(t.def)), 1)) : N("", !0),
|
|
1856
|
+
et(t.id) ? (B(), P("span", gi, [L(G(ze), {
|
|
1857
|
+
size: 12,
|
|
1858
|
+
class: ge({ "is-desc": et(t.id).dir === "desc" })
|
|
1859
|
+
}, null, 8, ["class"]), et(t.id).index ? (B(), P("span", _i, U(et(t.id).index), 1)) : N("", !0)])) : N("", !0)
|
|
1860
|
+
], 8, fi),
|
|
1861
|
+
t.def.description ? (B(), P("span", {
|
|
1862
|
+
key: 1,
|
|
1863
|
+
id: `${G(i)}-desc-${t.id}`,
|
|
1864
|
+
class: "dt-sr-only"
|
|
1865
|
+
}, U(t.def.description), 9, vi)) : N("", !0),
|
|
1866
|
+
n[4] ||= F("span", {
|
|
1867
|
+
class: "dt-head-sep",
|
|
1868
|
+
"aria-hidden": "true"
|
|
1869
|
+
}, null, -1),
|
|
1870
|
+
F("span", {
|
|
1871
|
+
class: "dt-resize",
|
|
1872
|
+
"aria-hidden": "true",
|
|
1873
|
+
onMousedown: (e) => rt(t, e),
|
|
1874
|
+
onTouchstartPassive: (e) => rt(t, e)
|
|
1875
|
+
}, [G(u).resizing.value?.id === t.id ? (B(), P("span", bi, U(Math.round(G(u).resizing.value.size)) + " px ", 1)) : N("", !0)], 40, yi)
|
|
1876
|
+
], 14, di))), 128)),
|
|
1877
|
+
n[5] ||= F("div", {
|
|
1878
|
+
class: "dt-head-cell dt-cell-fill",
|
|
1879
|
+
role: "presentation",
|
|
1880
|
+
"aria-hidden": "true"
|
|
1881
|
+
}, null, -1)
|
|
1882
|
+
]), F("div", {
|
|
1883
|
+
class: "dt-body",
|
|
1884
|
+
role: "presentation",
|
|
1885
|
+
style: _e({ height: `${z.value}px` })
|
|
1886
|
+
}, [(B(!0), P(A, null, xe(de.value, (t) => (B(), P("div", {
|
|
1887
|
+
key: String(t.key),
|
|
1888
|
+
class: "dt-item",
|
|
1889
|
+
"data-index": t.index,
|
|
1890
|
+
style: _e({ transform: `translateY(${t.start - S.value}px)` })
|
|
1891
|
+
}, [e.skeleton ? (B(), M(G(C), {
|
|
1892
|
+
key: 0,
|
|
1893
|
+
index: t.index,
|
|
1894
|
+
columns: E.value,
|
|
1895
|
+
gutter: !e.phone
|
|
1896
|
+
}, null, 8, [
|
|
1897
|
+
"index",
|
|
1898
|
+
"columns",
|
|
1899
|
+
"gutter"
|
|
1900
|
+
])) : (B(), M(G(si), {
|
|
1901
|
+
key: 1,
|
|
1902
|
+
row: e.rows[t.index],
|
|
1903
|
+
index: t.index,
|
|
1904
|
+
"row-no": G(m).rowNoOf(G(h)(e.rows[t.index])),
|
|
1905
|
+
gutter: !e.phone,
|
|
1906
|
+
uid: G(i),
|
|
1907
|
+
columns: E.value,
|
|
1908
|
+
env: ne.value,
|
|
1909
|
+
"key-column": e.keyColumn,
|
|
1910
|
+
read: G(m).read,
|
|
1911
|
+
original: G(m).original,
|
|
1912
|
+
"can-edit": G(f).canEdit,
|
|
1913
|
+
current: G(m).current,
|
|
1914
|
+
"editor-for": G(f).editorFor,
|
|
1915
|
+
draft: G(m).rowDraft(G(h)(e.rows[t.index])),
|
|
1916
|
+
issues: G(m).rowIssues(G(h)(e.rows[t.index])),
|
|
1917
|
+
"is-new": G(m).isNew(G(h)(e.rows[t.index])),
|
|
1918
|
+
"row-error": G(m).rowError(G(h)(e.rows[t.index])),
|
|
1919
|
+
active: D.value === t.index ? G(ae).columnId : null,
|
|
1920
|
+
selection: se(t.index),
|
|
1921
|
+
"handle-at": ce(t.index),
|
|
1922
|
+
fill: Ze(t.index),
|
|
1923
|
+
found: ue(t.index),
|
|
1924
|
+
editing: le(t.index),
|
|
1925
|
+
"tip-below": t.index === 0,
|
|
1926
|
+
onEditValue: n[0] ||= (e) => G(f).edit.setValue(e),
|
|
1927
|
+
onUseSuggestion: (n, r) => G(f).useSuggestion(e.rows[t.index], n, r)
|
|
1928
|
+
}, null, 8, [
|
|
1929
|
+
"row",
|
|
1930
|
+
"index",
|
|
1931
|
+
"row-no",
|
|
1932
|
+
"gutter",
|
|
1933
|
+
"uid",
|
|
1934
|
+
"columns",
|
|
1935
|
+
"env",
|
|
1936
|
+
"key-column",
|
|
1937
|
+
"read",
|
|
1938
|
+
"original",
|
|
1939
|
+
"can-edit",
|
|
1940
|
+
"current",
|
|
1941
|
+
"editor-for",
|
|
1942
|
+
"draft",
|
|
1943
|
+
"issues",
|
|
1944
|
+
"is-new",
|
|
1945
|
+
"row-error",
|
|
1946
|
+
"active",
|
|
1947
|
+
"selection",
|
|
1948
|
+
"handle-at",
|
|
1949
|
+
"fill",
|
|
1950
|
+
"found",
|
|
1951
|
+
"editing",
|
|
1952
|
+
"tip-below",
|
|
1953
|
+
"onUseSuggestion"
|
|
1954
|
+
]))], 12, xi))), 128))], 4)], 544),
|
|
1955
|
+
Be.value ? (B(), P("div", {
|
|
1956
|
+
key: 0,
|
|
1957
|
+
class: "dt-fill-label",
|
|
1958
|
+
role: "status",
|
|
1959
|
+
style: _e({
|
|
1960
|
+
left: `${Be.value.left}px`,
|
|
1961
|
+
top: `${Be.value.top}px`
|
|
1962
|
+
})
|
|
1963
|
+
}, U(Be.value.text), 5)) : N("", !0),
|
|
1964
|
+
t.$slots.state && !e.skeleton && e.rows.length === 0 ? (B(), P("div", Si, [Se(t.$slots, "state")])) : N("", !0),
|
|
1965
|
+
L(ii, {
|
|
1966
|
+
sheet: G(f),
|
|
1967
|
+
entity: e.entity,
|
|
1968
|
+
href: $e.value,
|
|
1969
|
+
"read-only": e.readOnly || e.loading
|
|
1970
|
+
}, null, 8, [
|
|
1971
|
+
"sheet",
|
|
1972
|
+
"entity",
|
|
1973
|
+
"href",
|
|
1974
|
+
"read-only"
|
|
1975
|
+
])
|
|
1976
|
+
], 42, ci)]),
|
|
1977
|
+
_: 3
|
|
1978
|
+
})]),
|
|
1979
|
+
_: 3
|
|
1980
|
+
}));
|
|
1981
|
+
}
|
|
1982
|
+
});
|
|
1983
|
+
//#endregion
|
|
1984
|
+
//#region src/sheet/useSheetEditing.ts
|
|
1985
|
+
function Di(e) {
|
|
1986
|
+
let t = H(null);
|
|
1987
|
+
return {
|
|
1988
|
+
editing: t,
|
|
1989
|
+
start: (n, r, i) => {
|
|
1990
|
+
if (!e.canEdit(n, r) || r.type === "boolean" && !r.editor) return !1;
|
|
1991
|
+
if (i.replace !== void 0 && !r.editor && r.type === "multiselect") return t.value = {
|
|
1992
|
+
row: n,
|
|
1993
|
+
def: r,
|
|
1994
|
+
value: e.store.read(n, r),
|
|
1995
|
+
inCell: i.inCell,
|
|
1996
|
+
seed: i.replace
|
|
1997
|
+
}, !0;
|
|
1998
|
+
let a = i.replace === void 0 ? e.store.read(n, r) : e.parse(r, i.replace);
|
|
1999
|
+
return t.value = {
|
|
2000
|
+
row: n,
|
|
2001
|
+
def: r,
|
|
2002
|
+
value: a,
|
|
2003
|
+
inCell: i.inCell,
|
|
2004
|
+
text: i.replace
|
|
2005
|
+
}, !0;
|
|
2006
|
+
},
|
|
2007
|
+
setValue: (e, n, r) => {
|
|
2008
|
+
let i = t.value;
|
|
2009
|
+
i && (t.value = {
|
|
2010
|
+
...i,
|
|
2011
|
+
value: e,
|
|
2012
|
+
text: n,
|
|
2013
|
+
inCell: r ?? i.inCell
|
|
2014
|
+
});
|
|
2015
|
+
},
|
|
2016
|
+
commit: () => {
|
|
2017
|
+
let n = t.value;
|
|
2018
|
+
return n ? (t.value = null, e.store.set(n.row, n.def, n.value === "" ? null : n.value), !0) : !1;
|
|
2019
|
+
},
|
|
2020
|
+
cancel: () => {
|
|
2021
|
+
t.value = null;
|
|
2022
|
+
}
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
//#endregion
|
|
2026
|
+
//#region src/sheet/useSheetStore.ts
|
|
2027
|
+
var Oi = 100, ki = (e, t) => T(e) && T(t) || Object.is(e, t) || Array.isArray(e) && Array.isArray(t) && e.length === t.length && e.every((e, n) => Object.is(e, t[n]));
|
|
2028
|
+
function Ai(e, t, n) {
|
|
2029
|
+
let r = t.split("."), i = e;
|
|
2030
|
+
for (let e of r.slice(0, -1)) {
|
|
2031
|
+
let t = i[e];
|
|
2032
|
+
i[e] = t && typeof t == "object" ? { ...t } : {}, i = i[e];
|
|
2033
|
+
}
|
|
2034
|
+
i[r[r.length - 1]] = n;
|
|
2035
|
+
}
|
|
2036
|
+
var ji = (e, t) => e.trim().toLocaleLowerCase(t).replace(/ı|i̇/g, "i");
|
|
2037
|
+
function Mi(e, t, n) {
|
|
2038
|
+
let r = ji(t, n);
|
|
2039
|
+
if (!r) return;
|
|
2040
|
+
let i = (e, t) => {
|
|
2041
|
+
let n = Array.from({ length: t.length + 1 }, (e, t) => t);
|
|
2042
|
+
for (let r = 1; r <= e.length; r++) {
|
|
2043
|
+
let i = n[0];
|
|
2044
|
+
n[0] = r;
|
|
2045
|
+
for (let a = 1; a <= t.length; a++) {
|
|
2046
|
+
let o = n[a];
|
|
2047
|
+
n[a] = Math.min(n[a] + 1, n[a - 1] + 1, i + (e[r - 1] === t[a - 1] ? 0 : 1)), i = o;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
return n[t.length];
|
|
2051
|
+
};
|
|
2052
|
+
return e.find((e) => ji(e.label, n).startsWith(r) || r.startsWith(ji(e.label, n))) ?? e.find((e) => i(ji(e.label, n), r) <= 2);
|
|
2053
|
+
}
|
|
2054
|
+
function Ni(e) {
|
|
2055
|
+
let t = e.i18n.t, n = j(() => Te(e.columns)), r = j(() => new Map(n.value.map((e) => [e.id, e]))), i = () => Te(e.keyColumn), a = Ce(/* @__PURE__ */ new Map()), o = Ce(/* @__PURE__ */ new Map()), s = Ce(/* @__PURE__ */ new Map()), c = Ce(/* @__PURE__ */ new Map()), d = Ce(/* @__PURE__ */ new Map()), f = H([]), p = Ce(/* @__PURE__ */ new Set()), h = H(0), g = [], _ = [], v = H(!1), y = H(!1), b = 0, x = (t) => String(u(t, Te(e.rowKey))), S = j(() => f.value.length ? [...Te(e.rows), ...f.value.map((e) => e.row)] : Te(e.rows)), C = j(() => {
|
|
2056
|
+
let e = /* @__PURE__ */ new Map();
|
|
2057
|
+
return S.value.forEach((t, n) => e.set(x(t), n)), e;
|
|
2058
|
+
}), ee = j(() => p.size ? S.value.filter((e) => !p.has(x(e))) : S.value), w = j(() => {
|
|
2059
|
+
let e = /* @__PURE__ */ new Map();
|
|
2060
|
+
for (let t of S.value) e.set(x(t), t);
|
|
2061
|
+
return e;
|
|
2062
|
+
}), te = j(() => new Map(f.value.map((e) => [e.key, e]))), ne = (e) => !!te.value.get(e) && !te.value.get(e).saved, E = (e) => (C.value.get(e) ?? -1) + 1, re = (e, t) => {
|
|
2063
|
+
let n = x(e), r = d.get(n);
|
|
2064
|
+
if (r) return t.accessor ? t.accessor(r.row) : u(r.row, t.id);
|
|
2065
|
+
if (!ne(n)) return t.accessor ? t.accessor(e) : u(e, t.id);
|
|
2066
|
+
}, ae = (e, t, n) => {
|
|
2067
|
+
let r = e.get(x(t)), i = n.id;
|
|
2068
|
+
return r?.has(i) ? r.get(i) : re(t, n);
|
|
2069
|
+
}, D = (e, t) => ae(a, e, t), oe = (e, t) => ae(W(a), e, t), se = (e) => {
|
|
2070
|
+
let t = x(e), n = d.get(t), r = a.get(t);
|
|
2071
|
+
if (!n && !r?.size) return e;
|
|
2072
|
+
let i = {
|
|
2073
|
+
...e,
|
|
2074
|
+
...n?.row
|
|
2075
|
+
};
|
|
2076
|
+
for (let [e, t] of r ?? []) Ai(i, e, t);
|
|
2077
|
+
return i;
|
|
2078
|
+
}, O = j(() => {
|
|
2079
|
+
h.value;
|
|
2080
|
+
let e = /* @__PURE__ */ new Map(), t = r.value.get(i());
|
|
2081
|
+
if (!t) return e;
|
|
2082
|
+
for (let n of ee.value) {
|
|
2083
|
+
let r = oe(n, t);
|
|
2084
|
+
if (T(r)) continue;
|
|
2085
|
+
let i = String(r), a = e.get(i);
|
|
2086
|
+
a || e.set(i, a = /* @__PURE__ */ new Set()), a.add(x(n));
|
|
2087
|
+
}
|
|
2088
|
+
return e;
|
|
2089
|
+
}), k = (n, r) => {
|
|
2090
|
+
if (T(r)) return null;
|
|
2091
|
+
let i = (e, t) => ({
|
|
2092
|
+
level: "error",
|
|
2093
|
+
message: e,
|
|
2094
|
+
suggest: t
|
|
2095
|
+
});
|
|
2096
|
+
if ((l[n.type].numeric || n.type === "star") && typeof r != "number") return i(typeof r == "string" && r.trim().startsWith("=") ? t("sheet.noFormulas") : t("sheet.notANumber"));
|
|
2097
|
+
if ((n.type === "date" || n.type === "datetime") && Number.isNaN(m(r).getTime())) return i(t("sheet.notADate"));
|
|
2098
|
+
if (n.type === "boolean" && typeof r != "boolean") return i(t("sheet.notAnOption", { value: String(r) }));
|
|
2099
|
+
if (n.type === "select" && !n.options.some((e) => e.value === r)) return i(t("sheet.notAnOption", { value: String(r) }), Mi(n.options, String(r), e.locale));
|
|
2100
|
+
if (n.type === "multiselect") {
|
|
2101
|
+
let e = (Array.isArray(r) ? r : [r]).find((e) => !n.options.some((t) => t.value === e));
|
|
2102
|
+
if (e !== void 0) return i(t("sheet.notAnOption", { value: String(e) }));
|
|
2103
|
+
}
|
|
2104
|
+
return null;
|
|
2105
|
+
}, ce = (e, n, r) => {
|
|
2106
|
+
if (e.type !== "select" && e.type !== "multiselect" || !e.optionEnabled || T(n) || ki(n, r.original)) return null;
|
|
2107
|
+
let { options: i, optionEnabled: a } = e, o = (Array.isArray(n) ? n : [n]).find((e) => {
|
|
2108
|
+
let t = i.find((t) => t.value === e);
|
|
2109
|
+
return t && !a(t, r.row);
|
|
2110
|
+
});
|
|
2111
|
+
return o === void 0 ? null : {
|
|
2112
|
+
level: "error",
|
|
2113
|
+
message: t("sheet.notAnOption", { value: ie(i, o) })
|
|
2114
|
+
};
|
|
2115
|
+
}, le = (e, n) => {
|
|
2116
|
+
if (T(n)) return null;
|
|
2117
|
+
let r = O.value.get(String(n));
|
|
2118
|
+
if (!r || r.size < 2) return null;
|
|
2119
|
+
let i = [...r].find((t) => t !== e);
|
|
2120
|
+
return i ? {
|
|
2121
|
+
level: "error",
|
|
2122
|
+
message: t("sheet.duplicateKey", {
|
|
2123
|
+
key: String(n),
|
|
2124
|
+
row: E(i)
|
|
2125
|
+
})
|
|
2126
|
+
} : null;
|
|
2127
|
+
}, A = (e) => {
|
|
2128
|
+
let r = x(e), a = ne(r), s = se(e), c = /* @__PURE__ */ new Map();
|
|
2129
|
+
for (let o of n.value) {
|
|
2130
|
+
let n = D(e, o), l = {
|
|
2131
|
+
row: s,
|
|
2132
|
+
isNew: a,
|
|
2133
|
+
original: re(e, o)
|
|
2134
|
+
}, u = o.id === i(), d = o.required || a && u, p = k(o, n) ?? ce(o, n, l) ?? (d && T(n) ? {
|
|
2135
|
+
level: "error",
|
|
2136
|
+
message: t("sheet.required")
|
|
2137
|
+
} : null) ?? (u && (a || f.value.length) ? le(r, n) : null) ?? (() => {
|
|
2138
|
+
let e = o.validate?.(n, l);
|
|
2139
|
+
if (e) return {
|
|
2140
|
+
level: "error",
|
|
2141
|
+
message: e
|
|
2142
|
+
};
|
|
2143
|
+
let t = o.warn?.(n, l);
|
|
2144
|
+
return t ? {
|
|
2145
|
+
level: "warning",
|
|
2146
|
+
message: t
|
|
2147
|
+
} : null;
|
|
2148
|
+
})();
|
|
2149
|
+
p && c.set(o.id, p);
|
|
2150
|
+
}
|
|
2151
|
+
c.size ? o.set(r, c) : o.delete(r);
|
|
2152
|
+
}, M = (e) => {
|
|
2153
|
+
for (let t of e) if (!T(t)) for (let e of O.value.get(String(t)) ?? []) {
|
|
2154
|
+
let t = w.value.get(e);
|
|
2155
|
+
t && A(t);
|
|
2156
|
+
}
|
|
2157
|
+
}, N = (e) => {
|
|
2158
|
+
let t = [], n = /* @__PURE__ */ new Map(), r = [];
|
|
2159
|
+
for (let o of e) {
|
|
2160
|
+
let e = x(o.row), l = o.def.id, u = D(o.row, o.def);
|
|
2161
|
+
if (ki(u, o.value)) continue;
|
|
2162
|
+
let d = n.get(e);
|
|
2163
|
+
d || n.set(e, d = {
|
|
2164
|
+
row: o.row,
|
|
2165
|
+
map: new Map(a.get(e))
|
|
2166
|
+
}), ki(o.value, re(o.row, o.def)) ? d.map.delete(l) : d.map.set(l, o.value), t.push({
|
|
2167
|
+
key: e,
|
|
2168
|
+
col: l,
|
|
2169
|
+
before: u,
|
|
2170
|
+
after: o.value
|
|
2171
|
+
}), l === i() && r.push(u, o.value);
|
|
2172
|
+
let f = s.get(e);
|
|
2173
|
+
if (f?.has(l)) {
|
|
2174
|
+
let t = new Map(f);
|
|
2175
|
+
t.delete(l), t.size ? s.set(e, t) : s.delete(e);
|
|
2176
|
+
}
|
|
2177
|
+
c.delete(e);
|
|
2178
|
+
}
|
|
2179
|
+
for (let [e, { map: t }] of n) t.size ? a.set(e, t) : a.delete(e);
|
|
2180
|
+
t.length && h.value++;
|
|
2181
|
+
for (let { row: e, map: t } of n.values()) t.size || ne(x(e)) ? A(e) : o.delete(x(e));
|
|
2182
|
+
return r.length && M(r), t;
|
|
2183
|
+
}, P = () => {
|
|
2184
|
+
v.value = g.length > 0, y.value = _.length > 0;
|
|
2185
|
+
}, F = (e) => {
|
|
2186
|
+
g.push(e), g.length > Oi && g.shift(), _.length = 0, P();
|
|
2187
|
+
}, ue = (e, t = []) => {
|
|
2188
|
+
let n = N(e);
|
|
2189
|
+
return (n.length || t.length) && F({
|
|
2190
|
+
patches: n,
|
|
2191
|
+
added: t.length ? t : void 0
|
|
2192
|
+
}), n;
|
|
2193
|
+
}, I = (e, t, n) => ue([{
|
|
2194
|
+
row: e,
|
|
2195
|
+
def: t,
|
|
2196
|
+
value: n
|
|
2197
|
+
}]), L = (t) => {
|
|
2198
|
+
let n = Array.from({ length: t }, () => {
|
|
2199
|
+
let t = `new:${++b}`, n = {};
|
|
2200
|
+
return Ai(n, Te(e.rowKey), t), {
|
|
2201
|
+
key: t,
|
|
2202
|
+
row: n
|
|
2203
|
+
};
|
|
2204
|
+
});
|
|
2205
|
+
f.value = [...f.value, ...n], h.value++;
|
|
2206
|
+
for (let e of n) A(e.row);
|
|
2207
|
+
return n;
|
|
2208
|
+
}, R = (e) => {
|
|
2209
|
+
let t = new Set(e);
|
|
2210
|
+
f.value = f.value.filter((e) => !t.has(e.key));
|
|
2211
|
+
for (let t of e) a.delete(t), o.delete(t), d.delete(t);
|
|
2212
|
+
h.value++;
|
|
2213
|
+
}, de = (e) => {
|
|
2214
|
+
let t = r.value.get(i()), n = t ? e.map((e) => w.value.get(e)).map((e) => e ? D(e, t) : null) : [];
|
|
2215
|
+
for (let t of e) p.add(t);
|
|
2216
|
+
h.value++, F({
|
|
2217
|
+
patches: [],
|
|
2218
|
+
removed: e
|
|
2219
|
+
}), M(n);
|
|
2220
|
+
}, z = (e) => {
|
|
2221
|
+
for (let t of e) p.delete(t);
|
|
2222
|
+
h.value++;
|
|
2223
|
+
let t = r.value.get(i());
|
|
2224
|
+
t && M(e.map((e) => w.value.get(e)).map((e) => e ? D(e, t) : null));
|
|
2225
|
+
}, fe = (e, t) => {
|
|
2226
|
+
if (t === "undo" && e.added && R(e.added.map((e) => e.key)), t === "redo" && e.added && (f.value = [...f.value, ...e.added], h.value++), e.removed) {
|
|
2227
|
+
if (t === "undo") z(e.removed);
|
|
2228
|
+
else {
|
|
2229
|
+
for (let t of e.removed) p.add(t);
|
|
2230
|
+
h.value++;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
let n = [];
|
|
2234
|
+
for (let i of e.patches) {
|
|
2235
|
+
let e = w.value.get(i.key), a = r.value.get(i.col);
|
|
2236
|
+
e && a && n.push({
|
|
2237
|
+
row: e,
|
|
2238
|
+
def: a,
|
|
2239
|
+
value: t === "undo" ? i.before : i.after
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
if (N(n), t === "redo" && e.added) for (let t of e.added) A(t.row);
|
|
2243
|
+
}, pe = () => {
|
|
2244
|
+
let e = g.pop();
|
|
2245
|
+
return e ? (fe(e, "undo"), _.push(e), P(), e) : null;
|
|
2246
|
+
}, me = () => {
|
|
2247
|
+
let e = _.pop();
|
|
2248
|
+
return e ? (fe(e, "redo"), g.push(e), P(), e) : null;
|
|
2249
|
+
}, he = () => {
|
|
2250
|
+
g.length = 0, _.length = 0, P();
|
|
2251
|
+
}, ge = (e) => a.get(e), _e = (e) => {
|
|
2252
|
+
let t = o.get(e), n = s.get(e);
|
|
2253
|
+
if (!n) return t;
|
|
2254
|
+
let r = new Map(t);
|
|
2255
|
+
for (let [e, t] of n) r.has(e) || r.set(e, {
|
|
2256
|
+
level: "error",
|
|
2257
|
+
message: t,
|
|
2258
|
+
server: !0
|
|
2259
|
+
});
|
|
2260
|
+
return r;
|
|
2261
|
+
}, ve = (e) => c.get(e), ye = (e) => {
|
|
2262
|
+
if (s.has(e) || c.has(e)) return !0;
|
|
2263
|
+
let t = o.get(e);
|
|
2264
|
+
if (!t) return !1;
|
|
2265
|
+
for (let e of t.values()) if (e.level === "error") return !0;
|
|
2266
|
+
return !1;
|
|
2267
|
+
}, B = j(() => {
|
|
2268
|
+
let e = 0, t = /* @__PURE__ */ new Set();
|
|
2269
|
+
for (let [n, r] of a) p.has(n) || (e += r.size, t.add(n));
|
|
2270
|
+
let n = 0, r = 0, i = /* @__PURE__ */ new Set([...s.keys(), ...c.keys()]);
|
|
2271
|
+
for (let [e, t] of o) {
|
|
2272
|
+
if (p.has(e)) continue;
|
|
2273
|
+
let n = !1;
|
|
2274
|
+
for (let r of t.values()) r.level === "error" ? i.add(e) : n = !0;
|
|
2275
|
+
n && r++;
|
|
2276
|
+
}
|
|
2277
|
+
for (let e of i) p.has(e) || n++;
|
|
2278
|
+
let l = 0, u = t.size;
|
|
2279
|
+
for (let e of f.value) e.saved || p.has(e.key) || (l++, t.has(e.key) || u++);
|
|
2280
|
+
return {
|
|
2281
|
+
changedCells: e,
|
|
2282
|
+
changedRows: t.size,
|
|
2283
|
+
errorRows: n,
|
|
2284
|
+
warningRows: r,
|
|
2285
|
+
newRows: l,
|
|
2286
|
+
changedOrNewRows: u
|
|
2287
|
+
};
|
|
2288
|
+
});
|
|
2289
|
+
return je(() => Te(e.rows), (e) => {
|
|
2290
|
+
if (!d.size) return;
|
|
2291
|
+
let t = /* @__PURE__ */ new Map();
|
|
2292
|
+
for (let n of e) t.set(x(n), n);
|
|
2293
|
+
for (let [e, n] of d) {
|
|
2294
|
+
let r = t.get(e);
|
|
2295
|
+
n.from && r && r !== n.from && d.delete(e);
|
|
2296
|
+
}
|
|
2297
|
+
h.value++;
|
|
2298
|
+
}), {
|
|
2299
|
+
keyOf: x,
|
|
2300
|
+
batch: S,
|
|
2301
|
+
allRows: ee,
|
|
2302
|
+
rowByKey: (e) => w.value.get(e),
|
|
2303
|
+
rowNoOf: E,
|
|
2304
|
+
isNew: ne,
|
|
2305
|
+
isRemoved: (e) => p.has(e),
|
|
2306
|
+
read: D,
|
|
2307
|
+
readUntracked: oe,
|
|
2308
|
+
original: re,
|
|
2309
|
+
current: se,
|
|
2310
|
+
set: I,
|
|
2311
|
+
apply: ue,
|
|
2312
|
+
addRows: L,
|
|
2313
|
+
removeRows: de,
|
|
2314
|
+
undo: pe,
|
|
2315
|
+
redo: me,
|
|
2316
|
+
canUndo: v,
|
|
2317
|
+
canRedo: y,
|
|
2318
|
+
clearHistory: he,
|
|
2319
|
+
version: h,
|
|
2320
|
+
rowDraft: ge,
|
|
2321
|
+
rowIssues: _e,
|
|
2322
|
+
rowError: ve,
|
|
2323
|
+
hasError: ye,
|
|
2324
|
+
counts: B,
|
|
2325
|
+
reset: () => {
|
|
2326
|
+
a.clear(), o.clear(), s.clear(), c.clear(), f.value = [], p.clear(), he(), h.value++;
|
|
2327
|
+
},
|
|
2328
|
+
getChanges: () => {
|
|
2329
|
+
let e = r.value.get(i()), t = n.value.filter((e) => e.required || e.id === i()), o = [];
|
|
2330
|
+
for (let [n, r] of a) {
|
|
2331
|
+
let a = w.value.get(n);
|
|
2332
|
+
if (!a || p.has(n) || ye(n)) continue;
|
|
2333
|
+
let s = ne(n), c = {};
|
|
2334
|
+
for (let [e, t] of r) (!s || !T(t)) && (c[e] = t);
|
|
2335
|
+
for (let e of t) {
|
|
2336
|
+
let t = e.id;
|
|
2337
|
+
if (t in c) continue;
|
|
2338
|
+
let n = D(a, e);
|
|
2339
|
+
T(n) || (c[t] = n);
|
|
2340
|
+
}
|
|
2341
|
+
o.push({
|
|
2342
|
+
clientId: n,
|
|
2343
|
+
key: String(e ? D(a, e) : u(a, i())),
|
|
2344
|
+
values: c
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
return o.sort((e, t) => E(e.clientId) - E(t.clientId)), { rows: o };
|
|
2348
|
+
},
|
|
2349
|
+
applyResult: (e) => {
|
|
2350
|
+
let t = 0, n = 0, r = 0, i = /* @__PURE__ */ new Set();
|
|
2351
|
+
for (let l of e) {
|
|
2352
|
+
let e = l.clientId, u = w.value.get(e);
|
|
2353
|
+
if (u) {
|
|
2354
|
+
if (l.status === "error") {
|
|
2355
|
+
r++;
|
|
2356
|
+
let t = l.fieldErrors ? new Map(Object.entries(l.fieldErrors)) : null;
|
|
2357
|
+
t?.size ? s.set(e, t) : s.delete(e), l.rowError ? c.set(e, l.rowError) : c.delete(e);
|
|
2358
|
+
} else l.status === "created" ? t++ : n++, d.set(e, {
|
|
2359
|
+
row: l.row ?? se(u),
|
|
2360
|
+
from: ne(e) ? void 0 : u
|
|
2361
|
+
}), a.delete(e), o.delete(e), s.delete(e), c.delete(e), te.value.has(e) && i.add(e);
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
return i.size && (f.value = f.value.map((e) => i.has(e.key) ? {
|
|
2365
|
+
...e,
|
|
2366
|
+
saved: !0
|
|
2367
|
+
} : e)), he(), h.value++, {
|
|
2368
|
+
created: t,
|
|
2369
|
+
updated: n,
|
|
2370
|
+
errors: r
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2375
|
+
//#endregion
|
|
2376
|
+
//#region src/sheet/useSheetTable.ts
|
|
2377
|
+
var Pi = rt({ cellSelectionFeature: nt });
|
|
2378
|
+
function Fi(e) {
|
|
2379
|
+
let t = j(() => Te(e.columnIds).map((e) => ({
|
|
2380
|
+
id: e,
|
|
2381
|
+
accessorFn: () => void 0
|
|
2382
|
+
}))), n = it({
|
|
2383
|
+
features: Pi,
|
|
2384
|
+
columns: t,
|
|
2385
|
+
data: j(() => Te(e.rows)),
|
|
2386
|
+
getRowId: e.rowId,
|
|
2387
|
+
autoResetCellSelection: !1,
|
|
2388
|
+
enableMultiCellRangeSelection: !1
|
|
2389
|
+
}), r = j(() => {
|
|
2390
|
+
let e = n.atoms.cellSelection.get(), t = e[e.length - 1];
|
|
2391
|
+
return t ? {
|
|
2392
|
+
rowId: t.anchorRowId,
|
|
2393
|
+
columnId: t.anchorColumnId
|
|
2394
|
+
} : null;
|
|
2395
|
+
}), i = j(() => n.getCellSelectionBounds()[0] ?? null), a = j(() => {
|
|
2396
|
+
let e = n.atoms.cellSelection.get()[0];
|
|
2397
|
+
return e ? {
|
|
2398
|
+
rowId: e.focusRowId,
|
|
2399
|
+
columnId: e.focusColumnId
|
|
2400
|
+
} : null;
|
|
2401
|
+
}), o = (e, t) => n.getCoreRowModel().rowsById[e]?.getAllCellsByColumnId()[t];
|
|
2402
|
+
return {
|
|
2403
|
+
active: r,
|
|
2404
|
+
bounds: i,
|
|
2405
|
+
rangeEnd: a,
|
|
2406
|
+
focus: (e, t) => n.setFocusedCell(e, t),
|
|
2407
|
+
move: (e) => n.moveCellSelection(e),
|
|
2408
|
+
extend: (e) => n.extendCellSelection(e),
|
|
2409
|
+
selectAll: () => n.selectAllCells(),
|
|
2410
|
+
selectRange: (e) => n.selectCellRange(e),
|
|
2411
|
+
clear: () => n.resetCellSelection(!0),
|
|
2412
|
+
startHandler: (e, t) => o(e, t)?.getSelectionStartHandler(),
|
|
2413
|
+
extendHandler: (e, t) => o(e, t)?.getSelectionExtendHandler()
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
//#endregion
|
|
2417
|
+
//#region src/sheet/DataSheet.vue?vue&type=script&setup=true&lang.ts
|
|
2418
|
+
var Ii = ["data-density"], Li = {
|
|
2419
|
+
key: 0,
|
|
2420
|
+
class: "dt-sheet-readonly",
|
|
2421
|
+
role: "note"
|
|
2422
|
+
}, Ri = { class: "dt-sheet-readonly-text" }, zi = {
|
|
2423
|
+
class: "dt-toolbar dt-sheet-toolbar",
|
|
2424
|
+
role: "toolbar"
|
|
2425
|
+
}, Bi = {
|
|
2426
|
+
key: 0,
|
|
2427
|
+
class: "dt-progress-strip"
|
|
2428
|
+
}, Vi = {
|
|
2429
|
+
key: 0,
|
|
2430
|
+
class: "dt-progress-count"
|
|
2431
|
+
}, Hi = ["aria-valuenow"], Ui = {
|
|
2432
|
+
key: 0,
|
|
2433
|
+
class: "dt-find-count",
|
|
2434
|
+
role: "status"
|
|
2435
|
+
}, Wi = {
|
|
2436
|
+
key: 0,
|
|
2437
|
+
class: "dt-find-count",
|
|
2438
|
+
role: "status"
|
|
2439
|
+
}, Gi = { class: "dt-seg-count" }, Ki = { class: "dt-seg-count" }, qi = { class: "dt-seg-count" }, Ji = ["aria-disabled"], Yi = ["aria-disabled"], Xi = {
|
|
2440
|
+
type: "button",
|
|
2441
|
+
class: "dt-btn dt-btn-ghost has-icon dt-sheet-export"
|
|
2442
|
+
}, Zi = {
|
|
2443
|
+
key: 0,
|
|
2444
|
+
class: "dt-sheet-dot",
|
|
2445
|
+
"aria-hidden": "true"
|
|
2446
|
+
}, Qi = ["disabled"], $i = [
|
|
2447
|
+
"disabled",
|
|
2448
|
+
"aria-disabled",
|
|
2449
|
+
"data-dt-tip"
|
|
2450
|
+
], ea = {
|
|
2451
|
+
key: 1,
|
|
2452
|
+
class: "dt-sheet-partly",
|
|
2453
|
+
role: "alert"
|
|
2454
|
+
}, ta = { class: "dt-partly-nav" }, na = ["aria-label"], ra = ["aria-label"], ia = {
|
|
2455
|
+
key: 2,
|
|
2456
|
+
class: "dt-strip dt-sheet-strip",
|
|
2457
|
+
role: "status"
|
|
2458
|
+
}, aa = {
|
|
2459
|
+
key: 3,
|
|
2460
|
+
class: "dt-formula"
|
|
2461
|
+
}, oa = { class: "dt-formula-name" }, sa = { class: "dt-mono" }, ca = { class: "dt-formula-col" }, la = [
|
|
2462
|
+
"value",
|
|
2463
|
+
"readonly",
|
|
2464
|
+
"aria-label"
|
|
2465
|
+
], ua = {
|
|
2466
|
+
key: 0,
|
|
2467
|
+
class: "dt-formula-hint"
|
|
2468
|
+
}, da = {
|
|
2469
|
+
key: 1,
|
|
2470
|
+
class: "dt-formula-hint"
|
|
2471
|
+
}, fa = {
|
|
2472
|
+
key: 4,
|
|
2473
|
+
class: "dt-sheet-footer",
|
|
2474
|
+
role: "status"
|
|
2475
|
+
}, pa = { class: "dt-sheet-footer-badge" }, ma = ["aria-label"], ha = { class: "dt-status-rows" }, ga = {
|
|
2476
|
+
key: 0,
|
|
2477
|
+
class: "dt-status-saved"
|
|
2478
|
+
}, _a = {
|
|
2479
|
+
key: 1,
|
|
2480
|
+
class: "dt-status-changes"
|
|
2481
|
+
}, va = {
|
|
2482
|
+
key: 2,
|
|
2483
|
+
class: "dt-status-muted"
|
|
2484
|
+
}, ya = {
|
|
2485
|
+
key: 3,
|
|
2486
|
+
class: "dt-status-new"
|
|
2487
|
+
}, ba = ["aria-label"], xa = { key: 0 }, Sa = { key: 1 }, Ca = {
|
|
2488
|
+
key: 6,
|
|
2489
|
+
class: "dt-toast dt-sheet-toast",
|
|
2490
|
+
role: "status"
|
|
2491
|
+
}, wa = { class: "dt-toast-warn" }, Ta = { class: "dt-kbd" }, Ea = {
|
|
2492
|
+
class: "dt-sr-only",
|
|
2493
|
+
"aria-live": "polite"
|
|
2494
|
+
}, Da = {
|
|
2495
|
+
class: "dt-sr-only",
|
|
2496
|
+
"aria-live": "assertive"
|
|
2497
|
+
}, Oa = /* @__PURE__ */ R({
|
|
2498
|
+
__name: "DataSheet",
|
|
2499
|
+
props: {
|
|
2500
|
+
tableId: {},
|
|
2501
|
+
columns: {},
|
|
2502
|
+
rows: {},
|
|
2503
|
+
rowKey: { default: "id" },
|
|
2504
|
+
density: {},
|
|
2505
|
+
entityName: {},
|
|
2506
|
+
keyColumn: {},
|
|
2507
|
+
loading: {
|
|
2508
|
+
type: [Boolean, Object],
|
|
2509
|
+
default: !1
|
|
2510
|
+
},
|
|
2511
|
+
saving: {
|
|
2512
|
+
type: [Boolean, Object],
|
|
2513
|
+
default: !1
|
|
2514
|
+
},
|
|
2515
|
+
newRowDefaults: {},
|
|
2516
|
+
parseFile: {},
|
|
2517
|
+
importable: {
|
|
2518
|
+
type: Boolean,
|
|
2519
|
+
default: !0
|
|
2520
|
+
},
|
|
2521
|
+
exportable: {
|
|
2522
|
+
type: Boolean,
|
|
2523
|
+
default: !0
|
|
2524
|
+
},
|
|
2525
|
+
maxRows: { default: 1e4 },
|
|
2526
|
+
readOnlyBelow: { default: 768 }
|
|
2527
|
+
},
|
|
2528
|
+
emits: ["save", "export"],
|
|
2529
|
+
setup(t, { expose: n, emit: a }) {
|
|
2530
|
+
let o = t, s = a, d = c(), { i18n: f } = d, m = x(d.locale), h = j(() => o.entityName ?? {
|
|
2531
|
+
one: o.tableId,
|
|
2532
|
+
other: o.tableId
|
|
2533
|
+
}), _ = "onExport" in (de()?.vnode.props ?? {}), S = (e) => o.parseFile ? o.parseFile(e) : Ur(e, f), C = ae(() => o.tableId, d.preferences, {
|
|
2534
|
+
density: o.density ?? "compact",
|
|
2535
|
+
verticalLines: !0,
|
|
2536
|
+
pageSize: 0,
|
|
2537
|
+
defaultViewId: null
|
|
2538
|
+
}), ne = j(() => o.density ?? C.prefs.density), ie = j(() => o.rows.length > o.maxRows), D = j(() => ie.value ? o.rows.slice(0, o.maxRows) : o.rows), O = j(() => o.loading !== !1), k = j(() => o.saving !== !1), le = j(() => {
|
|
2539
|
+
let e = O.value ? o.loading : o.saving;
|
|
2540
|
+
return typeof e == "object" ? e : null;
|
|
2541
|
+
}), R = j(() => le.value && le.value.total > 0 ? Math.round(100 * le.value.done / le.value.total) : null), z = typeof matchMedia == "function" && (matchMedia(`(max-width: ${o.readOnlyBelow - 1}px)`).matches || !matchMedia("(any-pointer: fine)").matches), fe = j(() => o.columns.map((e) => e.id === o.keyColumn ? {
|
|
2542
|
+
...e,
|
|
2543
|
+
width: z ? 104 : 128
|
|
2544
|
+
} : e)), pe = j(() => fe.value.filter((e) => e.id === o.keyColumn || e.primary && !z).map((e) => e.id)), Ce = j(() => new Map(fe.value.map((e) => [e.id, e]))), W = j(() => Ce.value.get(o.keyColumn)), Te = j(() => fe.value.find((e) => e.primary)), K = Ni({
|
|
2545
|
+
rows: D,
|
|
2546
|
+
columns: fe,
|
|
2547
|
+
rowKey: () => o.rowKey,
|
|
2548
|
+
keyColumn: () => o.keyColumn,
|
|
2549
|
+
i18n: f,
|
|
2550
|
+
locale: d.locale
|
|
2551
|
+
}), Ee = V([]), Oe = H(null), ke = V("all"), Me = H(/* @__PURE__ */ new Set()), Pe = (e) => ke.value === "changed" ? !!K.rowDraft(e)?.size || K.isNew(e) : ke.value !== "errors" || K.hasError(e), Fe = (e) => {
|
|
2552
|
+
let t = e ? new Set(Me.value) : /* @__PURE__ */ new Set();
|
|
2553
|
+
for (let e of K.batch.value) {
|
|
2554
|
+
let n = K.keyOf(e);
|
|
2555
|
+
Pe(n) && t.add(n);
|
|
2556
|
+
}
|
|
2557
|
+
Me.value = t;
|
|
2558
|
+
}, Ie = (e) => {
|
|
2559
|
+
ke.value = e, Fe(!1);
|
|
2560
|
+
};
|
|
2561
|
+
je(K.version, () => {
|
|
2562
|
+
ke.value !== "all" && Fe(!0);
|
|
2563
|
+
});
|
|
2564
|
+
let ze = j(() => {
|
|
2565
|
+
let e = K.batch.value, t = Oe.value;
|
|
2566
|
+
if (!t) return e;
|
|
2567
|
+
let n = new Set(t), r = [];
|
|
2568
|
+
for (let e of t) {
|
|
2569
|
+
let t = K.rowByKey(e);
|
|
2570
|
+
t && r.push(t);
|
|
2571
|
+
}
|
|
2572
|
+
for (let t of e) n.has(K.keyOf(t)) || r.push(t);
|
|
2573
|
+
return r;
|
|
2574
|
+
}), J = j(() => {
|
|
2575
|
+
let e = ke.value === "all", t = Me.value;
|
|
2576
|
+
return ze.value.filter((n) => {
|
|
2577
|
+
let r = K.keyOf(n);
|
|
2578
|
+
return !K.isRemoved(r) && (e || t.has(r));
|
|
2579
|
+
});
|
|
2580
|
+
}), Y = i({
|
|
2581
|
+
columns: fe,
|
|
2582
|
+
rows: J,
|
|
2583
|
+
rowKey: () => o.rowKey,
|
|
2584
|
+
fixedStart: pe,
|
|
2585
|
+
flexLastStart: !0
|
|
2586
|
+
}), X = Fi({
|
|
2587
|
+
rows: J,
|
|
2588
|
+
columnIds: () => Y.columns.value.map((e) => e.id),
|
|
2589
|
+
rowId: K.keyOf
|
|
2590
|
+
}), qe = j(() => {
|
|
2591
|
+
let e = /* @__PURE__ */ new Map();
|
|
2592
|
+
return J.value.forEach((t, n) => e.set(K.keyOf(t), n)), e;
|
|
2593
|
+
}), Z = j(() => Y.columns.value), Qe = j(() => O.value || k.value || z), tt = {
|
|
2594
|
+
string: Fn,
|
|
2595
|
+
text: Fn,
|
|
2596
|
+
uppercase: Fn,
|
|
2597
|
+
lowercase: Fn,
|
|
2598
|
+
email: Fn,
|
|
2599
|
+
url: Fn,
|
|
2600
|
+
phone: Fn,
|
|
2601
|
+
id: Fn,
|
|
2602
|
+
color: Fn,
|
|
2603
|
+
int: jn,
|
|
2604
|
+
float: jn,
|
|
2605
|
+
percentage: jn,
|
|
2606
|
+
currency: jn,
|
|
2607
|
+
star: jn,
|
|
2608
|
+
select: Mn,
|
|
2609
|
+
multiselect: Un,
|
|
2610
|
+
date: Bn,
|
|
2611
|
+
datetime: Bn
|
|
2612
|
+
}, nt = (e) => e.editor ?? tt[e.type] ?? null, rt = (e, t) => {
|
|
2613
|
+
if (Qe.value) return !1;
|
|
2614
|
+
let n = K.isNew(K.keyOf(e));
|
|
2615
|
+
return t.id === o.keyColumn ? n : t.type !== "boolean" && !nt(t) ? !1 : typeof t.editable == "function" ? t.editable(K.current(e), { isNew: n }) : t.editable === !0;
|
|
2616
|
+
}, it = (e = d.locale) => ({
|
|
2617
|
+
locale: e,
|
|
2618
|
+
today: /* @__PURE__ */ new Date(),
|
|
2619
|
+
todayWord: f.t("date.today"),
|
|
2620
|
+
yesWord: f.t("common.yes"),
|
|
2621
|
+
noWord: f.t("common.no")
|
|
2622
|
+
}), Q = Di({
|
|
2623
|
+
store: K,
|
|
2624
|
+
canEdit: rt,
|
|
2625
|
+
parse: (e, t) => wn(e, t, it())
|
|
2626
|
+
});
|
|
2627
|
+
be(Vn, { seed: () => Q.editing.value?.seed });
|
|
2628
|
+
let at = De("grid"), $ = K.counts, ot = {
|
|
2629
|
+
fmt: m,
|
|
2630
|
+
i18n: f,
|
|
2631
|
+
today: /* @__PURE__ */ new Date(),
|
|
2632
|
+
labels: new v()
|
|
2633
|
+
}, st = (e, t, n, r) => {
|
|
2634
|
+
let i = J.value, a = Z.value, o = i[e], s = i[n];
|
|
2635
|
+
o && s && a[t] && a[r] && (X.selectRange({
|
|
2636
|
+
anchorRowId: K.keyOf(o),
|
|
2637
|
+
anchorColumnId: a[t].id,
|
|
2638
|
+
focusRowId: K.keyOf(s),
|
|
2639
|
+
focusColumnId: a[r].id
|
|
2640
|
+
}), at.value?.focusActive());
|
|
2641
|
+
}, ct = (e, t) => {
|
|
2642
|
+
let n = J.value[Math.max(0, Math.min(J.value.length - 1, e))];
|
|
2643
|
+
n && (X.focus(K.keyOf(n), t), at.value?.focusActive());
|
|
2644
|
+
}, lt = () => {
|
|
2645
|
+
let e = X.bounds.value;
|
|
2646
|
+
if (!e) return [];
|
|
2647
|
+
let t = [];
|
|
2648
|
+
for (let n = e.minRowIndex; n <= e.maxRowIndex; n++) for (let r = e.minColumnIndex; r <= e.maxColumnIndex; r++) t.push({
|
|
2649
|
+
r: n,
|
|
2650
|
+
c: r
|
|
2651
|
+
});
|
|
2652
|
+
return t;
|
|
2653
|
+
}, ut = (e, t) => K.set(e, t, !K.read(e, t)), dt = () => {
|
|
2654
|
+
let e = [];
|
|
2655
|
+
for (let { r: t, c: n } of lt()) {
|
|
2656
|
+
let r = J.value[t], i = Z.value[n]?.def;
|
|
2657
|
+
r && i && rt(r, i) && e.push({
|
|
2658
|
+
row: r,
|
|
2659
|
+
def: i,
|
|
2660
|
+
value: null
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
K.apply(e);
|
|
2664
|
+
}, ft = j(() => (K.version.value, ze.value.map((e) => K.keyOf(e)).filter((e) => !K.isRemoved(e) && K.hasError(e)))), pt = (e) => {
|
|
2665
|
+
let t = J.value, n = t.length, r = X.active.value, i = r ? qe.value.get(r.rowId) ?? -1 : -1;
|
|
2666
|
+
for (let r = 1; r <= n; r++) {
|
|
2667
|
+
let a = ((i + e * r) % n + n) % n, s = K.keyOf(t[a]);
|
|
2668
|
+
if (!K.hasError(s)) continue;
|
|
2669
|
+
let c = K.rowIssues(s), l = Z.value.find((e) => c?.get(e.id)?.level === "error") ?? (K.rowError(s) ? Z.value.find((e) => e.id === o.keyColumn) : void 0);
|
|
2670
|
+
if (l) {
|
|
2671
|
+
X.focus(s, l.id), at.value?.focusActive();
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
ft.value.length && ke.value !== "all" && cr({
|
|
2676
|
+
text: f.t("sheet.nextErrorHidden"),
|
|
2677
|
+
action: {
|
|
2678
|
+
label: f.t("sheet.showIt"),
|
|
2679
|
+
run: () => {
|
|
2680
|
+
Ie("all"), pt(e);
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
});
|
|
2684
|
+
}, mt = (e, t, n) => r(e, t, n, ot), ht = () => {
|
|
2685
|
+
let e = X.bounds.value;
|
|
2686
|
+
if (!e) return null;
|
|
2687
|
+
let t = [];
|
|
2688
|
+
for (let n = e.minRowIndex; n <= e.maxRowIndex; n++) {
|
|
2689
|
+
let r = J.value[n];
|
|
2690
|
+
if (!r) continue;
|
|
2691
|
+
let i = [];
|
|
2692
|
+
for (let t = e.minColumnIndex; t <= e.maxColumnIndex; t++) {
|
|
2693
|
+
let e = Z.value[t].def;
|
|
2694
|
+
i.push(mt(e, r, K.read(r, e)));
|
|
2695
|
+
}
|
|
2696
|
+
t.push(i);
|
|
2697
|
+
}
|
|
2698
|
+
return t;
|
|
2699
|
+
}, gt = (e) => {
|
|
2700
|
+
let t = ht();
|
|
2701
|
+
return !t || !e ? !1 : (e.setData("text/plain", fn(t)), e.setData("text/html", mn(t)), !0);
|
|
2702
|
+
}, _t = (e) => gt(e) ? (Qe.value || dt(), !0) : !1, vt = (e) => {
|
|
2703
|
+
let t = ht(), n = typeof navigator < "u" ? navigator.clipboard : void 0;
|
|
2704
|
+
if (!t || !n) return;
|
|
2705
|
+
let r = fn(t);
|
|
2706
|
+
(typeof ClipboardItem == "function" && n.write ? n.write([new ClipboardItem({
|
|
2707
|
+
"text/plain": new Blob([r], { type: "text/plain" }),
|
|
2708
|
+
"text/html": new Blob([mn(t)], { type: "text/html" })
|
|
2709
|
+
})]) : n.writeText(r)).catch(() => n.writeText(r)).catch(() => {}), e && !Qe.value && dt();
|
|
2710
|
+
}, yt = (e) => {
|
|
2711
|
+
let t = X.active.value, n = Math.max(0, ...e.map((e) => e.length));
|
|
2712
|
+
if (!t || !e.length || !n || Qe.value) return !1;
|
|
2713
|
+
let r = Z.value, i = qe.value.get(t.rowId), a = r.findIndex((e) => e.id === t.columnId);
|
|
2714
|
+
if (i === void 0 || a < 0) return !1;
|
|
2715
|
+
let s = X.bounds.value, c = [];
|
|
2716
|
+
if (e.length === 1 && n === 1 && s && (s.maxRowIndex > s.minRowIndex || s.maxColumnIndex > s.minColumnIndex)) for (let { r: t, c: n } of lt()) c.push({
|
|
2717
|
+
r: t,
|
|
2718
|
+
c: n,
|
|
2719
|
+
text: e[0][0]
|
|
2720
|
+
});
|
|
2721
|
+
else e.forEach((e, t) => e.forEach((e, n) => {
|
|
2722
|
+
a + n < r.length && c.push({
|
|
2723
|
+
r: i + t,
|
|
2724
|
+
c: a + n,
|
|
2725
|
+
text: e
|
|
2726
|
+
});
|
|
2727
|
+
}));
|
|
2728
|
+
let u = Math.max(...c.map((e) => e.r)), p = u - J.value.length + 1;
|
|
2729
|
+
if (p > 0 && K.allRows.value.length + p > o.maxRows) return cr({ text: f.t("sheet.limitPaste", {
|
|
2730
|
+
count: m.int(K.allRows.value.length + p),
|
|
2731
|
+
max: m.int(o.maxRows)
|
|
2732
|
+
}) }), !0;
|
|
2733
|
+
let h = p > 0 ? K.addRows(p) : [];
|
|
2734
|
+
h.length && Oe.value && (Oe.value = [...Oe.value, ...h.map((e) => e.key)]);
|
|
2735
|
+
let g = J.value, _ = /* @__PURE__ */ new Map();
|
|
2736
|
+
for (let e of new Set(c.map((e) => e.c))) {
|
|
2737
|
+
let t = r[e].def;
|
|
2738
|
+
if (!l[t.type].numeric) continue;
|
|
2739
|
+
let n = bn(c.filter((t) => t.c === e).map((e) => e.text));
|
|
2740
|
+
_.set(e, n === "," ? "de" : n === "." ? "en" : d.locale);
|
|
2741
|
+
}
|
|
2742
|
+
let v = [];
|
|
2743
|
+
for (let e of c) {
|
|
2744
|
+
let t = g[e.r], n = r[e.c]?.def;
|
|
2745
|
+
t && n && rt(t, n) && v.push({
|
|
2746
|
+
row: t,
|
|
2747
|
+
def: n,
|
|
2748
|
+
value: wn(n, e.text, it(_.get(e.c)))
|
|
2749
|
+
});
|
|
2750
|
+
}
|
|
2751
|
+
K.apply(v, h);
|
|
2752
|
+
let y = Math.min(...c.map((e) => e.r)), b = Math.min(...c.map((e) => e.c)), x = Math.max(...c.map((e) => e.c));
|
|
2753
|
+
st(y, b, u, x);
|
|
2754
|
+
let S = c.map((e) => {
|
|
2755
|
+
let t = g[e.r];
|
|
2756
|
+
return (t && K.rowIssues(K.keyOf(t))?.get(r[e.c].id))?.level === "error" ? {
|
|
2757
|
+
...e,
|
|
2758
|
+
option: r[e.c].def.type === "select" || r[e.c].def.type === "multiselect"
|
|
2759
|
+
} : null;
|
|
2760
|
+
}).filter((e) => e !== null), C = S.filter((e) => e.option).length, ee = S.length - C, w = {
|
|
2761
|
+
rows: u - y + 1,
|
|
2762
|
+
cols: x - b + 1
|
|
2763
|
+
}, T = S[0];
|
|
2764
|
+
return cr({
|
|
2765
|
+
text: f.t("sheet.pasted", {
|
|
2766
|
+
rows: m.int(w.rows),
|
|
2767
|
+
cols: m.int(w.cols)
|
|
2768
|
+
}),
|
|
2769
|
+
issues: [C ? f.t("sheet.pasteIssues", { count: C }) : "", ee ? f.t("sheet.pasteErrors", { count: ee }) : ""].filter(Boolean).join(" · ") || void 0,
|
|
2770
|
+
review: T ? () => st(T.r, T.c, T.r, T.c) : void 0,
|
|
2771
|
+
undo: !0
|
|
2772
|
+
}), dr.value = f.t("sr.pasted", w), !0;
|
|
2773
|
+
}, bt = (e) => yt(_n(e)), xt = () => {
|
|
2774
|
+
navigator.clipboard?.readText().then((e) => yt(hn(e))).catch(() => {});
|
|
2775
|
+
}, St = (e, t, n, r) => {
|
|
2776
|
+
let i = J.value, a = r < e, o = a ? e - r : r - t, s = [];
|
|
2777
|
+
for (let r = n[0]; r <= n[1]; r++) {
|
|
2778
|
+
let n = Z.value[r]?.def;
|
|
2779
|
+
if (!n) continue;
|
|
2780
|
+
let c = Wn(i.slice(e, t + 1).map((e) => K.read(e, n)), o, a);
|
|
2781
|
+
for (let r = 0; r < o; r++) {
|
|
2782
|
+
let o = i[a ? e - 1 - r : t + 1 + r];
|
|
2783
|
+
o && rt(o, n) && s.push({
|
|
2784
|
+
row: o,
|
|
2785
|
+
def: n,
|
|
2786
|
+
value: c[r]
|
|
2787
|
+
});
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
return {
|
|
2791
|
+
changes: s,
|
|
2792
|
+
count: o
|
|
2793
|
+
};
|
|
2794
|
+
}, Ct = (e, t, n, r) => {
|
|
2795
|
+
let { changes: i } = St(e, t, n, r);
|
|
2796
|
+
K.apply(i), st(Math.min(e, r), n[0], Math.max(t, r), n[1]);
|
|
2797
|
+
}, wt = (e, t, n, r) => {
|
|
2798
|
+
let { changes: i, count: a } = St(e, t, n, r), o = i[0], s = o ? oe(o.def, o.row, o.value, ot) : "";
|
|
2799
|
+
return f.t("sheet.fillPreview", {
|
|
2800
|
+
count: a * (n[1] - n[0] + 1),
|
|
2801
|
+
value: s
|
|
2802
|
+
});
|
|
2803
|
+
}, Tt = () => {
|
|
2804
|
+
let e = X.bounds.value;
|
|
2805
|
+
e && e.maxRowIndex !== e.minRowIndex && Ct(e.minRowIndex, e.minRowIndex, [e.minColumnIndex, e.maxColumnIndex], e.maxRowIndex);
|
|
2806
|
+
}, Et = (e) => {
|
|
2807
|
+
if (!e) return;
|
|
2808
|
+
if (e.removed?.length && !e.patches.length) {
|
|
2809
|
+
let t = qe.value.get(e.removed[0]);
|
|
2810
|
+
t !== void 0 && ct(t, X.active.value?.columnId ?? Z.value[0].id);
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
if (!e.patches.length) return;
|
|
2814
|
+
let t = Z.value.map((e) => e.id), n = Infinity, r = -1, i = Infinity, a = -1;
|
|
2815
|
+
for (let o of e.patches) {
|
|
2816
|
+
let e = qe.value.get(o.key), s = t.indexOf(o.col);
|
|
2817
|
+
e === void 0 || s < 0 || (n = Math.min(n, e), r = Math.max(r, e), i = Math.min(i, s), a = Math.max(a, s));
|
|
2818
|
+
}
|
|
2819
|
+
r >= 0 && st(n, i, r, a);
|
|
2820
|
+
}, Dt = () => {
|
|
2821
|
+
Qe.value || (Q.cancel(), Et(K.undo()));
|
|
2822
|
+
}, Ot = () => {
|
|
2823
|
+
Qe.value || (Q.cancel(), Et(K.redo()));
|
|
2824
|
+
}, kt = (e, t, n) => K.set(e, t, n), At = (e) => {
|
|
2825
|
+
if (Qe.value) return;
|
|
2826
|
+
if (K.allRows.value.length + 1 > o.maxRows) {
|
|
2827
|
+
cr({ text: f.t("sheet.limitPaste", {
|
|
2828
|
+
count: m.int(K.allRows.value.length + 1),
|
|
2829
|
+
max: m.int(o.maxRows)
|
|
2830
|
+
}) });
|
|
2831
|
+
return;
|
|
2832
|
+
}
|
|
2833
|
+
Q.commit();
|
|
2834
|
+
let [t] = K.addRows(1);
|
|
2835
|
+
if (!t) return;
|
|
2836
|
+
let n = o.newRowDefaults?.() ?? {}, r = [];
|
|
2837
|
+
for (let [e, i] of Object.entries(n)) {
|
|
2838
|
+
let n = Ce.value.get(e);
|
|
2839
|
+
n && !T(i) && r.push({
|
|
2840
|
+
row: t.row,
|
|
2841
|
+
def: n,
|
|
2842
|
+
value: i
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
if (K.apply(r, [t]), e !== void 0) {
|
|
2846
|
+
let n = Oe.value ?? K.batch.value.map((e) => K.keyOf(e)).filter((e) => e !== t.key), r = Math.max(0, Math.min(n.length, e));
|
|
2847
|
+
Oe.value = [
|
|
2848
|
+
...n.slice(0, r),
|
|
2849
|
+
t.key,
|
|
2850
|
+
...n.slice(r)
|
|
2851
|
+
];
|
|
2852
|
+
} else Oe.value &&= [...Oe.value, t.key];
|
|
2853
|
+
ke.value !== "all" && (Me.value = /* @__PURE__ */ new Set([...Me.value, t.key])), X.focus(t.key, o.keyColumn), he(() => at.value?.scrollToIndex(J.value.findIndex((e) => K.keyOf(e) === t.key))), at.value?.focusActive(), W.value && Q.start(t.row, W.value, { inCell: !0 });
|
|
2854
|
+
}, jt = (e) => {
|
|
2855
|
+
let t = X.active.value, n = t ? ze.value.findIndex((e) => K.keyOf(e) === t.rowId) : -1;
|
|
2856
|
+
At(n < 0 ? void 0 : e === "above" ? n : n + 1);
|
|
2857
|
+
}, Mt = () => {
|
|
2858
|
+
if (Qe.value) return;
|
|
2859
|
+
let e = X.bounds.value;
|
|
2860
|
+
if (!e) return;
|
|
2861
|
+
Q.cancel();
|
|
2862
|
+
let t = J.value.slice(e.minRowIndex, e.maxRowIndex + 1).map((e) => K.keyOf(e));
|
|
2863
|
+
t.length && (K.removeRows(t), cr({
|
|
2864
|
+
text: t.length === 1 ? f.t("sheet.removed", {
|
|
2865
|
+
count: 1,
|
|
2866
|
+
row: K.rowNoOf(t[0]),
|
|
2867
|
+
entity: h.value
|
|
2868
|
+
}) : f.t("sheet.removed", {
|
|
2869
|
+
count: t.length,
|
|
2870
|
+
entity: h.value
|
|
2871
|
+
}),
|
|
2872
|
+
undo: !0
|
|
2873
|
+
}), ct(e.minRowIndex, X.active.value?.columnId ?? Z.value[0].id));
|
|
2874
|
+
}, Nt = (e, t) => {
|
|
2875
|
+
let n = Ce.value.get(e);
|
|
2876
|
+
if (!n || !(n.sortable ?? l[n.type].sortable)) return;
|
|
2877
|
+
let r = Ee.value, i = r.find((t) => t.column === e), a = i ? i.dir === "asc" ? {
|
|
2878
|
+
column: e,
|
|
2879
|
+
dir: "desc"
|
|
2880
|
+
} : null : {
|
|
2881
|
+
column: e,
|
|
2882
|
+
dir: "asc"
|
|
2883
|
+
}, o = r.filter((t) => t.column !== e);
|
|
2884
|
+
if (Ee.value = t ? a ? i ? r.map((t) => t.column === e ? a : t) : [...o, a].slice(-3) : o : a ? [a] : [], !Ee.value.length) {
|
|
2885
|
+
Oe.value = null;
|
|
2886
|
+
return;
|
|
2887
|
+
}
|
|
2888
|
+
let s = Ee.value.map((e) => ({
|
|
2889
|
+
def: Ce.value.get(e.column),
|
|
2890
|
+
cmp: w(Ce.value.get(e.column), d.locale),
|
|
2891
|
+
sign: e.dir === "desc" ? -1 : 1
|
|
2892
|
+
}));
|
|
2893
|
+
Oe.value = [...K.batch.value].sort((e, t) => {
|
|
2894
|
+
for (let { def: n, cmp: r, sign: i } of s) {
|
|
2895
|
+
let a = r(K.read(e, n), K.read(t, n)) * i;
|
|
2896
|
+
if (a) return a;
|
|
2897
|
+
}
|
|
2898
|
+
return K.rowNoOf(K.keyOf(e)) - K.rowNoOf(K.keyOf(t));
|
|
2899
|
+
}).map((e) => K.keyOf(e));
|
|
2900
|
+
}, Pt = j(() => {
|
|
2901
|
+
let e = /* @__PURE__ */ new Map();
|
|
2902
|
+
return Ee.value.forEach((t, n) => e.set(t.column, {
|
|
2903
|
+
dir: t.dir,
|
|
2904
|
+
index: Ee.value.length > 1 ? n + 1 : null
|
|
2905
|
+
})), e;
|
|
2906
|
+
}), Ft = V(!1), It = j(() => ft.value.filter((e) => !!K.rowDraft(e)?.size || K.isNew(e)).map((e) => {
|
|
2907
|
+
let t = K.rowByKey(e), n = K.rowIssues(e), r = n ? [...n.values()].find((e) => e.level === "error") : void 0;
|
|
2908
|
+
return {
|
|
2909
|
+
rowNo: K.rowNoOf(e),
|
|
2910
|
+
key: W.value ? Tn(W.value, K.read(t, W.value)) : e,
|
|
2911
|
+
message: r?.message ?? K.rowError(e) ?? ""
|
|
2912
|
+
};
|
|
2913
|
+
})), Lt = H({
|
|
2914
|
+
created: 0,
|
|
2915
|
+
updated: 0,
|
|
2916
|
+
errors: 0
|
|
2917
|
+
}), Rt = H(null), zt = H(null), Bt = () => {
|
|
2918
|
+
Lt.value = {
|
|
2919
|
+
created: 0,
|
|
2920
|
+
updated: 0,
|
|
2921
|
+
errors: 0
|
|
2922
|
+
}, Rt.value = null, zt.value = null, s("save", K.getChanges());
|
|
2923
|
+
}, Vt = () => {
|
|
2924
|
+
Qe.value || (Q.commit(), ($.value.changedCells || $.value.newRows) && (It.value.length ? Ft.value = !0 : Bt()));
|
|
2925
|
+
}, Ht = () => {
|
|
2926
|
+
Ie("errors"), pt(1);
|
|
2927
|
+
}, Ut = () => {
|
|
2928
|
+
let e = Lt.value;
|
|
2929
|
+
(e.created || e.updated || e.errors) && (e.errors ? (zt.value = {
|
|
2930
|
+
failed: e.errors,
|
|
2931
|
+
saved: e.created + e.updated
|
|
2932
|
+
}, fr.value = f.t("sheet.partly.title", { count: m.int(e.errors) }), Ie("errors"), pt(1)) : (Rt.value = {
|
|
2933
|
+
count: e.created + e.updated,
|
|
2934
|
+
created: e.created,
|
|
2935
|
+
updated: e.updated
|
|
2936
|
+
}, dr.value = f.t("sheet.saved", { count: m.int(e.created + e.updated) })), Lt.value = {
|
|
2937
|
+
created: 0,
|
|
2938
|
+
updated: 0,
|
|
2939
|
+
errors: 0
|
|
2940
|
+
});
|
|
2941
|
+
}, Qt = -1, $t = (e) => {
|
|
2942
|
+
let t = K.applyResult(e);
|
|
2943
|
+
Qt = K.version.value;
|
|
2944
|
+
let n = Lt.value;
|
|
2945
|
+
Lt.value = {
|
|
2946
|
+
created: n.created + t.created,
|
|
2947
|
+
updated: n.updated + t.updated,
|
|
2948
|
+
errors: n.errors + t.errors
|
|
2949
|
+
}, k.value || Ut();
|
|
2950
|
+
};
|
|
2951
|
+
je(k, (e) => {
|
|
2952
|
+
e || Ut();
|
|
2953
|
+
}), je(K.version, (e) => {
|
|
2954
|
+
e !== Qt && (Rt.value = null), zt.value && !$.value.errorRows && (zt.value = null);
|
|
2955
|
+
});
|
|
2956
|
+
let en = j(() => {
|
|
2957
|
+
let e = X.active.value, t = e ? ft.value.indexOf(e.rowId) : -1;
|
|
2958
|
+
return t < 0 ? 0 : t + 1;
|
|
2959
|
+
}), tn = () => {
|
|
2960
|
+
let e = [[
|
|
2961
|
+
f.t("sheet.err.row"),
|
|
2962
|
+
W.value?.header ?? o.keyColumn,
|
|
2963
|
+
f.t("sheet.err.column"),
|
|
2964
|
+
f.t("sheet.err.message")
|
|
2965
|
+
]];
|
|
2966
|
+
for (let t of ft.value) {
|
|
2967
|
+
let n = K.rowByKey(t), r = W.value ? Tn(W.value, K.read(n, W.value)) : t, i = K.rowError(t);
|
|
2968
|
+
i && e.push([
|
|
2969
|
+
String(K.rowNoOf(t)),
|
|
2970
|
+
r,
|
|
2971
|
+
"",
|
|
2972
|
+
i
|
|
2973
|
+
]);
|
|
2974
|
+
for (let [n, i] of K.rowIssues(t) ?? []) i.level === "error" && e.push([
|
|
2975
|
+
String(K.rowNoOf(t)),
|
|
2976
|
+
r,
|
|
2977
|
+
Ce.value.get(n)?.header ?? n,
|
|
2978
|
+
i.message
|
|
2979
|
+
]);
|
|
2980
|
+
}
|
|
2981
|
+
navigator.clipboard?.writeText(fn(e)).catch(() => {});
|
|
2982
|
+
}, an = (e) => {
|
|
2983
|
+
if (!K.isNew(K.keyOf(e))) return W.value?.href?.(e) ?? Te.value?.href?.(e);
|
|
2984
|
+
}, on = V(!1), sn = j(() => {
|
|
2985
|
+
K.version.value;
|
|
2986
|
+
let e = /* @__PURE__ */ new Set(), t = W.value;
|
|
2987
|
+
if (!t) return e;
|
|
2988
|
+
for (let n of K.allRows.value) {
|
|
2989
|
+
let r = K.readUntracked(n, t);
|
|
2990
|
+
T(r) || e.add(String(r));
|
|
2991
|
+
}
|
|
2992
|
+
return e;
|
|
2993
|
+
}), cn = (e) => sn.value.has(e), ln = (e) => {
|
|
2994
|
+
if (Qe.value || !W.value) return;
|
|
2995
|
+
Q.commit();
|
|
2996
|
+
let t = W.value, n = /* @__PURE__ */ new Map();
|
|
2997
|
+
for (let e of K.allRows.value) {
|
|
2998
|
+
let r = K.readUntracked(e, t);
|
|
2999
|
+
T(r) || n.set(String(r), e);
|
|
3000
|
+
}
|
|
3001
|
+
let r = K.allRows.value.length, i = /* @__PURE__ */ new Set();
|
|
3002
|
+
for (let t of e.rows) if (!(n.has(t.key) || i.has(t.key)) && e.addNew) {
|
|
3003
|
+
if (r + i.size + 1 > o.maxRows) break;
|
|
3004
|
+
i.add(t.key);
|
|
3005
|
+
}
|
|
3006
|
+
let a = i.size ? K.addRows(i.size) : [], s = new Map([...i].map((e, t) => [e, a[t]])), c = [], l = [], u = 0, d = 0;
|
|
3007
|
+
for (let r of e.rows) {
|
|
3008
|
+
let i = n.get(r.key);
|
|
3009
|
+
if (i) u++;
|
|
3010
|
+
else {
|
|
3011
|
+
if (!e.addNew) continue;
|
|
3012
|
+
let a = s.get(r.key);
|
|
3013
|
+
if (!a) break;
|
|
3014
|
+
i = a.row, l.push(a), n.set(r.key, i), c.push({
|
|
3015
|
+
row: i,
|
|
3016
|
+
def: t,
|
|
3017
|
+
value: r.key
|
|
3018
|
+
}), d++;
|
|
3019
|
+
}
|
|
3020
|
+
for (let [e, t] of Object.entries(r.values)) {
|
|
3021
|
+
let n = Ce.value.get(e);
|
|
3022
|
+
n && rt(i, n) && c.push({
|
|
3023
|
+
row: i,
|
|
3024
|
+
def: n,
|
|
3025
|
+
value: t
|
|
3026
|
+
});
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
K.apply(c, l), l.length && Oe.value && (Oe.value = [...Oe.value, ...l.map((e) => e.key)]), cr({
|
|
3030
|
+
text: f.t("import.done", {
|
|
3031
|
+
count: m.int(e.rows.length),
|
|
3032
|
+
updated: m.int(u),
|
|
3033
|
+
news: m.int(d)
|
|
3034
|
+
}),
|
|
3035
|
+
undo: !0
|
|
3036
|
+
});
|
|
3037
|
+
let p = e.rows[0]?.key, h = p ? n.get(p) : void 0, g = h ? qe.value.get(K.keyOf(h)) : void 0;
|
|
3038
|
+
g !== void 0 && ct(g, o.keyColumn);
|
|
3039
|
+
}, un = (e, t) => {
|
|
3040
|
+
Q.commit();
|
|
3041
|
+
let n = (t === "all" ? K.allRows.value : J.value).map((e) => K.current(e));
|
|
3042
|
+
if (_) return s("export", {
|
|
3043
|
+
format: e,
|
|
3044
|
+
scope: t,
|
|
3045
|
+
columns: Z.value.map((e) => e.id),
|
|
3046
|
+
rows: n
|
|
3047
|
+
});
|
|
3048
|
+
E({
|
|
3049
|
+
format: e,
|
|
3050
|
+
columns: Z.value.map((e) => e.def),
|
|
3051
|
+
rows: n,
|
|
3052
|
+
read: (e, t) => t.accessor ? t.accessor(e) : u(e, t.id),
|
|
3053
|
+
env: ot,
|
|
3054
|
+
name: h.value.other
|
|
3055
|
+
});
|
|
3056
|
+
}, dn = (e) => f.t(e === "all" ? "sheet.exportAll" : "sheet.exportVisible", { count: m.int(e === "all" ? K.allRows.value.length : J.value.length) }), pn = () => void navigator.clipboard?.writeText(location.href).catch(() => {}), gn = {
|
|
3057
|
+
store: K,
|
|
3058
|
+
table: X,
|
|
3059
|
+
edit: Q,
|
|
3060
|
+
canEdit: rt,
|
|
3061
|
+
editorFor: nt,
|
|
3062
|
+
toggle: ut,
|
|
3063
|
+
clearCells: dt,
|
|
3064
|
+
save: Vt,
|
|
3065
|
+
goToError: pt,
|
|
3066
|
+
copy: gt,
|
|
3067
|
+
cut: _t,
|
|
3068
|
+
paste: bt,
|
|
3069
|
+
fill: Ct,
|
|
3070
|
+
fillLabel: wt,
|
|
3071
|
+
fillDown: Tt,
|
|
3072
|
+
undo: Dt,
|
|
3073
|
+
redo: Ot,
|
|
3074
|
+
useSuggestion: kt,
|
|
3075
|
+
copyToClipboard: vt,
|
|
3076
|
+
pasteFromClipboard: xt,
|
|
3077
|
+
insertRow: jt,
|
|
3078
|
+
removeSelectedRows: Mt,
|
|
3079
|
+
sort: Nt,
|
|
3080
|
+
openHref: an
|
|
3081
|
+
}, vn = (e) => {
|
|
3082
|
+
Q.editing.value && (e.target?.closest(".dt-cell.is-editing, .dt-formula, .dt-sheet-layer") || Q.commit());
|
|
3083
|
+
}, yn = () => $.value.changedCells > 0 || $.value.newRows > 0, xn = (e) => {
|
|
3084
|
+
yn() && (e.preventDefault(), e.returnValue = "");
|
|
3085
|
+
};
|
|
3086
|
+
ye(() => {
|
|
3087
|
+
document.addEventListener("pointerdown", vn, !0), window.addEventListener("beforeunload", xn);
|
|
3088
|
+
}), ve(() => {
|
|
3089
|
+
document.removeEventListener("pointerdown", vn, !0), window.removeEventListener("beforeunload", xn), clearTimeout(sr);
|
|
3090
|
+
});
|
|
3091
|
+
let Sn = De("findBox"), Cn = (e) => {
|
|
3092
|
+
if (e.defaultPrevented || !(e.metaKey || e.ctrlKey)) return;
|
|
3093
|
+
let t = e.key.toLowerCase();
|
|
3094
|
+
t === "s" ? (e.preventDefault(), Vt()) : t === "f" && !O.value && (e.preventDefault(), Sn.value?.focus());
|
|
3095
|
+
}, En = (e) => e.toLocaleLowerCase(d.locale), Dn = V(""), On = V(0), kn = j(() => {
|
|
3096
|
+
let e = En(Dn.value.trim());
|
|
3097
|
+
if (!e) return null;
|
|
3098
|
+
K.version.value;
|
|
3099
|
+
let t = /* @__PURE__ */ new Map(), n = [], r = J.value, i = Z.value;
|
|
3100
|
+
for (let a = 0; a < r.length; a++) {
|
|
3101
|
+
let o = r[a];
|
|
3102
|
+
for (let r = 0; r < i.length; r++) {
|
|
3103
|
+
let s = i[r].def, c = K.readUntracked(o, s);
|
|
3104
|
+
if (T(c) || !En(oe(s, o, c, ot)).includes(e)) continue;
|
|
3105
|
+
let l = K.keyOf(o), u = t.get(l);
|
|
3106
|
+
u || t.set(l, u = /* @__PURE__ */ new Set()), u.add(s.id), n.push({
|
|
3107
|
+
r: a,
|
|
3108
|
+
c: r
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
return {
|
|
3113
|
+
map: t,
|
|
3114
|
+
list: n
|
|
3115
|
+
};
|
|
3116
|
+
}), An = (e) => {
|
|
3117
|
+
let t = kn.value?.list[e];
|
|
3118
|
+
if (!t) return;
|
|
3119
|
+
On.value = e;
|
|
3120
|
+
let n = J.value[t.r];
|
|
3121
|
+
X.focus(K.keyOf(n), Z.value[t.c].id), at.value?.scrollToIndex(t.r);
|
|
3122
|
+
};
|
|
3123
|
+
je(() => kn.value?.list.length ?? 0, () => An(0));
|
|
3124
|
+
let Nn = (e) => {
|
|
3125
|
+
let t = kn.value?.list.length ?? 0;
|
|
3126
|
+
t && An(((On.value + e) % t + t) % t);
|
|
3127
|
+
}, Pn = (e) => {
|
|
3128
|
+
e.key === "Enter" ? (e.preventDefault(), Nn(e.shiftKey ? -1 : 1)) : e.key === "Escape" && !Dn.value && (e.preventDefault(), at.value?.focusActive());
|
|
3129
|
+
}, In = j(() => kn.value ? f.t("sheet.findCount", {
|
|
3130
|
+
index: kn.value.list.length ? On.value + 1 : 0,
|
|
3131
|
+
total: kn.value.list.length
|
|
3132
|
+
}) : ""), Ln = j(() => ({
|
|
3133
|
+
all: K.allRows.value.length,
|
|
3134
|
+
changed: $.value.changedOrNewRows,
|
|
3135
|
+
errors: $.value.errorRows
|
|
3136
|
+
})), Rn = j(() => {
|
|
3137
|
+
let e = X.active.value;
|
|
3138
|
+
return e ? K.rowByKey(e.rowId) ?? null : null;
|
|
3139
|
+
}), zn = j(() => {
|
|
3140
|
+
let e = X.active.value;
|
|
3141
|
+
return e ? Ce.value.get(e.columnId) ?? null : null;
|
|
3142
|
+
}), Hn = j(() => {
|
|
3143
|
+
let e = X.bounds.value;
|
|
3144
|
+
if (!e) return null;
|
|
3145
|
+
let t = e.maxRowIndex - e.minRowIndex + 1, n = e.maxColumnIndex - e.minColumnIndex + 1;
|
|
3146
|
+
return t * n > 1 ? {
|
|
3147
|
+
rows: t,
|
|
3148
|
+
cols: n
|
|
3149
|
+
} : null;
|
|
3150
|
+
}), Gn = j(() => Hn.value ? f.t("sheet.cells", Hn.value) : null), Kn = j(() => Rn.value && W.value ? Tn(W.value, K.read(Rn.value, W.value)) : ""), qn = j(() => {
|
|
3151
|
+
let e = Q.editing.value;
|
|
3152
|
+
return e ? e.text ?? Tn(e.def, e.value) : Rn.value && zn.value ? Tn(zn.value, K.read(Rn.value, zn.value)) : "";
|
|
3153
|
+
}), Jn = j(() => !!Rn.value && !!zn.value && zn.value.type !== "boolean" && rt(Rn.value, zn.value)), Yn = (e) => {
|
|
3154
|
+
let t = e.target.value, n = Rn.value, r = zn.value;
|
|
3155
|
+
n && r && Jn.value && (Q.editing.value || Q.start(n, r, { inCell: !1 })) && Q.setValue(wn(r, t, it()), t, !1);
|
|
3156
|
+
}, Xn = (e) => {
|
|
3157
|
+
e.key === "Enter" ? (e.preventDefault(), Q.commit() && X.move("down"), at.value?.focusActive()) : e.key === "Escape" && (e.preventDefault(), Q.cancel(), at.value?.focusActive());
|
|
3158
|
+
}, Zn = j(() => {
|
|
3159
|
+
let t = zn.value;
|
|
3160
|
+
if (!t) return "";
|
|
3161
|
+
let n = [f.t(e(t.type))];
|
|
3162
|
+
return t.type === "currency" && typeof t.currency == "string" && n.push(t.currency), t.required && n.push(f.t("sheet.required").toLocaleLowerCase(d.locale)), t.hint && n.push(t.hint), n.join(" · ");
|
|
3163
|
+
}), Qn = j(() => zn.value ? f.t("sheet.valueAria", {
|
|
3164
|
+
column: zn.value.header,
|
|
3165
|
+
key: Kn.value
|
|
3166
|
+
}) : ""), $n = j(() => {
|
|
3167
|
+
K.version.value;
|
|
3168
|
+
let e = X.bounds.value;
|
|
3169
|
+
if (!e || !Hn.value) return null;
|
|
3170
|
+
let t = 0, n = 0, r = 0;
|
|
3171
|
+
for (let i = e.minRowIndex; i <= e.maxRowIndex; i++) {
|
|
3172
|
+
let a = J.value[i];
|
|
3173
|
+
if (a) for (let i = e.minColumnIndex; i <= e.maxColumnIndex; i++) {
|
|
3174
|
+
let e = Z.value[i].def, o = K.readUntracked(a, e);
|
|
3175
|
+
T(o) || (t++, l[e.type].numeric && typeof o == "number" && (n += o, r++));
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
return {
|
|
3179
|
+
count: t,
|
|
3180
|
+
sum: r ? m.decimal(n, 2) : null,
|
|
3181
|
+
avg: r ? m.decimal(n / r, 2) : null
|
|
3182
|
+
};
|
|
3183
|
+
}), er = j(() => ({
|
|
3184
|
+
phase: O.value ? "loading" : k.value ? "saving" : zt.value ? "partly-saved" : Rt.value ? "saved" : "ready",
|
|
3185
|
+
...$.value
|
|
3186
|
+
})), tr = j(() => $.value.changedCells ? f.t("sheet.changes", {
|
|
3187
|
+
cells: m.int($.value.changedCells),
|
|
3188
|
+
rows: m.int($.value.changedRows)
|
|
3189
|
+
}) : f.t("sheet.noChanges")), nr = `${f.t("sheet.save")} · ${se}`, rr = `${f.t("common.undo")} (${ce})`, ir = `${f.t("common.redo")} (${y})`, ar = j(() => !Qe.value && ($.value.changedCells > 0 || $.value.newRows > 0)), or = H(null), sr, cr = (e) => {
|
|
3190
|
+
or.value = e, clearTimeout(sr), sr = setTimeout(() => or.value = null, 6e3);
|
|
3191
|
+
}, lr = () => {
|
|
3192
|
+
or.value = null, Dt();
|
|
3193
|
+
}, ur = () => {
|
|
3194
|
+
let e = or.value?.action?.run;
|
|
3195
|
+
or.value = null, e?.();
|
|
3196
|
+
}, dr = V(""), fr = V(""), pr = -1;
|
|
3197
|
+
je(R, (e) => {
|
|
3198
|
+
if (e === null) {
|
|
3199
|
+
pr = -1;
|
|
3200
|
+
return;
|
|
3201
|
+
}
|
|
3202
|
+
let t = Math.floor(e / 25);
|
|
3203
|
+
t !== pr && e !== 0 && (pr = t, dr.value = f.t(O.value ? "sr.loadingPercent" : "sr.savingPercent", { percent: t * 25 }));
|
|
3204
|
+
});
|
|
3205
|
+
let mr = V(!1), hr = () => {
|
|
3206
|
+
Q.cancel(), K.reset(), Oe.value = null, Ee.value = [], zt.value = null, Rt.value = null, at.value?.focusActive();
|
|
3207
|
+
}, gr = j(() => ({
|
|
3208
|
+
density: ne.value,
|
|
3209
|
+
verticalLines: C.prefs.verticalLines,
|
|
3210
|
+
columns: Y.panel.value,
|
|
3211
|
+
counts: Y.counts.value,
|
|
3212
|
+
persistent: C.persistent
|
|
3213
|
+
})), _r = {
|
|
3214
|
+
"update:density": (e) => C.set({ density: e }),
|
|
3215
|
+
"update:verticalLines": (e) => C.set({ verticalLines: e }),
|
|
3216
|
+
"columns-save": (e) => Y.arrange(e),
|
|
3217
|
+
reset: () => {
|
|
3218
|
+
C.reset(), Y.reset();
|
|
3219
|
+
}
|
|
3220
|
+
}, vr = V(null), yr = g(vr);
|
|
3221
|
+
return n({
|
|
3222
|
+
status: er,
|
|
3223
|
+
isDirty: yn,
|
|
3224
|
+
getChanges: K.getChanges,
|
|
3225
|
+
applyResult: $t,
|
|
3226
|
+
reset: hr,
|
|
3227
|
+
undo: Dt,
|
|
3228
|
+
redo: Ot,
|
|
3229
|
+
goToNextError: () => pt(1)
|
|
3230
|
+
}), (e, n) => (B(), P("div", {
|
|
3231
|
+
ref_key: "rootEl",
|
|
3232
|
+
ref: vr,
|
|
3233
|
+
class: ge(["dt dt-sheet", { "is-phone": G(z) }]),
|
|
3234
|
+
"data-density": ne.value,
|
|
3235
|
+
onKeydown: Cn
|
|
3236
|
+
}, [
|
|
3237
|
+
G(z) ? (B(), P("div", Li, [L(G(Xe), {
|
|
3238
|
+
size: 20,
|
|
3239
|
+
"aria-hidden": "true"
|
|
3240
|
+
}), F("div", Ri, [
|
|
3241
|
+
F("strong", null, U(G(f).t("sheet.readOnly.title")), 1),
|
|
3242
|
+
F("span", null, U(G(f).t("sheet.readOnly.body", { entity: h.value })), 1),
|
|
3243
|
+
F("button", {
|
|
3244
|
+
type: "button",
|
|
3245
|
+
class: "dt-btn has-icon",
|
|
3246
|
+
onClick: pn
|
|
3247
|
+
}, [L(G(Je), {
|
|
3248
|
+
size: 16,
|
|
3249
|
+
"aria-hidden": "true"
|
|
3250
|
+
}), I(" " + U(G(f).t("common.copyLink")), 1)])
|
|
3251
|
+
])])) : N("", !0),
|
|
3252
|
+
F("div", zi, [
|
|
3253
|
+
O.value || k.value ? (B(), P("div", Bi, [
|
|
3254
|
+
F("strong", null, U(O.value ? G(f).t("sheet.loading", { entity: h.value }) : le.value ? G(f).t("sheet.saving", {
|
|
3255
|
+
sent: G(m).int(le.value.done),
|
|
3256
|
+
total: G(m).int(le.value.total)
|
|
3257
|
+
}) : G(f).t("sheet.savingIndeterminate")), 1),
|
|
3258
|
+
O.value && le.value ? (B(), P("span", Vi, U(G(f).t("sheet.loadingCount", {
|
|
3259
|
+
loaded: G(m).int(le.value.done),
|
|
3260
|
+
total: G(m).int(le.value.total)
|
|
3261
|
+
})), 1)) : N("", !0),
|
|
3262
|
+
F("div", {
|
|
3263
|
+
class: ge(["dt-progress", { "is-indeterminate": R.value === null }]),
|
|
3264
|
+
role: "progressbar",
|
|
3265
|
+
"aria-valuemin": "0",
|
|
3266
|
+
"aria-valuemax": "100",
|
|
3267
|
+
"aria-valuenow": R.value ?? void 0
|
|
3268
|
+
}, [F("div", {
|
|
3269
|
+
class: "dt-progress-fill",
|
|
3270
|
+
style: _e(R.value === null ? void 0 : { width: `${R.value}%` })
|
|
3271
|
+
}, null, 4)], 10, Hi)
|
|
3272
|
+
])) : G(z) ? (B(), P("div", {
|
|
3273
|
+
key: 1,
|
|
3274
|
+
class: "dt-find",
|
|
3275
|
+
onKeydown: Pn
|
|
3276
|
+
}, [L(b, {
|
|
3277
|
+
ref_key: "findBox",
|
|
3278
|
+
ref: Sn,
|
|
3279
|
+
"model-value": Dn.value,
|
|
3280
|
+
placeholder: G(f).t("sheet.find"),
|
|
3281
|
+
kbd: G(ee),
|
|
3282
|
+
"onUpdate:modelValue": n[0] ||= (e) => Dn.value = e
|
|
3283
|
+
}, null, 8, [
|
|
3284
|
+
"model-value",
|
|
3285
|
+
"placeholder",
|
|
3286
|
+
"kbd"
|
|
3287
|
+
]), In.value ? (B(), P("span", Ui, U(In.value), 1)) : N("", !0)], 32)) : (B(), P(A, { key: 2 }, [
|
|
3288
|
+
F("div", {
|
|
3289
|
+
class: "dt-find",
|
|
3290
|
+
onKeydown: Pn
|
|
3291
|
+
}, [L(b, {
|
|
3292
|
+
ref_key: "findBox",
|
|
3293
|
+
ref: Sn,
|
|
3294
|
+
"model-value": Dn.value,
|
|
3295
|
+
placeholder: G(f).t("sheet.find"),
|
|
3296
|
+
kbd: G(ee),
|
|
3297
|
+
"onUpdate:modelValue": n[1] ||= (e) => Dn.value = e
|
|
3298
|
+
}, null, 8, [
|
|
3299
|
+
"model-value",
|
|
3300
|
+
"placeholder",
|
|
3301
|
+
"kbd"
|
|
3302
|
+
]), In.value ? (B(), P("span", Wi, U(In.value), 1)) : N("", !0)], 32),
|
|
3303
|
+
n[16] ||= F("span", {
|
|
3304
|
+
class: "dt-toolbar-sep",
|
|
3305
|
+
"aria-hidden": "true"
|
|
3306
|
+
}, null, -1),
|
|
3307
|
+
L(G(rn), {
|
|
3308
|
+
class: "dt-seg dt-sheet-views",
|
|
3309
|
+
type: "single",
|
|
3310
|
+
"model-value": ke.value,
|
|
3311
|
+
"aria-label": G(f).t("sheet.showRows"),
|
|
3312
|
+
"onUpdate:modelValue": n[2] ||= (e) => e && Ie(e)
|
|
3313
|
+
}, {
|
|
3314
|
+
default: q(() => [
|
|
3315
|
+
L(G(nn), {
|
|
3316
|
+
class: "dt-seg-item",
|
|
3317
|
+
value: "all"
|
|
3318
|
+
}, {
|
|
3319
|
+
default: q(() => [I(U(G(f).t("sheet.all")) + " ", 1), F("span", Gi, U(G(m).int(Ln.value.all)), 1)]),
|
|
3320
|
+
_: 1
|
|
3321
|
+
}),
|
|
3322
|
+
L(G(nn), {
|
|
3323
|
+
class: "dt-seg-item",
|
|
3324
|
+
value: "changed"
|
|
3325
|
+
}, {
|
|
3326
|
+
default: q(() => [I(U(G(f).t("sheet.changed")) + " ", 1), F("span", Ki, U(G(m).int(Ln.value.changed)), 1)]),
|
|
3327
|
+
_: 1
|
|
3328
|
+
}),
|
|
3329
|
+
L(G(nn), {
|
|
3330
|
+
class: ge(["dt-seg-item", { "is-errors": Ln.value.errors > 0 }]),
|
|
3331
|
+
value: "errors"
|
|
3332
|
+
}, {
|
|
3333
|
+
default: q(() => [I(U(G(f).t("sheet.errors")) + " ", 1), F("span", qi, U(G(m).int(Ln.value.errors)), 1)]),
|
|
3334
|
+
_: 1
|
|
3335
|
+
}, 8, ["class"])
|
|
3336
|
+
]),
|
|
3337
|
+
_: 1
|
|
3338
|
+
}, 8, ["model-value", "aria-label"]),
|
|
3339
|
+
F("button", {
|
|
3340
|
+
type: "button",
|
|
3341
|
+
class: "dt-btn dt-sheet-undo",
|
|
3342
|
+
"aria-disabled": G(K).canUndo.value ? void 0 : "true",
|
|
3343
|
+
"aria-label": rr,
|
|
3344
|
+
"data-dt-tip": rr,
|
|
3345
|
+
onClick: n[3] ||= (e) => G(K).canUndo.value && Dt()
|
|
3346
|
+
}, [L(G(Le), {
|
|
3347
|
+
size: 16,
|
|
3348
|
+
"aria-hidden": "true"
|
|
3349
|
+
})], 8, Ji),
|
|
3350
|
+
F("button", {
|
|
3351
|
+
type: "button",
|
|
3352
|
+
class: "dt-btn dt-sheet-undo",
|
|
3353
|
+
"aria-disabled": G(K).canRedo.value ? void 0 : "true",
|
|
3354
|
+
"aria-label": ir,
|
|
3355
|
+
"data-dt-tip": ir,
|
|
3356
|
+
onClick: n[4] ||= (e) => G(K).canRedo.value && Ot()
|
|
3357
|
+
}, [L(G(Re), {
|
|
3358
|
+
size: 16,
|
|
3359
|
+
"aria-hidden": "true"
|
|
3360
|
+
})], 8, Yi),
|
|
3361
|
+
n[17] ||= F("span", {
|
|
3362
|
+
class: "dt-toolbar-sep",
|
|
3363
|
+
"aria-hidden": "true"
|
|
3364
|
+
}, null, -1),
|
|
3365
|
+
F("button", {
|
|
3366
|
+
type: "button",
|
|
3367
|
+
class: "dt-btn dt-btn-ghost has-icon dt-sheet-add",
|
|
3368
|
+
onClick: n[5] ||= (e) => At()
|
|
3369
|
+
}, [L(G(Ze), {
|
|
3370
|
+
size: 16,
|
|
3371
|
+
"aria-hidden": "true"
|
|
3372
|
+
}), I(" " + U(G(f).t("sheet.addRow")), 1)]),
|
|
3373
|
+
t.importable ? (B(), P("button", {
|
|
3374
|
+
key: 0,
|
|
3375
|
+
type: "button",
|
|
3376
|
+
class: "dt-btn dt-btn-ghost has-icon dt-sheet-import",
|
|
3377
|
+
onClick: n[6] ||= (e) => on.value = !0
|
|
3378
|
+
}, [L(G(Ge), {
|
|
3379
|
+
size: 16,
|
|
3380
|
+
"aria-hidden": "true"
|
|
3381
|
+
}), I(" " + U(G(f).t("sheet.import")), 1)])) : N("", !0),
|
|
3382
|
+
t.exportable ? (B(), M(G(qt), { key: 1 }, {
|
|
3383
|
+
default: q(() => [L(G(Zt), { "as-child": "" }, {
|
|
3384
|
+
default: q(() => [F("button", Xi, [L(G(Ke), {
|
|
3385
|
+
size: 16,
|
|
3386
|
+
"aria-hidden": "true"
|
|
3387
|
+
}), I(" " + U(G(f).t("sheet.export")), 1)])]),
|
|
3388
|
+
_: 1
|
|
3389
|
+
}), L(G(Kt), null, {
|
|
3390
|
+
default: q(() => [L(G(Wt), {
|
|
3391
|
+
class: "dt-menu",
|
|
3392
|
+
align: "start",
|
|
3393
|
+
"side-offset": 4
|
|
3394
|
+
}, {
|
|
3395
|
+
default: q(() => [(B(), P(A, null, xe(["all", "visible"], (e) => L(G(Jt), { key: e }, {
|
|
3396
|
+
default: q(() => [L(G(Xt), { class: "dt-menu-item" }, {
|
|
3397
|
+
default: q(() => [I(U(dn(e)), 1)]),
|
|
3398
|
+
_: 2
|
|
3399
|
+
}, 1024), L(G(Kt), null, {
|
|
3400
|
+
default: q(() => [L(G(Yt), {
|
|
3401
|
+
class: "dt-menu",
|
|
3402
|
+
"side-offset": 4
|
|
3403
|
+
}, {
|
|
3404
|
+
default: q(() => [L(G(Gt), {
|
|
3405
|
+
class: "dt-menu-item",
|
|
3406
|
+
onSelect: (t) => un("xlsx", e)
|
|
3407
|
+
}, {
|
|
3408
|
+
default: q(() => [I(U(G(f).t("toolbar.xlsx")), 1)]),
|
|
3409
|
+
_: 1
|
|
3410
|
+
}, 8, ["onSelect"]), L(G(Gt), {
|
|
3411
|
+
class: "dt-menu-item",
|
|
3412
|
+
onSelect: (t) => un("csv", e)
|
|
3413
|
+
}, {
|
|
3414
|
+
default: q(() => [I(U(G(f).t("toolbar.csv")), 1)]),
|
|
3415
|
+
_: 1
|
|
3416
|
+
}, 8, ["onSelect"])]),
|
|
3417
|
+
_: 2
|
|
3418
|
+
}, 1024)]),
|
|
3419
|
+
_: 2
|
|
3420
|
+
}, 1024)]),
|
|
3421
|
+
_: 2
|
|
3422
|
+
}, 1024)), 64))]),
|
|
3423
|
+
_: 1
|
|
3424
|
+
})]),
|
|
3425
|
+
_: 1
|
|
3426
|
+
})]),
|
|
3427
|
+
_: 1
|
|
3428
|
+
})) : N("", !0),
|
|
3429
|
+
L(p, me(gr.value, we(_r)), null, 16)
|
|
3430
|
+
], 64)),
|
|
3431
|
+
n[18] ||= F("span", { class: "dt-toolbar-spacer" }, null, -1),
|
|
3432
|
+
G(z) ? (B(), P(A, { key: 3 }, [], 64)) : k.value ? N("", !0) : (B(), P("span", {
|
|
3433
|
+
key: 4,
|
|
3434
|
+
class: ge(["dt-sheet-changes", { "is-empty": !G($).changedCells }])
|
|
3435
|
+
}, [
|
|
3436
|
+
G($).changedCells ? (B(), P("span", Zi)) : N("", !0),
|
|
3437
|
+
I(" " + U(tr.value) + " ", 1),
|
|
3438
|
+
G($).newRows ? (B(), P(A, { key: 1 }, [I("· " + U(G(f).t("sheet.newShort", { count: G($).newRows })), 1)], 64)) : N("", !0)
|
|
3439
|
+
], 2)),
|
|
3440
|
+
G(z) ? N("", !0) : (B(), P("button", {
|
|
3441
|
+
key: 5,
|
|
3442
|
+
type: "button",
|
|
3443
|
+
class: "dt-btn dt-btn-ghost",
|
|
3444
|
+
disabled: k.value || !G($).changedCells && !G($).newRows,
|
|
3445
|
+
onClick: n[7] ||= (e) => mr.value = !0
|
|
3446
|
+
}, U(G(f).t("sheet.discard")), 9, Qi)),
|
|
3447
|
+
G(z) ? N("", !0) : (B(), P("button", {
|
|
3448
|
+
key: 6,
|
|
3449
|
+
type: "button",
|
|
3450
|
+
class: "dt-btn dt-btn-primary has-icon dt-sheet-save",
|
|
3451
|
+
disabled: !k.value && !ar.value,
|
|
3452
|
+
"aria-disabled": k.value ? "true" : void 0,
|
|
3453
|
+
"data-dt-tip": k.value ? void 0 : nr,
|
|
3454
|
+
onClick: n[8] ||= (e) => !k.value && Vt()
|
|
3455
|
+
}, [k.value ? (B(), M(G(Ue), {
|
|
3456
|
+
key: 0,
|
|
3457
|
+
size: 16,
|
|
3458
|
+
class: "dt-spin",
|
|
3459
|
+
"aria-hidden": "true"
|
|
3460
|
+
})) : (B(), M(G(He), {
|
|
3461
|
+
key: 1,
|
|
3462
|
+
size: 16,
|
|
3463
|
+
"aria-hidden": "true"
|
|
3464
|
+
})), I(" " + U(k.value ? G(f).t("sheet.savingButton") : G(f).t("sheet.save")), 1)], 8, $i))
|
|
3465
|
+
]),
|
|
3466
|
+
zt.value ? (B(), P("div", ea, [
|
|
3467
|
+
L(G(et), {
|
|
3468
|
+
size: 16,
|
|
3469
|
+
"aria-hidden": "true"
|
|
3470
|
+
}),
|
|
3471
|
+
F("span", null, [F("strong", null, U(G(f).t("sheet.partly.title", { count: G(m).int(zt.value.failed) })), 1), I(" " + U(G(f).t("sheet.partly.body", { count: G(m).int(zt.value.saved) })), 1)]),
|
|
3472
|
+
n[19] ||= F("span", { class: "dt-partly-spacer" }, null, -1),
|
|
3473
|
+
F("span", ta, [
|
|
3474
|
+
F("button", {
|
|
3475
|
+
type: "button",
|
|
3476
|
+
class: "dt-partly-btn",
|
|
3477
|
+
"aria-label": G(f).t("sheet.prevError"),
|
|
3478
|
+
onClick: n[9] ||= (e) => pt(-1)
|
|
3479
|
+
}, [L(G(Ve), {
|
|
3480
|
+
size: 14,
|
|
3481
|
+
"aria-hidden": "true"
|
|
3482
|
+
})], 8, na),
|
|
3483
|
+
F("span", null, U(G(f).t("sheet.findCount", {
|
|
3484
|
+
index: en.value,
|
|
3485
|
+
total: ft.value.length
|
|
3486
|
+
})), 1),
|
|
3487
|
+
F("button", {
|
|
3488
|
+
type: "button",
|
|
3489
|
+
class: "dt-partly-btn",
|
|
3490
|
+
"aria-label": G(f).t("sheet.nextError"),
|
|
3491
|
+
onClick: n[10] ||= (e) => pt(1)
|
|
3492
|
+
}, [L(G(Be), {
|
|
3493
|
+
size: 14,
|
|
3494
|
+
"aria-hidden": "true"
|
|
3495
|
+
})], 8, ra)
|
|
3496
|
+
]),
|
|
3497
|
+
n[20] ||= F("span", {
|
|
3498
|
+
class: "dt-partly-sep",
|
|
3499
|
+
"aria-hidden": "true"
|
|
3500
|
+
}, null, -1),
|
|
3501
|
+
F("button", {
|
|
3502
|
+
type: "button",
|
|
3503
|
+
class: "dt-partly-copy",
|
|
3504
|
+
onClick: tn
|
|
3505
|
+
}, [L(G(We), {
|
|
3506
|
+
size: 14,
|
|
3507
|
+
"aria-hidden": "true"
|
|
3508
|
+
}), I(" " + U(G(f).t("sheet.copyErrors")), 1)])
|
|
3509
|
+
])) : N("", !0),
|
|
3510
|
+
ie.value ? (B(), P("div", ia, [L(G($e), {
|
|
3511
|
+
size: 16,
|
|
3512
|
+
"aria-hidden": "true"
|
|
3513
|
+
}), F("span", null, U(G(f).t("sheet.firstN", {
|
|
3514
|
+
max: G(m).int(t.maxRows),
|
|
3515
|
+
entity: h.value
|
|
3516
|
+
})), 1)])) : N("", !0),
|
|
3517
|
+
G(z) ? N("", !0) : (B(), P("div", aa, [
|
|
3518
|
+
F("div", oa, [Gn.value ? (B(), P(A, { key: 0 }, [I(U(Gn.value), 1)], 64)) : zn.value ? (B(), P(A, { key: 1 }, [F("span", sa, U(Kn.value), 1), F("span", ca, "· " + U(zn.value.header), 1)], 64)) : N("", !0)]),
|
|
3519
|
+
n[21] ||= F("span", {
|
|
3520
|
+
class: "dt-formula-fx",
|
|
3521
|
+
"aria-hidden": "true"
|
|
3522
|
+
}, "fx", -1),
|
|
3523
|
+
F("input", {
|
|
3524
|
+
class: "dt-formula-value",
|
|
3525
|
+
type: "text",
|
|
3526
|
+
value: qn.value,
|
|
3527
|
+
readonly: !Jn.value,
|
|
3528
|
+
"aria-label": Qn.value,
|
|
3529
|
+
autocomplete: "off",
|
|
3530
|
+
onInput: Yn,
|
|
3531
|
+
onKeydown: Xn
|
|
3532
|
+
}, null, 40, la),
|
|
3533
|
+
k.value ? (B(), P("span", ua, [L(G(Ye), {
|
|
3534
|
+
size: 12,
|
|
3535
|
+
"aria-hidden": "true"
|
|
3536
|
+
}), I(" " + U(G(f).t("sheet.savingReadOnly")), 1)])) : Zn.value ? (B(), P("span", da, U(Zn.value), 1)) : N("", !0)
|
|
3537
|
+
])),
|
|
3538
|
+
L(Ei, {
|
|
3539
|
+
ref_key: "grid",
|
|
3540
|
+
ref: at,
|
|
3541
|
+
sheet: gn,
|
|
3542
|
+
layout: G(Y),
|
|
3543
|
+
rows: J.value,
|
|
3544
|
+
density: ne.value,
|
|
3545
|
+
label: h.value.other,
|
|
3546
|
+
entity: h.value,
|
|
3547
|
+
loading: O.value,
|
|
3548
|
+
skeleton: O.value,
|
|
3549
|
+
"read-only": k.value,
|
|
3550
|
+
"vertical-lines": G(C).prefs.verticalLines,
|
|
3551
|
+
"key-column": t.keyColumn,
|
|
3552
|
+
found: kn.value?.map ?? null,
|
|
3553
|
+
sort: Pt.value,
|
|
3554
|
+
phone: G(z)
|
|
3555
|
+
}, ue({ _: 2 }, [!O.value && J.value.length === 0 ? {
|
|
3556
|
+
name: "state",
|
|
3557
|
+
fn: q(() => [Se(e.$slots, "empty", {}, () => [L(te, {
|
|
3558
|
+
kind: "empty",
|
|
3559
|
+
title: G(f).t("state.emptyTitle", { entity: h.value })
|
|
3560
|
+
}, null, 8, ["title"])])]),
|
|
3561
|
+
key: "0"
|
|
3562
|
+
} : void 0]), 1032, [
|
|
3563
|
+
"layout",
|
|
3564
|
+
"rows",
|
|
3565
|
+
"density",
|
|
3566
|
+
"label",
|
|
3567
|
+
"entity",
|
|
3568
|
+
"loading",
|
|
3569
|
+
"skeleton",
|
|
3570
|
+
"read-only",
|
|
3571
|
+
"vertical-lines",
|
|
3572
|
+
"key-column",
|
|
3573
|
+
"found",
|
|
3574
|
+
"sort",
|
|
3575
|
+
"phone"
|
|
3576
|
+
]),
|
|
3577
|
+
G(z) ? (B(), P("div", fa, [
|
|
3578
|
+
F("span", null, U(G(f).t("sheet.readOnly.total", {
|
|
3579
|
+
count: G(m).int(G(K).allRows.value.length),
|
|
3580
|
+
entity: h.value
|
|
3581
|
+
})), 1),
|
|
3582
|
+
n[22] ||= F("span", { "aria-hidden": "true" }, "·", -1),
|
|
3583
|
+
F("span", pa, [L(G(Ye), {
|
|
3584
|
+
size: 14,
|
|
3585
|
+
"aria-hidden": "true"
|
|
3586
|
+
}), I(" " + U(G(f).t("sheet.readOnly.badge")), 1)])
|
|
3587
|
+
])) : (B(), P("div", {
|
|
3588
|
+
key: 5,
|
|
3589
|
+
class: "dt-status",
|
|
3590
|
+
role: "status",
|
|
3591
|
+
"aria-label": G(f).t("sheet.statusAria")
|
|
3592
|
+
}, [F("span", ha, U(O.value ? G(f).t("common.loading") : G(f).t("sheet.rows", { count: G(m).int(G(K).allRows.value.length) })), 1), O.value ? N("", !0) : (B(), P(A, { key: 0 }, [
|
|
3593
|
+
Rt.value ? (B(), P("span", ga, [
|
|
3594
|
+
L(G(He), {
|
|
3595
|
+
size: 14,
|
|
3596
|
+
"aria-hidden": "true"
|
|
3597
|
+
}),
|
|
3598
|
+
F("strong", null, U(G(f).t("sheet.saved", { count: G(m).int(Rt.value.count) })), 1),
|
|
3599
|
+
F("span", null, " · " + U(G(f).t("sheet.savedDetail", {
|
|
3600
|
+
created: G(m).int(Rt.value.created),
|
|
3601
|
+
updated: G(m).int(Rt.value.updated)
|
|
3602
|
+
})), 1)
|
|
3603
|
+
])) : G($).changedCells ? (B(), P("span", _a, [n[23] ||= F("span", {
|
|
3604
|
+
class: "dt-mark is-changed",
|
|
3605
|
+
"aria-hidden": "true"
|
|
3606
|
+
}, null, -1), I(" " + U(tr.value), 1)])) : (B(), P("span", va, U(tr.value), 1)),
|
|
3607
|
+
G($).newRows ? (B(), P("span", ya, U(G(f).t("sheet.newRows", { count: G($).newRows })), 1)) : N("", !0),
|
|
3608
|
+
G($).errorRows ? (B(), P("button", {
|
|
3609
|
+
key: 4,
|
|
3610
|
+
type: "button",
|
|
3611
|
+
class: "dt-status-errors",
|
|
3612
|
+
onClick: n[11] ||= (e) => pt(1)
|
|
3613
|
+
}, [n[24] ||= F("span", {
|
|
3614
|
+
class: "dt-mark is-error",
|
|
3615
|
+
"aria-hidden": "true"
|
|
3616
|
+
}, null, -1), I(" " + U(G(f).t("sheet.errorsGoTo", { count: G($).errorRows })), 1)])) : N("", !0),
|
|
3617
|
+
$n.value ? (B(), P("span", {
|
|
3618
|
+
key: 5,
|
|
3619
|
+
class: "dt-status-summary",
|
|
3620
|
+
"aria-label": G(f).t("sheet.selectionSummary")
|
|
3621
|
+
}, [
|
|
3622
|
+
F("span", null, [I(U(G(f).t("sheet.agg.count")) + " ", 1), F("b", null, U(G(m).int($n.value.count)), 1)]),
|
|
3623
|
+
$n.value.sum === null ? N("", !0) : (B(), P("span", xa, [I(U(G(f).t("sheet.agg.sum")) + " ", 1), F("b", null, U($n.value.sum), 1)])),
|
|
3624
|
+
$n.value.avg === null ? N("", !0) : (B(), P("span", Sa, [I(U(G(f).t("sheet.agg.avg")) + " ", 1), F("b", null, U($n.value.avg), 1)]))
|
|
3625
|
+
], 8, ba)) : N("", !0)
|
|
3626
|
+
], 64))], 8, ma)),
|
|
3627
|
+
or.value ? (B(), P("div", Ca, [
|
|
3628
|
+
F("strong", null, U(or.value.text), 1),
|
|
3629
|
+
or.value.issues ? (B(), P(A, { key: 0 }, [
|
|
3630
|
+
n[25] ||= F("span", { "aria-hidden": "true" }, "·", -1),
|
|
3631
|
+
F("span", wa, U(or.value.issues), 1),
|
|
3632
|
+
or.value.review ? (B(), P("button", {
|
|
3633
|
+
key: 0,
|
|
3634
|
+
type: "button",
|
|
3635
|
+
class: "dt-toast-link",
|
|
3636
|
+
onClick: n[12] ||= (e) => or.value.review()
|
|
3637
|
+
}, U(G(f).t("sheet.review")), 1)) : N("", !0)
|
|
3638
|
+
], 64)) : N("", !0),
|
|
3639
|
+
or.value.action ? (B(), P("button", {
|
|
3640
|
+
key: 1,
|
|
3641
|
+
type: "button",
|
|
3642
|
+
class: "dt-toast-link",
|
|
3643
|
+
onClick: ur
|
|
3644
|
+
}, U(or.value.action.label), 1)) : N("", !0),
|
|
3645
|
+
or.value.undo ? (B(), P(A, { key: 2 }, [n[26] ||= F("span", {
|
|
3646
|
+
class: "dt-toast-sep",
|
|
3647
|
+
"aria-hidden": "true"
|
|
3648
|
+
}, null, -1), F("button", {
|
|
3649
|
+
type: "button",
|
|
3650
|
+
class: "dt-toast-undo",
|
|
3651
|
+
onClick: lr
|
|
3652
|
+
}, [I(U(G(f).t("common.undo")) + " ", 1), F("kbd", Ta, U(G(ce)), 1)])], 64)) : N("", !0)
|
|
3653
|
+
])) : N("", !0),
|
|
3654
|
+
F("span", Ea, U(dr.value), 1),
|
|
3655
|
+
F("span", Da, U(fr.value), 1),
|
|
3656
|
+
Ne(F("div", {
|
|
3657
|
+
class: ge(["dt-tip", { "is-multi": G(yr).text.value.includes("\n") }]),
|
|
3658
|
+
role: "tooltip",
|
|
3659
|
+
style: _e(G(yr).style.value)
|
|
3660
|
+
}, U(G(yr).text.value), 7), [[Ae, G(yr).open.value]]),
|
|
3661
|
+
L(re, {
|
|
3662
|
+
open: mr.value,
|
|
3663
|
+
"onUpdate:open": n[13] ||= (e) => mr.value = e,
|
|
3664
|
+
title: G(f).t("sheet.discard.title", {
|
|
3665
|
+
cells: G(m).int(G($).changedCells),
|
|
3666
|
+
rows: G(m).int(G($).changedRows)
|
|
3667
|
+
}),
|
|
3668
|
+
body: G(f).t("sheet.discard.body"),
|
|
3669
|
+
"confirm-label": G(f).t("sheet.leave.discard"),
|
|
3670
|
+
"cancel-label": G(f).t("sheet.discard.keep"),
|
|
3671
|
+
danger: "",
|
|
3672
|
+
onConfirm: hr
|
|
3673
|
+
}, null, 8, [
|
|
3674
|
+
"open",
|
|
3675
|
+
"title",
|
|
3676
|
+
"body",
|
|
3677
|
+
"confirm-label",
|
|
3678
|
+
"cancel-label"
|
|
3679
|
+
]),
|
|
3680
|
+
t.importable && on.value ? (B(), M(Vr, {
|
|
3681
|
+
key: 7,
|
|
3682
|
+
open: on.value,
|
|
3683
|
+
"onUpdate:open": n[14] ||= (e) => on.value = e,
|
|
3684
|
+
"parse-file": S,
|
|
3685
|
+
columns: fe.value,
|
|
3686
|
+
"key-column": t.keyColumn,
|
|
3687
|
+
entity: h.value,
|
|
3688
|
+
"max-rows": t.maxRows,
|
|
3689
|
+
"row-count": G(K).allRows.value.length,
|
|
3690
|
+
"in-list": cn,
|
|
3691
|
+
"parse-env": it,
|
|
3692
|
+
"fmt-env": ot,
|
|
3693
|
+
onApply: ln
|
|
3694
|
+
}, null, 8, [
|
|
3695
|
+
"open",
|
|
3696
|
+
"columns",
|
|
3697
|
+
"key-column",
|
|
3698
|
+
"entity",
|
|
3699
|
+
"max-rows",
|
|
3700
|
+
"row-count"
|
|
3701
|
+
])) : N("", !0),
|
|
3702
|
+
Ft.value ? (B(), M(Xr, {
|
|
3703
|
+
key: 8,
|
|
3704
|
+
open: Ft.value,
|
|
3705
|
+
"onUpdate:open": n[15] ||= (e) => Ft.value = e,
|
|
3706
|
+
errors: It.value,
|
|
3707
|
+
"ok-rows": G(K).getChanges().rows.length,
|
|
3708
|
+
onFix: Ht,
|
|
3709
|
+
onSave: Bt
|
|
3710
|
+
}, null, 8, [
|
|
3711
|
+
"open",
|
|
3712
|
+
"errors",
|
|
3713
|
+
"ok-rows"
|
|
3714
|
+
])) : N("", !0)
|
|
3715
|
+
], 42, Ii));
|
|
3716
|
+
}
|
|
3717
|
+
});
|
|
3718
|
+
//#endregion
|
|
3719
|
+
export { Oa as DataSheet, D as ME, Xn as detectHeaderRow, Zn as matchColumns, Jn as normalizeHeader };
|
|
3720
|
+
|
|
3721
|
+
//# sourceMappingURL=sheet.js.map
|