@svgrid/grid-wc 2.0.1 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -25
- package/README.md +110 -90
- package/dist/GridMenus-CdOznO0T.js +417 -0
- package/dist/SvDateTimePicker-Duf-XIOa.js +2011 -0
- package/dist/SvGridChart-EY7OOxv6.js +1192 -0
- package/dist/SvGridChartPanel-Co6RTvAr.js +576 -0
- package/dist/SvGridChartView-BOOZMn2C.js +50 -0
- package/dist/SvGridDropdown-N9LVZsIs.js +251 -0
- package/dist/chart-CSZhFIR9.js +1212 -0
- package/dist/client-DOa609yZ.js +3036 -0
- package/dist/conditional-formatting-Dz-bxLJ2.js +265 -0
- package/dist/dismissable-DvhBKm3q.js +41 -0
- package/dist/editor-contract-peBDxir_.js +22 -0
- package/dist/export-format-DsOZUiL3.js +160 -0
- package/dist/fill-patterns-BWj5Zuhp.js +650 -0
- package/dist/popover-WsGlvtQv.js +69 -0
- package/dist/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/dist/sv-grid-element.js +7392 -16192
- package/package.json +8 -4
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
//#region ../grid/dist/cell-formatting.js
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (e) switch (e.trim()) {
|
|
4
|
+
case "d": return t === "datetime" ? {
|
|
5
|
+
year: "numeric",
|
|
6
|
+
month: "numeric",
|
|
7
|
+
day: "numeric",
|
|
8
|
+
hour: "numeric",
|
|
9
|
+
minute: "numeric"
|
|
10
|
+
} : {
|
|
11
|
+
year: "numeric",
|
|
12
|
+
month: "numeric",
|
|
13
|
+
day: "numeric"
|
|
14
|
+
};
|
|
15
|
+
case "D": return t === "datetime" ? {
|
|
16
|
+
weekday: "long",
|
|
17
|
+
year: "numeric",
|
|
18
|
+
month: "long",
|
|
19
|
+
day: "numeric",
|
|
20
|
+
hour: "numeric",
|
|
21
|
+
minute: "numeric"
|
|
22
|
+
} : {
|
|
23
|
+
weekday: "long",
|
|
24
|
+
year: "numeric",
|
|
25
|
+
month: "long",
|
|
26
|
+
day: "numeric"
|
|
27
|
+
};
|
|
28
|
+
case "y-m-d": return t === "datetime" ? {
|
|
29
|
+
year: "numeric",
|
|
30
|
+
month: "2-digit",
|
|
31
|
+
day: "2-digit",
|
|
32
|
+
hour: "2-digit",
|
|
33
|
+
minute: "2-digit",
|
|
34
|
+
hour12: !1
|
|
35
|
+
} : {
|
|
36
|
+
year: "numeric",
|
|
37
|
+
month: "2-digit",
|
|
38
|
+
day: "2-digit"
|
|
39
|
+
};
|
|
40
|
+
case "medium": return {
|
|
41
|
+
dateStyle: "medium",
|
|
42
|
+
timeStyle: t === "datetime" ? "short" : void 0
|
|
43
|
+
};
|
|
44
|
+
case "short": return {
|
|
45
|
+
dateStyle: "short",
|
|
46
|
+
timeStyle: t === "datetime" ? "short" : void 0
|
|
47
|
+
};
|
|
48
|
+
case "long": return {
|
|
49
|
+
dateStyle: "long",
|
|
50
|
+
timeStyle: t === "datetime" ? "short" : void 0
|
|
51
|
+
};
|
|
52
|
+
default: return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
var t = /* @__PURE__ */ new Map();
|
|
56
|
+
function n(e, n) {
|
|
57
|
+
let r = (Array.isArray(e) ? e.join(",") : e ?? "") + "|" + (n.style ?? "") + "|" + (n.currency ?? "") + "|" + (n.minimumFractionDigits ?? "") + "|" + (n.maximumFractionDigits ?? "") + "|" + (n.useGrouping ?? "") + "|" + (n.currencyDisplay ?? "") + "|" + (n.notation ?? ""), i = t.get(r);
|
|
58
|
+
return i || (i = new Intl.NumberFormat(e, n), t.set(r, i)), i;
|
|
59
|
+
}
|
|
60
|
+
var r = /* @__PURE__ */ new Map();
|
|
61
|
+
function i(e, t) {
|
|
62
|
+
let n = (Array.isArray(e) ? e.join(",") : e ?? "") + "|" + (t.dateStyle ?? "") + "|" + (t.timeStyle ?? "") + "|" + (t.year ?? "") + "|" + (t.month ?? "") + "|" + (t.day ?? "") + "|" + (t.hour ?? "") + "|" + (t.minute ?? "") + "|" + (t.second ?? "") + "|" + (t.weekday ?? "") + "|" + (t.hour12 ?? ""), i = r.get(n);
|
|
63
|
+
return i || (i = new Intl.DateTimeFormat(e, t), r.set(n, i)), i;
|
|
64
|
+
}
|
|
65
|
+
function a(e, t) {
|
|
66
|
+
let r = typeof e == "number" ? e : Number(e);
|
|
67
|
+
if (!Number.isFinite(r)) return String(e ?? "");
|
|
68
|
+
let i = t.locales;
|
|
69
|
+
if (t.type === "currency") return n(i, {
|
|
70
|
+
style: "currency",
|
|
71
|
+
currency: t.currency ?? "USD",
|
|
72
|
+
...t.options
|
|
73
|
+
}).format(r);
|
|
74
|
+
if (t.type === "percent") {
|
|
75
|
+
let e = t.valueIsPercentPoints === !0 ? r / 100 : r;
|
|
76
|
+
return n(i, {
|
|
77
|
+
style: "percent",
|
|
78
|
+
minimumFractionDigits: 0,
|
|
79
|
+
maximumFractionDigits: 2,
|
|
80
|
+
...t.options
|
|
81
|
+
}).format(e);
|
|
82
|
+
}
|
|
83
|
+
return n(i, t.options ?? {}).format(r);
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region ../grid/dist/conditional-formatting.js
|
|
87
|
+
var o = {
|
|
88
|
+
arrows: [
|
|
89
|
+
"↓",
|
|
90
|
+
"→",
|
|
91
|
+
"↑"
|
|
92
|
+
],
|
|
93
|
+
traffic: [
|
|
94
|
+
"🔴",
|
|
95
|
+
"🟡",
|
|
96
|
+
"🟢"
|
|
97
|
+
],
|
|
98
|
+
triangles: [
|
|
99
|
+
"▼",
|
|
100
|
+
"◆",
|
|
101
|
+
"▲"
|
|
102
|
+
]
|
|
103
|
+
};
|
|
104
|
+
function s(e) {
|
|
105
|
+
let t = Infinity, n = -Infinity, r = !1;
|
|
106
|
+
for (let i of e) {
|
|
107
|
+
if (i == null || i === "") continue;
|
|
108
|
+
let e = Number(i);
|
|
109
|
+
Number.isFinite(e) && (r = !0, e < t && (t = e), e > n && (n = e));
|
|
110
|
+
}
|
|
111
|
+
return r ? {
|
|
112
|
+
min: t,
|
|
113
|
+
max: n
|
|
114
|
+
} : null;
|
|
115
|
+
}
|
|
116
|
+
function c(e, t, n) {
|
|
117
|
+
let r = 0;
|
|
118
|
+
for (let e = 0; e < t.length; e += 1) n >= t[e] && (r = e + 1);
|
|
119
|
+
return e[Math.min(e.length - 1, Math.max(0, r))] ?? e[e.length - 1];
|
|
120
|
+
}
|
|
121
|
+
function l(e) {
|
|
122
|
+
return e < 0 ? 0 : e > 1 ? 1 : e;
|
|
123
|
+
}
|
|
124
|
+
function u(e) {
|
|
125
|
+
let t = /^#?([0-9a-f]{6})$/i.exec(e.trim());
|
|
126
|
+
if (!t) return null;
|
|
127
|
+
let n = parseInt(t[1], 16);
|
|
128
|
+
return [
|
|
129
|
+
n >> 16 & 255,
|
|
130
|
+
n >> 8 & 255,
|
|
131
|
+
n & 255
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
function d(e) {
|
|
135
|
+
return "#" + e.map((e) => Math.round(l(e / 255) * 255).toString(16).padStart(2, "0")).join("");
|
|
136
|
+
}
|
|
137
|
+
function f(e) {
|
|
138
|
+
let t = u(e);
|
|
139
|
+
if (!t) return null;
|
|
140
|
+
let n = t.map((e) => {
|
|
141
|
+
let t = e / 255;
|
|
142
|
+
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
143
|
+
});
|
|
144
|
+
return .2126 * n[0] + .7152 * n[1] + .0722 * n[2] > .45 ? "#1e293b" : "#ffffff";
|
|
145
|
+
}
|
|
146
|
+
function p(e, t, n) {
|
|
147
|
+
let r = u(e), i = u(t);
|
|
148
|
+
if (!r || !i) return e;
|
|
149
|
+
let a = l(n);
|
|
150
|
+
return d([
|
|
151
|
+
r[0] + (i[0] - r[0]) * a,
|
|
152
|
+
r[1] + (i[1] - r[1]) * a,
|
|
153
|
+
r[2] + (i[2] - r[2]) * a
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
function m(e, t) {
|
|
157
|
+
let n = u(e);
|
|
158
|
+
return n ? `rgba(${n[0]}, ${n[1]}, ${n[2]}, ${l(t).toFixed(3)})` : e;
|
|
159
|
+
}
|
|
160
|
+
function h(e, t) {
|
|
161
|
+
let n = [...e].sort((e, t) => e.offset - t.offset);
|
|
162
|
+
if (n.length === 0) return "#000000";
|
|
163
|
+
if (t <= n[0].offset) return n[0].color;
|
|
164
|
+
let r = n[n.length - 1];
|
|
165
|
+
if (t >= r.offset) return r.color;
|
|
166
|
+
for (let e = 0; e < n.length - 1; e += 1) {
|
|
167
|
+
let r = n[e], i = n[e + 1];
|
|
168
|
+
if (t >= r.offset && t <= i.offset) {
|
|
169
|
+
let e = i.offset - r.offset || 1;
|
|
170
|
+
return p(r.color, i.color, (t - r.offset) / e);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return r.color;
|
|
174
|
+
}
|
|
175
|
+
function g(e, t) {
|
|
176
|
+
if (e.stops && e.stops.length >= 2) return h(e.stops, t);
|
|
177
|
+
let n = e.min ?? "#ffffff", r = e.max ?? "#000000";
|
|
178
|
+
return e.mid ? t <= .5 ? p(n, e.mid, t / .5) : p(e.mid, r, (t - .5) / .5) : p(n, r, t);
|
|
179
|
+
}
|
|
180
|
+
function _(e, t, n, r) {
|
|
181
|
+
let i;
|
|
182
|
+
if (e.compareColumn) {
|
|
183
|
+
let r = Number(n?.[e.compareColumn]);
|
|
184
|
+
if (!Number.isFinite(r) || r === 0) return null;
|
|
185
|
+
i = l(t / r);
|
|
186
|
+
} else if (e.type === "colorScale" && e.zeroCentred) {
|
|
187
|
+
let n = e.minValue ?? r?.min ?? t, a = e.maxValue ?? r?.max ?? t;
|
|
188
|
+
i = l(.5 + t / (Math.max(Math.abs(n), Math.abs(a)) || 1) / 2);
|
|
189
|
+
} else {
|
|
190
|
+
let n = r?.min ?? t, a = r?.max ?? t, o, s;
|
|
191
|
+
if (e.bounds === "percent") {
|
|
192
|
+
let t = a - n;
|
|
193
|
+
o = n + (e.minValue ?? 0) / 100 * t, s = n + (e.maxValue ?? 100) / 100 * t;
|
|
194
|
+
} else o = e.minValue ?? n, s = e.maxValue ?? a;
|
|
195
|
+
i = s === o ? .5 : l((t - o) / (s - o));
|
|
196
|
+
}
|
|
197
|
+
return e.type === "colorScale" && e.reverse && (i = 1 - i), i;
|
|
198
|
+
}
|
|
199
|
+
function v(e, t, n, r, i) {
|
|
200
|
+
let a = {};
|
|
201
|
+
for (let s of r) {
|
|
202
|
+
if (s.columns && !s.columns.includes(n)) continue;
|
|
203
|
+
let r = Number(e);
|
|
204
|
+
if (s.type === "rule") {
|
|
205
|
+
if (s.when({
|
|
206
|
+
value: e,
|
|
207
|
+
row: t
|
|
208
|
+
})) {
|
|
209
|
+
if (s.background && (a.background = s.background, !s.color)) {
|
|
210
|
+
let e = f(s.background);
|
|
211
|
+
e && (a.color = e);
|
|
212
|
+
}
|
|
213
|
+
s.color && (a.color = s.color), s.fontWeight != null && (a.fontWeight = s.fontWeight);
|
|
214
|
+
}
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (!(e == null || e === "" || !Number.isFinite(r))) {
|
|
218
|
+
if (s.type === "colorScale") {
|
|
219
|
+
let n = _(s, r, t, i);
|
|
220
|
+
if (n == null) continue;
|
|
221
|
+
if (s.mode === "alpha") {
|
|
222
|
+
let [e, t] = s.alphaBounds ?? [.05, .85];
|
|
223
|
+
a.background = m(s.base ?? "#2563eb", e + (t - e) * n);
|
|
224
|
+
} else {
|
|
225
|
+
a.background = g(s, n);
|
|
226
|
+
let e = f(a.background);
|
|
227
|
+
e && (a.color = e);
|
|
228
|
+
}
|
|
229
|
+
s.tooltip === "value" ? a.title = String(e) : s.tooltip === "percent" && (a.title = `${Math.round(n * 100)}%`);
|
|
230
|
+
} else if (s.type === "dataBar") {
|
|
231
|
+
let e;
|
|
232
|
+
if (s.compareColumn) {
|
|
233
|
+
let n = _(s, r, t, i);
|
|
234
|
+
if (n == null) continue;
|
|
235
|
+
e = n * 100;
|
|
236
|
+
} else if (s.bounds === "percent") {
|
|
237
|
+
let n = _(s, r, t, i);
|
|
238
|
+
if (n == null) continue;
|
|
239
|
+
e = n * 100;
|
|
240
|
+
} else {
|
|
241
|
+
let t = s.minValue ?? Math.min(0, i?.min ?? 0), n = (s.maxValue ?? i?.max ?? r) - t || 1;
|
|
242
|
+
e = l((r - t) / n) * 100;
|
|
243
|
+
}
|
|
244
|
+
a.dataBar = {
|
|
245
|
+
percent: e,
|
|
246
|
+
color: r < 0 ? s.negativeColor ?? "#ef4444" : s.color,
|
|
247
|
+
fromRight: !1,
|
|
248
|
+
gradient: s.gradient
|
|
249
|
+
}, s.showValue === !1 && (a.color = "transparent");
|
|
250
|
+
} else if (s.type === "iconSet") {
|
|
251
|
+
let e = o[s.set ?? "arrows"];
|
|
252
|
+
a.icon = c(e, s.thresholds, r), s.iconOnly && (a.iconOnly = !0);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return a;
|
|
257
|
+
}
|
|
258
|
+
function y(e) {
|
|
259
|
+
return (e.type === "colorScale" || e.type === "dataBar") && !("compareColumn" in e && e.compareColumn);
|
|
260
|
+
}
|
|
261
|
+
function b(e) {
|
|
262
|
+
return e.some(y);
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
export { v as a, e as c, b as i, f as n, a as o, y as r, i as s, s as t };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region ../grid/dist/a11y/dismissable.js
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
return t ? (Array.isArray(e) ? e : [e]).some((e) => e != null && e.contains(t)) : !1;
|
|
4
|
+
}
|
|
5
|
+
var t = [], n = !1;
|
|
6
|
+
function r() {
|
|
7
|
+
n || typeof document > "u" || (n = !0, document.addEventListener("keydown", (e) => {
|
|
8
|
+
if (e.key !== "Escape") return;
|
|
9
|
+
let n = t[t.length - 1];
|
|
10
|
+
n?.closeOnEscape && (e.stopPropagation(), n.onDismiss("escape"));
|
|
11
|
+
}, !0), document.addEventListener("pointerdown", (n) => {
|
|
12
|
+
let r = t[t.length - 1];
|
|
13
|
+
r?.closeOnOutside && (e(r.element(), n.target) || r.onDismiss("outside"));
|
|
14
|
+
}, !0));
|
|
15
|
+
}
|
|
16
|
+
function i(e) {
|
|
17
|
+
let n = {
|
|
18
|
+
element: e.element,
|
|
19
|
+
onDismiss: e.onDismiss,
|
|
20
|
+
closeOnEscape: e.closeOnEscape ?? !0,
|
|
21
|
+
closeOnOutside: e.closeOnOutside ?? !0
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
activate() {
|
|
25
|
+
r(), t.includes(n) || t.push(n);
|
|
26
|
+
},
|
|
27
|
+
release() {
|
|
28
|
+
let e = t.indexOf(n);
|
|
29
|
+
e >= 0 && t.splice(e, 1);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function a(t, n) {
|
|
34
|
+
if (typeof window > "u") return () => {};
|
|
35
|
+
let r = (r) => {
|
|
36
|
+
e(t(), r.target) || n();
|
|
37
|
+
};
|
|
38
|
+
return window.addEventListener("scroll", r, !0), () => window.removeEventListener("scroll", r, !0);
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { a as n, i as t };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region ../grid/dist/editor-contract.js
|
|
2
|
+
var e = (e) => e ? `${e}__error` : void 0, t = (e) => e ? `${e}__hint` : void 0, n = 0, r = (e = "sv-ed") => `${e}-${n++}`;
|
|
3
|
+
function i(n) {
|
|
4
|
+
let r = [n.error ? e(n.id) : void 0, n.hint ? t(n.id) : void 0].filter(Boolean);
|
|
5
|
+
return {
|
|
6
|
+
"aria-invalid": n.invalid ? "true" : void 0,
|
|
7
|
+
"aria-required": n.required ? "true" : void 0,
|
|
8
|
+
"aria-describedby": r.length ? r.join(" ") : void 0,
|
|
9
|
+
"aria-label": n.ariaLabel
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function a(e, t) {
|
|
13
|
+
if (!t) return e;
|
|
14
|
+
let n = { ...e };
|
|
15
|
+
for (let e in t) {
|
|
16
|
+
let r = t[e];
|
|
17
|
+
r != null && r !== "" && (n[e] = r);
|
|
18
|
+
}
|
|
19
|
+
return n;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { a, r as i, e as n, t as r, i as t };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { c as e, o as t, s as n } from "./conditional-formatting-Dz-bxLJ2.js";
|
|
2
|
+
//#region ../grid/dist/export-format.js
|
|
3
|
+
function r(e) {
|
|
4
|
+
if (e instanceof Date) return Number.isNaN(e.getTime()) ? null : e;
|
|
5
|
+
if (typeof e == "number" && Number.isFinite(e)) {
|
|
6
|
+
let t = new Date(e);
|
|
7
|
+
return Number.isNaN(t.getTime()) ? null : t;
|
|
8
|
+
}
|
|
9
|
+
if (typeof e == "string" && e.trim() !== "") {
|
|
10
|
+
let t = new Date(e);
|
|
11
|
+
return Number.isNaN(t.getTime()) ? null : t;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
function i(i, a) {
|
|
16
|
+
if (i == null) return "";
|
|
17
|
+
if (!a) return String(i);
|
|
18
|
+
if (a.type === "number" || a.type === "currency" || a.type === "percent") return t(i, {
|
|
19
|
+
type: a.type,
|
|
20
|
+
locales: a.locales,
|
|
21
|
+
currency: a.type === "currency" ? a.currency ?? "USD" : void 0,
|
|
22
|
+
valueIsPercentPoints: a.type === "percent" ? a.valueIsPercentPoints : void 0,
|
|
23
|
+
options: a.options
|
|
24
|
+
});
|
|
25
|
+
if (a.type === "date" || a.type === "datetime") {
|
|
26
|
+
let t = r(i);
|
|
27
|
+
if (t) {
|
|
28
|
+
let r = e(a.pattern, a.type), i = r || a.options ? {
|
|
29
|
+
...r,
|
|
30
|
+
...a.options
|
|
31
|
+
} : a.type === "date" ? {
|
|
32
|
+
year: "numeric",
|
|
33
|
+
month: "2-digit",
|
|
34
|
+
day: "2-digit"
|
|
35
|
+
} : {
|
|
36
|
+
year: "numeric",
|
|
37
|
+
month: "2-digit",
|
|
38
|
+
day: "2-digit",
|
|
39
|
+
hour: "2-digit",
|
|
40
|
+
minute: "2-digit"
|
|
41
|
+
};
|
|
42
|
+
return n(a.locales, i).format(t);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return String(i);
|
|
46
|
+
}
|
|
47
|
+
function a(e, t, n = {}) {
|
|
48
|
+
let r = n.columns && n.columns.length ? n.columns.map((e) => t.find((t) => t.field === e)).filter((e) => !!e) : t.filter((e) => e.field), a = r.map((e) => e.field), o = {};
|
|
49
|
+
for (let e of r) e.align && (o[e.field] = e.align);
|
|
50
|
+
let s = {};
|
|
51
|
+
for (let e of r) s[e.field] = e.header;
|
|
52
|
+
let c = [s];
|
|
53
|
+
for (let t of e) {
|
|
54
|
+
let e = {};
|
|
55
|
+
for (let a of r) {
|
|
56
|
+
let r = t[a.field];
|
|
57
|
+
e[a.field] = n.rawValues ? r : i(r, a.format);
|
|
58
|
+
}
|
|
59
|
+
c.push(e);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
records: c,
|
|
63
|
+
fields: a,
|
|
64
|
+
align: o
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
var o = "";
|
|
68
|
+
function s(e) {
|
|
69
|
+
if (e?.aborted) throw new DOMException("Export aborted", "AbortError");
|
|
70
|
+
}
|
|
71
|
+
var c = () => new Promise((e) => setTimeout(e, 0));
|
|
72
|
+
function l(e, t) {
|
|
73
|
+
let n = e == null ? "" : e instanceof Date ? e.toISOString() : String(e);
|
|
74
|
+
return n === "" ? n : n.includes(t) || n.includes("\"") || n.includes("\n") || n.includes("\r") ? `"${n.replace(/"/g, "\"\"")}"` : n;
|
|
75
|
+
}
|
|
76
|
+
async function u(e, t, n = {}) {
|
|
77
|
+
let r = n.csv?.delimiter ?? ",", i = n.csv?.eol ?? "\r\n", a = n.csv?.bom ?? !0, u = Math.max(1, n.chunkRows ?? 5e3), d = e.length, f = [];
|
|
78
|
+
for (let i = 0; i < e.length; i++) {
|
|
79
|
+
s(n.signal);
|
|
80
|
+
let a = e[i];
|
|
81
|
+
f.push(t.map((e) => l(a[e], r)).join(r)), i > 0 && i % u === 0 && (n.onProgress?.({
|
|
82
|
+
phase: "serialize",
|
|
83
|
+
ratio: i / d,
|
|
84
|
+
row: i,
|
|
85
|
+
total: d
|
|
86
|
+
}), await c());
|
|
87
|
+
}
|
|
88
|
+
n.onProgress?.({
|
|
89
|
+
phase: "serialize",
|
|
90
|
+
ratio: 1,
|
|
91
|
+
row: d,
|
|
92
|
+
total: d
|
|
93
|
+
});
|
|
94
|
+
let p = f.join(i);
|
|
95
|
+
return (a ? o : "") + p;
|
|
96
|
+
}
|
|
97
|
+
async function d(e, t, n = {}) {
|
|
98
|
+
let r = Math.max(1, n.chunkRows ?? 5e3), i = e.length - 1, a = [];
|
|
99
|
+
for (let o = 1; o < e.length; o++) {
|
|
100
|
+
s(n.signal);
|
|
101
|
+
let l = e[o], u = {};
|
|
102
|
+
for (let e of t) u[e] = l[e];
|
|
103
|
+
a.push(u), o > 0 && o % r === 0 && (n.onProgress?.({
|
|
104
|
+
phase: "serialize",
|
|
105
|
+
ratio: o / i,
|
|
106
|
+
row: o,
|
|
107
|
+
total: i
|
|
108
|
+
}), await c());
|
|
109
|
+
}
|
|
110
|
+
return n.onProgress?.({
|
|
111
|
+
phase: "serialize",
|
|
112
|
+
ratio: 1,
|
|
113
|
+
row: i,
|
|
114
|
+
total: i
|
|
115
|
+
}), JSON.stringify(a, null, 2);
|
|
116
|
+
}
|
|
117
|
+
function f(e) {
|
|
118
|
+
return (e == null ? "" : e instanceof Date ? e.toISOString() : String(e)).replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\r?\n/g, "<br>");
|
|
119
|
+
}
|
|
120
|
+
async function p(e, t, n = {}) {
|
|
121
|
+
let r = Math.max(1, n.chunkRows ?? 5e3), i = e.length, a = n.align ?? {}, o = e[0], l = `| ${t.map((e) => f(o?.[e])).join(" | ")} |`, u = `| ${t.map((e) => {
|
|
122
|
+
let t = a[e];
|
|
123
|
+
return t === "right" ? "---:" : t === "center" ? ":--:" : "---";
|
|
124
|
+
}).join(" | ")} |`, d = [];
|
|
125
|
+
for (let a = 1; a < e.length; a++) {
|
|
126
|
+
s(n.signal);
|
|
127
|
+
let o = e[a];
|
|
128
|
+
d.push(`| ${t.map((e) => f(o[e])).join(" | ")} |`), a > 0 && a % r === 0 && (n.onProgress?.({
|
|
129
|
+
phase: "serialize",
|
|
130
|
+
ratio: a / i,
|
|
131
|
+
row: a,
|
|
132
|
+
total: i
|
|
133
|
+
}), await c());
|
|
134
|
+
}
|
|
135
|
+
return n.onProgress?.({
|
|
136
|
+
phase: "serialize",
|
|
137
|
+
ratio: 1,
|
|
138
|
+
row: i,
|
|
139
|
+
total: i
|
|
140
|
+
}), [
|
|
141
|
+
l,
|
|
142
|
+
u,
|
|
143
|
+
...d
|
|
144
|
+
].join("\n") + "\n";
|
|
145
|
+
}
|
|
146
|
+
function m(e, t) {
|
|
147
|
+
if (typeof document > "u" || typeof URL > "u") throw Error("@svgrid/grid: export requires a browser environment");
|
|
148
|
+
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
149
|
+
r.href = n, r.download = t, document.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 0);
|
|
150
|
+
}
|
|
151
|
+
function h(e, t, n) {
|
|
152
|
+
if (typeof document > "u" || typeof URL > "u") throw Error("@svgrid/grid: text export requires a browser environment");
|
|
153
|
+
m(new Blob([e], { type: n }), t);
|
|
154
|
+
}
|
|
155
|
+
async function g(e) {
|
|
156
|
+
if (typeof navigator > "u" || !navigator.clipboard) throw Error("@svgrid/grid: clipboard API is unavailable in this context");
|
|
157
|
+
await navigator.clipboard.writeText(e);
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
export { g as copyTextToClipboard, h as downloadTextFile, a as projectGridRows, u as serializeDelimited, d as serializeJson, p as serializeMarkdown };
|