@ai-matrx/design-system 0.22.0 → 0.25.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/CHANGELOG.md +151 -0
- package/dist/data-table/cell-undo.cjs +98 -0
- package/dist/data-table/cell-undo.cjs.map +1 -0
- package/dist/data-table/cell-undo.d.cts +85 -0
- package/dist/data-table/cell-undo.d.ts +85 -0
- package/dist/data-table/cell-undo.js +78 -0
- package/dist/data-table/cell-undo.js.map +1 -0
- package/dist/data-table/copy-helpers.d.cts +6 -2
- package/dist/data-table/copy-helpers.d.ts +6 -2
- package/dist/data-table/coverage.cjs +116 -0
- package/dist/data-table/coverage.cjs.map +1 -0
- package/dist/data-table/coverage.d.cts +65 -0
- package/dist/data-table/coverage.d.ts +65 -0
- package/dist/data-table/coverage.js +96 -0
- package/dist/data-table/coverage.js.map +1 -0
- package/dist/data-table/fill.cjs +299 -0
- package/dist/data-table/fill.cjs.map +1 -0
- package/dist/data-table/fill.d.cts +129 -0
- package/dist/data-table/fill.d.ts +129 -0
- package/dist/data-table/fill.js +277 -0
- package/dist/data-table/fill.js.map +1 -0
- package/dist/data-table/filter-engine.d.cts +6 -2
- package/dist/data-table/filter-engine.d.ts +6 -2
- package/dist/data-table/grid-clipboard.cjs +165 -0
- package/dist/data-table/grid-clipboard.cjs.map +1 -0
- package/dist/data-table/grid-clipboard.d.cts +85 -0
- package/dist/data-table/grid-clipboard.d.ts +85 -0
- package/dist/data-table/grid-clipboard.js +145 -0
- package/dist/data-table/grid-clipboard.js.map +1 -0
- package/dist/data-table/grid-selection.cjs +258 -0
- package/dist/data-table/grid-selection.cjs.map +1 -0
- package/dist/data-table/grid-selection.d.cts +166 -0
- package/dist/data-table/grid-selection.d.ts +166 -0
- package/dist/data-table/grid-selection.js +238 -0
- package/dist/data-table/grid-selection.js.map +1 -0
- package/dist/data-table/grouping.cjs +302 -0
- package/dist/data-table/grouping.cjs.map +1 -0
- package/dist/data-table/grouping.d.cts +119 -0
- package/dist/data-table/grouping.d.ts +119 -0
- package/dist/data-table/grouping.js +282 -0
- package/dist/data-table/grouping.js.map +1 -0
- package/dist/data-table/host.d.cts +6 -2
- package/dist/data-table/host.d.ts +6 -2
- package/dist/data-table/index.cjs +2433 -246
- package/dist/data-table/index.cjs.map +1 -1
- package/dist/data-table/index.d.cts +11 -3
- package/dist/data-table/index.d.ts +11 -3
- package/dist/data-table/index.js +2425 -238
- package/dist/data-table/index.js.map +1 -1
- package/dist/data-table/infer-filter.d.cts +6 -2
- package/dist/data-table/infer-filter.d.ts +6 -2
- package/dist/data-table/layered-filters.d.cts +6 -2
- package/dist/data-table/layered-filters.d.ts +6 -2
- package/dist/data-table/query-control.d.cts +6 -2
- package/dist/data-table/query-control.d.ts +6 -2
- package/dist/data-table/spreadsheet.cjs +1014 -0
- package/dist/data-table/spreadsheet.cjs.map +1 -0
- package/dist/data-table/spreadsheet.d.cts +118 -0
- package/dist/data-table/spreadsheet.d.ts +118 -0
- package/dist/data-table/spreadsheet.js +994 -0
- package/dist/data-table/spreadsheet.js.map +1 -0
- package/dist/data-table/types.cjs.map +1 -1
- package/dist/data-table/types.d.cts +6 -2
- package/dist/data-table/types.d.ts +6 -2
- package/dist/data-table/url-state.d.cts +6 -2
- package/dist/data-table/url-state.d.ts +6 -2
- package/dist/data-table/validation.cjs +229 -0
- package/dist/data-table/validation.cjs.map +1 -0
- package/dist/data-table/validation.d.cts +125 -0
- package/dist/data-table/validation.d.ts +125 -0
- package/dist/data-table/validation.js +209 -0
- package/dist/data-table/validation.js.map +1 -0
- package/dist/data-table/virtual-window.cjs +203 -0
- package/dist/data-table/virtual-window.cjs.map +1 -0
- package/dist/data-table/virtual-window.d.cts +84 -0
- package/dist/data-table/virtual-window.d.ts +84 -0
- package/dist/data-table/virtual-window.js +183 -0
- package/dist/data-table/virtual-window.js.map +1 -0
- package/dist/data-table/xlsx.d.cts +6 -2
- package/dist/data-table/xlsx.d.ts +6 -2
- package/dist/field-formats/index.d.cts +2 -2
- package/dist/field-formats/index.d.ts +2 -2
- package/dist/formulas/index.cjs +1041 -0
- package/dist/formulas/index.cjs.map +1 -0
- package/dist/formulas/index.d.cts +389 -0
- package/dist/formulas/index.d.ts +389 -0
- package/dist/formulas/index.js +1019 -0
- package/dist/formulas/index.js.map +1 -0
- package/dist/{types-BdbvlF9-.d.cts → types-CJWU1Gae.d.cts} +1 -1
- package/dist/{types-BdbvlF9-.d.ts → types-CJWU1Gae.d.ts} +1 -1
- package/dist/{types-Sn249eoy.d.cts → types-CmQrOz-T.d.cts} +154 -2
- package/dist/{types-D-flTpK0.d.ts → types-nlLCMiqd.d.ts} +154 -2
- package/package.json +109 -2
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
|
|
2
|
+
// src/data-table/virtual-window.ts
|
|
3
|
+
var DEFAULT_OVERSCAN = 6;
|
|
4
|
+
function isNum(value) {
|
|
5
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
6
|
+
}
|
|
7
|
+
function toCount(value) {
|
|
8
|
+
return isNum(value) && value > 0 ? Math.floor(value) : 0;
|
|
9
|
+
}
|
|
10
|
+
function toLength(value) {
|
|
11
|
+
return isNum(value) && value > 0 ? value : 0;
|
|
12
|
+
}
|
|
13
|
+
function toOverscan(value) {
|
|
14
|
+
if (!isNum(value)) return DEFAULT_OVERSCAN;
|
|
15
|
+
return value > 0 ? Math.floor(value) : 0;
|
|
16
|
+
}
|
|
17
|
+
function toPinned(value, count) {
|
|
18
|
+
if (!isNum(value) || value <= 0) return 0;
|
|
19
|
+
return Math.min(Math.floor(value), count);
|
|
20
|
+
}
|
|
21
|
+
function assemble(args) {
|
|
22
|
+
const { pinnedCount, start, end, padStart, body, total } = args;
|
|
23
|
+
let padEnd = total - (padStart + body);
|
|
24
|
+
if (!Number.isFinite(padEnd)) padEnd = 0;
|
|
25
|
+
const sum = padStart + body + padEnd;
|
|
26
|
+
if (sum !== total) padEnd = padEnd + (total - sum);
|
|
27
|
+
const pinned = [];
|
|
28
|
+
for (let i = 0; i < pinnedCount; i += 1) pinned.push(i);
|
|
29
|
+
return { start, end, padStart, padEnd, total, pinned };
|
|
30
|
+
}
|
|
31
|
+
function emptyWindow(pinnedCount) {
|
|
32
|
+
const pinned = [];
|
|
33
|
+
for (let i = 0; i < pinnedCount; i += 1) pinned.push(i);
|
|
34
|
+
return { start: pinnedCount, end: pinnedCount, padStart: 0, padEnd: 0, total: 0, pinned };
|
|
35
|
+
}
|
|
36
|
+
function band(firstVisible, lastVisible, scrollCount, overscan) {
|
|
37
|
+
let first = firstVisible;
|
|
38
|
+
if (first > scrollCount - 1) first = scrollCount - 1;
|
|
39
|
+
if (first < 0) first = 0;
|
|
40
|
+
let last = lastVisible;
|
|
41
|
+
if (last < first + 1) last = first + 1;
|
|
42
|
+
if (last > scrollCount) last = scrollCount;
|
|
43
|
+
const start = Math.max(0, first - overscan);
|
|
44
|
+
let end = Math.min(scrollCount, last + overscan);
|
|
45
|
+
if (end < start) end = start;
|
|
46
|
+
return { start, end };
|
|
47
|
+
}
|
|
48
|
+
function computeWindow(input) {
|
|
49
|
+
const count = toCount(input?.count);
|
|
50
|
+
const pinnedCount = toPinned(input?.pinnedStart, count);
|
|
51
|
+
if (count <= 0) return emptyWindow(0);
|
|
52
|
+
const itemSize = toLength(input?.itemSize);
|
|
53
|
+
const viewport = toLength(input?.viewport);
|
|
54
|
+
const overscan = toOverscan(input?.overscan);
|
|
55
|
+
const scrollCount = count - pinnedCount;
|
|
56
|
+
if (scrollCount <= 0) return emptyWindow(pinnedCount);
|
|
57
|
+
if (itemSize <= 0) {
|
|
58
|
+
return assemble({ pinnedCount, start: pinnedCount, end: count, padStart: 0, body: 0, total: 0 });
|
|
59
|
+
}
|
|
60
|
+
const total = scrollCount * itemSize;
|
|
61
|
+
const maxOffset = Math.max(0, total - viewport);
|
|
62
|
+
const offset = Math.min(toLength(input?.offset), maxOffset);
|
|
63
|
+
const { start: relStart, end: relEnd } = band(
|
|
64
|
+
Math.floor(offset / itemSize),
|
|
65
|
+
Math.ceil((offset + viewport) / itemSize),
|
|
66
|
+
scrollCount,
|
|
67
|
+
overscan
|
|
68
|
+
);
|
|
69
|
+
return assemble({
|
|
70
|
+
pinnedCount,
|
|
71
|
+
start: pinnedCount + relStart,
|
|
72
|
+
end: pinnedCount + relEnd,
|
|
73
|
+
padStart: relStart * itemSize,
|
|
74
|
+
body: (relEnd - relStart) * itemSize,
|
|
75
|
+
total
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
var PREFIX_CACHE = /* @__PURE__ */ new WeakMap();
|
|
79
|
+
function prefixFor(sizeAt, count) {
|
|
80
|
+
let byCount = PREFIX_CACHE.get(sizeAt);
|
|
81
|
+
if (!byCount) {
|
|
82
|
+
byCount = /* @__PURE__ */ new Map();
|
|
83
|
+
PREFIX_CACHE.set(sizeAt, byCount);
|
|
84
|
+
}
|
|
85
|
+
const cached = byCount.get(count);
|
|
86
|
+
if (cached) return cached;
|
|
87
|
+
const prefix = new Float64Array(count + 1);
|
|
88
|
+
let running = 0;
|
|
89
|
+
for (let i = 0; i < count; i += 1) {
|
|
90
|
+
let size = 0;
|
|
91
|
+
try {
|
|
92
|
+
size = sizeAt(i);
|
|
93
|
+
} catch {
|
|
94
|
+
size = 0;
|
|
95
|
+
}
|
|
96
|
+
running += isNum(size) && size > 0 ? size : 0;
|
|
97
|
+
prefix[i + 1] = running;
|
|
98
|
+
}
|
|
99
|
+
byCount.set(count, prefix);
|
|
100
|
+
return prefix;
|
|
101
|
+
}
|
|
102
|
+
function at(prefix, index) {
|
|
103
|
+
return prefix[index] ?? 0;
|
|
104
|
+
}
|
|
105
|
+
function lastAtOrBefore(prefix, lo, hi, target) {
|
|
106
|
+
let a = lo;
|
|
107
|
+
let b = hi;
|
|
108
|
+
while (a < b) {
|
|
109
|
+
const mid = a + Math.ceil((b - a) / 2);
|
|
110
|
+
if (at(prefix, mid) <= target) a = mid;
|
|
111
|
+
else b = mid - 1;
|
|
112
|
+
}
|
|
113
|
+
return a;
|
|
114
|
+
}
|
|
115
|
+
function firstAtOrAfter(prefix, lo, hi, target) {
|
|
116
|
+
let a = lo;
|
|
117
|
+
let b = hi;
|
|
118
|
+
while (a < b) {
|
|
119
|
+
const mid = a + Math.floor((b - a) / 2);
|
|
120
|
+
if (at(prefix, mid) >= target) b = mid;
|
|
121
|
+
else a = mid + 1;
|
|
122
|
+
}
|
|
123
|
+
return a;
|
|
124
|
+
}
|
|
125
|
+
function computeVariableWindow(input) {
|
|
126
|
+
const count = toCount(input?.count);
|
|
127
|
+
const pinnedCount = toPinned(input?.pinnedStart, count);
|
|
128
|
+
if (count <= 0) return emptyWindow(0);
|
|
129
|
+
const sizeAt = typeof input?.sizeAt === "function" ? input.sizeAt : () => 0;
|
|
130
|
+
const viewport = toLength(input?.viewport);
|
|
131
|
+
const overscan = toOverscan(input?.overscan);
|
|
132
|
+
const scrollCount = count - pinnedCount;
|
|
133
|
+
if (scrollCount <= 0) return emptyWindow(pinnedCount);
|
|
134
|
+
const prefix = prefixFor(sizeAt, count);
|
|
135
|
+
const pinnedLength = at(prefix, pinnedCount);
|
|
136
|
+
const total = at(prefix, count) - pinnedLength;
|
|
137
|
+
if (total <= 0) {
|
|
138
|
+
return assemble({ pinnedCount, start: pinnedCount, end: count, padStart: 0, body: 0, total: total > 0 ? total : 0 });
|
|
139
|
+
}
|
|
140
|
+
const maxOffset = Math.max(0, total - viewport);
|
|
141
|
+
const offset = Math.min(toLength(input?.offset), maxOffset);
|
|
142
|
+
const firstVisible = lastAtOrBefore(prefix, pinnedCount, count, pinnedLength + offset) - pinnedCount;
|
|
143
|
+
const lastVisible = firstAtOrAfter(prefix, pinnedCount, count, pinnedLength + offset + viewport) - pinnedCount;
|
|
144
|
+
const { start: relStart, end: relEnd } = band(firstVisible, lastVisible, scrollCount, overscan);
|
|
145
|
+
const absStart = pinnedCount + relStart;
|
|
146
|
+
const absEnd = pinnedCount + relEnd;
|
|
147
|
+
return assemble({
|
|
148
|
+
pinnedCount,
|
|
149
|
+
start: absStart,
|
|
150
|
+
end: absEnd,
|
|
151
|
+
padStart: at(prefix, absStart) - pinnedLength,
|
|
152
|
+
body: at(prefix, absEnd) - at(prefix, absStart),
|
|
153
|
+
total
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function scrollOffsetForIndex(input) {
|
|
157
|
+
const count = toCount(input?.count);
|
|
158
|
+
if (count <= 0) return null;
|
|
159
|
+
const pinnedCount = toPinned(input?.pinnedStart, count);
|
|
160
|
+
const itemSize = toLength(input?.itemSize);
|
|
161
|
+
const viewport = toLength(input?.viewport);
|
|
162
|
+
const scrollCount = count - pinnedCount;
|
|
163
|
+
if (scrollCount <= 0 || itemSize <= 0) return null;
|
|
164
|
+
const rawIndex = isNum(input?.index) ? Math.floor(input.index) : 0;
|
|
165
|
+
const index = Math.min(Math.max(rawIndex, 0), count - 1);
|
|
166
|
+
if (index < pinnedCount) return null;
|
|
167
|
+
const total = scrollCount * itemSize;
|
|
168
|
+
const maxOffset = Math.max(0, total - viewport);
|
|
169
|
+
const offset = Math.min(toLength(input?.offset), maxOffset);
|
|
170
|
+
const itemStart = (index - pinnedCount) * itemSize;
|
|
171
|
+
const itemEnd = itemStart + itemSize;
|
|
172
|
+
if (itemStart >= offset && itemEnd <= offset + viewport) return null;
|
|
173
|
+
const next = itemStart < offset ? itemStart : itemEnd - viewport;
|
|
174
|
+
const clamped = Math.min(Math.max(next, 0), maxOffset);
|
|
175
|
+
return clamped === offset ? null : clamped;
|
|
176
|
+
}
|
|
177
|
+
export {
|
|
178
|
+
DEFAULT_OVERSCAN,
|
|
179
|
+
computeVariableWindow,
|
|
180
|
+
computeWindow,
|
|
181
|
+
scrollOffsetForIndex
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=virtual-window.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data-table/virtual-window.ts"],"sourcesContent":["/**\n * Row / column windowing math for the canonical data table.\n *\n * Pure arithmetic: no React, no DOM, no measurement. The table hands in what it\n * knows (how many items, how big they are, how much of them the viewport shows,\n * where the scroller is) and gets back the slice it should actually render plus\n * the two spacers that keep the scrollbar honest.\n *\n * THE INVARIANT this module exists to hold:\n *\n * padStart + (end - start) * itemSize + padEnd === total\n *\n * exactly, for every input. A scrollbar whose thumb size disagrees with the\n * content it can reach is a lie on screen, so `padEnd` is computed as the\n * residual of `total` rather than as an independent multiplication, and the\n * sum is re-checked and corrected once against floating-point drift.\n *\n * PINNED ITEMS (frozen columns) live OUTSIDE the scrollable length. They are\n * always rendered, they are never counted in `padStart`, and the scrollable\n * `total` covers only the items after them. `offset` is therefore measured\n * inside the scrollable region: offset 0 shows item index `pinnedStart`.\n */\n\n/** Items rendered outside the viewport on each side when the caller says nothing. */\nexport const DEFAULT_OVERSCAN = 6;\n\nexport interface WindowInput {\n /** Total item count. */\n count: number;\n /** Fixed item size in px (row height, or column width when windowing columns). */\n itemSize: number;\n /** Visible viewport length in px along the windowed axis. */\n viewport: number;\n /** Current scroll offset in px along that axis. */\n offset: number;\n /** Extra items rendered outside the viewport on each side. Default 6. */\n overscan?: number;\n /** Items pinned at the start that never leave the DOM (frozen columns). Default 0. */\n pinnedStart?: number;\n}\n\nexport interface WindowResult {\n /** First rendered index, inclusive. */\n start: number;\n /** Last rendered index, EXCLUSIVE. */\n end: number;\n /** Spacer length in px before `start` (excluding pinned items). */\n padStart: number;\n /** Spacer length in px after `end`. */\n padEnd: number;\n /** Total scrollable length in px. */\n total: number;\n /** Indexes pinned at the start that are always rendered, ascending. */\n pinned: number[];\n}\n\nexport interface VariableWindowInput extends Omit<WindowInput, \"itemSize\"> {\n /** Size in px of the item at `index`. Must be pure and stable for a given index. */\n sizeAt: (index: number) => number;\n}\n\n/* ------------------------------------------------------------------ */\n/* clamping — nothing here throws, every hostile number is flattened */\n/* ------------------------------------------------------------------ */\n\nfunction isNum(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value);\n}\n\n/** Whole, non-negative item count. NaN / Infinity / negatives collapse to 0. */\nfunction toCount(value: number): number {\n return isNum(value) && value > 0 ? Math.floor(value) : 0;\n}\n\n/** Non-negative px length. NaN / Infinity / negatives collapse to 0. */\nfunction toLength(value: number): number {\n return isNum(value) && value > 0 ? value : 0;\n}\n\nfunction toOverscan(value: number | undefined): number {\n if (!isNum(value)) return DEFAULT_OVERSCAN;\n return value > 0 ? Math.floor(value) : 0;\n}\n\nfunction toPinned(value: number | undefined, count: number): number {\n if (!isNum(value) || value <= 0) return 0;\n return Math.min(Math.floor(value), count);\n}\n\n/**\n * Assemble the result, deriving `padEnd` as the residual of `total` so the\n * invariant holds bit-for-bit, then correcting one rounding step if the sum\n * the caller will compute still drifts.\n */\nfunction assemble(args: {\n pinnedCount: number;\n start: number;\n end: number;\n padStart: number;\n body: number;\n total: number;\n}): WindowResult {\n const { pinnedCount, start, end, padStart, body, total } = args;\n let padEnd = total - (padStart + body);\n if (!Number.isFinite(padEnd)) padEnd = 0;\n const sum = padStart + body + padEnd;\n if (sum !== total) padEnd = padEnd + (total - sum);\n const pinned: number[] = [];\n for (let i = 0; i < pinnedCount; i += 1) pinned.push(i);\n return { start, end, padStart, padEnd, total, pinned };\n}\n\n/** A window that renders nothing but still names whatever is pinned. */\nfunction emptyWindow(pinnedCount: number): WindowResult {\n const pinned: number[] = [];\n for (let i = 0; i < pinnedCount; i += 1) pinned.push(i);\n return { start: pinnedCount, end: pinnedCount, padStart: 0, padEnd: 0, total: 0, pinned };\n}\n\n/**\n * The visible band, in RELATIVE indexes inside the scrollable region, widened\n * by overscan and clamped by both ends. Shared by the fixed and variable paths\n * so the two agree exactly when sizes are constant.\n */\nfunction band(firstVisible: number, lastVisible: number, scrollCount: number, overscan: number): { start: number; end: number } {\n let first = firstVisible;\n if (first > scrollCount - 1) first = scrollCount - 1;\n if (first < 0) first = 0;\n let last = lastVisible;\n if (last < first + 1) last = first + 1;\n if (last > scrollCount) last = scrollCount;\n const start = Math.max(0, first - overscan);\n let end = Math.min(scrollCount, last + overscan);\n if (end < start) end = start;\n return { start, end };\n}\n\n/* ------------------------------------------------------------------ */\n/* fixed-size windowing */\n/* ------------------------------------------------------------------ */\n\n/**\n * The slice to render for uniformly sized items.\n *\n * O(1). Never returns `start < 0`, `end > count`, or `end < start`.\n */\nexport function computeWindow(input: WindowInput): WindowResult {\n const count = toCount(input?.count as number);\n const pinnedCount = toPinned(input?.pinnedStart, count);\n if (count <= 0) return emptyWindow(0);\n\n const itemSize = toLength(input?.itemSize as number);\n const viewport = toLength(input?.viewport as number);\n const overscan = toOverscan(input?.overscan);\n const scrollCount = count - pinnedCount;\n\n if (scrollCount <= 0) return emptyWindow(pinnedCount);\n\n if (itemSize <= 0) {\n // Zero-height items: nothing to scroll, so render the whole scrollable run.\n return assemble({ pinnedCount, start: pinnedCount, end: count, padStart: 0, body: 0, total: 0 });\n }\n\n const total = scrollCount * itemSize;\n const maxOffset = Math.max(0, total - viewport);\n const offset = Math.min(toLength(input?.offset as number), maxOffset);\n\n const { start: relStart, end: relEnd } = band(\n Math.floor(offset / itemSize),\n Math.ceil((offset + viewport) / itemSize),\n scrollCount,\n overscan,\n );\n\n return assemble({\n pinnedCount,\n start: pinnedCount + relStart,\n end: pinnedCount + relEnd,\n padStart: relStart * itemSize,\n body: (relEnd - relStart) * itemSize,\n total,\n });\n}\n\n/* ------------------------------------------------------------------ */\n/* variable-size windowing */\n/* ------------------------------------------------------------------ */\n\n/**\n * Prefix sums keyed by the `sizeAt` identity and the item count, so repeated\n * calls during a scroll do NOT walk the list again. `sizeAt` must be pure:\n * a different measurement for the same index needs a new function identity.\n */\nconst PREFIX_CACHE = new WeakMap<(index: number) => number, Map<number, Float64Array>>();\n\nfunction prefixFor(sizeAt: (index: number) => number, count: number): Float64Array {\n let byCount = PREFIX_CACHE.get(sizeAt);\n if (!byCount) {\n byCount = new Map<number, Float64Array>();\n PREFIX_CACHE.set(sizeAt, byCount);\n }\n const cached = byCount.get(count);\n if (cached) return cached;\n const prefix = new Float64Array(count + 1);\n let running = 0;\n for (let i = 0; i < count; i += 1) {\n let size = 0;\n try {\n size = sizeAt(i);\n } catch {\n size = 0;\n }\n running += isNum(size) && size > 0 ? size : 0;\n prefix[i + 1] = running;\n }\n byCount.set(count, prefix);\n return prefix;\n}\n\nfunction at(prefix: Float64Array, index: number): number {\n return prefix[index] ?? 0;\n}\n\n/** Largest `i` in `[lo, hi]` whose prefix is <= `target`. */\nfunction lastAtOrBefore(prefix: Float64Array, lo: number, hi: number, target: number): number {\n let a = lo;\n let b = hi;\n while (a < b) {\n const mid = a + Math.ceil((b - a) / 2);\n if (at(prefix, mid) <= target) a = mid;\n else b = mid - 1;\n }\n return a;\n}\n\n/** Smallest `j` in `[lo, hi]` whose prefix is >= `target`. */\nfunction firstAtOrAfter(prefix: Float64Array, lo: number, hi: number, target: number): number {\n let a = lo;\n let b = hi;\n while (a < b) {\n const mid = a + Math.floor((b - a) / 2);\n if (at(prefix, mid) >= target) b = mid;\n else a = mid + 1;\n }\n return a;\n}\n\n/**\n * The slice to render for items whose size varies by index.\n *\n * Agrees with `computeWindow` exactly when `sizeAt` is constant. The prefix-sum\n * array is built once per `(sizeAt, count)` pair and then binary-searched, so a\n * scroll costs O(log count) per call after the first O(count) build.\n */\nexport function computeVariableWindow(input: VariableWindowInput): WindowResult {\n const count = toCount(input?.count as number);\n const pinnedCount = toPinned(input?.pinnedStart, count);\n if (count <= 0) return emptyWindow(0);\n\n const sizeAt = typeof input?.sizeAt === \"function\" ? input.sizeAt : () => 0;\n const viewport = toLength(input?.viewport as number);\n const overscan = toOverscan(input?.overscan);\n const scrollCount = count - pinnedCount;\n\n if (scrollCount <= 0) return emptyWindow(pinnedCount);\n\n const prefix = prefixFor(sizeAt, count);\n const pinnedLength = at(prefix, pinnedCount);\n const total = at(prefix, count) - pinnedLength;\n\n if (total <= 0) {\n return assemble({ pinnedCount, start: pinnedCount, end: count, padStart: 0, body: 0, total: total > 0 ? total : 0 });\n }\n\n const maxOffset = Math.max(0, total - viewport);\n const offset = Math.min(toLength(input?.offset as number), maxOffset);\n\n const firstVisible = lastAtOrBefore(prefix, pinnedCount, count, pinnedLength + offset) - pinnedCount;\n const lastVisible = firstAtOrAfter(prefix, pinnedCount, count, pinnedLength + offset + viewport) - pinnedCount;\n\n const { start: relStart, end: relEnd } = band(firstVisible, lastVisible, scrollCount, overscan);\n const absStart = pinnedCount + relStart;\n const absEnd = pinnedCount + relEnd;\n\n return assemble({\n pinnedCount,\n start: absStart,\n end: absEnd,\n padStart: at(prefix, absStart) - pinnedLength,\n body: at(prefix, absEnd) - at(prefix, absStart),\n total,\n });\n}\n\n/* ------------------------------------------------------------------ */\n/* scroll-to-index */\n/* ------------------------------------------------------------------ */\n\nexport interface ScrollToIndexInput extends WindowInput {\n /** The item to bring into view. */\n index: number;\n}\n\n/**\n * The scroll offset that brings `index` fully into view, or `null` when it is\n * already fully visible (pinned items are always visible, so they return\n * `null` too). Moves the minimum distance: up to the item's own start when it\n * sits above the viewport, down until its end meets the viewport end when it\n * sits below.\n */\nexport function scrollOffsetForIndex(input: ScrollToIndexInput): number | null {\n const count = toCount(input?.count as number);\n if (count <= 0) return null;\n const pinnedCount = toPinned(input?.pinnedStart, count);\n const itemSize = toLength(input?.itemSize as number);\n const viewport = toLength(input?.viewport as number);\n const scrollCount = count - pinnedCount;\n if (scrollCount <= 0 || itemSize <= 0) return null;\n\n const rawIndex = isNum(input?.index) ? Math.floor(input.index) : 0;\n const index = Math.min(Math.max(rawIndex, 0), count - 1);\n if (index < pinnedCount) return null; // pinned: never leaves the DOM\n\n const total = scrollCount * itemSize;\n const maxOffset = Math.max(0, total - viewport);\n const offset = Math.min(toLength(input?.offset as number), maxOffset);\n\n const itemStart = (index - pinnedCount) * itemSize;\n const itemEnd = itemStart + itemSize;\n\n if (itemStart >= offset && itemEnd <= offset + viewport) return null;\n\n const next = itemStart < offset ? itemStart : itemEnd - viewport;\n const clamped = Math.min(Math.max(next, 0), maxOffset);\n return clamped === offset ? null : clamped;\n}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,SAAS,qBAAqB,OAA0C;AAC7E,QAAM,QAAQ,QAAQ,OAAO,KAAe;AAC5C,MAAI,SAAS,EAAG,QAAO;AACvB,QAAM,cAAc,SAAS,OAAO,aAAa,KAAK;AACtD,QAAM,WAAW,SAAS,OAAO,QAAkB;AACnD,QAAM,WAAW,SAAS,OAAO,QAAkB;AACnD,QAAM,cAAc,QAAQ;AAC5B,MAAI,eAAe,KAAK,YAAY,EAAG,QAAO;AAE9C,QAAM,WAAW,MAAM,OAAO,KAAK,IAAI,KAAK,MAAM,MAAM,KAAK,IAAI;AACjE,QAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,UAAU,CAAC,GAAG,QAAQ,CAAC;AACvD,MAAI,QAAQ,YAAa,QAAO;AAEhC,QAAM,QAAQ,cAAc;AAC5B,QAAM,YAAY,KAAK,IAAI,GAAG,QAAQ,QAAQ;AAC9C,QAAM,SAAS,KAAK,IAAI,SAAS,OAAO,MAAgB,GAAG,SAAS;AAEpE,QAAM,aAAa,QAAQ,eAAe;AAC1C,QAAM,UAAU,YAAY;AAE5B,MAAI,aAAa,UAAU,WAAW,SAAS,SAAU,QAAO;AAEhE,QAAM,OAAO,YAAY,SAAS,YAAY,UAAU;AACxD,QAAM,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,GAAG,SAAS;AACrD,SAAO,YAAY,SAAS,OAAO;AACrC;","names":[]}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { M as MatrxColumnDef } from '../types-
|
|
1
|
+
import { M as MatrxColumnDef } from '../types-CmQrOz-T.cjs';
|
|
2
2
|
import '../content-transfer.cjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@ai-matrx/kit/content-transfer';
|
|
5
5
|
import '../content-transfer/icon.cjs';
|
|
6
6
|
import './copy-types.cjs';
|
|
7
|
-
import '../types-
|
|
7
|
+
import '../types-CJWU1Gae.cjs';
|
|
8
|
+
import './grouping.cjs';
|
|
9
|
+
import './fill.cjs';
|
|
10
|
+
import './spreadsheet.cjs';
|
|
11
|
+
import './grid-selection.cjs';
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* Download the same visible columns and rendered cell values used by the
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { M as MatrxColumnDef } from '../types-
|
|
1
|
+
import { M as MatrxColumnDef } from '../types-nlLCMiqd.js';
|
|
2
2
|
import '../content-transfer.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@ai-matrx/kit/content-transfer';
|
|
5
5
|
import '../content-transfer/icon.js';
|
|
6
6
|
import './copy-types.js';
|
|
7
|
-
import '../types-
|
|
7
|
+
import '../types-CJWU1Gae.js';
|
|
8
|
+
import './grouping.js';
|
|
9
|
+
import './fill.js';
|
|
10
|
+
import './spreadsheet.js';
|
|
11
|
+
import './grid-selection.js';
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* Download the same visible columns and rendered cell values used by the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { d as FieldBaseType, e as FieldChoice, f as FieldEditorKind, g as FieldFormatOptions, S as StructuredListBinding } from '../types-
|
|
1
|
+
import { a as FieldFormatId, b as FieldFormatDef, F as FieldFormatConfig, c as FormatResult } from '../types-CJWU1Gae.cjs';
|
|
2
|
+
export { d as FieldBaseType, e as FieldChoice, f as FieldEditorKind, g as FieldFormatOptions, S as StructuredListBinding } from '../types-CJWU1Gae.cjs';
|
|
3
3
|
|
|
4
4
|
declare const FIELD_FORMATS: Readonly<Record<FieldFormatId, FieldFormatDef>>;
|
|
5
5
|
declare const FIELD_FORMAT_LIST: readonly FieldFormatDef[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { d as FieldBaseType, e as FieldChoice, f as FieldEditorKind, g as FieldFormatOptions, S as StructuredListBinding } from '../types-
|
|
1
|
+
import { a as FieldFormatId, b as FieldFormatDef, F as FieldFormatConfig, c as FormatResult } from '../types-CJWU1Gae.js';
|
|
2
|
+
export { d as FieldBaseType, e as FieldChoice, f as FieldEditorKind, g as FieldFormatOptions, S as StructuredListBinding } from '../types-CJWU1Gae.js';
|
|
3
3
|
|
|
4
4
|
declare const FIELD_FORMATS: Readonly<Record<FieldFormatId, FieldFormatDef>>;
|
|
5
5
|
declare const FIELD_FORMAT_LIST: readonly FieldFormatDef[];
|