@svgrid/grid-wc 2.2.0 → 2.4.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.
@@ -0,0 +1,614 @@
1
+ import { R as e, X as t, Z as n } from "./client-DoXxrq8q.js";
2
+ //#region ../grid/dist/sv-grid-scrollbar.js
3
+ var r = 16, i = 280, a = 50, o = "http://www.w3.org/2000/svg";
4
+ function s() {
5
+ let e = document.createElementNS(o, "svg");
6
+ e.setAttribute("viewBox", "0 0 24 24"), e.setAttribute("fill", "none"), e.setAttribute("stroke", "currentColor"), e.setAttribute("stroke-width", "3"), e.setAttribute("stroke-linecap", "round"), e.setAttribute("stroke-linejoin", "round");
7
+ let t = document.createElementNS(o, "path");
8
+ return t.setAttribute("d", "M6 9l6 6 6-6"), e.appendChild(t), e;
9
+ }
10
+ var c = `
11
+ :host {
12
+ display: flex;
13
+ user-select: none;
14
+ background: var(--sg-scrollbar-bg, #eef2f8);
15
+ /* The 1px separator is drawn on the INNER edge only (the edge facing
16
+ the grid body) via the orientation rules below. A full inset box
17
+ here doubled up with the grid's own frame border on the outer edge,
18
+ reading as a 2px border - most visible in dense-gridline themes
19
+ like Excel, which should show a single 1px line. */
20
+ /* Start hidden + non-interactive - viewport/content sizes are 0 until
21
+ after the first layout pass, so without this default the scrollbar
22
+ paints visible for one frame and then JS hides it on mount. That
23
+ flicker is what shows up as a "flashing horizontal scrollbar"
24
+ every time a demo first renders. updateGeometry() switches us to
25
+ opacity 1 the moment the grid genuinely has overflow. */
26
+ opacity: 0;
27
+ pointer-events: none;
28
+ transition: opacity 120ms ease;
29
+ }
30
+ :host([orientation="vertical"]) {
31
+ flex-direction: column;
32
+ width: ${r}px;
33
+ /* LTR: vertical scrollbar sits at the right, inner edge is the left. */
34
+ box-shadow: inset 1px 0 0 0 var(--sg-scrollbar-border, rgba(15, 23, 42, 0.04));
35
+ }
36
+ :host([orientation="vertical"]:dir(rtl)) {
37
+ /* RTL flips the scrollbar to the left, so the inner edge is the right. */
38
+ box-shadow: inset -1px 0 0 0 var(--sg-scrollbar-border, rgba(15, 23, 42, 0.04));
39
+ }
40
+ :host([orientation="horizontal"]) {
41
+ flex-direction: row;
42
+ height: ${r}px;
43
+ /* Horizontal scrollbar sits at the bottom, inner edge is the top. */
44
+ box-shadow: inset 0 1px 0 0 var(--sg-scrollbar-border, rgba(15, 23, 42, 0.04));
45
+ }
46
+ .arrow {
47
+ flex: none;
48
+ display: flex;
49
+ align-items: center;
50
+ justify-content: center;
51
+ width: ${r}px;
52
+ height: ${r}px;
53
+ margin: 0;
54
+ padding: 0;
55
+ border: 0;
56
+ border-radius: 3px;
57
+ background: transparent;
58
+ color: var(--sg-scrollbar-arrow, #64748b);
59
+ cursor: pointer;
60
+ transition: background-color 100ms ease, color 100ms ease;
61
+ }
62
+ .arrow:hover {
63
+ background: var(--sg-scrollbar-arrow-hover-bg, #dde4ee);
64
+ color: var(--sg-scrollbar-arrow-hover, #1f2937);
65
+ }
66
+ .arrow:active {
67
+ background: var(--sg-scrollbar-arrow-active-bg, #c7d1df);
68
+ color: var(--sg-scrollbar-arrow-active, #0f172a);
69
+ }
70
+ .arrow:disabled {
71
+ color: var(--sg-scrollbar-arrow-disabled, #cbd5e1);
72
+ cursor: default;
73
+ }
74
+ .arrow:disabled:hover {
75
+ background: transparent;
76
+ }
77
+ .arrow svg {
78
+ width: 10px;
79
+ height: 10px;
80
+ display: block;
81
+ }
82
+ :host([orientation="vertical"]) .arrow-start svg {
83
+ transform: rotate(180deg);
84
+ }
85
+ :host([orientation="horizontal"]) .arrow-start svg {
86
+ transform: rotate(90deg);
87
+ }
88
+ :host([orientation="horizontal"]) .arrow-end svg {
89
+ transform: rotate(-90deg);
90
+ }
91
+ .track {
92
+ position: relative;
93
+ flex: 1 1 0;
94
+ min-width: 0;
95
+ min-height: 0;
96
+ }
97
+ .thumb {
98
+ position: absolute;
99
+ border-radius: var(--sg-scrollbar-thumb-radius, 6px);
100
+ background: var(--sg-scrollbar-thumb, #b1bccd);
101
+ cursor: pointer;
102
+ transition: background-color 100ms ease;
103
+ }
104
+ .thumb:hover {
105
+ background: var(--sg-scrollbar-thumb-hover, #8693a7);
106
+ }
107
+ .thumb:active {
108
+ background: var(--sg-scrollbar-thumb-active, #64748b);
109
+ }
110
+ :host([orientation="vertical"]) .thumb {
111
+ left: 3px;
112
+ right: 3px;
113
+ }
114
+ :host([orientation="horizontal"]) .thumb {
115
+ top: 3px;
116
+ bottom: 3px;
117
+ }
118
+ `, l = typeof HTMLElement < "u" ? HTMLElement : class {}, u = class extends l {
119
+ constructor() {
120
+ super(...arguments), this.dragging = !1, this.dragStart = 0, this.valueStart = 0, this.holdTimer = null, this.resizeObserver = null, this.resizeFrame = 0, this.onArrowStartPointerDown = (e) => {
121
+ e.preventDefault(), this.startHold(-1);
122
+ }, this.onArrowEndPointerDown = (e) => {
123
+ e.preventDefault(), this.startHold(1);
124
+ }, this.stopHold = () => {
125
+ this.holdTimer !== null && (clearTimeout(this.holdTimer), clearInterval(this.holdTimer), this.holdTimer = null);
126
+ }, this.onThumbPointerDown = (e) => {
127
+ e.preventDefault(), this.dragging = !0, this.dragStart = this.orientation === "vertical" ? e.clientY : e.clientX, this.valueStart = this.value, document.addEventListener("pointermove", this.onPointerMove), document.addEventListener("pointerup", this.onPointerUp);
128
+ }, this.onTrackPointerDown = (e) => {
129
+ if (e.target === this.thumb) return;
130
+ let t = this.track.getBoundingClientRect(), n = this.orientation === "vertical" ? e.clientY - t.top : e.clientX - t.left, r = this.orientation === "vertical" ? t.height : t.width, i = this.computeThumbSize(r), a = Math.max(r - i, 1), o = Math.min(Math.max(n - i / 2, 0), a);
131
+ this.emitScroll(o / a * this.maxValue);
132
+ }, this.onPointerMove = (e) => {
133
+ if (!this.dragging) return;
134
+ let t = (this.orientation === "vertical" ? e.clientY : e.clientX) - this.dragStart, n = this.track.getBoundingClientRect(), r = this.orientation === "vertical" ? n.height : n.width, i = this.computeThumbSize(r), a = Math.max(r - i, 1);
135
+ this.emitScroll(this.valueStart + t / a * this.maxValue);
136
+ }, this.onPointerUp = () => {
137
+ this.dragging = !1, document.removeEventListener("pointermove", this.onPointerMove), document.removeEventListener("pointerup", this.onPointerUp);
138
+ };
139
+ }
140
+ static get observedAttributes() {
141
+ return [
142
+ "orientation",
143
+ "viewport-size",
144
+ "content-size",
145
+ "value",
146
+ "step"
147
+ ];
148
+ }
149
+ connectedCallback() {
150
+ if (this.shadowRoot) return;
151
+ let e = this.attachShadow({ mode: "open" }), t = document.createElement("style");
152
+ t.textContent = c, this.startArrow = this.createArrow("start"), this.endArrow = this.createArrow("end"), this.track = document.createElement("div"), this.track.className = "track", this.thumb = document.createElement("div"), this.thumb.className = "thumb", this.track.appendChild(this.thumb), e.append(t, this.startArrow, this.track, this.endArrow), this.thumb.addEventListener("pointerdown", this.onThumbPointerDown), this.track.addEventListener("pointerdown", this.onTrackPointerDown), this.startArrow.addEventListener("pointerdown", this.onArrowStartPointerDown), this.endArrow.addEventListener("pointerdown", this.onArrowEndPointerDown);
153
+ for (let e of [this.startArrow, this.endArrow]) e.addEventListener("pointerup", this.stopHold), e.addEventListener("pointerleave", this.stopHold), e.addEventListener("pointercancel", this.stopHold);
154
+ this.resizeObserver = new ResizeObserver(() => {
155
+ this.resizeFrame ||= requestAnimationFrame(() => {
156
+ this.resizeFrame = 0, this.render();
157
+ });
158
+ }), this.resizeObserver.observe(this), this.render();
159
+ }
160
+ disconnectedCallback() {
161
+ this.stopHold(), this.resizeFrame && cancelAnimationFrame(this.resizeFrame), this.resizeFrame = 0, this.resizeObserver?.disconnect(), this.resizeObserver = null, document.removeEventListener("pointermove", this.onPointerMove), document.removeEventListener("pointerup", this.onPointerUp);
162
+ }
163
+ attributeChangedCallback() {
164
+ this.render();
165
+ }
166
+ get orientation() {
167
+ return this.getAttribute("orientation") === "horizontal" ? "horizontal" : "vertical";
168
+ }
169
+ get viewportSize() {
170
+ return Number(this.getAttribute("viewport-size") || "0");
171
+ }
172
+ get contentSize() {
173
+ return Number(this.getAttribute("content-size") || "0");
174
+ }
175
+ get value() {
176
+ return Number(this.getAttribute("value") || "0");
177
+ }
178
+ get step() {
179
+ let e = Number(this.getAttribute("step") || "40");
180
+ return e > 0 ? e : 40;
181
+ }
182
+ get maxValue() {
183
+ return Math.max(this.contentSize - this.viewportSize, 0);
184
+ }
185
+ getTrackLength() {
186
+ let e = this.track.getBoundingClientRect(), t = this.orientation === "vertical" ? e.height : e.width;
187
+ return t > 0 ? t : Math.max(this.viewportSize - 32, 1);
188
+ }
189
+ computeThumbSize(e) {
190
+ if (this.contentSize <= 0 || this.viewportSize <= 0 || e <= 0) return 0;
191
+ let t = Math.min(this.viewportSize / this.contentSize, 1);
192
+ return Math.max(20, t * e);
193
+ }
194
+ createArrow(e) {
195
+ let t = document.createElement("button");
196
+ return t.type = "button", t.className = `arrow arrow-${e}`, t.setAttribute("aria-label", e === "start" ? "Scroll back" : "Scroll forward"), t.appendChild(s()), t;
197
+ }
198
+ startHold(e) {
199
+ this.stopHold();
200
+ let t = () => this.emitScroll(this.value + e * this.step);
201
+ t(), this.holdTimer = setTimeout(() => {
202
+ this.holdTimer = setInterval(t, a);
203
+ }, i);
204
+ }
205
+ emitScroll(e) {
206
+ let t = Math.min(Math.max(e, 0), this.maxValue);
207
+ this.dispatchEvent(new CustomEvent("scroll-change", {
208
+ detail: { value: t },
209
+ bubbles: !0,
210
+ composed: !0
211
+ }));
212
+ }
213
+ render() {
214
+ if (!this.shadowRoot) return;
215
+ let e = this.viewportSize, t = this.contentSize <= e || e <= 0;
216
+ this.style.opacity = t ? "0" : "1", this.style.pointerEvents = t ? "none" : "auto";
217
+ let n = this.getTrackLength(), r = this.computeThumbSize(n), i = this.maxValue, a = (i > 0 ? this.value / i : 0) * Math.max(n - r, 0);
218
+ this.orientation === "vertical" ? (this.thumb.style.height = `${r}px`, this.thumb.style.transform = `translateY(${a}px)`) : (this.thumb.style.width = `${r}px`, this.thumb.style.transform = `translateX(${a}px)`), this.startArrow.disabled = t || this.value <= 0, this.endArrow.disabled = t || this.value >= i;
219
+ }
220
+ };
221
+ typeof window < "u" && !customElements.get("sv-grid-scrollbar") && customElements.define("sv-grid-scrollbar", u);
222
+ //#endregion
223
+ //#region ../grid/dist/SvGrid.helpers.js
224
+ function d(e) {
225
+ let t = "";
226
+ return e.color && (t += `color:${e.color};`), e.fontWeight != null && (t += `font-weight:${e.fontWeight};`), t;
227
+ }
228
+ function f(e) {
229
+ return Number.isInteger(e) ? e.toLocaleString() : e.toLocaleString(void 0, { maximumFractionDigits: 2 });
230
+ }
231
+ function p(e, t) {
232
+ return `${e}:${t}`;
233
+ }
234
+ function m(e) {
235
+ if (!e) return "";
236
+ if (typeof e == "string") return e;
237
+ if (Array.isArray(e)) return e.filter(Boolean).join(" ");
238
+ if (typeof e == "object") {
239
+ let t = [];
240
+ for (let [n, r] of Object.entries(e)) r && t.push(n);
241
+ return t.join(" ");
242
+ }
243
+ return "";
244
+ }
245
+ function h(e) {
246
+ if (e == null || e === "") return "";
247
+ if (typeof e == "string" && /^\d{4}-\d{2}-\d{2}$/.test(e)) return e;
248
+ let t = e instanceof Date ? e : new Date(e);
249
+ return Number.isNaN(t.getTime()) ? "" : t.toISOString().slice(0, 10);
250
+ }
251
+ function g(e) {
252
+ if (e == null || e === "") return "";
253
+ if (typeof e == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(e)) return e;
254
+ let t = e instanceof Date ? e : new Date(e);
255
+ return Number.isNaN(t.getTime()) ? "" : t.toISOString().slice(0, 16);
256
+ }
257
+ function _(e) {
258
+ return String(e).replace(/-native$/, "");
259
+ }
260
+ function v(e) {
261
+ if (e instanceof Date) return e;
262
+ if (typeof e == "string") {
263
+ let t = e.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?/);
264
+ if (t) {
265
+ let e = /* @__PURE__ */ new Date();
266
+ return e.setHours(Math.min(23, +t[1]), Math.min(59, +t[2]), t[3] ? +t[3] : 0, 0), e;
267
+ }
268
+ }
269
+ return null;
270
+ }
271
+ function y(e) {
272
+ return e ? `${String(e.getHours()).padStart(2, "0")}:${String(e.getMinutes()).padStart(2, "0")}` : null;
273
+ }
274
+ function b(e, t) {
275
+ let n = _(e);
276
+ return n === "date" ? h(t) : n === "datetime" ? g(t) : String(t ?? "");
277
+ }
278
+ function x(e) {
279
+ let t = _(e);
280
+ return t === "number" ? "number" : t === "date" ? "date" : t === "datetime" ? "datetime-local" : t === "time" ? "time" : t === "password" ? "password" : t === "color" ? "color" : "text";
281
+ }
282
+ function S(e) {
283
+ return e == null || e === "" ? [] : Array.isArray(e) ? e.filter((e) => e != null && e !== "") : [e];
284
+ }
285
+ function C(e, t) {
286
+ let n = e.find((e) => e.value === t || String(e.value) === String(t));
287
+ return n ? n.label : String(t ?? "");
288
+ }
289
+ function w(e, t) {
290
+ return e.find((e) => e.value === t || String(e.value) === String(t))?.color;
291
+ }
292
+ function T(e) {
293
+ return e ? `background: color-mix(in srgb, ${e} 22%, transparent);border-color: color-mix(in srgb, ${e} 45%, transparent);color: color-mix(in srgb, ${e} 80%, var(--sg-fg, #0f172a));` : "";
294
+ }
295
+ function E(e) {
296
+ let t = _(e);
297
+ return t === "number" ? "sv-grid-cell-editor sv-grid-cell-editor-number" : t === "date" ? "sv-grid-cell-editor sv-grid-cell-editor-date" : t === "datetime" ? "sv-grid-cell-editor sv-grid-cell-editor-datetime" : t === "color" ? "sv-grid-cell-editor sv-grid-cell-editor-color" : "sv-grid-cell-editor";
298
+ }
299
+ function D(e) {
300
+ if (e == null || e === "") return null;
301
+ let t = e instanceof Date ? e : new Date(e);
302
+ return Number.isNaN(t.getTime()) ? null : t;
303
+ }
304
+ function O(e, t) {
305
+ return Math.max(8, Math.min(e, window.innerWidth - t - 8));
306
+ }
307
+ function k(e) {
308
+ return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/"/g, "\\\"");
309
+ }
310
+ function A(e, t) {
311
+ if (e == null || e === "") return NaN;
312
+ if (t) {
313
+ let t = (e instanceof Date ? e : new Date(String(e))).getTime();
314
+ return Number.isFinite(t) ? t : NaN;
315
+ }
316
+ let n = typeof e == "number" ? e : Number(e);
317
+ return Number.isFinite(n) ? n : NaN;
318
+ }
319
+ function j(e) {
320
+ let t = Math.abs(e), n = t >= 1e3 ? 0 : t >= 100 ? 1 : t >= 1 ? 2 : 4;
321
+ return e.toLocaleString(void 0, { maximumFractionDigits: n });
322
+ }
323
+ function M(e) {
324
+ return new Date(e).toLocaleDateString(void 0, {
325
+ year: "numeric",
326
+ month: "short",
327
+ day: "numeric"
328
+ });
329
+ }
330
+ //#endregion
331
+ //#region ../grid/dist/filtering/excel-filters.js
332
+ var N = /[̀-ͯ]/g;
333
+ function P(e, t) {
334
+ if (!e) return "";
335
+ let n = e.normalize("NFD").replace(N, "");
336
+ return t ? n.toLocaleLowerCase(t) : n.toLowerCase();
337
+ }
338
+ function F(e) {
339
+ let { tokens: t, trailing: n } = R(e);
340
+ return n && t.push(n), t;
341
+ }
342
+ function I(e) {
343
+ return e.map((e) => e.trim()).filter((e) => e.length > 0).map((e) => /["\n,]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e).join(", ");
344
+ }
345
+ function L(e) {
346
+ return R(e).trailing;
347
+ }
348
+ function R(e) {
349
+ let t = String(e ?? ""), n = [], r = "", i = !1, a = !1, o = !1, s = () => {
350
+ let e = a ? r : r.trim();
351
+ return r = "", a = !1, o = !1, e;
352
+ };
353
+ for (let e = 0; e < t.length; e += 1) {
354
+ let c = t[e];
355
+ if (i) {
356
+ if (c !== "\"") {
357
+ r += c;
358
+ continue;
359
+ }
360
+ if (t[e + 1] === "\"") {
361
+ r += "\"", e += 1;
362
+ continue;
363
+ }
364
+ i = !1, o = !0;
365
+ continue;
366
+ }
367
+ if (c === "," || c === "\n") {
368
+ let e = s();
369
+ e.length && n.push(e);
370
+ continue;
371
+ }
372
+ if (c === "\"" && !o && !r.trim()) {
373
+ i = !0, a = !0, r = "";
374
+ continue;
375
+ }
376
+ r += c;
377
+ }
378
+ return {
379
+ tokens: n,
380
+ trailing: s()
381
+ };
382
+ }
383
+ function z(e, t, n) {
384
+ let r = String(e ?? ""), i = P(r, n?.locale), a = P(String(t.value ?? ""), n?.locale);
385
+ switch (t.operator) {
386
+ case "contains": return i.includes(a);
387
+ case "notContains": return a === "" || !i.includes(a);
388
+ case "equals": return i === a;
389
+ case "notEquals": return a === "" || i !== a;
390
+ case "startsWith": return i.startsWith(a);
391
+ case "endsWith": return i.endsWith(a);
392
+ case "regex": {
393
+ let e = String(t.value ?? "");
394
+ if (!e) return !0;
395
+ try {
396
+ return new RegExp(e, "i").test(r);
397
+ } catch {
398
+ return !1;
399
+ }
400
+ }
401
+ case "in":
402
+ case "notIn": {
403
+ let e = F(t.value);
404
+ if (e.length === 0) return !0;
405
+ let r = e.some((e) => P(e, n?.locale) === i);
406
+ return t.operator === "in" ? r : !r;
407
+ }
408
+ case "greaterThan": {
409
+ let n = Number(e), r = Number(t.value);
410
+ return Number.isFinite(n) && Number.isFinite(r) ? n > r : String(e ?? "") > String(t.value ?? "");
411
+ }
412
+ case "lessThan": {
413
+ let n = Number(e), r = Number(t.value);
414
+ return Number.isFinite(n) && Number.isFinite(r) ? n < r : String(e ?? "") < String(t.value ?? "");
415
+ }
416
+ case "between": {
417
+ let n = t.value == null ? 0 : Number(t.value), r = t.valueTo == null ? 0 : Number(t.valueTo), i = Number(e ?? 0);
418
+ if (Number.isFinite(i) && Number.isFinite(n) && Number.isFinite(r)) return i >= n && i <= r;
419
+ let a = String(e ?? ""), o = String(t.value ?? ""), s = String(t.valueTo ?? "");
420
+ return a >= o && a <= s;
421
+ }
422
+ case "isBlank": return r.trim().length === 0;
423
+ case "isNotBlank": return r.trim().length > 0;
424
+ }
425
+ }
426
+ //#endregion
427
+ //#region ../grid/dist/virtualization/virtualizer.js
428
+ function B(e, t, n) {
429
+ return Math.min(Math.max(e, t), n);
430
+ }
431
+ function V(e, t) {
432
+ return e.count === t.count && e.estimateSize === t.estimateSize && (e.overscan ?? 6) === (t.overscan ?? 6) && e.viewportHeight === t.viewportHeight && (e.scrollOffset ?? 0) === (t.scrollOffset ?? 0);
433
+ }
434
+ function H(e, t) {
435
+ if (e.totalSize !== t.totalSize || e.startIndex !== t.startIndex || e.endIndex !== t.endIndex || e.viewportHeight !== t.viewportHeight || e.items.length !== t.items.length) return !1;
436
+ for (let n = 0; n < e.items.length; n += 1) {
437
+ let r = e.items[n], i = t.items[n];
438
+ if (r.index !== i.index || r.start !== i.start || r.size !== i.size) return !1;
439
+ }
440
+ return !0;
441
+ }
442
+ function U(e, t, n) {
443
+ let r = [];
444
+ for (let i = e; i <= t; i += 1) {
445
+ let t = i * n;
446
+ r.push({
447
+ index: i,
448
+ start: t,
449
+ size: n,
450
+ end: t + n,
451
+ key: `virtual_slot_${i - e}`
452
+ });
453
+ }
454
+ return r;
455
+ }
456
+ function W(e, t, n) {
457
+ let r = [];
458
+ for (let i = e; i <= t; i += 1) {
459
+ let t = n[i] ?? 0, a = n[i + 1] ?? t;
460
+ r.push({
461
+ index: i,
462
+ start: t,
463
+ size: a - t,
464
+ end: a,
465
+ key: `virtual_slot_${i - e}`
466
+ });
467
+ }
468
+ return r;
469
+ }
470
+ function G(e, t) {
471
+ let n = Math.max(e.count, 0), r = Math.max(e.overscan ?? 6, 0), i = Math.max(e.viewportHeight, 0);
472
+ if (typeof e.estimateSize == "function" && t) {
473
+ let a = t[n] ?? 0, o = Math.max(a - i, 0), s = B(e.scrollOffset ?? 0, 0, o), c = 0, l = n;
474
+ for (; c < l;) {
475
+ let e = c + l >>> 1;
476
+ (t[e + 1] ?? 0) <= s ? c = e + 1 : l = e;
477
+ }
478
+ let u = c, d = s + i;
479
+ for (c = u, l = n; c < l;) {
480
+ let e = c + l >>> 1;
481
+ (t[e] ?? 0) < d ? c = e + 1 : l = e;
482
+ }
483
+ let f = Math.max(c - 1, u), p = n === 0 ? 0 : B(u - r, 0, n - 1), m = n === 0 ? -1 : B(f + r, 0, n - 1);
484
+ return {
485
+ items: m >= p ? W(p, m, t) : [],
486
+ totalSize: a,
487
+ startIndex: p,
488
+ endIndex: m,
489
+ scrollOffset: s,
490
+ viewportHeight: i
491
+ };
492
+ }
493
+ let a = Math.max(typeof e.estimateSize == "number" ? e.estimateSize : 1, 1), o = n * a, s = Math.max(o - i, 0), c = B(e.scrollOffset ?? 0, 0, s), l = Math.floor(c / a), u = Math.ceil(i / a), d = Math.min(l + u, Math.max(n - 1, 0)), f = n === 0 ? 0 : B(l - r, 0, n - 1), p = n === 0 ? -1 : B(d + r, 0, n - 1);
494
+ return {
495
+ items: p >= f ? U(f, p, a) : [],
496
+ totalSize: o,
497
+ startIndex: f,
498
+ endIndex: p,
499
+ scrollOffset: c,
500
+ viewportHeight: i
501
+ };
502
+ }
503
+ function K(e) {
504
+ let t = e, n = null;
505
+ function r() {
506
+ if (typeof t.estimateSize != "function") return null;
507
+ let e = Math.max(t.count, 0);
508
+ if (n && n.fn === t.estimateSize && n.count === e) return n.offsets;
509
+ let r = t.estimateSize, i = Array(e + 1);
510
+ i[0] = 0;
511
+ for (let t = 0; t < e; t += 1) i[t + 1] = i[t] + Math.max(r(t), 1);
512
+ return n = {
513
+ fn: r,
514
+ count: e,
515
+ offsets: i
516
+ }, i;
517
+ }
518
+ let i = G(t, r()), a = /* @__PURE__ */ new Set();
519
+ function o() {
520
+ a.forEach((e) => e());
521
+ }
522
+ function s() {
523
+ let e = G(t, r());
524
+ H(i, e) || (i = e, o());
525
+ }
526
+ return {
527
+ setOptions(e) {
528
+ let n = {
529
+ ...t,
530
+ ...e
531
+ };
532
+ V(t, n) || (t = n, s());
533
+ },
534
+ setScrollOffset(e) {
535
+ (t.scrollOffset ?? 0) !== e && (t = {
536
+ ...t,
537
+ scrollOffset: e
538
+ }, s());
539
+ },
540
+ setViewportHeight(e) {
541
+ t.viewportHeight !== e && (t = {
542
+ ...t,
543
+ viewportHeight: e
544
+ }, s());
545
+ },
546
+ scrollToIndex(e) {
547
+ let n = B(e, 0, Math.max(t.count - 1, 0)), a = i.totalSize, o;
548
+ if (typeof t.estimateSize == "function") {
549
+ let e = r();
550
+ if (e) o = e[n] ?? 0;
551
+ else {
552
+ let e = 0, r = t.estimateSize;
553
+ for (let t = 0; t < n; t += 1) e += Math.max(r(t), 1);
554
+ o = e;
555
+ }
556
+ } else o = n * Math.max(t.estimateSize, 1);
557
+ let c = Math.max(a - t.viewportHeight, 0), l = B(o, 0, c);
558
+ (t.scrollOffset ?? 0) !== l && (t = {
559
+ ...t,
560
+ scrollOffset: l
561
+ }, s());
562
+ },
563
+ getVirtualItems() {
564
+ return i.items;
565
+ },
566
+ getTotalSize() {
567
+ return i.totalSize;
568
+ },
569
+ getOffsetForIndex(e) {
570
+ if (e <= 0) return 0;
571
+ let n = Math.max(t.count, 0), i = Math.min(e, n);
572
+ if (typeof t.estimateSize == "function") {
573
+ let e = r();
574
+ if (e) return e[i] ?? 0;
575
+ let n = 0, a = t.estimateSize;
576
+ for (let e = 0; e < i; e += 1) n += Math.max(a(e), 1);
577
+ return n;
578
+ }
579
+ return i * Math.max(t.estimateSize, 1);
580
+ },
581
+ getSizeForIndex(e) {
582
+ return e < 0 || e >= t.count ? 0 : typeof t.estimateSize == "function" ? Math.max(t.estimateSize(e), 1) : Math.max(t.estimateSize, 1);
583
+ },
584
+ getState() {
585
+ return i;
586
+ },
587
+ subscribe(e) {
588
+ return a.add(e), () => a.delete(e);
589
+ }
590
+ };
591
+ }
592
+ //#endregion
593
+ //#region ../grid/dist/virtualization/svelte-virtualizer.svelte.js
594
+ function q(r) {
595
+ let i = K(r), a = n(0);
596
+ return i.subscribe(() => {
597
+ t(a, e(a) + 1);
598
+ }), {
599
+ get version() {
600
+ return e(a);
601
+ },
602
+ setOptions: i.setOptions,
603
+ setScrollOffset: i.setScrollOffset,
604
+ setViewportHeight: i.setViewportHeight,
605
+ scrollToIndex: i.scrollToIndex,
606
+ getVirtualItems: i.getVirtualItems,
607
+ getTotalSize: i.getTotalSize,
608
+ getOffsetForIndex: i.getOffsetForIndex,
609
+ getSizeForIndex: i.getSizeForIndex,
610
+ getState: i.getState
611
+ };
612
+ }
613
+ //#endregion
614
+ export { A as C, S as E, C as S, v as T, p as _, P as a, x as b, D as c, T as d, k as f, j as g, M as h, I as i, d as l, f as m, K as n, F as o, y as p, z as r, L as s, q as t, O as u, b as v, m as w, w as x, E as y };
package/package.json CHANGED
@@ -4,15 +4,15 @@
4
4
  "type": "commercial",
5
5
  "url": "https://svgrid.com/pricing"
6
6
  },
7
- "version": "2.2.0",
7
+ "version": "2.4.0",
8
8
  "description": "SvGrid as a framework-agnostic web component (<sv-grid> custom element). Drop into React, Vue, Angular, or plain HTML - no build step required.",
9
9
  "type": "module",
10
10
  "license": "MIT",
11
11
  "author": "jQWidgets Ltd",
12
- "homepage": "https://www.svgrid.com",
12
+ "homepage": "https://svgrid.com",
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "https://github.com/sv-grid/sv-grid.git",
15
+ "url": "git+https://github.com/sv-grid/sv-grid.git",
16
16
  "directory": "packages/grid-wc"
17
17
  },
18
18
  "keywords": [
@@ -53,8 +53,8 @@
53
53
  "devDependencies": {
54
54
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
55
55
  "svelte": "^5.55.5",
56
- "vite": "^8.0.10",
57
- "@svgrid/grid": "^2.2.0"
56
+ "vite": "^8.2.1",
57
+ "@svgrid/grid": "^2.4.0"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "vite build",