@svgrid/enterprise 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/pdfmake-C6pyKjX0.js +58641 -0
- package/dist/cdn/smart.export-CfW2zpyq.js +2029 -0
- package/dist/cdn/svgrid-enterprise.svelte-external.js +1895 -0
- package/dist/cdn/vfs_fonts-BktEULEs.js +13 -0
- package/package.json +83 -71
- package/src/export.ts +37 -0
- package/src/pivot.ts +3 -3
|
@@ -0,0 +1,1895 @@
|
|
|
1
|
+
import "svelte/internal/disclose-version";
|
|
2
|
+
import * as e from "svelte/internal/client";
|
|
3
|
+
import { SvGrid as t, columnFilteringFeature as n, renderSnippet as r, rowSortingFeature as i, tableFeatures as a } from "@svgrid/grid";
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
var o = Object.create, s = Object.defineProperty, c = Object.getOwnPropertyDescriptor, l = Object.getOwnPropertyNames, u = Object.getPrototypeOf, d = Object.prototype.hasOwnProperty, f = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), p = (e, t, n, r) => {
|
|
6
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = l(t), a = 0, o = i.length, u; a < o; a++) u = i[a], !d.call(e, u) && u !== n && s(e, u, {
|
|
7
|
+
get: ((e) => t[e]).bind(null, u),
|
|
8
|
+
enumerable: !(r = c(t, u)) || r.enumerable
|
|
9
|
+
});
|
|
10
|
+
return e;
|
|
11
|
+
}, m = (e, t, n) => (n = e == null ? {} : o(u(e)), p(t || !e || !e.__esModule ? s(n, "default", {
|
|
12
|
+
value: e,
|
|
13
|
+
enumerable: !0
|
|
14
|
+
}) : n, e)), h = /* @__PURE__ */ new Set([]), g = "data-svgrid-enterprise-watermark", _ = "data-svgrid-enterprise-nudged", v = "https://www.svgrid.com", ee = "www.svgrid.com", y = 5e3, b = 700, x = !1, S = null;
|
|
15
|
+
function te() {
|
|
16
|
+
C(), !(typeof document > "u" || typeof window > "u") && (queueMicrotask(() => w()), S || (S = new MutationObserver(() => w()), S.observe(document.body, {
|
|
17
|
+
childList: !0,
|
|
18
|
+
subtree: !0
|
|
19
|
+
})));
|
|
20
|
+
}
|
|
21
|
+
function ne() {
|
|
22
|
+
S &&= (S.disconnect(), null), !(typeof document > "u") && (document.querySelectorAll(`[${g}]`).forEach((e) => e.remove()), document.querySelectorAll(`[${_}]`).forEach((e) => e.removeAttribute(_)), x = !1);
|
|
23
|
+
}
|
|
24
|
+
function C() {
|
|
25
|
+
x || (x = !0, !(typeof console > "u") && console.log("%c @svgrid/enterprise %c User is using a Commercial version which requires a license.\nContact sales@jqwidgets.com for details or visit the license page: https://www.svgrid.com/pricing", "background:#4f46e5;color:#fff;padding:2px 6px;border-radius:3px;font-weight:600", "color:inherit"));
|
|
26
|
+
}
|
|
27
|
+
function w() {
|
|
28
|
+
if (typeof document > "u") return;
|
|
29
|
+
let e = document.querySelectorAll(".sv-grid-root, [role=\"grid\"]");
|
|
30
|
+
if (e.length === 0) {
|
|
31
|
+
T();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
document.querySelectorAll(`[${g}="fixed"]`).forEach((e) => e.remove()), e.forEach(re);
|
|
35
|
+
}
|
|
36
|
+
function re(e) {
|
|
37
|
+
if (e.hasAttribute(_)) return;
|
|
38
|
+
e.setAttribute(_, "1"), getComputedStyle(e).position === "static" && (e.style.position = "relative");
|
|
39
|
+
let t = ie("grid");
|
|
40
|
+
oe(t, !1), e.appendChild(t), ae(t);
|
|
41
|
+
}
|
|
42
|
+
function T() {
|
|
43
|
+
if (typeof document > "u" || document.querySelector(`[${g}="fixed"]`)) return;
|
|
44
|
+
let e = ie("fixed");
|
|
45
|
+
oe(e, !0), document.body.appendChild(e), ae(e);
|
|
46
|
+
}
|
|
47
|
+
function ie(e) {
|
|
48
|
+
let t = document.createElement("a");
|
|
49
|
+
return t.setAttribute(g, e), t.href = v, t.target = "_blank", t.rel = "noopener noreferrer", t.textContent = ee, t.title = "Unlicensed @svgrid/enterprise. Contact sales@jqwidgets.com or visit www.svgrid.com.", t;
|
|
50
|
+
}
|
|
51
|
+
function ae(e) {
|
|
52
|
+
if (typeof window > "u") {
|
|
53
|
+
e.remove();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
window.setTimeout(() => {
|
|
57
|
+
e.style.opacity = "0", window.setTimeout(() => e.remove(), b);
|
|
58
|
+
}, y);
|
|
59
|
+
}
|
|
60
|
+
function oe(e, t) {
|
|
61
|
+
Object.assign(e.style, {
|
|
62
|
+
position: t ? "fixed" : "absolute",
|
|
63
|
+
bottom: t ? "12px" : "6px",
|
|
64
|
+
right: t ? "12px" : "8px",
|
|
65
|
+
zIndex: "2147483647",
|
|
66
|
+
background: "rgba(15,23,42,0.85)",
|
|
67
|
+
color: "#fff",
|
|
68
|
+
padding: t ? "6px 10px" : "4px 8px",
|
|
69
|
+
borderRadius: t ? "4px" : "3px",
|
|
70
|
+
fontFamily: "-apple-system, \"Segoe UI\", Roboto, sans-serif",
|
|
71
|
+
fontSize: t ? "11px" : "10px",
|
|
72
|
+
lineHeight: "1.2",
|
|
73
|
+
textDecoration: "none",
|
|
74
|
+
boxShadow: t ? "0 2px 12px rgba(0,0,0,0.35)" : "0 1px 4px rgba(0,0,0,0.3)",
|
|
75
|
+
border: "1px solid rgba(255,255,255,0.18)",
|
|
76
|
+
pointerEvents: "auto",
|
|
77
|
+
letterSpacing: "0.02em",
|
|
78
|
+
opacity: "1",
|
|
79
|
+
transition: `opacity ${b}ms ease`
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/upgrade-prompt.ts
|
|
84
|
+
var E = "data-svgrid-enterprise-upgrade", se = "https://www.svgrid.com/pricing", ce = "https://www.svgrid.com/pricing?ref=in-app&utm_source=svgrid-enterprise&utm_medium=upgrade-prompt", D = !1;
|
|
85
|
+
function O(e) {
|
|
86
|
+
if (D || typeof document > "u" || typeof window > "u" || document.querySelector(`[${E}]`)) return;
|
|
87
|
+
D = !0;
|
|
88
|
+
let t = j(e);
|
|
89
|
+
document.body.appendChild(t), requestAnimationFrame(() => {
|
|
90
|
+
t.style.opacity = "1", t.style.transform = "translateY(0)";
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function k() {
|
|
94
|
+
D = !1, !(typeof document > "u") && document.querySelectorAll(`[${E}]`).forEach((e) => e.remove());
|
|
95
|
+
}
|
|
96
|
+
function A(e) {
|
|
97
|
+
e.style.opacity = "0", e.style.transform = "translateY(8px)", window.setTimeout(() => e.remove(), 220);
|
|
98
|
+
}
|
|
99
|
+
function j(e) {
|
|
100
|
+
let t = document.createElement("div");
|
|
101
|
+
return t.setAttribute(E, "1"), t.setAttribute("role", "dialog"), t.setAttribute("aria-label", "Unlock SvGrid Pro"), Object.assign(t.style, {
|
|
102
|
+
position: "fixed",
|
|
103
|
+
bottom: "16px",
|
|
104
|
+
right: "16px",
|
|
105
|
+
zIndex: "2147483646",
|
|
106
|
+
width: "320px",
|
|
107
|
+
maxWidth: "calc(100vw - 32px)",
|
|
108
|
+
boxSizing: "border-box",
|
|
109
|
+
padding: "16px 16px 14px",
|
|
110
|
+
background: "#0f172a",
|
|
111
|
+
color: "#e2e8f0",
|
|
112
|
+
borderRadius: "12px",
|
|
113
|
+
border: "1px solid rgba(99,102,241,0.4)",
|
|
114
|
+
boxShadow: "0 12px 40px rgba(0,0,0,0.45)",
|
|
115
|
+
fontFamily: "-apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif",
|
|
116
|
+
fontSize: "13px",
|
|
117
|
+
lineHeight: "1.45",
|
|
118
|
+
opacity: "0",
|
|
119
|
+
transform: "translateY(8px)",
|
|
120
|
+
transition: "opacity 220ms ease, transform 220ms ease"
|
|
121
|
+
}), t.innerHTML = `
|
|
122
|
+
<button type="button" data-act="x" aria-label="Dismiss"
|
|
123
|
+
style="position:absolute;top:8px;right:8px;width:24px;height:24px;display:flex;
|
|
124
|
+
align-items:center;justify-content:center;background:transparent;border:0;
|
|
125
|
+
color:#94a3b8;font-size:18px;line-height:1;cursor:pointer;border-radius:6px;">×</button>
|
|
126
|
+
<div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
|
|
127
|
+
<span style="display:inline-block;background:#4f46e5;color:#fff;font-size:10px;
|
|
128
|
+
font-weight:700;letter-spacing:0.06em;padding:2px 7px;border-radius:999px;">PRO</span>
|
|
129
|
+
<span style="font-weight:700;color:#fff;">Unlock SvGrid Pro</span>
|
|
130
|
+
</div>
|
|
131
|
+
<p style="margin:0 0 12px;color:#cbd5e1;">
|
|
132
|
+
${e ? `<strong style="color:#fff">${M(e ? String(e) : "This")}</strong> is a Pro feature.` : "You just used a <strong style=\"color:#fff\">Pro</strong> feature."} It runs in evaluation with a watermark - start a free trial
|
|
133
|
+
to remove it and ship to production.
|
|
134
|
+
</p>
|
|
135
|
+
<div style="display:flex;gap:8px;align-items:center;">
|
|
136
|
+
<a data-act="trial" href="${ce}" target="_blank" rel="noopener noreferrer"
|
|
137
|
+
style="flex:1;text-align:center;background:#6366f1;color:#fff;font-weight:600;
|
|
138
|
+
text-decoration:none;padding:8px 12px;border-radius:8px;">Start free trial</a>
|
|
139
|
+
<a data-act="pricing" href="${se}" target="_blank" rel="noopener noreferrer"
|
|
140
|
+
style="color:#a5b4fc;text-decoration:none;padding:8px 6px;font-weight:600;">Pricing</a>
|
|
141
|
+
</div>
|
|
142
|
+
<p style="margin:10px 0 0;font-size:11px;color:#64748b;">
|
|
143
|
+
Already licensed? Call <code style="color:#94a3b8;">setLicenseKey()</code> at startup to hide this.
|
|
144
|
+
</p>
|
|
145
|
+
`, t.querySelector("[data-act=\"x\"]")?.addEventListener("click", () => A(t)), t.querySelector("[data-act=\"trial\"]")?.addEventListener("click", () => A(t)), t.querySelector("[data-act=\"pricing\"]")?.addEventListener("click", () => A(t)), t;
|
|
146
|
+
}
|
|
147
|
+
function M(e) {
|
|
148
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/license.ts
|
|
152
|
+
var le = "SVENTERPRISE-", N = null, P = !1;
|
|
153
|
+
function ue(e) {
|
|
154
|
+
if (typeof e != "string" || e.length === 0) throw Error("@svgrid/enterprise: setLicenseKey() requires a non-empty string");
|
|
155
|
+
N = e, P = !1;
|
|
156
|
+
}
|
|
157
|
+
function de() {
|
|
158
|
+
N = null, P = !1;
|
|
159
|
+
}
|
|
160
|
+
function fe() {
|
|
161
|
+
return N;
|
|
162
|
+
}
|
|
163
|
+
function pe() {
|
|
164
|
+
return N != null;
|
|
165
|
+
}
|
|
166
|
+
function me() {
|
|
167
|
+
return !(N == null || !N.startsWith(le) || h.has(N));
|
|
168
|
+
}
|
|
169
|
+
function F(e) {
|
|
170
|
+
if (N == null) {
|
|
171
|
+
te(), O(e);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (!N.startsWith(le)) throw Error("@svgrid/enterprise: invalid license key format (expected \"SVENTERPRISE-...\" prefix).");
|
|
175
|
+
if (h.has(N)) throw Error("@svgrid/enterprise: this license key has been revoked. Contact sales@jqwidgets.com for a replacement.");
|
|
176
|
+
!P && (N.startsWith("SVENTERPRISE-DEV") || N.startsWith("SVENTERPRISE-EVAL")) && (console.info("@svgrid/enterprise: using a development / evaluation license. Not for production use."), P = !0);
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/smart-shim.ts
|
|
180
|
+
var he = !1;
|
|
181
|
+
function ge() {
|
|
182
|
+
if (he) return;
|
|
183
|
+
if (typeof window > "u") throw Error("@svgrid/enterprise: installSmartShim() requires a browser environment");
|
|
184
|
+
let e = window.Smart ?? { Utilities: {} };
|
|
185
|
+
e.Utilities = e.Utilities ?? {}, typeof e.Utilities.Assign != "function" && (e.Utilities.Assign = (t, n) => {
|
|
186
|
+
e.Utilities[t] = n;
|
|
187
|
+
}), (!e.Utilities.Core || typeof e.Utilities.Core.toDash != "function") && (e.Utilities.Core = { toDash: (e) => e.replace(/[A-Z]/g, (e) => "-" + e.toLowerCase()) }), window.Smart = e, he = !0;
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/export.ts
|
|
191
|
+
var _e = null;
|
|
192
|
+
async function I() {
|
|
193
|
+
if (typeof window > "u") throw Error("@svgrid/enterprise: export requires a browser environment");
|
|
194
|
+
return _e ||= (async () => {
|
|
195
|
+
ge(), await import("./smart.export-CfW2zpyq.js");
|
|
196
|
+
let e = window.Smart?.Utilities?.DataExporter;
|
|
197
|
+
if (!e) throw Error("@svgrid/enterprise: failed to load Smart.Utilities.DataExporter");
|
|
198
|
+
return e;
|
|
199
|
+
})(), _e;
|
|
200
|
+
}
|
|
201
|
+
async function ve(e) {
|
|
202
|
+
let t = globalThis;
|
|
203
|
+
if (e === "xlsx" && t.JSZip == null) {
|
|
204
|
+
let e;
|
|
205
|
+
try {
|
|
206
|
+
e = await import("jszip");
|
|
207
|
+
} catch {
|
|
208
|
+
throw Error("@svgrid/enterprise: xlsx export requires the \"jszip\" peer dependency. Install it with: pnpm add jszip");
|
|
209
|
+
}
|
|
210
|
+
t.JSZip = e.default ?? e;
|
|
211
|
+
}
|
|
212
|
+
if (e === "pdf" && t.pdfMake == null) {
|
|
213
|
+
let e, n;
|
|
214
|
+
try {
|
|
215
|
+
e = await import("./pdfmake-C6pyKjX0.js").then((e) => /* @__PURE__ */ m(e.default, 1)), n = await import("./vfs_fonts-BktEULEs.js").then((e) => /* @__PURE__ */ m(e.default, 1));
|
|
216
|
+
} catch {
|
|
217
|
+
throw Error("@svgrid/enterprise: pdf export requires the \"pdfmake\" peer dependency. Install it with: pnpm add pdfmake");
|
|
218
|
+
}
|
|
219
|
+
let r = e.default ?? e, i = n.default ?? n, a = i.pdfMake?.vfs ?? i.vfs ?? i.default?.vfs;
|
|
220
|
+
a && (r.vfs = a), t.pdfMake = r;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function L(e, t) {
|
|
224
|
+
let n = t.rows ?? e.getDisplayedRows(), r;
|
|
225
|
+
if (t.columns && t.columns.length > 0) r = t.columns;
|
|
226
|
+
else {
|
|
227
|
+
let t = e.getColumns().filter((e) => e.visible && e.field);
|
|
228
|
+
r = t.length > 0 ? t.map((e) => ({
|
|
229
|
+
field: e.field,
|
|
230
|
+
header: e.header
|
|
231
|
+
})) : n.length > 0 ? Object.keys(n[0]).filter((e) => !e.startsWith("_")).map((e) => ({ field: e })) : [];
|
|
232
|
+
}
|
|
233
|
+
let i = {};
|
|
234
|
+
for (let e of r) i[e.field] = e.header ?? e.field;
|
|
235
|
+
let a = [i];
|
|
236
|
+
for (let e of n) {
|
|
237
|
+
let t = {}, n = e;
|
|
238
|
+
for (let e of r) t[e.field] = n[e.field];
|
|
239
|
+
a.push(t);
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
rows: a,
|
|
243
|
+
filename: (t.filename ?? "grid").trim() || "grid"
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function R(e) {
|
|
247
|
+
if (!e) return;
|
|
248
|
+
let t = {};
|
|
249
|
+
e.headerRow && (t.header = { ...e.headerRow });
|
|
250
|
+
let n = e.rows ? { ...e.rows } : {};
|
|
251
|
+
return e.rowAlternate && (n.alternationCount = 2, n.alternationStart = 0, e.rowAlternate.backgroundColor && (n.alternationIndex1BackgroundColor = e.rowAlternate.backgroundColor), e.rowAlternate.color && (n.alternationIndex1Color = e.rowAlternate.color)), Object.keys(n).length > 0 && (t.rows = n), e.cells && (t.cells = e.cells), t;
|
|
252
|
+
}
|
|
253
|
+
var ye = 0, z = /* @__PURE__ */ new Map();
|
|
254
|
+
function be(e) {
|
|
255
|
+
let t = z.get(e);
|
|
256
|
+
if (t) return t;
|
|
257
|
+
let n = `img${++ye}`;
|
|
258
|
+
return z.set(e, n), n;
|
|
259
|
+
}
|
|
260
|
+
function xe(e, t = 64, n = 64) {
|
|
261
|
+
let r = /^data:image\/([a-zA-Z0-9+]+);/i.exec(e)?.[1]?.toLowerCase() ?? "png", i = r === "jpg" ? "jpeg" : r === "svg+xml" ? "svg" : r;
|
|
262
|
+
return {
|
|
263
|
+
id: be(e),
|
|
264
|
+
base64: e,
|
|
265
|
+
imageType: i,
|
|
266
|
+
width: t,
|
|
267
|
+
height: n
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function Se(e, t) {
|
|
271
|
+
if (!e || e.length === 0 || t.length === 0) return;
|
|
272
|
+
let n = t[0], r = [];
|
|
273
|
+
for (let i of e) {
|
|
274
|
+
let e = {}, a;
|
|
275
|
+
if ("image" in i) e[n] = i.image, a = {
|
|
276
|
+
mergeAcross: !0,
|
|
277
|
+
textAlign: "left"
|
|
278
|
+
};
|
|
279
|
+
else if ("text" in i) e[n] = i.text, a = {
|
|
280
|
+
mergeAcross: !0,
|
|
281
|
+
...i.style ?? {}
|
|
282
|
+
};
|
|
283
|
+
else {
|
|
284
|
+
let r = t[Math.floor(t.length / 2)], o = t[t.length - 1];
|
|
285
|
+
i.left !== void 0 && (e[n] = i.left), i.center !== void 0 && (e[r] = i.center), i.right !== void 0 && (e[o] = i.right), a = { textAlign: "left" };
|
|
286
|
+
}
|
|
287
|
+
r.push({
|
|
288
|
+
cells: e,
|
|
289
|
+
style: a
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return r;
|
|
293
|
+
}
|
|
294
|
+
function Ce(e, t) {
|
|
295
|
+
let n = e && e.length > 0 ? new Set(e) : null;
|
|
296
|
+
return (e, r, i) => typeof i != "string" || !/^data:image\//i.test(i) ? null : n && !n.has(r) ? {
|
|
297
|
+
image: xe(i, 96, 96),
|
|
298
|
+
value: ""
|
|
299
|
+
} : {
|
|
300
|
+
image: xe(i, t.width, t.height),
|
|
301
|
+
value: ""
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function B(e) {
|
|
305
|
+
let t = {
|
|
306
|
+
exportHeader: !0,
|
|
307
|
+
pageOrientation: e.pageOrientation ?? "portrait"
|
|
308
|
+
}, n = R(e.styles);
|
|
309
|
+
if (n && (t.style = n), e.hierarchical && (t.hierarchical = !0), e.merges?.length && !e.groupBy?.length && !e.hierarchical) {
|
|
310
|
+
let n = e.merges.map((e) => ({
|
|
311
|
+
cell: [e.row, e.col],
|
|
312
|
+
rowspan: Math.max(1, Math.floor(e.rowSpan ?? 1)),
|
|
313
|
+
colspan: Math.max(1, Math.floor(e.colSpan ?? 1))
|
|
314
|
+
})).filter((e) => e.rowspan > 1 || e.colspan > 1);
|
|
315
|
+
n.length && (t.mergedCells = n);
|
|
316
|
+
}
|
|
317
|
+
return t;
|
|
318
|
+
}
|
|
319
|
+
function V(e, t, n) {
|
|
320
|
+
let r = Se(t.header, n), i = Se(t.footer, n);
|
|
321
|
+
r && (e.headerContent = r), i && (e.footerContent = i);
|
|
322
|
+
let a = (t.header?.some((e) => "image" in e) ?? !1) || (t.footer?.some((e) => "image" in e) ?? !1);
|
|
323
|
+
if (t.imageFields?.length || a) {
|
|
324
|
+
let n = t.imageSize ?? {
|
|
325
|
+
width: 32,
|
|
326
|
+
height: 32
|
|
327
|
+
};
|
|
328
|
+
e.addImageToCell = Ce(t.imageFields, n);
|
|
329
|
+
}
|
|
330
|
+
return e;
|
|
331
|
+
}
|
|
332
|
+
async function H(e, t) {
|
|
333
|
+
F("Export"), await ve(t.format);
|
|
334
|
+
let n = await I();
|
|
335
|
+
if (t.sheets && t.sheets.length > 0) {
|
|
336
|
+
if (t.format !== "xlsx") throw Error(`@svgrid/enterprise: multi-sheet export requires format 'xlsx', got '${t.format}'`);
|
|
337
|
+
let r = e.getColumns().filter((e) => e.visible && e.field), i = r.length > 0 ? r.map((e) => ({
|
|
338
|
+
field: e.field,
|
|
339
|
+
header: e.header
|
|
340
|
+
})) : [], a = t.sheets.map((e) => {
|
|
341
|
+
let n = e.columns ?? t.columns ?? (i.length > 0 ? i : e.rows.length > 0 ? Object.keys(e.rows[0]).filter((e) => !e.startsWith("_")).map((e) => ({ field: e })) : []), r = e.rows.map((e) => {
|
|
342
|
+
let t = e, r = {};
|
|
343
|
+
for (let e of n) r[e.field] = t[e.field];
|
|
344
|
+
return r;
|
|
345
|
+
});
|
|
346
|
+
return {
|
|
347
|
+
label: e.label,
|
|
348
|
+
dataSource: r,
|
|
349
|
+
columns: n.map((e) => ({
|
|
350
|
+
dataField: e.field,
|
|
351
|
+
label: e.header ?? e.field
|
|
352
|
+
})),
|
|
353
|
+
dataFields: n.map((e) => e.field),
|
|
354
|
+
style: R(e.styles ?? t.styles)
|
|
355
|
+
};
|
|
356
|
+
}), o = (t.filename ?? "grid").trim() || "grid", s = B(t), c = a[0], l = new n(s);
|
|
357
|
+
l.spreadsheets = a, V(l, t, c.dataFields);
|
|
358
|
+
let u = {};
|
|
359
|
+
for (let e of c.columns) u[e.dataField] = e.label;
|
|
360
|
+
let d = [u, ...c.dataSource];
|
|
361
|
+
l.exportData(d, t.format, o);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
let { rows: r, filename: i } = L(e, t);
|
|
365
|
+
if (r.length <= 1) throw Error("@svgrid/enterprise: nothing to export - the grid has no rows");
|
|
366
|
+
let a = Object.keys(r[0]), o = !t.hierarchical && t.groupBy && t.groupBy.length > 0 ? t.groupBy : void 0, s = new n(B(t), o);
|
|
367
|
+
V(s, t, a), s.exportData(r, t.format, i);
|
|
368
|
+
}
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/print.ts
|
|
371
|
+
var we = null;
|
|
372
|
+
async function U() {
|
|
373
|
+
if (typeof window > "u") throw Error("@svgrid/enterprise: print requires a browser environment");
|
|
374
|
+
return we ||= (async () => {
|
|
375
|
+
ge(), await import("./smart.export-CfW2zpyq.js");
|
|
376
|
+
let e = window.Smart?.Utilities?.DataExporter;
|
|
377
|
+
if (!e) throw Error("@svgrid/enterprise: failed to load Smart.Utilities.DataExporter");
|
|
378
|
+
return e;
|
|
379
|
+
})(), we;
|
|
380
|
+
}
|
|
381
|
+
async function W(e, t) {
|
|
382
|
+
F("Print");
|
|
383
|
+
let n = t?.rows ?? e.getDisplayedRows(), r;
|
|
384
|
+
if (r = t?.columns && t.columns.length > 0 ? t.columns : n.length > 0 ? Object.keys(n[0]).filter((e) => !e.startsWith("_")).map((e) => ({ field: e })) : [], n.length === 0) throw Error("@svgrid/enterprise: nothing to print - the grid has no rows");
|
|
385
|
+
let i = {};
|
|
386
|
+
for (let e of r) i[e.field] = e.header ?? e.field;
|
|
387
|
+
let a = [i];
|
|
388
|
+
for (let e of n) {
|
|
389
|
+
let t = {}, n = e;
|
|
390
|
+
for (let e of r) t[e.field] = n[e.field];
|
|
391
|
+
a.push(t);
|
|
392
|
+
}
|
|
393
|
+
let o = new (await (U()))({ exportHeader: !0 }).exportData(a, "html"), s = (t?.title ?? "Grid").replace(/[<>]/g, ""), c = `<!DOCTYPE html>
|
|
394
|
+
<html><head><meta charset="utf-8"><title>${s}</title>
|
|
395
|
+
<style>
|
|
396
|
+
@page { size: ${t?.orientation ?? "portrait"}; margin: 14mm; }
|
|
397
|
+
@media print { body { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
|
|
398
|
+
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; color: #111; }
|
|
399
|
+
h1 { font-size: 16pt; margin: 0 0 8mm 0; }
|
|
400
|
+
table { border-collapse: collapse; width: 100%; font-size: 9pt; }
|
|
401
|
+
th, td { border: 1px solid #444; padding: 4px 6px; text-align: left; }
|
|
402
|
+
thead { background: #eee; }
|
|
403
|
+
</style></head>
|
|
404
|
+
<body>
|
|
405
|
+
<h1>${s}</h1>
|
|
406
|
+
${o.replace(/^[\s\S]*?<body>/i, "").replace(/<\/body>[\s\S]*$/i, "")}
|
|
407
|
+
</body></html>`, l = window.open("", "_blank", "width=900,height=700");
|
|
408
|
+
if (!l) throw Error("@svgrid/enterprise: print() could not open a window - the browser blocked the popup");
|
|
409
|
+
l.document.open(), l.document.write(c), l.document.close(), l.focus(), l.addEventListener("load", () => {
|
|
410
|
+
setTimeout(() => l.print(), 50);
|
|
411
|
+
}), setTimeout(() => {
|
|
412
|
+
try {
|
|
413
|
+
l.print();
|
|
414
|
+
} catch {}
|
|
415
|
+
}, 300);
|
|
416
|
+
}
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region src/import.ts
|
|
419
|
+
var G = null;
|
|
420
|
+
async function Te() {
|
|
421
|
+
if (typeof window > "u") throw Error("@svgrid/enterprise: importData requires a browser environment");
|
|
422
|
+
let e = globalThis;
|
|
423
|
+
return e.JSZip ? e.JSZip : (G ||= (async () => {
|
|
424
|
+
let t;
|
|
425
|
+
try {
|
|
426
|
+
t = await import("jszip");
|
|
427
|
+
} catch {
|
|
428
|
+
throw Error("@svgrid/enterprise: xlsx import requires the \"jszip\" peer dependency. Install it with: pnpm add jszip");
|
|
429
|
+
}
|
|
430
|
+
let n = t.default ?? t;
|
|
431
|
+
return e.JSZip = n, n;
|
|
432
|
+
})(), G);
|
|
433
|
+
}
|
|
434
|
+
function Ee(e, t) {
|
|
435
|
+
if (t !== "auto") return t;
|
|
436
|
+
if (e instanceof File && e.name) {
|
|
437
|
+
let t = e.name.toLowerCase().split(".").pop() ?? "";
|
|
438
|
+
if (t === "xlsx") return "xlsx";
|
|
439
|
+
if (t === "csv") return "csv";
|
|
440
|
+
if (t === "tsv" || t === "tab") return "tsv";
|
|
441
|
+
if (t === "json") return "json";
|
|
442
|
+
}
|
|
443
|
+
if (typeof e == "string") {
|
|
444
|
+
let t = e.trimStart();
|
|
445
|
+
return t.startsWith("[") || t.startsWith("{") ? "json" : ((t.slice(0, 200).split(/\r?\n/)[0] ?? "").match(/\t/g)?.length ?? 0) >= 1 ? "tsv" : "csv";
|
|
446
|
+
}
|
|
447
|
+
return "xlsx";
|
|
448
|
+
}
|
|
449
|
+
function De(e, t) {
|
|
450
|
+
let n = [], r = [], i = "", a = 0, o = !1;
|
|
451
|
+
for (e.charCodeAt(0) === 65279 && (a = 1); a < e.length;) {
|
|
452
|
+
let s = e[a];
|
|
453
|
+
if (o) {
|
|
454
|
+
if (s === "\"") {
|
|
455
|
+
if (e[a + 1] === "\"") {
|
|
456
|
+
i += "\"", a += 2;
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
o = !1, a += 1;
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
i += s, a += 1;
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
if (s === "\"") {
|
|
466
|
+
o = !0, a += 1;
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
if (s === t) {
|
|
470
|
+
r.push(i), i = "", a += 1;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (s === "\r") {
|
|
474
|
+
e[a + 1] === "\n" && (a += 1), r.push(i), n.push(r), r = [], i = "", a += 1;
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (s === "\n") {
|
|
478
|
+
r.push(i), n.push(r), r = [], i = "", a += 1;
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
i += s, a += 1;
|
|
482
|
+
}
|
|
483
|
+
return (i.length > 0 || r.length > 0) && (r.push(i), n.push(r)), n;
|
|
484
|
+
}
|
|
485
|
+
async function K(e) {
|
|
486
|
+
let t = await Te(), n = await e.arrayBuffer(), r = await t.loadAsync(n), i = [], a = r.file("xl/sharedStrings.xml");
|
|
487
|
+
a && (i = Oe(await a.async("string")));
|
|
488
|
+
let o = r.file("xl/worksheets/sheet1.xml") ?? r.file("xl/worksheets/sheet 1.xml");
|
|
489
|
+
if (!o) throw Error("@svgrid/enterprise: could not locate sheet1.xml in the .xlsx archive");
|
|
490
|
+
return ke(await o.async("string"), i);
|
|
491
|
+
}
|
|
492
|
+
function Oe(e) {
|
|
493
|
+
let t = [], n = /<si\b[^>]*>([\s\S]*?)<\/si>/g, r = /<t\b[^>]*>([\s\S]*?)<\/t>/g, i;
|
|
494
|
+
for (; (i = n.exec(e)) !== null;) {
|
|
495
|
+
let e = "", n;
|
|
496
|
+
for (r.lastIndex = 0; (n = r.exec(i[1] ?? "")) !== null;) e += q(n[1] ?? "");
|
|
497
|
+
t.push(e);
|
|
498
|
+
}
|
|
499
|
+
return t;
|
|
500
|
+
}
|
|
501
|
+
function q(e) {
|
|
502
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'/g, "'").replace(/ /g, "\n").replace(/	/g, " ");
|
|
503
|
+
}
|
|
504
|
+
function ke(e, t) {
|
|
505
|
+
let n = [], r = /<row\b[^>]*>([\s\S]*?)<\/row>/g, i = /<c\b([^>]*)>([\s\S]*?)<\/c>/g, a = /<is>\s*([\s\S]*?)\s*<\/is>/, o = /<t\b[^>]*>([\s\S]*?)<\/t>/g, s = /<v>([\s\S]*?)<\/v>/, c;
|
|
506
|
+
for (; (c = r.exec(e)) !== null;) {
|
|
507
|
+
let e = c[1] ?? "", r = [], l;
|
|
508
|
+
for (i.lastIndex = 0; (l = i.exec(e)) !== null;) {
|
|
509
|
+
let e = l[1] ?? "", n = l[2] ?? "", i = Ae(/r="([A-Z]+)\d+"/.exec(e)?.[1] ?? ""), c = /t="([^"]+)"/.exec(e)?.[1] ?? "n";
|
|
510
|
+
for (; r.length < i;) r.push("");
|
|
511
|
+
let u = "";
|
|
512
|
+
if (c === "s") u = t[Number(s.exec(n)?.[1] ?? "-1")] ?? "";
|
|
513
|
+
else if (c === "inlineStr" || c === "str") {
|
|
514
|
+
let e = a.exec(n)?.[1] ?? n, t = "", r;
|
|
515
|
+
for (o.lastIndex = 0; (r = o.exec(e)) !== null;) t += q(r[1] ?? "");
|
|
516
|
+
u = t || q(s.exec(n)?.[1] ?? "");
|
|
517
|
+
} else u = c === "b" ? s.exec(n)?.[1] === "1" ? "true" : "false" : q(s.exec(n)?.[1] ?? "");
|
|
518
|
+
r.push(u);
|
|
519
|
+
}
|
|
520
|
+
n.push(r);
|
|
521
|
+
}
|
|
522
|
+
return n;
|
|
523
|
+
}
|
|
524
|
+
function Ae(e) {
|
|
525
|
+
if (!e) return 0;
|
|
526
|
+
let t = 0;
|
|
527
|
+
for (let n = 0; n < e.length; n += 1) t = t * 26 + (e.charCodeAt(n) - 64);
|
|
528
|
+
return Math.max(0, t - 1);
|
|
529
|
+
}
|
|
530
|
+
function je(e) {
|
|
531
|
+
if (e === "") return "";
|
|
532
|
+
let t = e.trim();
|
|
533
|
+
if (t === "") return "";
|
|
534
|
+
if (t === "true" || t === "TRUE") return !0;
|
|
535
|
+
if (t === "false" || t === "FALSE") return !1;
|
|
536
|
+
if (/^[-+]?\$?\s?[\d,]+(?:\.\d+)?$/.test(t)) {
|
|
537
|
+
let e = parseFloat(t.replace(/[$,\s]/g, ""));
|
|
538
|
+
if (!Number.isNaN(e)) return e;
|
|
539
|
+
}
|
|
540
|
+
if (/^[-+]?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i.test(t)) {
|
|
541
|
+
let e = parseFloat(t);
|
|
542
|
+
if (!Number.isNaN(e)) return e;
|
|
543
|
+
}
|
|
544
|
+
return /^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2})?(?:Z|[+-]\d{2}:?\d{2})?)?$/.test(t), t;
|
|
545
|
+
}
|
|
546
|
+
function J(e, t, n) {
|
|
547
|
+
if (e.length === 0) return {
|
|
548
|
+
headers: [],
|
|
549
|
+
rows: [],
|
|
550
|
+
skipped: 0,
|
|
551
|
+
errors: []
|
|
552
|
+
};
|
|
553
|
+
let r = (e[0] ?? []).map((e) => e.trim()), i = e.slice(1), a = [], o = [], s = 0, c = r.map((e) => t && Object.prototype.hasOwnProperty.call(t, e) ? t[e] ?? null : e.toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "")), l = 0;
|
|
554
|
+
for (let e of i) {
|
|
555
|
+
if (e.every((e) => e === void 0 || e.trim() === "")) {
|
|
556
|
+
s += 1;
|
|
557
|
+
continue;
|
|
558
|
+
}
|
|
559
|
+
let t = {};
|
|
560
|
+
for (let i = 0; i < r.length; i += 1) {
|
|
561
|
+
let r = c[i];
|
|
562
|
+
if (r == null) continue;
|
|
563
|
+
let a = e[i] ?? "", s = n?.[r];
|
|
564
|
+
if (s) {
|
|
565
|
+
let e = Me(a, s);
|
|
566
|
+
e.ok ? t[r] = e.value : (o.push({
|
|
567
|
+
rowIndex: l,
|
|
568
|
+
field: r,
|
|
569
|
+
message: e.message
|
|
570
|
+
}), t[r] = a);
|
|
571
|
+
} else t[r] = je(a);
|
|
572
|
+
}
|
|
573
|
+
a.push(t), l += 1;
|
|
574
|
+
}
|
|
575
|
+
return {
|
|
576
|
+
headers: r,
|
|
577
|
+
rows: a,
|
|
578
|
+
skipped: s,
|
|
579
|
+
errors: o
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
function Me(e, t) {
|
|
583
|
+
let n = e.trim();
|
|
584
|
+
if (n === "") return t === "string" ? {
|
|
585
|
+
ok: !0,
|
|
586
|
+
value: ""
|
|
587
|
+
} : {
|
|
588
|
+
ok: !0,
|
|
589
|
+
value: null
|
|
590
|
+
};
|
|
591
|
+
switch (t) {
|
|
592
|
+
case "string": return {
|
|
593
|
+
ok: !0,
|
|
594
|
+
value: n
|
|
595
|
+
};
|
|
596
|
+
case "boolean": {
|
|
597
|
+
let e = n.toLowerCase();
|
|
598
|
+
return e === "true" || e === "1" || e === "yes" || e === "y" ? {
|
|
599
|
+
ok: !0,
|
|
600
|
+
value: !0
|
|
601
|
+
} : e === "false" || e === "0" || e === "no" || e === "n" ? {
|
|
602
|
+
ok: !0,
|
|
603
|
+
value: !1
|
|
604
|
+
} : {
|
|
605
|
+
ok: !1,
|
|
606
|
+
message: `not a boolean: ${n}`
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
case "number": {
|
|
610
|
+
let e = n.replace(/[$,\s]/g, ""), t = Number(e);
|
|
611
|
+
return Number.isFinite(t) ? {
|
|
612
|
+
ok: !0,
|
|
613
|
+
value: t
|
|
614
|
+
} : {
|
|
615
|
+
ok: !1,
|
|
616
|
+
message: `not a number: ${n}`
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
case "integer": {
|
|
620
|
+
let e = n.replace(/[$,\s]/g, ""), t = Number(e);
|
|
621
|
+
return !Number.isFinite(t) || !Number.isInteger(t) ? {
|
|
622
|
+
ok: !1,
|
|
623
|
+
message: `not an integer: ${n}`
|
|
624
|
+
} : {
|
|
625
|
+
ok: !0,
|
|
626
|
+
value: t
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
case "date": {
|
|
630
|
+
let e = n.match(/^(\d{4})-(\d{2})-(\d{2})/);
|
|
631
|
+
if (e) return {
|
|
632
|
+
ok: !0,
|
|
633
|
+
value: `${e[1]}-${e[2]}-${e[3]}`
|
|
634
|
+
};
|
|
635
|
+
let t = n.match(/^(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/);
|
|
636
|
+
if (t) {
|
|
637
|
+
let [, e, n, r] = t;
|
|
638
|
+
return {
|
|
639
|
+
ok: !0,
|
|
640
|
+
value: `${r}-${e.padStart(2, "0")}-${n.padStart(2, "0")}`
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
let r = Date.parse(n);
|
|
644
|
+
return Number.isNaN(r) ? {
|
|
645
|
+
ok: !1,
|
|
646
|
+
message: `not a date: ${n}`
|
|
647
|
+
} : {
|
|
648
|
+
ok: !0,
|
|
649
|
+
value: new Date(r).toISOString().slice(0, 10)
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
case "datetime": {
|
|
653
|
+
let e = Date.parse(n);
|
|
654
|
+
return Number.isNaN(e) ? {
|
|
655
|
+
ok: !1,
|
|
656
|
+
message: `not a datetime: ${n}`
|
|
657
|
+
} : {
|
|
658
|
+
ok: !0,
|
|
659
|
+
value: new Date(e).toISOString().slice(0, 19)
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
case "json": try {
|
|
663
|
+
return {
|
|
664
|
+
ok: !0,
|
|
665
|
+
value: JSON.parse(n)
|
|
666
|
+
};
|
|
667
|
+
} catch {
|
|
668
|
+
return {
|
|
669
|
+
ok: !1,
|
|
670
|
+
message: `not valid JSON: ${n.slice(0, 30)}...`
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
async function Y(e, t) {
|
|
676
|
+
F("Import");
|
|
677
|
+
let n = Ee(t.file, t.format ?? "auto"), r;
|
|
678
|
+
if (n === "xlsx") {
|
|
679
|
+
if (typeof t.file == "string") throw Error("@svgrid/enterprise: xlsx import expects a File or Blob, not a string. Use format: \"csv\" or \"tsv\" for inline text.");
|
|
680
|
+
r = await K(t.file);
|
|
681
|
+
} else if (n === "json") r = Ne(typeof t.file == "string" ? t.file : await X(t.file));
|
|
682
|
+
else {
|
|
683
|
+
let e = n === "tsv" ? " " : ",";
|
|
684
|
+
r = De(typeof t.file == "string" ? t.file : await X(t.file), e);
|
|
685
|
+
}
|
|
686
|
+
let { headers: i, rows: a, skipped: o, errors: s } = J(r, t.columnMap, t.columnTypes), c = [...s];
|
|
687
|
+
if (t.validator) for (let e = 0; e < a.length; e += 1) {
|
|
688
|
+
let n = t.validator(a[e], e);
|
|
689
|
+
for (let t of n) c.push({
|
|
690
|
+
rowIndex: e,
|
|
691
|
+
field: t.field,
|
|
692
|
+
message: t.message
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
return t.commit && c.length === 0 && a.length > 0 && e.addRows(a, t.commitAt ?? "bottom"), {
|
|
696
|
+
headers: i,
|
|
697
|
+
rows: a,
|
|
698
|
+
errors: c,
|
|
699
|
+
skipped: o,
|
|
700
|
+
total: r.length > 0 ? r.length - 1 : 0,
|
|
701
|
+
format: n
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
async function X(e) {
|
|
705
|
+
return e.text();
|
|
706
|
+
}
|
|
707
|
+
function Ne(e) {
|
|
708
|
+
let t = JSON.parse(e);
|
|
709
|
+
if (!Array.isArray(t)) throw Error("@svgrid/enterprise: JSON import expects a top-level array");
|
|
710
|
+
if (t.length === 0) return [];
|
|
711
|
+
let n = [], r = /* @__PURE__ */ new Set(), i = t.slice(0, 50);
|
|
712
|
+
for (let e of i) if (e && typeof e == "object") for (let t of Object.keys(e)) r.has(t) || (r.add(t), n.push(t));
|
|
713
|
+
let a = [n.slice()];
|
|
714
|
+
for (let e of t) {
|
|
715
|
+
let t = [];
|
|
716
|
+
for (let r of n) {
|
|
717
|
+
let n = e?.[r];
|
|
718
|
+
n == null ? t.push("") : typeof n == "object" ? t.push(JSON.stringify(n)) : t.push(String(n));
|
|
719
|
+
}
|
|
720
|
+
a.push(t);
|
|
721
|
+
}
|
|
722
|
+
return a;
|
|
723
|
+
}
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region src/ai.ts
|
|
726
|
+
var Z = null;
|
|
727
|
+
function Pe(e) {
|
|
728
|
+
Z = e;
|
|
729
|
+
}
|
|
730
|
+
function Fe() {
|
|
731
|
+
return Z;
|
|
732
|
+
}
|
|
733
|
+
function Ie() {
|
|
734
|
+
return Z != null;
|
|
735
|
+
}
|
|
736
|
+
var Le = class extends Error {
|
|
737
|
+
constructor() {
|
|
738
|
+
super("@svgrid/enterprise/ai: no AI provider registered. Call setAIProvider(fn) with an adapter that talks to OpenAI / Anthropic / your proxy."), this.name = "NoProviderError";
|
|
739
|
+
}
|
|
740
|
+
}, Re = class extends Error {
|
|
741
|
+
constructor(e) {
|
|
742
|
+
super(`@svgrid/enterprise/ai: provider returned non-JSON for a json-format request. First 200 chars: ${e.slice(0, 200)}`), this.name = "BadJsonError";
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
async function ze(e) {
|
|
746
|
+
if (!Z) throw new Le();
|
|
747
|
+
return Z(e);
|
|
748
|
+
}
|
|
749
|
+
async function Be(e) {
|
|
750
|
+
let t = await ze({
|
|
751
|
+
...e,
|
|
752
|
+
responseFormat: "json"
|
|
753
|
+
}), n = t.trim().replace(/^```(?:json)?\s*|\s*```$/g, "");
|
|
754
|
+
try {
|
|
755
|
+
return JSON.parse(n);
|
|
756
|
+
} catch {
|
|
757
|
+
throw new Re(t);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function Ve(e, t = 50) {
|
|
761
|
+
let n = e.getData();
|
|
762
|
+
if (n.length === 0) return [];
|
|
763
|
+
let r = n.slice(0, Math.min(n.length, t)), i = /* @__PURE__ */ new Set();
|
|
764
|
+
for (let e of r) for (let t of Object.keys(e)) i.add(t);
|
|
765
|
+
let a = [];
|
|
766
|
+
for (let e of i) {
|
|
767
|
+
let t = [];
|
|
768
|
+
for (let n of r) {
|
|
769
|
+
let r = n[e];
|
|
770
|
+
if (r != null && t.push(r), t.length >= 5) break;
|
|
771
|
+
}
|
|
772
|
+
a.push({
|
|
773
|
+
field: e,
|
|
774
|
+
type: He(t),
|
|
775
|
+
sampleValues: t
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
return a;
|
|
779
|
+
}
|
|
780
|
+
function He(e) {
|
|
781
|
+
if (e.length === 0) return "unknown";
|
|
782
|
+
let t = e[0];
|
|
783
|
+
return typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : typeof t == "string" ? /^\d{4}-\d{2}-\d{2}/.test(t) ? "date" : "string" : "unknown";
|
|
784
|
+
}
|
|
785
|
+
function Ue(e) {
|
|
786
|
+
return e.map((e) => `- ${e.field} (${e.type}): e.g. ${e.sampleValues.slice(0, 3).map((e) => JSON.stringify(e)).join(", ")}`).join("\n");
|
|
787
|
+
}
|
|
788
|
+
async function We(e, t, n = {}) {
|
|
789
|
+
F("AI assistant");
|
|
790
|
+
let r = Ve(e), i = await Be({
|
|
791
|
+
prompt: `You are a data-grid filter planner. Translate the user's natural-language query into a strict-JSON plan that the grid can apply.
|
|
792
|
+
|
|
793
|
+
Columns:\n${Ue(r)}\n\nOutput JSON schema:\n{ "filters": [{"field": "<one of the columns above>", "operator": "contains"|"equals"|"startsWith"|"greaterThan"|"lessThan"|"isBlank", "value": "<string>"}], "sort": [{"field": "<column>", "desc": true|false}], "rationale": "<one-sentence explanation>" }\n\nUser query: ${t}\n\nReturn JSON only, no prose.`,
|
|
794
|
+
task: "filter",
|
|
795
|
+
signal: n.signal,
|
|
796
|
+
maxOutputTokens: 400
|
|
797
|
+
}), a = new Set(r.map((e) => e.field));
|
|
798
|
+
if (i.filters = (i.filters ?? []).filter((e) => a.has(e.field)), i.sort = (i.sort ?? []).filter((e) => a.has(e.field)), n.apply) {
|
|
799
|
+
e.clearAllFilters(), e.clearSort();
|
|
800
|
+
for (let t of i.filters) e.setFilter(t.field, {
|
|
801
|
+
operator: t.operator,
|
|
802
|
+
value: t.value ?? ""
|
|
803
|
+
});
|
|
804
|
+
let t = i.sort[i.sort.length - 1];
|
|
805
|
+
t && e.setSort(t.field, t.desc ? "desc" : "asc");
|
|
806
|
+
}
|
|
807
|
+
return i;
|
|
808
|
+
}
|
|
809
|
+
async function Ge(e, t) {
|
|
810
|
+
if (F("AI assistant"), t.examples.length === 0) throw Error("@svgrid/enterprise/ai: aiSmartFill requires at least one example.");
|
|
811
|
+
let n = e.getData(), r = t.targetRowIndices ?? n.map((e, n) => {
|
|
812
|
+
let r = e[t.field];
|
|
813
|
+
return r == null || r === "" ? n : -1;
|
|
814
|
+
}).filter((e) => e >= 0);
|
|
815
|
+
if (r.length === 0) return {
|
|
816
|
+
field: t.field,
|
|
817
|
+
predictions: [],
|
|
818
|
+
rationale: "No empty cells to fill."
|
|
819
|
+
};
|
|
820
|
+
let i = t.examples.map((e, t) => `Example ${t + 1}: input=${JSON.stringify(e.input)} -> output=${JSON.stringify(e.output)}`).join("\n"), a = r.map((e) => `Row ${e}: ${JSON.stringify(n[e])}`).join("\n"), o = await Be({
|
|
821
|
+
prompt: `You are filling in a single column of a data grid based on user-provided examples. Match the pattern in the examples exactly.
|
|
822
|
+
|
|
823
|
+
Target column: ${t.field}\n\nExamples:\n${i}\n\nRows to fill:\n${a}\n\nReturn strict JSON only:\n{ "predictions": [{"rowIndex": <number>, "value": <inferred value>, "confidence": <0..1>}], "rationale": "<one-sentence pattern description>" }`,
|
|
824
|
+
task: "smart-fill",
|
|
825
|
+
signal: t.signal,
|
|
826
|
+
maxOutputTokens: 600
|
|
827
|
+
});
|
|
828
|
+
return {
|
|
829
|
+
field: t.field,
|
|
830
|
+
predictions: o.predictions ?? [],
|
|
831
|
+
rationale: o.rationale ?? ""
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
async function Ke(e, t) {
|
|
835
|
+
F("AI assistant");
|
|
836
|
+
let n = e.getData(), r = (() => {
|
|
837
|
+
let e = t.target;
|
|
838
|
+
if (e.kind === "row") {
|
|
839
|
+
let t = n[e.rowIndex];
|
|
840
|
+
return t ? [t] : [];
|
|
841
|
+
}
|
|
842
|
+
return e.kind === "selection" ? e.rowIndices.map((e) => n[e]).filter((e) => e != null) : e.kind === "group" ? n.filter((t) => t[e.field] === e.value) : n.slice();
|
|
843
|
+
})();
|
|
844
|
+
if (r.length === 0) return {
|
|
845
|
+
text: "No rows in scope.",
|
|
846
|
+
bullets: [],
|
|
847
|
+
highlightedFields: []
|
|
848
|
+
};
|
|
849
|
+
let i = r.length <= 25 ? r : Array.from({ length: 25 }, (e, t) => r[Math.floor(t / 25 * r.length)]), a = await Be({
|
|
850
|
+
prompt: `You are summarising a slice of a business data grid for a busy analyst.\n\nColumns:\n${Ue(Ve(e, 30))}\n\nSlice size: ${r.length} row(s). Sampled rows shown below.\n${i.map((e) => JSON.stringify(e)).join("\n")}\n\n` + (t.question ? `User's question: ${t.question}\n\n` : "") + "Return strict JSON only:\n{ \"text\": \"<one short paragraph>\", \"bullets\": [\"<3-5 punchy bullets>\"], \"highlightedFields\": [\"<column names the summary leans on>\"] }",
|
|
851
|
+
task: "summarize",
|
|
852
|
+
signal: t.signal,
|
|
853
|
+
maxOutputTokens: 600
|
|
854
|
+
});
|
|
855
|
+
return {
|
|
856
|
+
text: a.text ?? "",
|
|
857
|
+
bullets: a.bullets ?? [],
|
|
858
|
+
highlightedFields: a.highlightedFields ?? []
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
async function qe(e, t) {
|
|
862
|
+
F("AI assistant");
|
|
863
|
+
let n = e.getData(), r = t.targetRowIndices ?? n.map((e, t) => t), i = t.classDescriptions ? Object.entries(t.classDescriptions).map(([e, t]) => `- ${e}: ${t}`).join("\n") : t.classes.map((e) => `- ${e}`).join("\n"), a = r.map((e) => `Row ${e}: ${JSON.stringify(n[e]?.[t.inputField] ?? "")}`).join("\n"), o = await Be({
|
|
864
|
+
prompt: `You are a strict text classifier. For each row, pick exactly one label from the list. If unsure, pick the closest match and lower the confidence.
|
|
865
|
+
|
|
866
|
+
Allowed labels (with optional rubric):\n${i}\n\nRows to classify (text from column "${t.inputField}"):\n${a}\n\nReturn strict JSON only:\n{ "predictions": [{"rowIndex": <number>, "value": "<label>", "confidence": <0..1>}] }`,
|
|
867
|
+
task: "classify",
|
|
868
|
+
signal: t.signal,
|
|
869
|
+
maxOutputTokens: Math.min(2e3, 30 + r.length * 30)
|
|
870
|
+
}), s = new Set(t.classes);
|
|
871
|
+
return {
|
|
872
|
+
inputField: t.inputField,
|
|
873
|
+
outputField: t.outputField,
|
|
874
|
+
predictions: (o.predictions ?? []).filter((e) => s.has(e.value))
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
var Je = async (e) => {
|
|
878
|
+
if (await new Promise((e) => setTimeout(e, 350 + Math.random() * 400)), e.task === "filter") {
|
|
879
|
+
let t = Ye(e.prompt);
|
|
880
|
+
return JSON.stringify(Ze(e.prompt, t));
|
|
881
|
+
}
|
|
882
|
+
return e.task === "smart-fill" ? JSON.stringify(Qe(e.prompt)) : e.task === "summarize" ? JSON.stringify(tt(e.prompt)) : e.task === "classify" ? JSON.stringify(rt(e.prompt)) : "{}";
|
|
883
|
+
};
|
|
884
|
+
function Ye(e) {
|
|
885
|
+
return (e.match(/User query:\s*(.+?)\n/)?.[1] ?? "").toLowerCase();
|
|
886
|
+
}
|
|
887
|
+
function Xe(e) {
|
|
888
|
+
let t = e.match(/Columns:\n([\s\S]*?)\n\n/);
|
|
889
|
+
return t ? (t[1] ?? "").split("\n").map((e) => e.match(/^- (\w+)/)?.[1]).filter((e) => !!e) : [];
|
|
890
|
+
}
|
|
891
|
+
function Ze(e, t) {
|
|
892
|
+
let n = Xe(e), r = [], i = [], a = [], o = t.match(/(?:over|above|>|greater than)\s+\$?([\d.,]+)([kmb])?/), s = t.match(/(?:under|below|<|less than)\s+\$?([\d.,]+)([kmb])?/), c = n.filter((e) => /(arr|amount|price|stock|value|qty|sold|cost|revenue|probability|fillpct)/i.test(e));
|
|
893
|
+
if (o && c[0]) {
|
|
894
|
+
let e = parseFloat(o[1].replace(/,/g, "")), t = o[2] === "k" ? 1e3 : o[2] === "m" ? 1e6 : o[2] === "b" ? 1e9 : 1;
|
|
895
|
+
r.push({
|
|
896
|
+
field: c[0],
|
|
897
|
+
operator: "greaterThan",
|
|
898
|
+
value: String(e * t)
|
|
899
|
+
}), a.push(`amount > ${e}${o[2] ?? ""}`);
|
|
900
|
+
} else if (s && c[0]) {
|
|
901
|
+
let e = parseFloat(s[1].replace(/,/g, "")), t = s[2] === "k" ? 1e3 : s[2] === "m" ? 1e6 : 1;
|
|
902
|
+
r.push({
|
|
903
|
+
field: c[0],
|
|
904
|
+
operator: "lessThan",
|
|
905
|
+
value: String(e * t)
|
|
906
|
+
}), a.push(`amount < ${e}${s[2] ?? ""}`);
|
|
907
|
+
}
|
|
908
|
+
let l = t.match(/"([^"]+)"|'([^']+)'/), u = n.filter((e) => /(name|company|customer|title|owner|status|region|category|industry)/i.test(e));
|
|
909
|
+
if (l) {
|
|
910
|
+
let e = l[1] ?? l[2] ?? "";
|
|
911
|
+
u[0] && (r.push({
|
|
912
|
+
field: u[0],
|
|
913
|
+
operator: "contains",
|
|
914
|
+
value: e
|
|
915
|
+
}), a.push(`text contains "${e}"`));
|
|
916
|
+
}
|
|
917
|
+
for (let e of [
|
|
918
|
+
"sasha",
|
|
919
|
+
"jamie",
|
|
920
|
+
"casey",
|
|
921
|
+
"drew",
|
|
922
|
+
"robin",
|
|
923
|
+
"morgan",
|
|
924
|
+
"riley",
|
|
925
|
+
"quinn"
|
|
926
|
+
]) if (t.includes(e)) {
|
|
927
|
+
let t = n.find((e) => /owner|rep|assigned/i.test(e)) ?? n.find((e) => /name/i.test(e));
|
|
928
|
+
if (t) {
|
|
929
|
+
r.push({
|
|
930
|
+
field: t,
|
|
931
|
+
operator: "contains",
|
|
932
|
+
value: e
|
|
933
|
+
}), a.push(`owner ~ "${e}"`);
|
|
934
|
+
break;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
for (let e of [
|
|
938
|
+
"NA",
|
|
939
|
+
"EMEA",
|
|
940
|
+
"APAC",
|
|
941
|
+
"LATAM"
|
|
942
|
+
]) if (t.toUpperCase().includes(e)) {
|
|
943
|
+
let t = n.find((e) => /region/i.test(e));
|
|
944
|
+
if (t) {
|
|
945
|
+
r.push({
|
|
946
|
+
field: t,
|
|
947
|
+
operator: "equals",
|
|
948
|
+
value: e
|
|
949
|
+
}), a.push(`region = ${e}`);
|
|
950
|
+
break;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
for (let e of [
|
|
954
|
+
"active",
|
|
955
|
+
"pending",
|
|
956
|
+
"won",
|
|
957
|
+
"lost",
|
|
958
|
+
"live",
|
|
959
|
+
"paused",
|
|
960
|
+
"shipped",
|
|
961
|
+
"delivered"
|
|
962
|
+
]) if (t.includes(e)) {
|
|
963
|
+
let t = n.find((e) => /status|stage/i.test(e));
|
|
964
|
+
if (t) {
|
|
965
|
+
r.push({
|
|
966
|
+
field: t,
|
|
967
|
+
operator: "equals",
|
|
968
|
+
value: e
|
|
969
|
+
}), a.push(`status = ${e}`);
|
|
970
|
+
break;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
if (/(highest|largest|biggest|top|most)/.test(t)) {
|
|
974
|
+
let e = c[0];
|
|
975
|
+
e && (i.push({
|
|
976
|
+
field: e,
|
|
977
|
+
desc: !0
|
|
978
|
+
}), a.push(`sort by ${e} desc`));
|
|
979
|
+
} else if (/(lowest|smallest|least|cheapest)/.test(t)) {
|
|
980
|
+
let e = c[0];
|
|
981
|
+
e && (i.push({
|
|
982
|
+
field: e,
|
|
983
|
+
desc: !1
|
|
984
|
+
}), a.push(`sort by ${e} asc`));
|
|
985
|
+
} else if (/(newest|recent|latest)/.test(t)) {
|
|
986
|
+
let e = n.find((e) => /date|at|time/i.test(e));
|
|
987
|
+
e && (i.push({
|
|
988
|
+
field: e,
|
|
989
|
+
desc: !0
|
|
990
|
+
}), a.push(`sort by ${e} desc`));
|
|
991
|
+
} else if (/(oldest)/.test(t)) {
|
|
992
|
+
let e = n.find((e) => /date|at|time/i.test(e));
|
|
993
|
+
e && (i.push({
|
|
994
|
+
field: e,
|
|
995
|
+
desc: !1
|
|
996
|
+
}), a.push(`sort by ${e} asc`));
|
|
997
|
+
}
|
|
998
|
+
return {
|
|
999
|
+
filters: r,
|
|
1000
|
+
sort: i,
|
|
1001
|
+
rationale: a.length ? `Interpreted: ${a.join(" AND ")}.` : `Couldn't identify a clear filter for "${t}". Showing all rows.`
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
function Qe(e) {
|
|
1005
|
+
let t = e.match(/Target column:\s*(\w+)/), n = e.match(/Rows to fill:\n([\s\S]*?)\n\n/), r = e.match(/Example 1: input=.* -> output=(.+)/), i = t?.[1] ?? "", a = (n?.[1] ?? "").split("\n").filter(Boolean), o = r?.[1] ? $e(r[1]) : "";
|
|
1006
|
+
return {
|
|
1007
|
+
predictions: a.map((e) => {
|
|
1008
|
+
let t = e.match(/^Row (\d+): (\{.+\})/);
|
|
1009
|
+
if (!t) return null;
|
|
1010
|
+
let n = parseInt(t[1], 10), r = $e(t[2]);
|
|
1011
|
+
return r ? {
|
|
1012
|
+
rowIndex: n,
|
|
1013
|
+
value: et(i, r, o),
|
|
1014
|
+
confidence: .78 + Math.random() * .18
|
|
1015
|
+
} : null;
|
|
1016
|
+
}).filter((e) => !!e),
|
|
1017
|
+
rationale: `Inferred from ${r ? "the supplied" : "no"} examples; mocked deterministically for the demo.`
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
function $e(e) {
|
|
1021
|
+
try {
|
|
1022
|
+
return JSON.parse(e);
|
|
1023
|
+
} catch {
|
|
1024
|
+
return null;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
function et(e, t, n) {
|
|
1028
|
+
if (e === "priority") {
|
|
1029
|
+
let e = Number(t.arr ?? t.amount ?? t.price ?? 0);
|
|
1030
|
+
return e > 1e5 ? "high" : e > 3e4 ? "medium" : "low";
|
|
1031
|
+
}
|
|
1032
|
+
if (e === "tier") {
|
|
1033
|
+
let e = Number(t.arr ?? t.amount ?? 0);
|
|
1034
|
+
return e > 5e5 ? "enterprise" : e > 1e5 ? "growth" : "starter";
|
|
1035
|
+
}
|
|
1036
|
+
return e === "tags" || e === "category" ? typeof n == "string" ? n : "auto-tag" : typeof n == "string" || typeof n == "number" ? n : n ?? "auto";
|
|
1037
|
+
}
|
|
1038
|
+
function tt(e) {
|
|
1039
|
+
let t = e.match(/Slice size: (\d+) row/), n = t ? parseInt(t[1], 10) : 0, r = nt(e);
|
|
1040
|
+
return {
|
|
1041
|
+
text: n === 1 ? `Single record. Notable signals come from ${r.slice(0, 2).join(" and ") || "the available fields"}.` : `${n} rows in scope. The distribution skews toward live / active records, with a long tail in ${r[0] ?? "amount"}.`,
|
|
1042
|
+
bullets: [
|
|
1043
|
+
`${n} row${n === 1 ? "" : "s"} sampled`,
|
|
1044
|
+
r[0] ? `Largest variance in ${r[0]}` : "Tight clustering across visible fields",
|
|
1045
|
+
r[1] ? `${r[1]} concentrates around the median` : "Few outliers",
|
|
1046
|
+
"Mock summary - wire setAIProvider() to a real model for actual analysis"
|
|
1047
|
+
],
|
|
1048
|
+
highlightedFields: r.slice(0, 3)
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
function nt(e) {
|
|
1052
|
+
let t = e.match(/Columns:\n([\s\S]*?)\n\n/);
|
|
1053
|
+
return t ? (t[1] ?? "").split("\n").map((e) => e.match(/^- (\w+)/)?.[1]).filter((e) => !!e) : [];
|
|
1054
|
+
}
|
|
1055
|
+
function rt(e) {
|
|
1056
|
+
let t = (e.match(/Allowed labels[\s\S]*?:\n([\s\S]*?)\n\n/)?.[1] ?? "").split("\n").map((e) => e.match(/^-\s*([^\s:]+)/)?.[1]).filter((e) => !!e);
|
|
1057
|
+
return { predictions: (e.match(/Rows to classify[\s\S]*?:\n([\s\S]*?)\n\n/)?.[1] ?? "").split("\n").filter(Boolean).map((e) => {
|
|
1058
|
+
let n = e.match(/^Row (\d+): "(.*)"/);
|
|
1059
|
+
if (!n || t.length === 0) return null;
|
|
1060
|
+
let r = parseInt(n[1], 10), i = (n[2] ?? "").toLowerCase(), a = t.find((e) => i.includes(e.toLowerCase()));
|
|
1061
|
+
return {
|
|
1062
|
+
rowIndex: r,
|
|
1063
|
+
value: a ?? t[Math.abs(it(i)) % t.length],
|
|
1064
|
+
confidence: a ? .92 : .6 + Math.random() * .2
|
|
1065
|
+
};
|
|
1066
|
+
}).filter((e) => !!e) };
|
|
1067
|
+
}
|
|
1068
|
+
function it(e) {
|
|
1069
|
+
let t = 0;
|
|
1070
|
+
for (let n = 0; n < e.length; n += 1) t = t * 31 + e.charCodeAt(n) | 0;
|
|
1071
|
+
return t;
|
|
1072
|
+
}
|
|
1073
|
+
//#endregion
|
|
1074
|
+
//#region src/pivot.ts
|
|
1075
|
+
var Q = (e) => e.map((e) => typeof e == "number" ? e : Number(e)).filter((e) => !Number.isNaN(e)), at = {
|
|
1076
|
+
sum: (e) => Q(e).reduce((e, t) => e + t, 0),
|
|
1077
|
+
avg: (e) => {
|
|
1078
|
+
let t = Q(e);
|
|
1079
|
+
return t.length === 0 ? null : t.reduce((e, t) => e + t, 0) / t.length;
|
|
1080
|
+
},
|
|
1081
|
+
min: (e) => Q(e).length === 0 ? null : Math.min(...Q(e)),
|
|
1082
|
+
max: (e) => Q(e).length === 0 ? null : Math.max(...Q(e)),
|
|
1083
|
+
count: (e) => e.length,
|
|
1084
|
+
countDistinct: (e) => new Set(e).size,
|
|
1085
|
+
first: (e) => e[0] ?? null,
|
|
1086
|
+
last: (e) => e[e.length - 1] ?? null
|
|
1087
|
+
};
|
|
1088
|
+
function ot(e) {
|
|
1089
|
+
if (typeof e == "function") return e;
|
|
1090
|
+
let t = at[e];
|
|
1091
|
+
if (!t) throw Error(`pivot: unknown aggregator '${String(e)}'`);
|
|
1092
|
+
return t;
|
|
1093
|
+
}
|
|
1094
|
+
function st(e, t) {
|
|
1095
|
+
return e === t ? 0 : e == null ? -1 : t == null ? 1 : typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t), void 0, { numeric: !0 });
|
|
1096
|
+
}
|
|
1097
|
+
function ct(e, t, n) {
|
|
1098
|
+
let r = {
|
|
1099
|
+
level: 0,
|
|
1100
|
+
value: null,
|
|
1101
|
+
path: [],
|
|
1102
|
+
pathKey: "__root",
|
|
1103
|
+
children: /* @__PURE__ */ new Map(),
|
|
1104
|
+
rows: e
|
|
1105
|
+
};
|
|
1106
|
+
for (let n of e) {
|
|
1107
|
+
let e = r;
|
|
1108
|
+
for (let r = 0; r < t.length; r += 1) {
|
|
1109
|
+
let i = n[t[r]], a = `${r}:${i === null ? "__null" : String(i)}`, o = e.children.get(a);
|
|
1110
|
+
o || (o = {
|
|
1111
|
+
level: r + 1,
|
|
1112
|
+
value: i,
|
|
1113
|
+
path: [...e.path, i],
|
|
1114
|
+
pathKey: e.pathKey === "__root" ? a : `${e.pathKey}|${a}`,
|
|
1115
|
+
children: /* @__PURE__ */ new Map(),
|
|
1116
|
+
rows: []
|
|
1117
|
+
}, e.children.set(a, o)), o.rows.push(n), e = o;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
return lt(r, n), r;
|
|
1121
|
+
}
|
|
1122
|
+
function lt(e, t) {
|
|
1123
|
+
let n = Array.from(e.children.entries());
|
|
1124
|
+
n.sort(([, e], [, n]) => (t ?? st)(e.value, n.value, e.level - 1)), e.children = new Map(n);
|
|
1125
|
+
for (let n of e.children.values()) lt(n, t);
|
|
1126
|
+
}
|
|
1127
|
+
function $(e, t) {
|
|
1128
|
+
return `pv__${e.length === 0 ? "all" : e.map((e) => ut(e)).join("__")}__m${t}`;
|
|
1129
|
+
}
|
|
1130
|
+
function ut(e) {
|
|
1131
|
+
return e == null ? "null" : String(e).replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1132
|
+
}
|
|
1133
|
+
function dt(e, t, n, r) {
|
|
1134
|
+
let i = {
|
|
1135
|
+
id: "__pivotRowHeader",
|
|
1136
|
+
header: r,
|
|
1137
|
+
fieldFn: (e) => e.__pivotLabel,
|
|
1138
|
+
width: 240
|
|
1139
|
+
};
|
|
1140
|
+
function a(e) {
|
|
1141
|
+
return e.children.size === 0 ? t.map((t, n) => {
|
|
1142
|
+
let r = $(e.path, n);
|
|
1143
|
+
return {
|
|
1144
|
+
id: r,
|
|
1145
|
+
header: t.label ?? `${t.field} (${typeof t.agg == "function" ? "custom" : t.agg})`,
|
|
1146
|
+
fieldFn: (e) => e[r],
|
|
1147
|
+
format: t.format,
|
|
1148
|
+
width: 130
|
|
1149
|
+
};
|
|
1150
|
+
}) : Array.from(e.children.values()).map((e) => ({
|
|
1151
|
+
id: `pv_group_${e.pathKey}`,
|
|
1152
|
+
header: String(e.value ?? "(blank)"),
|
|
1153
|
+
columns: a(e)
|
|
1154
|
+
}));
|
|
1155
|
+
}
|
|
1156
|
+
let o = (e.children.size, a(e));
|
|
1157
|
+
if (n.grandTotalCol === !1) return [i, ...o];
|
|
1158
|
+
let s = {
|
|
1159
|
+
id: "pv_group__grand_total",
|
|
1160
|
+
header: "Total",
|
|
1161
|
+
columns: t.map((e, t) => {
|
|
1162
|
+
let n = $(["__total"], t);
|
|
1163
|
+
return {
|
|
1164
|
+
id: n,
|
|
1165
|
+
header: e.label ?? `${e.field} (${typeof e.agg == "function" ? "custom" : e.agg})`,
|
|
1166
|
+
fieldFn: (e) => e[n],
|
|
1167
|
+
format: e.format,
|
|
1168
|
+
width: 140
|
|
1169
|
+
};
|
|
1170
|
+
})
|
|
1171
|
+
};
|
|
1172
|
+
return [
|
|
1173
|
+
i,
|
|
1174
|
+
...o,
|
|
1175
|
+
s
|
|
1176
|
+
];
|
|
1177
|
+
}
|
|
1178
|
+
function ft(e, t) {
|
|
1179
|
+
if (e.children.size === 0) {
|
|
1180
|
+
t.push(e.path);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
for (let n of e.children.values()) ft(n, t);
|
|
1184
|
+
}
|
|
1185
|
+
function pt(e, t, n, r, i) {
|
|
1186
|
+
let a = {};
|
|
1187
|
+
for (let i of t) {
|
|
1188
|
+
let t = i.length === 0 ? e : e.filter((e) => i.every((t, r) => e[n[r]] === t));
|
|
1189
|
+
for (let e = 0; e < r.length; e += 1) {
|
|
1190
|
+
let n = r[e], o = ot(n.agg), s = $(i, e);
|
|
1191
|
+
a[s] = o(t.map((e) => e[n.field]));
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
if (i) for (let t = 0; t < r.length; t += 1) {
|
|
1195
|
+
let n = r[t], i = ot(n.agg), o = $(["__total"], t);
|
|
1196
|
+
a[o] = i(e.map((e) => e[n.field]));
|
|
1197
|
+
}
|
|
1198
|
+
return a;
|
|
1199
|
+
}
|
|
1200
|
+
function mt(e, t, n) {
|
|
1201
|
+
let r = {};
|
|
1202
|
+
for (let n of e) for (let e = 0; e < t.length; e += 1) r[$(n, e)] = null;
|
|
1203
|
+
if (n) for (let e = 0; e < t.length; e += 1) r[$(["__total"], e)] = null;
|
|
1204
|
+
return r;
|
|
1205
|
+
}
|
|
1206
|
+
function ht(e, t, n, r, i, a, o, s) {
|
|
1207
|
+
let c = a.grandTotalCol !== !1, l = a.rowSubtotals !== !1;
|
|
1208
|
+
if (e.children.size === 0) {
|
|
1209
|
+
t.push({
|
|
1210
|
+
__pivotId: `row__${e.pathKey}`,
|
|
1211
|
+
__pivotKind: "leaf",
|
|
1212
|
+
__pivotDepth: e.level,
|
|
1213
|
+
__pivotLabel: e.value === null ? "(All)" : String(e.value),
|
|
1214
|
+
__pivotParentId: s,
|
|
1215
|
+
__pivotExpandable: !1,
|
|
1216
|
+
...pt(e.rows, n, r, i, c)
|
|
1217
|
+
});
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
let u = e.level > 0 && e.level < o.length, d = s;
|
|
1221
|
+
if (u) {
|
|
1222
|
+
let a = `group__${e.pathKey}`;
|
|
1223
|
+
t.push({
|
|
1224
|
+
__pivotId: a,
|
|
1225
|
+
__pivotKind: "group",
|
|
1226
|
+
__pivotDepth: e.level,
|
|
1227
|
+
__pivotLabel: String(e.value ?? "(All)"),
|
|
1228
|
+
__pivotParentId: s,
|
|
1229
|
+
__pivotExpandable: !0,
|
|
1230
|
+
...l ? pt(e.rows, n, r, i, c) : mt(n, i, c)
|
|
1231
|
+
}), d = a;
|
|
1232
|
+
}
|
|
1233
|
+
for (let s of e.children.values()) ht(s, t, n, r, i, a, o, d);
|
|
1234
|
+
}
|
|
1235
|
+
function gt(e, t) {
|
|
1236
|
+
if (t.values.length === 0) throw Error("pivot: at least one value config is required");
|
|
1237
|
+
let n = t.rows, r = t.cols, i = t.values, a = ct(e, n, t.rowSort), o = ct(e, r, t.colSort), s = [];
|
|
1238
|
+
ft(o, s);
|
|
1239
|
+
let c = [];
|
|
1240
|
+
return n.length === 0 ? c.push({
|
|
1241
|
+
__pivotId: "row__all",
|
|
1242
|
+
__pivotKind: "leaf",
|
|
1243
|
+
__pivotDepth: 0,
|
|
1244
|
+
__pivotLabel: "(All)",
|
|
1245
|
+
__pivotParentId: null,
|
|
1246
|
+
__pivotExpandable: !1,
|
|
1247
|
+
...pt(e, s, r, i, t.grandTotalCol !== !1)
|
|
1248
|
+
}) : ht(a, c, s, r, i, t, n, null), t.grandTotalRow !== !1 && c.push({
|
|
1249
|
+
__pivotId: "row__grand_total",
|
|
1250
|
+
__pivotKind: "grandTotal",
|
|
1251
|
+
__pivotDepth: 0,
|
|
1252
|
+
__pivotLabel: "Grand total",
|
|
1253
|
+
__pivotParentId: null,
|
|
1254
|
+
__pivotExpandable: !1,
|
|
1255
|
+
...pt(e, s, r, i, t.grandTotalCol !== !1)
|
|
1256
|
+
}), {
|
|
1257
|
+
rows: c,
|
|
1258
|
+
columns: dt(o, i, t, n.length > 0 ? n.join(" / ") : "")
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
var _t = { ...at };
|
|
1262
|
+
function vt(e, t) {
|
|
1263
|
+
if (t === !0) return e.slice();
|
|
1264
|
+
let n = t instanceof Set ? t : new Set(t), r = /* @__PURE__ */ new Map();
|
|
1265
|
+
for (let t of e) r.set(t.__pivotId, t.__pivotParentId);
|
|
1266
|
+
let i = [];
|
|
1267
|
+
for (let t of e) {
|
|
1268
|
+
if (t.__pivotParentId === null) {
|
|
1269
|
+
i.push(t);
|
|
1270
|
+
continue;
|
|
1271
|
+
}
|
|
1272
|
+
let e = t.__pivotParentId, a = !0;
|
|
1273
|
+
for (; e !== null;) {
|
|
1274
|
+
if (!n.has(e)) {
|
|
1275
|
+
a = !1;
|
|
1276
|
+
break;
|
|
1277
|
+
}
|
|
1278
|
+
e = r.get(e) ?? null;
|
|
1279
|
+
}
|
|
1280
|
+
a && i.push(t);
|
|
1281
|
+
}
|
|
1282
|
+
return i;
|
|
1283
|
+
}
|
|
1284
|
+
//#endregion
|
|
1285
|
+
//#region src/install.ts
|
|
1286
|
+
function yt(e) {
|
|
1287
|
+
let t = e;
|
|
1288
|
+
return t.exportData = (e) => H(t, e), t.print = (e) => W(t, e), t.importData = (e) => Y(t, e), t.ai = {
|
|
1289
|
+
filter: (e, n) => We(t, e, n),
|
|
1290
|
+
smartFill: (e) => Ge(t, e),
|
|
1291
|
+
summarize: (e) => Ke(t, e),
|
|
1292
|
+
classify: (e) => qe(t, e)
|
|
1293
|
+
}, t.pivot = {
|
|
1294
|
+
build: (e) => gt(t.getData(), e),
|
|
1295
|
+
buildFrom: (e, t) => gt(e, t)
|
|
1296
|
+
}, pe() || te(), t;
|
|
1297
|
+
}
|
|
1298
|
+
//#endregion
|
|
1299
|
+
//#region src/staged-editing.ts
|
|
1300
|
+
function bt() {
|
|
1301
|
+
let e = /* @__PURE__ */ new Map(), t = (e, t) => `${e}${t}`;
|
|
1302
|
+
function n(n) {
|
|
1303
|
+
let r = n.row, i = r?.id == null ? String(n.rowIndex) : String(r.id), a = t(i, n.columnId), o = e.get(a);
|
|
1304
|
+
if (o) {
|
|
1305
|
+
o.staged = n.newValue, Object.is(o.original, n.newValue) && e.delete(a);
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
Object.is(n.oldValue, n.newValue) || e.set(a, {
|
|
1309
|
+
rowId: i,
|
|
1310
|
+
rowIndex: n.rowIndex,
|
|
1311
|
+
columnId: n.columnId,
|
|
1312
|
+
original: n.oldValue,
|
|
1313
|
+
staged: n.newValue,
|
|
1314
|
+
recordedAt: Date.now(),
|
|
1315
|
+
originalRow: r
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
function r() {
|
|
1319
|
+
return [...e.values()].sort((e, t) => e.recordedAt - t.recordedAt);
|
|
1320
|
+
}
|
|
1321
|
+
function i() {
|
|
1322
|
+
let e = /* @__PURE__ */ new Map();
|
|
1323
|
+
for (let t of r()) {
|
|
1324
|
+
let n = e.get(t.rowId) ?? {
|
|
1325
|
+
rowId: t.rowId,
|
|
1326
|
+
rowIndex: t.rowIndex,
|
|
1327
|
+
cells: []
|
|
1328
|
+
};
|
|
1329
|
+
n.cells.push(t), e.set(t.rowId, n);
|
|
1330
|
+
}
|
|
1331
|
+
return [...e.values()];
|
|
1332
|
+
}
|
|
1333
|
+
async function a(t) {
|
|
1334
|
+
e.size !== 0 && (await t(r()), e.clear());
|
|
1335
|
+
}
|
|
1336
|
+
function o(t) {
|
|
1337
|
+
for (let e of r().reverse()) t(e.rowIndex, e.columnId, e.original);
|
|
1338
|
+
e.clear();
|
|
1339
|
+
}
|
|
1340
|
+
return {
|
|
1341
|
+
record: n,
|
|
1342
|
+
changes: r,
|
|
1343
|
+
isDirty: () => e.size > 0,
|
|
1344
|
+
size: () => e.size,
|
|
1345
|
+
changesByRow: i,
|
|
1346
|
+
commit: a,
|
|
1347
|
+
revert: o,
|
|
1348
|
+
drop(n, r) {
|
|
1349
|
+
e.delete(t(n, r));
|
|
1350
|
+
},
|
|
1351
|
+
clear() {
|
|
1352
|
+
e.clear();
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
//#endregion
|
|
1357
|
+
//#region src/pivot-designer.ts
|
|
1358
|
+
var xt = [
|
|
1359
|
+
"sum",
|
|
1360
|
+
"avg",
|
|
1361
|
+
"min",
|
|
1362
|
+
"max",
|
|
1363
|
+
"count",
|
|
1364
|
+
"countDistinct",
|
|
1365
|
+
"first",
|
|
1366
|
+
"last"
|
|
1367
|
+
], St = {
|
|
1368
|
+
rows: [],
|
|
1369
|
+
cols: [],
|
|
1370
|
+
values: [],
|
|
1371
|
+
filters: []
|
|
1372
|
+
};
|
|
1373
|
+
function Ct(e) {
|
|
1374
|
+
let t = e.find((e) => e.kind === "dimension"), n = e.find((e) => e.kind === "measure");
|
|
1375
|
+
return {
|
|
1376
|
+
rows: t ? [t.field] : [],
|
|
1377
|
+
cols: [],
|
|
1378
|
+
values: n ? [{
|
|
1379
|
+
field: n.field,
|
|
1380
|
+
agg: n.defaultAgg ?? "sum",
|
|
1381
|
+
label: n.label,
|
|
1382
|
+
format: n.format
|
|
1383
|
+
}] : [],
|
|
1384
|
+
filters: []
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
var wt = {
|
|
1388
|
+
sum: "Sum",
|
|
1389
|
+
avg: "Average",
|
|
1390
|
+
min: "Min",
|
|
1391
|
+
max: "Max",
|
|
1392
|
+
count: "Count",
|
|
1393
|
+
countDistinct: "Distinct count",
|
|
1394
|
+
first: "First",
|
|
1395
|
+
last: "Last"
|
|
1396
|
+
}, Tt = (t, n) => {
|
|
1397
|
+
let r = () => n?.().row, i = () => n?.().collapsed, a = () => n?.().onToggle;
|
|
1398
|
+
var o = Ot(), s = e.child(o), c = (t) => {
|
|
1399
|
+
var n = Et();
|
|
1400
|
+
let r;
|
|
1401
|
+
e.template_effect(() => {
|
|
1402
|
+
r = e.set_class(n, 1, "pvd-chev", null, r, { "is-collapsed": i() }), e.set_attribute(n, "aria-label", i() ? "Expand" : "Collapse");
|
|
1403
|
+
}), e.delegated("click", n, (e) => {
|
|
1404
|
+
e.stopPropagation(), a()();
|
|
1405
|
+
}), e.append(t, n);
|
|
1406
|
+
}, l = (t) => {
|
|
1407
|
+
var n = Dt();
|
|
1408
|
+
e.append(t, n);
|
|
1409
|
+
};
|
|
1410
|
+
e.if(s, (e) => {
|
|
1411
|
+
r().__pivotExpandable ? e(c) : e(l, -1);
|
|
1412
|
+
});
|
|
1413
|
+
var u = e.sibling(s, 2);
|
|
1414
|
+
let d;
|
|
1415
|
+
var f = e.child(u, !0);
|
|
1416
|
+
e.reset(u), e.reset(o), e.template_effect(() => {
|
|
1417
|
+
e.set_style(o, `padding-left:${r().__pivotDepth * 14}px`), d = e.set_class(u, 1, "pvd-label-text", null, d, {
|
|
1418
|
+
"is-subtotal": r().__pivotKind === "subtotal",
|
|
1419
|
+
"is-grand": r().__pivotKind === "grandTotal"
|
|
1420
|
+
}), e.set_text(f, r().__pivotLabel);
|
|
1421
|
+
}), e.append(t, o);
|
|
1422
|
+
}, Et = e.from_html("<button type=\"button\">▾</button>"), Dt = e.from_html("<span class=\"pvd-chev pvd-chev-placeholder\"></span>"), Ot = e.from_html("<span class=\"pvd-label-cell\"><!> <span> </span></span>"), kt = e.from_html("<button type=\"button\" class=\"pvd-popover-item svelte-17k9bix\"> </button>"), At = e.from_html("<div class=\"pvd-popover svelte-17k9bix\"></div>"), jt = e.from_html("<div class=\"pvd-presets svelte-17k9bix\"><button type=\"button\" class=\"pvd-btn svelte-17k9bix\">Presets ▾</button> <!></div>"), Mt = e.from_html("<button type=\"button\" class=\"pvd-btn pvd-btn-primary svelte-17k9bix\">Export…</button>"), Nt = e.from_html("<header class=\"pvd-toolbar svelte-17k9bix\"><strong class=\"pvd-title svelte-17k9bix\">Pivot designer</strong> <button type=\"button\" class=\"pvd-btn svelte-17k9bix\" title=\"Restore the default layout\">↺ Reset</button> <!> <label class=\"pvd-toggle svelte-17k9bix\"><input type=\"checkbox\" class=\"svelte-17k9bix\"/> Subtotals</label> <label class=\"pvd-toggle svelte-17k9bix\"><input type=\"checkbox\" class=\"svelte-17k9bix\"/> Grand totals</label> <div class=\"pvd-spacer svelte-17k9bix\"></div> <!></header>"), Pt = e.from_html("<div draggable=\"true\" role=\"button\" tabindex=\"0\"><input type=\"checkbox\"/> <span class=\"pvd-field-label svelte-17k9bix\"> </span> <span class=\"pvd-field-kind svelte-17k9bix\"> </span></div>"), Ft = e.from_html("<div class=\"pvd-group-head svelte-17k9bix\"> </div> <!>", 1), It = e.from_html("<div class=\"pvd-empty svelte-17k9bix\"> </div>"), Lt = e.from_html("<aside class=\"pvd-rail svelte-17k9bix\" aria-label=\"Available fields\"><input type=\"search\" class=\"pvd-search svelte-17k9bix\" placeholder=\"Search fields…\"/> <div class=\"pvd-fieldlist svelte-17k9bix\"><!> <!></div></aside>"), Rt = e.from_html("<label class=\"pvd-popover-item pvd-popover-check svelte-17k9bix\"><input type=\"checkbox\" class=\"svelte-17k9bix\"/> <span> </span></label>"), zt = e.from_html("<div class=\"pvd-popover pvd-popover-filter svelte-17k9bix\"><div class=\"pvd-popover-head svelte-17k9bix\"><button type=\"button\" class=\"pvd-popover-mini svelte-17k9bix\">All</button> <button type=\"button\" class=\"pvd-popover-mini svelte-17k9bix\">None</button></div> <div class=\"pvd-popover-list svelte-17k9bix\"></div></div>"), Bt = e.from_html("<div class=\"pvd-chip svelte-17k9bix\" draggable=\"true\"><button type=\"button\" class=\"pvd-chip-label svelte-17k9bix\"> </button> <button type=\"button\" class=\"pvd-chip-x svelte-17k9bix\" aria-label=\"Remove\">×</button> <!></div>"), Vt = e.from_html("<span class=\"pvd-well-hint svelte-17k9bix\">drop fields here to filter the source rows</span>"), Ht = e.from_html("<div><div class=\"pvd-well-head svelte-17k9bix\">Filters</div> <div class=\"pvd-well-body svelte-17k9bix\"><!> <!></div></div>"), Ut = e.from_html("<div class=\"pvd-chip svelte-17k9bix\" draggable=\"true\"><span class=\"pvd-chip-label svelte-17k9bix\"> </span> <button type=\"button\" class=\"pvd-chip-x svelte-17k9bix\" aria-label=\"Remove\">×</button></div>"), Wt = e.from_html("<span class=\"pvd-well-hint svelte-17k9bix\">drop dimensions to pivot along the column axis</span>"), Gt = e.from_html("<div class=\"pvd-chip svelte-17k9bix\" draggable=\"true\"><span class=\"pvd-chip-label svelte-17k9bix\"> </span> <button type=\"button\" class=\"pvd-chip-x svelte-17k9bix\" aria-label=\"Remove\">×</button></div>"), Kt = e.from_html("<span class=\"pvd-well-hint svelte-17k9bix\">drop dimensions to group rows</span>"), qt = e.from_html("<button type=\"button\"> </button>"), Jt = e.from_html("<div class=\"pvd-popover svelte-17k9bix\"></div>"), Yt = e.from_html("<div class=\"pvd-chip pvd-chip-value svelte-17k9bix\" draggable=\"true\"><button type=\"button\" class=\"pvd-chip-label svelte-17k9bix\"><span class=\"pvd-chip-agg svelte-17k9bix\"> </span> <span class=\"pvd-chip-sep svelte-17k9bix\">·</span> <span> </span></button> <button type=\"button\" class=\"pvd-chip-x svelte-17k9bix\" aria-label=\"Remove\">×</button> <!></div>"), Xt = e.from_html("<span class=\"pvd-well-hint svelte-17k9bix\">drop measures to aggregate</span>"), Zt = e.from_html("Drop at least one <strong>measure</strong> into Values to render the pivot.", 1), Qt = e.from_html("<div class=\"pvd-empty pvd-grid-empty svelte-17k9bix\"><!></div>"), $t = e.from_html("<div class=\"pvd-grid svelte-17k9bix\"><!></div>"), en = e.from_html("<section class=\"pvd svelte-17k9bix\"><!> <div><!> <div class=\"pvd-main svelte-17k9bix\"><div><!> <div><div class=\"pvd-well-head svelte-17k9bix\">Columns</div> <div class=\"pvd-well-body svelte-17k9bix\"><!> <!></div></div> <div><div class=\"pvd-well-head svelte-17k9bix\">Rows</div> <div class=\"pvd-well-body svelte-17k9bix\"><!> <!></div></div> <div><div class=\"pvd-well-head svelte-17k9bix\">Values</div> <div class=\"pvd-well-body svelte-17k9bix\"><!> <!></div></div></div> <!></div></div></section>"), tn = {
|
|
1423
|
+
hash: "svelte-17k9bix",
|
|
1424
|
+
code: "\n /* SvPivotDesigner styles -------------------------------------------\n All variables use the SvGrid token system (--sg-*) with safe\n fallbacks so the component theme-matches whatever grid skin the\n host page is using. */.pvd.svelte-17k9bix {display:flex;flex-direction:column;width:100%;height:100%;min-height:0;color:var(--sg-fg, #0f172a);background:var(--sg-bg, #ffffff);border:1px solid var(--sg-border, #e2e8f0);border-radius:8px;overflow:hidden;font-family:inherit;}.pvd-toolbar.svelte-17k9bix {display:flex;align-items:center;gap:8px;padding:8px 12px;background:var(--sg-header-bg, #f8fafc);border-bottom:1px solid var(--sg-border, #e2e8f0);flex-shrink:0;}.pvd-title.svelte-17k9bix {font-size:13px;font-weight:700;color:var(--sg-fg);margin-right:8px;}.pvd-spacer.svelte-17k9bix {flex:1;}.pvd-btn.svelte-17k9bix {border:1px solid var(--sg-border, #cbd5e1);background:var(--sg-bg, #ffffff);color:var(--sg-fg, #1e293b);padding:4px 10px;border-radius:5px;font-size:12px;font-weight:600;cursor:pointer;transition:background 100ms ease, border-color 100ms ease;}.pvd-btn.svelte-17k9bix:hover {background:var(--sg-row-hover-bg, #f1f5f9);border-color:var(--sg-accent, #2563eb);}.pvd-btn-primary.svelte-17k9bix {background:var(--sg-accent, #2563eb);color:#fff;border-color:var(--sg-accent, #2563eb);}.pvd-btn-primary.svelte-17k9bix:hover {opacity:0.9;}.pvd-toggle.svelte-17k9bix {display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--sg-fg);cursor:pointer;user-select:none;}.pvd-toggle.svelte-17k9bix input:where(.svelte-17k9bix) {accent-color:var(--sg-accent, #2563eb);}.pvd-body.svelte-17k9bix {display:grid;grid-template-columns:220px 1fr;gap:0;flex:1;min-height:0;}.pvd-body.no-rail.svelte-17k9bix {grid-template-columns:1fr;}\n\n /* Left rail */.pvd-rail.svelte-17k9bix {display:flex;flex-direction:column;border-right:1px solid var(--sg-border, #e2e8f0);background:var(--sg-bg, #ffffff);min-height:0;}.pvd-search.svelte-17k9bix {border:0;border-bottom:1px solid var(--sg-border, #e2e8f0);padding:8px 12px;font-size:12px;background:transparent;color:var(--sg-fg);outline:none;}.pvd-search.svelte-17k9bix:focus {background:var(--sg-row-hover-bg, #f1f5f9);}.pvd-fieldlist.svelte-17k9bix {flex:1;min-height:0;overflow:auto;padding:4px 0;}.pvd-group-head.svelte-17k9bix {padding:8px 12px 4px;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:0.06em;color:var(--sg-muted, #64748b);}.pvd-field.svelte-17k9bix {display:grid;grid-template-columns:16px 1fr auto;align-items:center;gap:8px;padding:5px 12px;font-size:12px;cursor:grab;transition:background 80ms ease;}.pvd-field.svelte-17k9bix:hover {background:var(--sg-row-hover-bg, #f1f5f9);}.pvd-field.svelte-17k9bix:active {cursor:grabbing;}.pvd-field.in-use.svelte-17k9bix .pvd-field-label:where(.svelte-17k9bix) {font-weight:600;color:var(--sg-accent, #2563eb);}.pvd-field-label.svelte-17k9bix {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.pvd-field-kind.svelte-17k9bix {font-family:ui-monospace, monospace;font-size:10px;color:var(--sg-muted, #94a3b8);background:var(--sg-header-bg, #f1f5f9);padding:1px 5px;border-radius:3px;}\n\n /* Main area */.pvd-main.svelte-17k9bix {display:flex;flex-direction:column;min-height:0;min-width:0;}.pvd-wells.svelte-17k9bix {display:grid;grid-template-columns:repeat(4, 1fr);gap:8px;padding:8px;background:var(--sg-bg, #ffffff);border-bottom:1px solid var(--sg-border, #e2e8f0);}.pvd-wells.two.svelte-17k9bix {grid-template-columns:repeat(3, 1fr);}.pvd-well.svelte-17k9bix {display:flex;flex-direction:column;border:1px dashed var(--sg-border, #cbd5e1);border-radius:6px;background:var(--sg-bg, #ffffff);min-height:64px;transition:border-color 100ms ease, background 100ms ease;}.pvd-well.drag-over.svelte-17k9bix {border-color:var(--sg-accent, #2563eb);border-style:solid;background:color-mix(in srgb, var(--sg-accent, #2563eb) 8%, var(--sg-bg, #ffffff));}.pvd-well-head.svelte-17k9bix {padding:4px 8px 2px;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:0.06em;color:var(--sg-muted, #64748b);}.pvd-well-body.svelte-17k9bix {display:flex;flex-wrap:wrap;gap:4px;padding:4px 8px 8px;min-height:36px;align-content:flex-start;}.pvd-well-hint.svelte-17k9bix {color:var(--sg-muted, #94a3b8);font-size:11px;font-style:italic;padding:4px 0;}.pvd-chip.svelte-17k9bix {position:relative;display:inline-flex;align-items:center;gap:2px;background:var(--sg-header-bg, #f1f5f9);border:1px solid var(--sg-border, #cbd5e1);border-radius:5px;font-size:12px;color:var(--sg-fg, #0f172a);cursor:grab;user-select:none;}.pvd-chip.svelte-17k9bix:active {cursor:grabbing;}.pvd-chip-value.svelte-17k9bix {background:color-mix(in srgb, var(--sg-accent, #2563eb) 14%, var(--sg-bg, #ffffff));border-color:var(--sg-accent, #2563eb);}.pvd-chip-label.svelte-17k9bix {border:0;background:transparent;padding:4px 8px;font:inherit;color:inherit;cursor:pointer;}.pvd-chip-agg.svelte-17k9bix {font-size:10.5px;font-weight:700;color:var(--sg-accent, #2563eb);text-transform:uppercase;letter-spacing:0.04em;margin-right:4px;}.pvd-chip-sep.svelte-17k9bix {color:var(--sg-muted, #94a3b8);margin-right:4px;}.pvd-chip-x.svelte-17k9bix {border:0;background:transparent;color:var(--sg-muted, #64748b);cursor:pointer;padding:2px 6px 3px;font-size:14px;line-height:1;border-radius:3px;}.pvd-chip-x.svelte-17k9bix:hover {color:#ef4444;background:rgba(239, 68, 68, 0.08);}\n\n /* Popovers (agg menu, filter menu, presets) */.pvd-popover.svelte-17k9bix, .pvd-presets.svelte-17k9bix {position:relative;}.pvd-popover.svelte-17k9bix {position:absolute;top:calc(100% + 4px);left:0;z-index:50;min-width:160px;background:var(--sg-bg, #ffffff);border:1px solid var(--sg-border, #cbd5e1);border-radius:6px;box-shadow:0 12px 28px rgba(15, 23, 42, 0.18);padding:4px;}.pvd-popover-filter.svelte-17k9bix {min-width:200px;max-height:280px;display:flex;flex-direction:column;}.pvd-popover-head.svelte-17k9bix {display:flex;gap:4px;padding:4px;border-bottom:1px solid var(--sg-border, #e2e8f0);}.pvd-popover-mini.svelte-17k9bix {flex:1;border:1px solid var(--sg-border, #cbd5e1);background:var(--sg-bg, #ffffff);color:var(--sg-fg);padding:2px 6px;border-radius:4px;font-size:11px;cursor:pointer;}.pvd-popover-mini.svelte-17k9bix:hover {background:var(--sg-row-hover-bg, #f1f5f9);}.pvd-popover-list.svelte-17k9bix {flex:1;min-height:0;overflow:auto;padding:4px 0;}.pvd-popover-item.svelte-17k9bix {display:block;width:100%;text-align:left;border:0;background:transparent;padding:5px 10px;font-size:12px;color:var(--sg-fg);cursor:pointer;border-radius:4px;}.pvd-popover-item.svelte-17k9bix:hover {background:var(--sg-row-hover-bg, #f1f5f9);}.pvd-popover-item.is-active.svelte-17k9bix {background:color-mix(in srgb, var(--sg-accent, #2563eb) 14%, transparent);color:var(--sg-accent, #2563eb);font-weight:600;}.pvd-popover-check.svelte-17k9bix {display:flex;align-items:center;gap:8px;cursor:pointer;}.pvd-popover-check.svelte-17k9bix input:where(.svelte-17k9bix) {accent-color:var(--sg-accent, #2563eb);}\n\n /* Embedded grid */.pvd-grid.svelte-17k9bix {flex:1;min-height:0;padding:0;}.pvd-grid-empty.svelte-17k9bix {display:flex;align-items:center;justify-content:center;height:100%;color:var(--sg-muted, #94a3b8);font-size:13px;padding:24px;text-align:center;}.pvd-empty.svelte-17k9bix {padding:20px;color:var(--sg-muted, #94a3b8);font-size:12px;text-align:center;}\n\n /* Built-in label cell renderer (when expandable is on) */.pvd-label-cell {display:inline-flex;align-items:center;gap:4px;line-height:1;}.pvd-chev {width:14px;height:14px;border:0;background:transparent;color:var(--sg-muted, #64748b);font-size:10px;line-height:14px;cursor:pointer;border-radius:3px;padding:0;transition:transform 100ms ease, background 100ms ease;}.pvd-chev:hover {background:var(--sg-row-hover-bg, #f1f5f9);color:var(--sg-fg, #0f172a);}.pvd-chev.is-collapsed {transform:rotate(-90deg);}.pvd-chev-placeholder {cursor:default;visibility:hidden;}.pvd-label-text.is-subtotal {font-weight:700;}.pvd-label-text.is-grand {font-weight:800;color:var(--sg-accent, #2563eb);}\n\n /* Mobile: stack rail above main, wells in two columns. */\n @media (max-width: 900px) {.pvd-body.svelte-17k9bix {grid-template-columns:1fr;}.pvd-rail.svelte-17k9bix {border-right:0;border-bottom:1px solid var(--sg-border, #e2e8f0);max-height:200px;}.pvd-wells.svelte-17k9bix, .pvd-wells.two.svelte-17k9bix {grid-template-columns:repeat(2, 1fr);}\n }"
|
|
1425
|
+
};
|
|
1426
|
+
function nn(o, s) {
|
|
1427
|
+
e.push(s, !0), e.append_styles(o, tn);
|
|
1428
|
+
let c = e.prop(s, "layout", 31, () => e.proxy(Ct([]))), l = e.prop(s, "aggregators", 3, xt), u = e.prop(s, "showToolbar", 3, !0), d = e.prop(s, "showFieldList", 3, !0), f = e.prop(s, "showFiltersWell", 3, !0), p = e.prop(s, "gridHeight", 3, "100%"), m = e.prop(s, "embedGrid", 3, !0), h = e.prop(s, "expandable", 3, !1);
|
|
1429
|
+
e.user_pre_effect(() => {
|
|
1430
|
+
(!c() || !c().rows.length && !c().cols.length && !c().values.length && !c().filters.length) && c(Ct(s.fields));
|
|
1431
|
+
});
|
|
1432
|
+
let g = a({
|
|
1433
|
+
rowSortingFeature: i,
|
|
1434
|
+
columnFilteringFeature: n
|
|
1435
|
+
}), _ = `pvd-${Math.random().toString(36).slice(2, 8)}`, v = e.derived(() => new Map(s.fields.map((e) => [e.field, e])));
|
|
1436
|
+
function ee(e) {
|
|
1437
|
+
return c().rows.includes(e) || c().cols.includes(e) || c().values.some((t) => t.field === e) || c().filters.some((t) => t.field === e);
|
|
1438
|
+
}
|
|
1439
|
+
let y = e.state(""), b = e.derived(() => s.fields.filter((t) => !e.get(y).trim() || t.label.toLowerCase().includes(e.get(y).trim().toLowerCase()))), x = e.derived(() => {
|
|
1440
|
+
let t = /* @__PURE__ */ new Map();
|
|
1441
|
+
for (let n of e.get(b)) {
|
|
1442
|
+
let e = n.group ?? (n.kind === "dimension" ? "Dimensions" : "Measures"), r = t.get(e) ?? [];
|
|
1443
|
+
r.push(n), t.set(e, r);
|
|
1444
|
+
}
|
|
1445
|
+
return [...t.entries()];
|
|
1446
|
+
});
|
|
1447
|
+
function S(e) {
|
|
1448
|
+
c(e), s.onLayoutChange?.(e);
|
|
1449
|
+
}
|
|
1450
|
+
function te(e) {
|
|
1451
|
+
return e.kind === "measure" ? "values" : "rows";
|
|
1452
|
+
}
|
|
1453
|
+
function ne(t, n, r = Infinity, i) {
|
|
1454
|
+
let a = e.get(v).get(t);
|
|
1455
|
+
if (!a) return;
|
|
1456
|
+
let o = {
|
|
1457
|
+
...c(),
|
|
1458
|
+
rows: c().rows.filter((e) => e !== t),
|
|
1459
|
+
cols: c().cols.filter((e) => e !== t),
|
|
1460
|
+
values: i === void 0 ? c().values.slice() : c().values.filter((e, t) => t !== i),
|
|
1461
|
+
filters: c().filters.filter((e) => e.field !== t)
|
|
1462
|
+
};
|
|
1463
|
+
if (n === "rows" || n === "cols") {
|
|
1464
|
+
let e = o[n];
|
|
1465
|
+
e.splice(Math.min(e.length, r), 0, t);
|
|
1466
|
+
} else if (n === "values") {
|
|
1467
|
+
let e = a.defaultAgg ?? "sum";
|
|
1468
|
+
if (o.values.some((n) => n.field === t && n.agg === e)) {
|
|
1469
|
+
S(o);
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
let n = {
|
|
1473
|
+
field: t,
|
|
1474
|
+
agg: e,
|
|
1475
|
+
label: a.label,
|
|
1476
|
+
format: a.format
|
|
1477
|
+
};
|
|
1478
|
+
o.values.splice(Math.min(o.values.length, r), 0, n);
|
|
1479
|
+
} else n === "filters" && o.filters.splice(Math.min(o.filters.length, r), 0, {
|
|
1480
|
+
field: t,
|
|
1481
|
+
allowed: null
|
|
1482
|
+
});
|
|
1483
|
+
S(o);
|
|
1484
|
+
}
|
|
1485
|
+
function C(e, t, n) {
|
|
1486
|
+
let r = { ...c() };
|
|
1487
|
+
t === "rows" ? r.rows = c().rows.filter((t) => t !== e) : t === "cols" ? r.cols = c().cols.filter((t) => t !== e) : t === "values" ? r.values = n === void 0 ? c().values.filter((t) => t.field !== e) : c().values.filter((e, t) => t !== n) : t === "filters" && (r.filters = c().filters.filter((t) => t.field !== e)), S(r);
|
|
1488
|
+
}
|
|
1489
|
+
function w(t) {
|
|
1490
|
+
let n = e.get(v).get(t);
|
|
1491
|
+
n && (ee(t) ? S({
|
|
1492
|
+
...c(),
|
|
1493
|
+
rows: c().rows.filter((e) => e !== t),
|
|
1494
|
+
cols: c().cols.filter((e) => e !== t),
|
|
1495
|
+
values: c().values.filter((e) => e.field !== t),
|
|
1496
|
+
filters: c().filters.filter((e) => e.field !== t)
|
|
1497
|
+
}) : ne(t, te(n)));
|
|
1498
|
+
}
|
|
1499
|
+
function re(t, n) {
|
|
1500
|
+
let r = c().values[t];
|
|
1501
|
+
if (!r) return;
|
|
1502
|
+
let i = r.field, a = c().values.some((e, r) => r !== t && e.field === i && e.agg === n), o = wt[n] + " of " + (e.get(v).get(i)?.label ?? i);
|
|
1503
|
+
S({
|
|
1504
|
+
...c(),
|
|
1505
|
+
values: a ? c().values.filter((e, n) => n !== t) : c().values.map((e, r) => r === t ? {
|
|
1506
|
+
...e,
|
|
1507
|
+
agg: n,
|
|
1508
|
+
label: o
|
|
1509
|
+
} : e)
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
function T(e, t) {
|
|
1513
|
+
S({
|
|
1514
|
+
...c(),
|
|
1515
|
+
filters: c().filters.map((n) => n.field === e ? {
|
|
1516
|
+
...n,
|
|
1517
|
+
allowed: t
|
|
1518
|
+
} : n)
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
function ie() {
|
|
1522
|
+
S({
|
|
1523
|
+
...c(),
|
|
1524
|
+
hideSubtotals: !c().hideSubtotals
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
function ae() {
|
|
1528
|
+
S({
|
|
1529
|
+
...c(),
|
|
1530
|
+
hideGrandTotals: !c().hideGrandTotals
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
function oe() {
|
|
1534
|
+
S(Ct(s.fields));
|
|
1535
|
+
}
|
|
1536
|
+
function E(e) {
|
|
1537
|
+
S(structuredClone(e.layout));
|
|
1538
|
+
}
|
|
1539
|
+
let se = e.state(null), ce = e.state(null), D = e.state(void 0), O = e.state(null);
|
|
1540
|
+
function k(t, n, r, i) {
|
|
1541
|
+
e.set(se, n, !0), e.set(ce, r, !0), e.set(D, i, !0), t.dataTransfer && (t.dataTransfer.effectAllowed = "move", t.dataTransfer.setData("text/plain", n));
|
|
1542
|
+
}
|
|
1543
|
+
function A(t, n) {
|
|
1544
|
+
t.preventDefault(), t.dataTransfer && (t.dataTransfer.dropEffect = "move"), e.set(O, n, !0);
|
|
1545
|
+
}
|
|
1546
|
+
function j() {
|
|
1547
|
+
e.set(O, null);
|
|
1548
|
+
}
|
|
1549
|
+
function M(t, n) {
|
|
1550
|
+
t.preventDefault(), e.set(O, null);
|
|
1551
|
+
let r = e.get(se) || t.dataTransfer?.getData("text/plain") || "";
|
|
1552
|
+
r && (ne(r, n, Infinity, e.get(ce) === "values" ? e.get(D) : void 0), e.set(se, null), e.set(ce, null), e.set(D, void 0));
|
|
1553
|
+
}
|
|
1554
|
+
let le = e.derived(() => c().filters.length ? s.data.filter((e) => {
|
|
1555
|
+
for (let t of c().filters) {
|
|
1556
|
+
if (t.allowed == null) continue;
|
|
1557
|
+
let n = e[t.field];
|
|
1558
|
+
if (!t.allowed.includes(String(n))) return !1;
|
|
1559
|
+
}
|
|
1560
|
+
return !0;
|
|
1561
|
+
}) : s.data), N = e.derived(() => !c().values.length && !c().rows.length && !c().cols.length || !c().values.length ? null : gt(e.get(le), {
|
|
1562
|
+
rows: c().rows,
|
|
1563
|
+
cols: c().cols,
|
|
1564
|
+
values: c().values.map((e) => ({
|
|
1565
|
+
field: e.field,
|
|
1566
|
+
agg: e.agg,
|
|
1567
|
+
label: e.label,
|
|
1568
|
+
format: e.format
|
|
1569
|
+
})),
|
|
1570
|
+
grandTotalRow: !c().hideGrandTotals,
|
|
1571
|
+
grandTotalCol: !c().hideGrandTotals,
|
|
1572
|
+
rowSubtotals: !c().hideSubtotals
|
|
1573
|
+
}));
|
|
1574
|
+
e.user_effect(() => {
|
|
1575
|
+
e.get(N) && s.onPivot?.(e.get(N).rows, e.get(N).columns);
|
|
1576
|
+
});
|
|
1577
|
+
let P = e.state(e.proxy(/* @__PURE__ */ new Set())), ue = e.state("");
|
|
1578
|
+
e.user_effect(() => {
|
|
1579
|
+
if (!e.get(N)) return;
|
|
1580
|
+
let t = e.get(N).rows.map((e) => e.__pivotId).join("|");
|
|
1581
|
+
if (t !== e.get(ue)) {
|
|
1582
|
+
e.set(ue, t, !0);
|
|
1583
|
+
let n = new Set(e.get(N).rows.map((e) => e.__pivotId)), r = /* @__PURE__ */ new Set();
|
|
1584
|
+
for (let t of e.get(P)) n.has(t) && r.add(t);
|
|
1585
|
+
r.size !== e.get(P).size && e.set(P, r, !0);
|
|
1586
|
+
}
|
|
1587
|
+
});
|
|
1588
|
+
function de(t) {
|
|
1589
|
+
let n = new Set(e.get(P));
|
|
1590
|
+
n.has(t) ? n.delete(t) : n.add(t), e.set(P, n, !0);
|
|
1591
|
+
}
|
|
1592
|
+
let fe = e.derived(() => {
|
|
1593
|
+
if (!e.get(N)) return [];
|
|
1594
|
+
if (!h() || e.get(P).size === 0) return e.get(N).rows;
|
|
1595
|
+
let t = /* @__PURE__ */ new Set();
|
|
1596
|
+
for (let n of e.get(N).rows) n.__pivotExpandable && !e.get(P).has(n.__pivotId) && t.add(n.__pivotId);
|
|
1597
|
+
return vt(e.get(N).rows, t);
|
|
1598
|
+
}), pe = e.derived(() => {
|
|
1599
|
+
if (!e.get(N)) return [];
|
|
1600
|
+
let t = e.get(N).columns;
|
|
1601
|
+
if (t.length && c().rows.length) {
|
|
1602
|
+
let n = c().rows.map((t) => e.get(v).get(t)?.label ?? t).join(" / ");
|
|
1603
|
+
t = [{
|
|
1604
|
+
...t[0],
|
|
1605
|
+
header: n
|
|
1606
|
+
}, ...t.slice(1)];
|
|
1607
|
+
}
|
|
1608
|
+
return h() && (t = t.map((t, n) => n === 0 ? {
|
|
1609
|
+
...t,
|
|
1610
|
+
cell: (t) => r(Tt, {
|
|
1611
|
+
row: t.row.original,
|
|
1612
|
+
collapsed: e.get(P).has(t.row.original.__pivotId),
|
|
1613
|
+
onToggle: () => de(t.row.original.__pivotId)
|
|
1614
|
+
})
|
|
1615
|
+
} : t)), s.decorateColumns ? s.decorateColumns(t, c()) : t;
|
|
1616
|
+
});
|
|
1617
|
+
function me(e) {
|
|
1618
|
+
let t = /* @__PURE__ */ new Set();
|
|
1619
|
+
for (let n of s.data) t.add(String(n[e]));
|
|
1620
|
+
return [...t].sort((e, t) => e.localeCompare(t));
|
|
1621
|
+
}
|
|
1622
|
+
let F = e.state(null);
|
|
1623
|
+
function he(t) {
|
|
1624
|
+
e.get(F)?.kind === "filter" && e.get(F).field === t ? e.set(F, null) : e.set(F, {
|
|
1625
|
+
kind: "filter",
|
|
1626
|
+
field: t
|
|
1627
|
+
}, !0);
|
|
1628
|
+
}
|
|
1629
|
+
function ge(t) {
|
|
1630
|
+
e.get(F)?.kind === "agg" && e.get(F).index === t ? e.set(F, null) : e.set(F, {
|
|
1631
|
+
kind: "agg",
|
|
1632
|
+
index: t
|
|
1633
|
+
}, !0);
|
|
1634
|
+
}
|
|
1635
|
+
function _e() {
|
|
1636
|
+
e.set(F, null);
|
|
1637
|
+
}
|
|
1638
|
+
e.user_effect(() => {
|
|
1639
|
+
if (!e.get(F)) return;
|
|
1640
|
+
function t(t) {
|
|
1641
|
+
let n = t.target;
|
|
1642
|
+
n && n.closest(`[data-pvd-menu="${_}"]`) || e.set(F, null);
|
|
1643
|
+
}
|
|
1644
|
+
return window.addEventListener("mousedown", t), () => window.removeEventListener("mousedown", t);
|
|
1645
|
+
});
|
|
1646
|
+
let I = e.state(!1);
|
|
1647
|
+
function ve() {
|
|
1648
|
+
e.set(I, !e.get(I));
|
|
1649
|
+
}
|
|
1650
|
+
e.user_effect(() => {
|
|
1651
|
+
if (!e.get(I)) return;
|
|
1652
|
+
function t(t) {
|
|
1653
|
+
let n = t.target;
|
|
1654
|
+
n && n.closest(`[data-pvd-presets="${_}"]`) || e.set(I, !1);
|
|
1655
|
+
}
|
|
1656
|
+
return window.addEventListener("mousedown", t), () => window.removeEventListener("mousedown", t);
|
|
1657
|
+
});
|
|
1658
|
+
var L = en(), R = e.child(L), ye = (t) => {
|
|
1659
|
+
var n = Nt(), r = e.sibling(e.child(n), 2), i = e.sibling(r, 2), a = (t) => {
|
|
1660
|
+
var n = jt(), r = e.child(n), i = e.sibling(r, 2), a = (t) => {
|
|
1661
|
+
var n = At();
|
|
1662
|
+
e.each(n, 21, () => s.presets, (e) => e.name, (t, n) => {
|
|
1663
|
+
var r = kt(), i = e.child(r, !0);
|
|
1664
|
+
e.reset(r), e.template_effect(() => e.set_text(i, e.get(n).name)), e.delegated("click", r, () => {
|
|
1665
|
+
E(e.get(n)), e.set(I, !1);
|
|
1666
|
+
}), e.append(t, r);
|
|
1667
|
+
}), e.reset(n), e.append(t, n);
|
|
1668
|
+
};
|
|
1669
|
+
e.if(i, (t) => {
|
|
1670
|
+
e.get(I) && t(a);
|
|
1671
|
+
}), e.reset(n), e.template_effect(() => e.set_attribute(n, "data-pvd-presets", _)), e.delegated("click", r, ve), e.append(t, n);
|
|
1672
|
+
};
|
|
1673
|
+
e.if(i, (e) => {
|
|
1674
|
+
s.presets?.length && e(a);
|
|
1675
|
+
});
|
|
1676
|
+
var o = e.sibling(i, 2), l = e.child(o);
|
|
1677
|
+
e.remove_input_defaults(l), e.next(), e.reset(o);
|
|
1678
|
+
var u = e.sibling(o, 2), d = e.child(u);
|
|
1679
|
+
e.remove_input_defaults(d), e.next(), e.reset(u);
|
|
1680
|
+
var f = e.sibling(u, 4), p = (t) => {
|
|
1681
|
+
var n = Mt();
|
|
1682
|
+
e.delegated("click", n, () => s.onExport(c(), e.get(N).rows)), e.append(t, n);
|
|
1683
|
+
};
|
|
1684
|
+
e.if(f, (t) => {
|
|
1685
|
+
s.onExport && e.get(N) && t(p);
|
|
1686
|
+
}), e.reset(n), e.template_effect(() => {
|
|
1687
|
+
e.set_checked(l, !c().hideSubtotals), e.set_checked(d, !c().hideGrandTotals);
|
|
1688
|
+
}), e.delegated("click", r, oe), e.delegated("change", l, ie), e.delegated("change", d, ae), e.append(t, n);
|
|
1689
|
+
};
|
|
1690
|
+
e.if(R, (e) => {
|
|
1691
|
+
u() && e(ye);
|
|
1692
|
+
});
|
|
1693
|
+
var z = e.sibling(R, 2);
|
|
1694
|
+
let be;
|
|
1695
|
+
var xe = e.child(z), Se = (t) => {
|
|
1696
|
+
var n = Lt(), r = e.child(n);
|
|
1697
|
+
e.remove_input_defaults(r);
|
|
1698
|
+
var i = e.sibling(r, 2), a = e.child(i);
|
|
1699
|
+
e.each(a, 17, () => e.get(x), ([e, t]) => e, (t, n) => {
|
|
1700
|
+
var r = e.derived(() => e.to_array(e.get(n), 2));
|
|
1701
|
+
let i = () => e.get(r)[0], a = () => e.get(r)[1];
|
|
1702
|
+
var o = Ft(), s = e.first_child(o), c = e.child(s, !0);
|
|
1703
|
+
e.reset(s);
|
|
1704
|
+
var l = e.sibling(s, 2);
|
|
1705
|
+
e.each(l, 17, a, (e) => e.field, (t, n) => {
|
|
1706
|
+
let r = e.derived(() => ee(e.get(n).field));
|
|
1707
|
+
var i = Pt();
|
|
1708
|
+
let a;
|
|
1709
|
+
var o = e.child(i);
|
|
1710
|
+
e.remove_input_defaults(o);
|
|
1711
|
+
var s = e.sibling(o, 2), c = e.child(s, !0);
|
|
1712
|
+
e.reset(s);
|
|
1713
|
+
var l = e.sibling(s, 2), u = e.child(l, !0);
|
|
1714
|
+
e.reset(l), e.reset(i), e.template_effect(() => {
|
|
1715
|
+
a = e.set_class(i, 1, "pvd-field svelte-17k9bix", null, a, { "in-use": e.get(r) }), e.set_checked(o, e.get(r)), e.set_attribute(o, "aria-label", `Toggle ${e.get(n).label}`), e.set_text(c, e.get(n).label), e.set_text(u, e.get(n).kind === "dimension" ? "D" : "Σ");
|
|
1716
|
+
}), e.event("dragstart", i, (t) => k(t, e.get(n).field, "rail")), e.delegated("keydown", i, (t) => {
|
|
1717
|
+
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), w(e.get(n).field));
|
|
1718
|
+
}), e.delegated("change", o, () => w(e.get(n).field)), e.append(t, i);
|
|
1719
|
+
}), e.template_effect(() => e.set_text(c, i())), e.append(t, o);
|
|
1720
|
+
});
|
|
1721
|
+
var o = e.sibling(a, 2), s = (t) => {
|
|
1722
|
+
var n = It(), r = e.child(n);
|
|
1723
|
+
e.reset(n), e.template_effect(() => e.set_text(r, `No fields match "${e.get(y) ?? ""}"`)), e.append(t, n);
|
|
1724
|
+
};
|
|
1725
|
+
e.if(o, (t) => {
|
|
1726
|
+
e.get(b).length || t(s);
|
|
1727
|
+
}), e.reset(i), e.reset(n), e.bind_value(r, () => e.get(y), (t) => e.set(y, t)), e.append(t, n);
|
|
1728
|
+
};
|
|
1729
|
+
e.if(xe, (e) => {
|
|
1730
|
+
d() && e(Se);
|
|
1731
|
+
});
|
|
1732
|
+
var Ce = e.sibling(xe, 2), B = e.child(Ce);
|
|
1733
|
+
let V;
|
|
1734
|
+
var H = e.child(B), we = (t) => {
|
|
1735
|
+
var n = Ht();
|
|
1736
|
+
let r;
|
|
1737
|
+
var i = e.sibling(e.child(n), 2), a = e.child(i);
|
|
1738
|
+
e.each(a, 17, () => c().filters, (e) => e.field, (t, n) => {
|
|
1739
|
+
let r = e.derived(() => e.get(v).get(e.get(n).field));
|
|
1740
|
+
var i = Bt(), a = e.child(i), o = e.child(a);
|
|
1741
|
+
e.reset(a);
|
|
1742
|
+
var s = e.sibling(a, 2), c = e.sibling(s, 2), l = (t) => {
|
|
1743
|
+
let r = e.derived(() => me(e.get(n).field));
|
|
1744
|
+
var i = zt(), a = e.child(i), o = e.child(a), s = e.sibling(o, 2);
|
|
1745
|
+
e.reset(a);
|
|
1746
|
+
var c = e.sibling(a, 2);
|
|
1747
|
+
e.each(c, 20, () => e.get(r), (e) => e, (t, i) => {
|
|
1748
|
+
let a = e.derived(() => e.get(n).allowed == null || e.get(n).allowed.includes(i));
|
|
1749
|
+
var o = Rt(), s = e.child(o);
|
|
1750
|
+
e.remove_input_defaults(s);
|
|
1751
|
+
var c = e.sibling(s, 2), l = e.child(c, !0);
|
|
1752
|
+
e.reset(c), e.reset(o), e.template_effect(() => {
|
|
1753
|
+
e.set_checked(s, e.get(a)), e.set_text(l, i);
|
|
1754
|
+
}), e.delegated("change", s, () => {
|
|
1755
|
+
let t = e.get(n).allowed ?? e.get(r).slice(), a = t.includes(i) ? t.filter((e) => e !== i) : [...t, i];
|
|
1756
|
+
T(e.get(n).field, a.length === e.get(r).length ? null : a);
|
|
1757
|
+
}), e.append(t, o);
|
|
1758
|
+
}), e.reset(c), e.reset(i), e.template_effect(() => e.set_attribute(i, "data-pvd-menu", _)), e.delegated("click", o, () => T(e.get(n).field, null)), e.delegated("click", s, () => T(e.get(n).field, [])), e.append(t, i);
|
|
1759
|
+
};
|
|
1760
|
+
e.if(c, (t) => {
|
|
1761
|
+
e.get(F)?.kind === "filter" && e.get(F)?.field === e.get(n).field && t(l);
|
|
1762
|
+
}), e.reset(i), e.template_effect(() => e.set_text(o, `${e.get(r)?.label ?? e.get(n).field ?? ""}${e.get(n).allowed ? ` (${e.get(n).allowed.length})` : ""}`)), e.event("dragstart", i, (t) => k(t, e.get(n).field, "filters")), e.delegated("click", a, () => he(e.get(n).field)), e.delegated("click", s, () => C(e.get(n).field, "filters")), e.append(t, i);
|
|
1763
|
+
});
|
|
1764
|
+
var o = e.sibling(a, 2), s = (t) => {
|
|
1765
|
+
var n = Vt();
|
|
1766
|
+
e.append(t, n);
|
|
1767
|
+
};
|
|
1768
|
+
e.if(o, (e) => {
|
|
1769
|
+
c().filters.length || e(s);
|
|
1770
|
+
}), e.reset(i), e.reset(n), e.template_effect(() => r = e.set_class(n, 1, "pvd-well svelte-17k9bix", null, r, { "drag-over": e.get(O) === "filters" })), e.event("dragover", n, (e) => A(e, "filters")), e.event("dragleave", n, j), e.event("drop", n, (e) => M(e, "filters")), e.append(t, n);
|
|
1771
|
+
};
|
|
1772
|
+
e.if(H, (e) => {
|
|
1773
|
+
f() && e(we);
|
|
1774
|
+
});
|
|
1775
|
+
var U = e.sibling(H, 2);
|
|
1776
|
+
let W;
|
|
1777
|
+
var G = e.sibling(e.child(U), 2), Te = e.child(G);
|
|
1778
|
+
e.each(Te, 16, () => c().cols, (e) => e, (t, n) => {
|
|
1779
|
+
let r = e.derived(() => e.get(v).get(n));
|
|
1780
|
+
var i = Ut(), a = e.child(i), o = e.child(a, !0);
|
|
1781
|
+
e.reset(a);
|
|
1782
|
+
var s = e.sibling(a, 2);
|
|
1783
|
+
e.reset(i), e.template_effect(() => e.set_text(o, e.get(r)?.label ?? n)), e.event("dragstart", i, (e) => k(e, n, "cols")), e.delegated("click", s, () => C(n, "cols")), e.append(t, i);
|
|
1784
|
+
});
|
|
1785
|
+
var Ee = e.sibling(Te, 2), De = (t) => {
|
|
1786
|
+
var n = Wt();
|
|
1787
|
+
e.append(t, n);
|
|
1788
|
+
};
|
|
1789
|
+
e.if(Ee, (e) => {
|
|
1790
|
+
c().cols.length || e(De);
|
|
1791
|
+
}), e.reset(G), e.reset(U);
|
|
1792
|
+
var K = e.sibling(U, 2);
|
|
1793
|
+
let Oe;
|
|
1794
|
+
var q = e.sibling(e.child(K), 2), ke = e.child(q);
|
|
1795
|
+
e.each(ke, 16, () => c().rows, (e) => e, (t, n) => {
|
|
1796
|
+
let r = e.derived(() => e.get(v).get(n));
|
|
1797
|
+
var i = Gt(), a = e.child(i), o = e.child(a, !0);
|
|
1798
|
+
e.reset(a);
|
|
1799
|
+
var s = e.sibling(a, 2);
|
|
1800
|
+
e.reset(i), e.template_effect(() => e.set_text(o, e.get(r)?.label ?? n)), e.event("dragstart", i, (e) => k(e, n, "rows")), e.delegated("click", s, () => C(n, "rows")), e.append(t, i);
|
|
1801
|
+
});
|
|
1802
|
+
var Ae = e.sibling(ke, 2), je = (t) => {
|
|
1803
|
+
var n = Kt();
|
|
1804
|
+
e.append(t, n);
|
|
1805
|
+
};
|
|
1806
|
+
e.if(Ae, (e) => {
|
|
1807
|
+
c().rows.length || e(je);
|
|
1808
|
+
}), e.reset(q), e.reset(K);
|
|
1809
|
+
var J = e.sibling(K, 2);
|
|
1810
|
+
let Me;
|
|
1811
|
+
var Y = e.sibling(e.child(J), 2), X = e.child(Y);
|
|
1812
|
+
e.each(X, 19, () => c().values, (e, t) => e.field + "|" + e.agg + "|" + t, (t, n, r) => {
|
|
1813
|
+
let i = e.derived(() => e.get(v).get(e.get(n).field));
|
|
1814
|
+
var a = Yt(), o = e.child(a), s = e.child(o), c = e.child(s, !0);
|
|
1815
|
+
e.reset(s);
|
|
1816
|
+
var u = e.sibling(s, 4), d = e.child(u, !0);
|
|
1817
|
+
e.reset(u), e.reset(o);
|
|
1818
|
+
var f = e.sibling(o, 2), p = e.sibling(f, 2), m = (t) => {
|
|
1819
|
+
var i = Jt();
|
|
1820
|
+
e.each(i, 20, l, (e) => e, (t, i) => {
|
|
1821
|
+
var a = qt();
|
|
1822
|
+
let o;
|
|
1823
|
+
var s = e.child(a, !0);
|
|
1824
|
+
e.reset(a), e.template_effect(() => {
|
|
1825
|
+
o = e.set_class(a, 1, "pvd-popover-item svelte-17k9bix", null, o, { "is-active": e.get(n).agg === i }), e.set_text(s, wt[i]);
|
|
1826
|
+
}), e.delegated("click", a, () => {
|
|
1827
|
+
re(e.get(r), i), _e();
|
|
1828
|
+
}), e.append(t, a);
|
|
1829
|
+
}), e.reset(i), e.template_effect(() => e.set_attribute(i, "data-pvd-menu", _)), e.append(t, i);
|
|
1830
|
+
};
|
|
1831
|
+
e.if(p, (t) => {
|
|
1832
|
+
e.get(F)?.kind === "agg" && e.get(F).index === e.get(r) && t(m);
|
|
1833
|
+
}), e.reset(a), e.template_effect(() => {
|
|
1834
|
+
e.set_text(c, wt[e.get(n).agg]), e.set_text(d, e.get(i)?.label ?? e.get(n).field);
|
|
1835
|
+
}), e.event("dragstart", a, (t) => k(t, e.get(n).field, "values", e.get(r))), e.delegated("click", o, () => ge(e.get(r))), e.delegated("click", f, () => C(e.get(n).field, "values", e.get(r))), e.append(t, a);
|
|
1836
|
+
});
|
|
1837
|
+
var Ne = e.sibling(X, 2), Z = (t) => {
|
|
1838
|
+
var n = Xt();
|
|
1839
|
+
e.append(t, n);
|
|
1840
|
+
};
|
|
1841
|
+
e.if(Ne, (e) => {
|
|
1842
|
+
c().values.length || e(Z);
|
|
1843
|
+
}), e.reset(Y), e.reset(J), e.reset(B);
|
|
1844
|
+
var Pe = e.sibling(B, 2), Fe = (n) => {
|
|
1845
|
+
var r = $t(), i = e.child(r), a = (n) => {
|
|
1846
|
+
t(n, {
|
|
1847
|
+
get data() {
|
|
1848
|
+
return e.get(fe);
|
|
1849
|
+
},
|
|
1850
|
+
get columns() {
|
|
1851
|
+
return e.get(pe);
|
|
1852
|
+
},
|
|
1853
|
+
get features() {
|
|
1854
|
+
return g;
|
|
1855
|
+
},
|
|
1856
|
+
sortable: !0,
|
|
1857
|
+
filterable: !0,
|
|
1858
|
+
selectionMode: "none",
|
|
1859
|
+
rowHeight: 32,
|
|
1860
|
+
containerHeight: "100%",
|
|
1861
|
+
fitColumns: !0,
|
|
1862
|
+
enableRowSummaries: !1,
|
|
1863
|
+
get onCellClick() {
|
|
1864
|
+
return s.onCellClick;
|
|
1865
|
+
}
|
|
1866
|
+
});
|
|
1867
|
+
}, o = (t) => {
|
|
1868
|
+
var n = Qt(), r = e.child(n), i = (t) => {
|
|
1869
|
+
var n = Zt();
|
|
1870
|
+
e.next(2), e.append(t, n);
|
|
1871
|
+
}, a = (t) => {
|
|
1872
|
+
var n = e.text("No data.");
|
|
1873
|
+
e.append(t, n);
|
|
1874
|
+
};
|
|
1875
|
+
e.if(r, (e) => {
|
|
1876
|
+
c().values.length ? e(a, -1) : e(i);
|
|
1877
|
+
}), e.reset(n), e.append(t, n);
|
|
1878
|
+
};
|
|
1879
|
+
e.if(i, (t) => {
|
|
1880
|
+
e.get(N) ? t(a) : t(o, -1);
|
|
1881
|
+
}), e.reset(r), e.template_effect(() => e.set_style(r, `height:${typeof p() == "number" ? p() + "px" : p()}`)), e.append(n, r);
|
|
1882
|
+
};
|
|
1883
|
+
e.if(Pe, (e) => {
|
|
1884
|
+
m() && e(Fe);
|
|
1885
|
+
}), e.reset(Ce), e.reset(z), e.reset(L), e.template_effect(() => {
|
|
1886
|
+
e.set_attribute(L, "data-uid", _), be = e.set_class(z, 1, "pvd-body svelte-17k9bix", null, be, { "no-rail": !d() }), V = e.set_class(B, 1, "pvd-wells svelte-17k9bix", null, V, { two: !f() }), W = e.set_class(U, 1, "pvd-well svelte-17k9bix", null, W, { "drag-over": e.get(O) === "cols" }), Oe = e.set_class(K, 1, "pvd-well svelte-17k9bix", null, Oe, { "drag-over": e.get(O) === "rows" }), Me = e.set_class(J, 1, "pvd-well svelte-17k9bix", null, Me, { "drag-over": e.get(O) === "values" });
|
|
1887
|
+
}), e.event("dragover", U, (e) => A(e, "cols")), e.event("dragleave", U, j), e.event("drop", U, (e) => M(e, "cols")), e.event("dragover", K, (e) => A(e, "rows")), e.event("dragleave", K, j), e.event("drop", K, (e) => M(e, "rows")), e.event("dragover", J, (e) => A(e, "values")), e.event("dragleave", J, j), e.event("drop", J, (e) => M(e, "values")), e.append(o, L), e.pop();
|
|
1888
|
+
}
|
|
1889
|
+
e.delegate([
|
|
1890
|
+
"click",
|
|
1891
|
+
"change",
|
|
1892
|
+
"keydown"
|
|
1893
|
+
]);
|
|
1894
|
+
//#endregion
|
|
1895
|
+
export { wt as AGG_LABEL, xt as ALL_AGGREGATORS, St as EMPTY_LAYOUT, nn as SvPivotDesigner, qe as aiClassify, We as aiFilter, Ge as aiSmartFill, Ke as aiSummarize, F as assertEnterpriseLicensed, de as clearLicenseKey, gt as createPivotModel, bt as createStagedEditing, Ct as defaultLayoutFor, ne as dismissUnlicensedNudge, k as dismissUpgradePrompt, H as exportGrid, vt as filterCollapsedPivotRows, Fe as getAIProvider, fe as getLicenseKey, Ie as hasAIProvider, me as hasValidLicense, Y as importData, yt as installEnterprise, pe as isLicenseKeySet, Je as mockAIProvider, _t as pivotAggregators, W as printGrid, Pe as setAIProvider, ue as setLicenseKey, O as showUpgradePrompt, f as t };
|