@easyv/biz-components 2.1.5 → 2.1.6

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.
Files changed (84) hide show
  1. package/dist/lib/components/ai-components/mobile-voice-input/icon-button.es.js +1 -1
  2. package/dist/lib/components/ai-components/mobile-voice-input/mobile-voice-input.es.js +5 -5
  3. package/dist/lib/components/code-mirror-editor/code-mirror-editor.es.js +9 -9
  4. package/dist/lib/components/code-mirror-editor/code-mirror-editor.es.js.map +1 -1
  5. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-context-menu.es.js +84 -0
  6. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-context-menu.es.js.map +1 -0
  7. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-editable-cell.es.js +58 -0
  8. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-editable-cell.es.js.map +1 -0
  9. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-selection.hook.es.js +97 -0
  10. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus-selection.hook.es.js.map +1 -0
  11. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus.es.js +1063 -0
  12. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid-plus.es.js.map +1 -0
  13. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid.module.less.es.js +7 -0
  14. package/dist/lib/components/easyv-reactgrid-plus/easyv-react-grid.module.less.es.js.map +1 -0
  15. package/dist/lib/components/easyv-reactgrid-plus/utils.es.js +93 -0
  16. package/dist/lib/components/easyv-reactgrid-plus/utils.es.js.map +1 -0
  17. package/dist/lib/easyv-biz-components/src/components/code-mirror-editor/code-mirror-editor.d.ts +2 -2
  18. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus-context-menu.d.ts +14 -0
  19. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus-editable-cell.d.ts +11 -0
  20. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus-selection.hook.d.ts +16 -0
  21. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus.d.ts +16 -0
  22. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/easyv-react-grid-plus.types.d.ts +18 -0
  23. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/index.d.ts +1 -0
  24. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/test/easyv-react-grid-plus.cy.d.ts +1 -0
  25. package/dist/lib/easyv-biz-components/src/components/easyv-reactgrid-plus/utils.d.ts +6 -0
  26. package/dist/lib/easyv-biz-components/src/components/index.d.ts +1 -0
  27. package/dist/lib/easyv-biz-components/src/utils/ai-agent-message-manager/constants.d.ts +3 -1
  28. package/dist/lib/easyv-biz-components/src/utils/ai-agent-message-manager/types.d.ts +1 -0
  29. package/dist/lib/easyv-biz-components/src/utils/ai-agent-message-manager/utils.d.ts +1 -0
  30. package/dist/lib/easyv-biz-components/src/utils/easy-fetch/easy-fetch.d.ts +13 -0
  31. package/dist/lib/easyv-biz-components/src/utils/easy-fetch/index.d.ts +1 -0
  32. package/dist/lib/easyv-biz-components/src/utils/easy-fetch/test/easy-fetch.cy.d.ts +1 -0
  33. package/dist/lib/easyv-biz-components/src/utils/easy-fetch/types.d.ts +6 -0
  34. package/dist/lib/easyv-biz-components/src/utils/easyv-gui-helper/component-dimension.d.ts +2 -0
  35. package/dist/lib/easyv-biz-components/src/utils/easyv-gui-helper/easyv-gui-helper.d.ts +3 -0
  36. package/dist/lib/easyv-biz-components/src/utils/easyv-gui-helper/types.d.ts +3 -0
  37. package/dist/lib/easyv-biz-components/src/utils/index.d.ts +2 -0
  38. package/dist/lib/easyv-biz-components/src/utils/twin/index.d.ts +1 -0
  39. package/dist/lib/easyv-biz-components/src/utils/twin/utils.d.ts +5 -0
  40. package/dist/lib/hooks/use-tencent-sentence-recognition/use-tencent-sentence-recognition.es.js +2 -2
  41. package/dist/lib/index.es.js +8 -1
  42. package/dist/lib/index.es.js.map +1 -1
  43. package/dist/lib/node_modules/.pnpm/@tanstack_react-table@8.21.3_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-table/build/lib/index.es.js +103 -0
  44. package/dist/lib/node_modules/.pnpm/@tanstack_react-table@8.21.3_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-table/build/lib/index.es.js.map +1 -0
  45. package/dist/lib/node_modules/.pnpm/@tanstack_react-virtual@3.13.23_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-virtual/dist/esm/index.es.js +53 -0
  46. package/dist/lib/node_modules/.pnpm/@tanstack_react-virtual@3.13.23_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@tanstack/react-virtual/dist/esm/index.es.js.map +1 -0
  47. package/dist/lib/node_modules/.pnpm/@tanstack_table-core@8.21.3/node_modules/@tanstack/table-core/build/lib/index.es.js +2672 -0
  48. package/dist/lib/node_modules/.pnpm/@tanstack_table-core@8.21.3/node_modules/@tanstack/table-core/build/lib/index.es.js.map +1 -0
  49. package/dist/lib/node_modules/.pnpm/@tanstack_virtual-core@3.13.23/node_modules/@tanstack/virtual-core/dist/esm/index.es.js +871 -0
  50. package/dist/lib/node_modules/.pnpm/@tanstack_virtual-core@3.13.23/node_modules/@tanstack/virtual-core/dist/esm/index.es.js.map +1 -0
  51. package/dist/lib/node_modules/.pnpm/@tanstack_virtual-core@3.13.23/node_modules/@tanstack/virtual-core/dist/esm/utils.es.js +73 -0
  52. package/dist/lib/node_modules/.pnpm/@tanstack_virtual-core@3.13.23/node_modules/@tanstack/virtual-core/dist/esm/utils.es.js.map +1 -0
  53. package/dist/lib/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.es.js +11 -0
  54. package/dist/lib/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.es.js.map +1 -0
  55. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{button-Dip6wfc7.es.es.js → button-VOE5PncW.es.es.js} +2 -2
  56. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{button-Dip6wfc7.es.es.js.map → button-VOE5PncW.es.es.js.map} +1 -1
  57. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{index-EAFzPBke.es.es.js → index-6AIVHTQ0.es.es.js} +11 -11
  58. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{index-EAFzPBke.es.es.js.map → index-6AIVHTQ0.es.es.js.map} +1 -1
  59. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{index-zvVd1BJp.es.es.js → index-DttpqRHH.es.es.js} +596 -605
  60. package/dist/lib/packages/easyv-arco/dist/lib/chunks/index-DttpqRHH.es.es.js.map +1 -0
  61. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{input-Dhdn9e9Z.es.es.js → input-CqQJPvav.es.es.js} +54 -54
  62. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{input-Dhdn9e9Z.es.es.js.map → input-CqQJPvav.es.es.js.map} +1 -1
  63. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{keycode-DOHuQiUY.es.es.js → keycode-cVKDBtW_.es.es.js} +4 -4
  64. package/dist/lib/packages/easyv-arco/dist/lib/chunks/{keycode-DOHuQiUY.es.es.js.map → keycode-cVKDBtW_.es.es.js.map} +1 -1
  65. package/dist/lib/packages/easyv-arco/dist/lib/index.es.es.js.map +1 -1
  66. package/dist/lib/stats.html +1 -1
  67. package/dist/lib/style.pkg.css +1 -1
  68. package/dist/lib/utils/ai-agent-message-manager/ai-agent-message-manager.es.js +9 -1
  69. package/dist/lib/utils/ai-agent-message-manager/ai-agent-message-manager.es.js.map +1 -1
  70. package/dist/lib/utils/ai-agent-message-manager/constants.es.js +4 -2
  71. package/dist/lib/utils/ai-agent-message-manager/constants.es.js.map +1 -1
  72. package/dist/lib/utils/ai-agent-message-manager/types.es.js.map +1 -1
  73. package/dist/lib/utils/ai-agent-message-manager/utils.es.js +10 -0
  74. package/dist/lib/utils/ai-agent-message-manager/utils.es.js.map +1 -0
  75. package/dist/lib/utils/easy-fetch/easy-fetch.es.js +88 -0
  76. package/dist/lib/utils/easy-fetch/easy-fetch.es.js.map +1 -0
  77. package/dist/lib/utils/easyv-gui-helper/easyv-gui-helper.es.js +13 -4
  78. package/dist/lib/utils/easyv-gui-helper/easyv-gui-helper.es.js.map +1 -1
  79. package/dist/lib/utils/show-modal/show-modal.es.js +5 -5
  80. package/dist/lib/utils/twin/utils.es.js +30 -0
  81. package/dist/lib/utils/twin/utils.es.js.map +1 -0
  82. package/dist/tailwindcss.pkg.css +113 -0
  83. package/package.json +13 -7
  84. package/dist/lib/packages/easyv-arco/dist/lib/chunks/index-zvVd1BJp.es.es.js.map +0 -1
@@ -0,0 +1,871 @@
1
+ import { memo, notUndefined, approxEqual, debounce } from "./utils.es.js";
2
+ const getRect = (element) => {
3
+ const { offsetWidth, offsetHeight } = element;
4
+ return { width: offsetWidth, height: offsetHeight };
5
+ };
6
+ const defaultKeyExtractor = (index) => index;
7
+ const defaultRangeExtractor = (range) => {
8
+ const start = Math.max(range.startIndex - range.overscan, 0);
9
+ const end = Math.min(range.endIndex + range.overscan, range.count - 1);
10
+ const arr = [];
11
+ for (let i = start; i <= end; i++) {
12
+ arr.push(i);
13
+ }
14
+ return arr;
15
+ };
16
+ const observeElementRect = (instance, cb) => {
17
+ const element = instance.scrollElement;
18
+ if (!element) {
19
+ return;
20
+ }
21
+ const targetWindow = instance.targetWindow;
22
+ if (!targetWindow) {
23
+ return;
24
+ }
25
+ const handler = (rect) => {
26
+ const { width, height } = rect;
27
+ cb({ width: Math.round(width), height: Math.round(height) });
28
+ };
29
+ handler(getRect(element));
30
+ if (!targetWindow.ResizeObserver) {
31
+ return () => {
32
+ };
33
+ }
34
+ const observer = new targetWindow.ResizeObserver((entries) => {
35
+ const run = () => {
36
+ const entry = entries[0];
37
+ if (entry == null ? void 0 : entry.borderBoxSize) {
38
+ const box = entry.borderBoxSize[0];
39
+ if (box) {
40
+ handler({ width: box.inlineSize, height: box.blockSize });
41
+ return;
42
+ }
43
+ }
44
+ handler(getRect(element));
45
+ };
46
+ instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
47
+ });
48
+ observer.observe(element, { box: "border-box" });
49
+ return () => {
50
+ observer.unobserve(element);
51
+ };
52
+ };
53
+ const addEventListenerOptions = {
54
+ passive: true
55
+ };
56
+ const supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
57
+ const observeElementOffset = (instance, cb) => {
58
+ const element = instance.scrollElement;
59
+ if (!element) {
60
+ return;
61
+ }
62
+ const targetWindow = instance.targetWindow;
63
+ if (!targetWindow) {
64
+ return;
65
+ }
66
+ let offset = 0;
67
+ const fallback = instance.options.useScrollendEvent && supportsScrollend ? () => void 0 : debounce(
68
+ targetWindow,
69
+ () => {
70
+ cb(offset, false);
71
+ },
72
+ instance.options.isScrollingResetDelay
73
+ );
74
+ const createHandler = (isScrolling) => () => {
75
+ const { horizontal, isRtl } = instance.options;
76
+ offset = horizontal ? element["scrollLeft"] * (isRtl && -1 || 1) : element["scrollTop"];
77
+ fallback();
78
+ cb(offset, isScrolling);
79
+ };
80
+ const handler = createHandler(true);
81
+ const endHandler = createHandler(false);
82
+ element.addEventListener("scroll", handler, addEventListenerOptions);
83
+ const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
84
+ if (registerScrollendEvent) {
85
+ element.addEventListener("scrollend", endHandler, addEventListenerOptions);
86
+ }
87
+ return () => {
88
+ element.removeEventListener("scroll", handler);
89
+ if (registerScrollendEvent) {
90
+ element.removeEventListener("scrollend", endHandler);
91
+ }
92
+ };
93
+ };
94
+ const measureElement = (element, entry, instance) => {
95
+ if (entry == null ? void 0 : entry.borderBoxSize) {
96
+ const box = entry.borderBoxSize[0];
97
+ if (box) {
98
+ const size = Math.round(
99
+ box[instance.options.horizontal ? "inlineSize" : "blockSize"]
100
+ );
101
+ return size;
102
+ }
103
+ }
104
+ return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
105
+ };
106
+ const elementScroll = (offset, {
107
+ adjustments = 0,
108
+ behavior
109
+ }, instance) => {
110
+ var _a, _b;
111
+ const toOffset = offset + adjustments;
112
+ (_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
113
+ [instance.options.horizontal ? "left" : "top"]: toOffset,
114
+ behavior
115
+ });
116
+ };
117
+ class Virtualizer {
118
+ constructor(opts) {
119
+ this.unsubs = [];
120
+ this.scrollElement = null;
121
+ this.targetWindow = null;
122
+ this.isScrolling = false;
123
+ this.scrollState = null;
124
+ this.measurementsCache = [];
125
+ this.itemSizeCache = /* @__PURE__ */ new Map();
126
+ this.laneAssignments = /* @__PURE__ */ new Map();
127
+ this.pendingMeasuredCacheIndexes = [];
128
+ this.prevLanes = void 0;
129
+ this.lanesChangedFlag = false;
130
+ this.lanesSettling = false;
131
+ this.scrollRect = null;
132
+ this.scrollOffset = null;
133
+ this.scrollDirection = null;
134
+ this.scrollAdjustments = 0;
135
+ this.elementsCache = /* @__PURE__ */ new Map();
136
+ this.now = () => {
137
+ var _a, _b, _c;
138
+ return ((_c = (_b = (_a = this.targetWindow) == null ? void 0 : _a.performance) == null ? void 0 : _b.now) == null ? void 0 : _c.call(_b)) ?? Date.now();
139
+ };
140
+ this.observer = /* @__PURE__ */ (() => {
141
+ let _ro = null;
142
+ const get = () => {
143
+ if (_ro) {
144
+ return _ro;
145
+ }
146
+ if (!this.targetWindow || !this.targetWindow.ResizeObserver) {
147
+ return null;
148
+ }
149
+ return _ro = new this.targetWindow.ResizeObserver((entries) => {
150
+ entries.forEach((entry) => {
151
+ const run = () => {
152
+ const node = entry.target;
153
+ const index = this.indexFromElement(node);
154
+ if (!node.isConnected) {
155
+ this.observer.unobserve(node);
156
+ return;
157
+ }
158
+ if (this.shouldMeasureDuringScroll(index)) {
159
+ this.resizeItem(
160
+ index,
161
+ this.options.measureElement(node, entry, this)
162
+ );
163
+ }
164
+ };
165
+ this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
166
+ });
167
+ });
168
+ };
169
+ return {
170
+ disconnect: () => {
171
+ var _a;
172
+ (_a = get()) == null ? void 0 : _a.disconnect();
173
+ _ro = null;
174
+ },
175
+ observe: (target) => {
176
+ var _a;
177
+ return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
178
+ },
179
+ unobserve: (target) => {
180
+ var _a;
181
+ return (_a = get()) == null ? void 0 : _a.unobserve(target);
182
+ }
183
+ };
184
+ })();
185
+ this.range = null;
186
+ this.setOptions = (opts2) => {
187
+ Object.entries(opts2).forEach(([key, value]) => {
188
+ if (typeof value === "undefined") delete opts2[key];
189
+ });
190
+ this.options = {
191
+ debug: false,
192
+ initialOffset: 0,
193
+ overscan: 1,
194
+ paddingStart: 0,
195
+ paddingEnd: 0,
196
+ scrollPaddingStart: 0,
197
+ scrollPaddingEnd: 0,
198
+ horizontal: false,
199
+ getItemKey: defaultKeyExtractor,
200
+ rangeExtractor: defaultRangeExtractor,
201
+ onChange: () => {
202
+ },
203
+ measureElement,
204
+ initialRect: { width: 0, height: 0 },
205
+ scrollMargin: 0,
206
+ gap: 0,
207
+ indexAttribute: "data-index",
208
+ initialMeasurementsCache: [],
209
+ lanes: 1,
210
+ isScrollingResetDelay: 150,
211
+ enabled: true,
212
+ isRtl: false,
213
+ useScrollendEvent: false,
214
+ useAnimationFrameWithResizeObserver: false,
215
+ ...opts2
216
+ };
217
+ };
218
+ this.notify = (sync) => {
219
+ var _a, _b;
220
+ (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
221
+ };
222
+ this.maybeNotify = memo(
223
+ () => {
224
+ this.calculateRange();
225
+ return [
226
+ this.isScrolling,
227
+ this.range ? this.range.startIndex : null,
228
+ this.range ? this.range.endIndex : null
229
+ ];
230
+ },
231
+ (isScrolling) => {
232
+ this.notify(isScrolling);
233
+ },
234
+ {
235
+ key: process.env.NODE_ENV !== "production" && "maybeNotify",
236
+ debug: () => this.options.debug,
237
+ initialDeps: [
238
+ this.isScrolling,
239
+ this.range ? this.range.startIndex : null,
240
+ this.range ? this.range.endIndex : null
241
+ ]
242
+ }
243
+ );
244
+ this.cleanup = () => {
245
+ this.unsubs.filter(Boolean).forEach((d) => d());
246
+ this.unsubs = [];
247
+ this.observer.disconnect();
248
+ if (this.rafId != null && this.targetWindow) {
249
+ this.targetWindow.cancelAnimationFrame(this.rafId);
250
+ this.rafId = null;
251
+ }
252
+ this.scrollState = null;
253
+ this.scrollElement = null;
254
+ this.targetWindow = null;
255
+ };
256
+ this._didMount = () => {
257
+ return () => {
258
+ this.cleanup();
259
+ };
260
+ };
261
+ this._willUpdate = () => {
262
+ var _a;
263
+ const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
264
+ if (this.scrollElement !== scrollElement) {
265
+ this.cleanup();
266
+ if (!scrollElement) {
267
+ this.maybeNotify();
268
+ return;
269
+ }
270
+ this.scrollElement = scrollElement;
271
+ if (this.scrollElement && "ownerDocument" in this.scrollElement) {
272
+ this.targetWindow = this.scrollElement.ownerDocument.defaultView;
273
+ } else {
274
+ this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
275
+ }
276
+ this.elementsCache.forEach((cached) => {
277
+ this.observer.observe(cached);
278
+ });
279
+ this.unsubs.push(
280
+ this.options.observeElementRect(this, (rect) => {
281
+ this.scrollRect = rect;
282
+ this.maybeNotify();
283
+ })
284
+ );
285
+ this.unsubs.push(
286
+ this.options.observeElementOffset(this, (offset, isScrolling) => {
287
+ this.scrollAdjustments = 0;
288
+ this.scrollDirection = isScrolling ? this.getScrollOffset() < offset ? "forward" : "backward" : null;
289
+ this.scrollOffset = offset;
290
+ this.isScrolling = isScrolling;
291
+ if (this.scrollState) {
292
+ this.scheduleScrollReconcile();
293
+ }
294
+ this.maybeNotify();
295
+ })
296
+ );
297
+ this._scrollToOffset(this.getScrollOffset(), {
298
+ adjustments: void 0,
299
+ behavior: void 0
300
+ });
301
+ }
302
+ };
303
+ this.rafId = null;
304
+ this.getSize = () => {
305
+ if (!this.options.enabled) {
306
+ this.scrollRect = null;
307
+ return 0;
308
+ }
309
+ this.scrollRect = this.scrollRect ?? this.options.initialRect;
310
+ return this.scrollRect[this.options.horizontal ? "width" : "height"];
311
+ };
312
+ this.getScrollOffset = () => {
313
+ if (!this.options.enabled) {
314
+ this.scrollOffset = null;
315
+ return 0;
316
+ }
317
+ this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
318
+ return this.scrollOffset;
319
+ };
320
+ this.getFurthestMeasurement = (measurements, index) => {
321
+ const furthestMeasurementsFound = /* @__PURE__ */ new Map();
322
+ const furthestMeasurements = /* @__PURE__ */ new Map();
323
+ for (let m = index - 1; m >= 0; m--) {
324
+ const measurement = measurements[m];
325
+ if (furthestMeasurementsFound.has(measurement.lane)) {
326
+ continue;
327
+ }
328
+ const previousFurthestMeasurement = furthestMeasurements.get(
329
+ measurement.lane
330
+ );
331
+ if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) {
332
+ furthestMeasurements.set(measurement.lane, measurement);
333
+ } else if (measurement.end < previousFurthestMeasurement.end) {
334
+ furthestMeasurementsFound.set(measurement.lane, true);
335
+ }
336
+ if (furthestMeasurementsFound.size === this.options.lanes) {
337
+ break;
338
+ }
339
+ }
340
+ return furthestMeasurements.size === this.options.lanes ? Array.from(furthestMeasurements.values()).sort((a, b) => {
341
+ if (a.end === b.end) {
342
+ return a.index - b.index;
343
+ }
344
+ return a.end - b.end;
345
+ })[0] : void 0;
346
+ };
347
+ this.getMeasurementOptions = memo(
348
+ () => [
349
+ this.options.count,
350
+ this.options.paddingStart,
351
+ this.options.scrollMargin,
352
+ this.options.getItemKey,
353
+ this.options.enabled,
354
+ this.options.lanes
355
+ ],
356
+ (count, paddingStart, scrollMargin, getItemKey, enabled, lanes) => {
357
+ const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
358
+ if (lanesChanged) {
359
+ this.lanesChangedFlag = true;
360
+ }
361
+ this.prevLanes = lanes;
362
+ this.pendingMeasuredCacheIndexes = [];
363
+ return {
364
+ count,
365
+ paddingStart,
366
+ scrollMargin,
367
+ getItemKey,
368
+ enabled,
369
+ lanes
370
+ };
371
+ },
372
+ {
373
+ key: false
374
+ }
375
+ );
376
+ this.getMeasurements = memo(
377
+ () => [this.getMeasurementOptions(), this.itemSizeCache],
378
+ ({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes }, itemSizeCache) => {
379
+ if (!enabled) {
380
+ this.measurementsCache = [];
381
+ this.itemSizeCache.clear();
382
+ this.laneAssignments.clear();
383
+ return [];
384
+ }
385
+ if (this.laneAssignments.size > count) {
386
+ for (const index of this.laneAssignments.keys()) {
387
+ if (index >= count) {
388
+ this.laneAssignments.delete(index);
389
+ }
390
+ }
391
+ }
392
+ if (this.lanesChangedFlag) {
393
+ this.lanesChangedFlag = false;
394
+ this.lanesSettling = true;
395
+ this.measurementsCache = [];
396
+ this.itemSizeCache.clear();
397
+ this.laneAssignments.clear();
398
+ this.pendingMeasuredCacheIndexes = [];
399
+ }
400
+ if (this.measurementsCache.length === 0 && !this.lanesSettling) {
401
+ this.measurementsCache = this.options.initialMeasurementsCache;
402
+ this.measurementsCache.forEach((item) => {
403
+ this.itemSizeCache.set(item.key, item.size);
404
+ });
405
+ }
406
+ const min = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
407
+ this.pendingMeasuredCacheIndexes = [];
408
+ if (this.lanesSettling && this.measurementsCache.length === count) {
409
+ this.lanesSettling = false;
410
+ }
411
+ const measurements = this.measurementsCache.slice(0, min);
412
+ const laneLastIndex = new Array(lanes).fill(
413
+ void 0
414
+ );
415
+ for (let m = 0; m < min; m++) {
416
+ const item = measurements[m];
417
+ if (item) {
418
+ laneLastIndex[item.lane] = m;
419
+ }
420
+ }
421
+ for (let i = min; i < count; i++) {
422
+ const key = getItemKey(i);
423
+ const cachedLane = this.laneAssignments.get(i);
424
+ let lane;
425
+ let start;
426
+ if (cachedLane !== void 0 && this.options.lanes > 1) {
427
+ lane = cachedLane;
428
+ const prevIndex = laneLastIndex[lane];
429
+ const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
430
+ start = prevInLane ? prevInLane.end + this.options.gap : paddingStart + scrollMargin;
431
+ } else {
432
+ const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
433
+ start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
434
+ lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
435
+ if (this.options.lanes > 1) {
436
+ this.laneAssignments.set(i, lane);
437
+ }
438
+ }
439
+ const measuredSize = itemSizeCache.get(key);
440
+ const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
441
+ const end = start + size;
442
+ measurements[i] = {
443
+ index: i,
444
+ start,
445
+ size,
446
+ end,
447
+ key,
448
+ lane
449
+ };
450
+ laneLastIndex[lane] = i;
451
+ }
452
+ this.measurementsCache = measurements;
453
+ return measurements;
454
+ },
455
+ {
456
+ key: process.env.NODE_ENV !== "production" && "getMeasurements",
457
+ debug: () => this.options.debug
458
+ }
459
+ );
460
+ this.calculateRange = memo(
461
+ () => [
462
+ this.getMeasurements(),
463
+ this.getSize(),
464
+ this.getScrollOffset(),
465
+ this.options.lanes
466
+ ],
467
+ (measurements, outerSize, scrollOffset, lanes) => {
468
+ return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
469
+ measurements,
470
+ outerSize,
471
+ scrollOffset,
472
+ lanes
473
+ }) : null;
474
+ },
475
+ {
476
+ key: process.env.NODE_ENV !== "production" && "calculateRange",
477
+ debug: () => this.options.debug
478
+ }
479
+ );
480
+ this.getVirtualIndexes = memo(
481
+ () => {
482
+ let startIndex = null;
483
+ let endIndex = null;
484
+ const range = this.calculateRange();
485
+ if (range) {
486
+ startIndex = range.startIndex;
487
+ endIndex = range.endIndex;
488
+ }
489
+ this.maybeNotify.updateDeps([this.isScrolling, startIndex, endIndex]);
490
+ return [
491
+ this.options.rangeExtractor,
492
+ this.options.overscan,
493
+ this.options.count,
494
+ startIndex,
495
+ endIndex
496
+ ];
497
+ },
498
+ (rangeExtractor, overscan, count, startIndex, endIndex) => {
499
+ return startIndex === null || endIndex === null ? [] : rangeExtractor({
500
+ startIndex,
501
+ endIndex,
502
+ overscan,
503
+ count
504
+ });
505
+ },
506
+ {
507
+ key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
508
+ debug: () => this.options.debug
509
+ }
510
+ );
511
+ this.indexFromElement = (node) => {
512
+ const attributeName = this.options.indexAttribute;
513
+ const indexStr = node.getAttribute(attributeName);
514
+ if (!indexStr) {
515
+ console.warn(
516
+ `Missing attribute name '${attributeName}={index}' on measured element.`
517
+ );
518
+ return -1;
519
+ }
520
+ return parseInt(indexStr, 10);
521
+ };
522
+ this.shouldMeasureDuringScroll = (index) => {
523
+ var _a;
524
+ if (!this.scrollState || this.scrollState.behavior !== "smooth") {
525
+ return true;
526
+ }
527
+ const scrollIndex = this.scrollState.index ?? ((_a = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : _a.index);
528
+ if (scrollIndex !== void 0 && this.range) {
529
+ const bufferSize = Math.max(
530
+ this.options.overscan,
531
+ Math.ceil((this.range.endIndex - this.range.startIndex) / 2)
532
+ );
533
+ const minIndex = Math.max(0, scrollIndex - bufferSize);
534
+ const maxIndex = Math.min(
535
+ this.options.count - 1,
536
+ scrollIndex + bufferSize
537
+ );
538
+ return index >= minIndex && index <= maxIndex;
539
+ }
540
+ return true;
541
+ };
542
+ this.measureElement = (node) => {
543
+ if (!node) {
544
+ this.elementsCache.forEach((cached, key2) => {
545
+ if (!cached.isConnected) {
546
+ this.observer.unobserve(cached);
547
+ this.elementsCache.delete(key2);
548
+ }
549
+ });
550
+ return;
551
+ }
552
+ const index = this.indexFromElement(node);
553
+ const key = this.options.getItemKey(index);
554
+ const prevNode = this.elementsCache.get(key);
555
+ if (prevNode !== node) {
556
+ if (prevNode) {
557
+ this.observer.unobserve(prevNode);
558
+ }
559
+ this.observer.observe(node);
560
+ this.elementsCache.set(key, node);
561
+ }
562
+ if ((!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(index)) {
563
+ this.resizeItem(index, this.options.measureElement(node, void 0, this));
564
+ }
565
+ };
566
+ this.resizeItem = (index, size) => {
567
+ var _a;
568
+ const item = this.measurementsCache[index];
569
+ if (!item) return;
570
+ const itemSize = this.itemSizeCache.get(item.key) ?? item.size;
571
+ const delta = size - itemSize;
572
+ if (delta !== 0) {
573
+ if (((_a = this.scrollState) == null ? void 0 : _a.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.getScrollOffset() + this.scrollAdjustments)) {
574
+ if (process.env.NODE_ENV !== "production" && this.options.debug) {
575
+ console.info("correction", delta);
576
+ }
577
+ this._scrollToOffset(this.getScrollOffset(), {
578
+ adjustments: this.scrollAdjustments += delta,
579
+ behavior: void 0
580
+ });
581
+ }
582
+ this.pendingMeasuredCacheIndexes.push(item.index);
583
+ this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size));
584
+ this.notify(false);
585
+ }
586
+ };
587
+ this.getVirtualItems = memo(
588
+ () => [this.getVirtualIndexes(), this.getMeasurements()],
589
+ (indexes, measurements) => {
590
+ const virtualItems = [];
591
+ for (let k = 0, len = indexes.length; k < len; k++) {
592
+ const i = indexes[k];
593
+ const measurement = measurements[i];
594
+ virtualItems.push(measurement);
595
+ }
596
+ return virtualItems;
597
+ },
598
+ {
599
+ key: process.env.NODE_ENV !== "production" && "getVirtualItems",
600
+ debug: () => this.options.debug
601
+ }
602
+ );
603
+ this.getVirtualItemForOffset = (offset) => {
604
+ const measurements = this.getMeasurements();
605
+ if (measurements.length === 0) {
606
+ return void 0;
607
+ }
608
+ return notUndefined(
609
+ measurements[findNearestBinarySearch(
610
+ 0,
611
+ measurements.length - 1,
612
+ (index) => notUndefined(measurements[index]).start,
613
+ offset
614
+ )]
615
+ );
616
+ };
617
+ this.getMaxScrollOffset = () => {
618
+ if (!this.scrollElement) return 0;
619
+ if ("scrollHeight" in this.scrollElement) {
620
+ return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
621
+ } else {
622
+ const doc = this.scrollElement.document.documentElement;
623
+ return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
624
+ }
625
+ };
626
+ this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
627
+ if (!this.scrollElement) return 0;
628
+ const size = this.getSize();
629
+ const scrollOffset = this.getScrollOffset();
630
+ if (align === "auto") {
631
+ align = toOffset >= scrollOffset + size ? "end" : "start";
632
+ }
633
+ if (align === "center") {
634
+ toOffset += (itemSize - size) / 2;
635
+ } else if (align === "end") {
636
+ toOffset -= size;
637
+ }
638
+ const maxOffset = this.getMaxScrollOffset();
639
+ return Math.max(Math.min(maxOffset, toOffset), 0);
640
+ };
641
+ this.getOffsetForIndex = (index, align = "auto") => {
642
+ index = Math.max(0, Math.min(index, this.options.count - 1));
643
+ const size = this.getSize();
644
+ const scrollOffset = this.getScrollOffset();
645
+ const item = this.measurementsCache[index];
646
+ if (!item) return;
647
+ if (align === "auto") {
648
+ if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) {
649
+ align = "end";
650
+ } else if (item.start <= scrollOffset + this.options.scrollPaddingStart) {
651
+ align = "start";
652
+ } else {
653
+ return [scrollOffset, align];
654
+ }
655
+ }
656
+ if (align === "end" && index === this.options.count - 1) {
657
+ return [this.getMaxScrollOffset(), align];
658
+ }
659
+ const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
660
+ return [
661
+ this.getOffsetForAlignment(toOffset, align, item.size),
662
+ align
663
+ ];
664
+ };
665
+ this.scrollToOffset = (toOffset, { align = "start", behavior = "auto" } = {}) => {
666
+ const offset = this.getOffsetForAlignment(toOffset, align);
667
+ const now = this.now();
668
+ this.scrollState = {
669
+ index: null,
670
+ align,
671
+ behavior,
672
+ startedAt: now,
673
+ lastTargetOffset: offset,
674
+ stableFrames: 0
675
+ };
676
+ this._scrollToOffset(offset, { adjustments: void 0, behavior });
677
+ this.scheduleScrollReconcile();
678
+ };
679
+ this.scrollToIndex = (index, {
680
+ align: initialAlign = "auto",
681
+ behavior = "auto"
682
+ } = {}) => {
683
+ index = Math.max(0, Math.min(index, this.options.count - 1));
684
+ const offsetInfo = this.getOffsetForIndex(index, initialAlign);
685
+ if (!offsetInfo) {
686
+ return;
687
+ }
688
+ const [offset, align] = offsetInfo;
689
+ const now = this.now();
690
+ this.scrollState = {
691
+ index,
692
+ align,
693
+ behavior,
694
+ startedAt: now,
695
+ lastTargetOffset: offset,
696
+ stableFrames: 0
697
+ };
698
+ this._scrollToOffset(offset, { adjustments: void 0, behavior });
699
+ this.scheduleScrollReconcile();
700
+ };
701
+ this.scrollBy = (delta, { behavior = "auto" } = {}) => {
702
+ const offset = this.getScrollOffset() + delta;
703
+ const now = this.now();
704
+ this.scrollState = {
705
+ index: null,
706
+ align: "start",
707
+ behavior,
708
+ startedAt: now,
709
+ lastTargetOffset: offset,
710
+ stableFrames: 0
711
+ };
712
+ this._scrollToOffset(offset, { adjustments: void 0, behavior });
713
+ this.scheduleScrollReconcile();
714
+ };
715
+ this.getTotalSize = () => {
716
+ var _a;
717
+ const measurements = this.getMeasurements();
718
+ let end;
719
+ if (measurements.length === 0) {
720
+ end = this.options.paddingStart;
721
+ } else if (this.options.lanes === 1) {
722
+ end = ((_a = measurements[measurements.length - 1]) == null ? void 0 : _a.end) ?? 0;
723
+ } else {
724
+ const endByLane = Array(this.options.lanes).fill(null);
725
+ let endIndex = measurements.length - 1;
726
+ while (endIndex >= 0 && endByLane.some((val) => val === null)) {
727
+ const item = measurements[endIndex];
728
+ if (endByLane[item.lane] === null) {
729
+ endByLane[item.lane] = item.end;
730
+ }
731
+ endIndex--;
732
+ }
733
+ end = Math.max(...endByLane.filter((val) => val !== null));
734
+ }
735
+ return Math.max(
736
+ end - this.options.scrollMargin + this.options.paddingEnd,
737
+ 0
738
+ );
739
+ };
740
+ this._scrollToOffset = (offset, {
741
+ adjustments,
742
+ behavior
743
+ }) => {
744
+ this.options.scrollToFn(offset, { behavior, adjustments }, this);
745
+ };
746
+ this.measure = () => {
747
+ this.itemSizeCache = /* @__PURE__ */ new Map();
748
+ this.laneAssignments = /* @__PURE__ */ new Map();
749
+ this.notify(false);
750
+ };
751
+ this.setOptions(opts);
752
+ }
753
+ scheduleScrollReconcile() {
754
+ if (!this.targetWindow) {
755
+ this.scrollState = null;
756
+ return;
757
+ }
758
+ if (this.rafId != null) return;
759
+ this.rafId = this.targetWindow.requestAnimationFrame(() => {
760
+ this.rafId = null;
761
+ this.reconcileScroll();
762
+ });
763
+ }
764
+ reconcileScroll() {
765
+ if (!this.scrollState) return;
766
+ const el = this.scrollElement;
767
+ if (!el) return;
768
+ const MAX_RECONCILE_MS = 5e3;
769
+ if (this.now() - this.scrollState.startedAt > MAX_RECONCILE_MS) {
770
+ this.scrollState = null;
771
+ return;
772
+ }
773
+ const offsetInfo = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0;
774
+ const targetOffset = offsetInfo ? offsetInfo[0] : this.scrollState.lastTargetOffset;
775
+ const STABLE_FRAMES = 1;
776
+ const targetChanged = targetOffset !== this.scrollState.lastTargetOffset;
777
+ if (!targetChanged && approxEqual(targetOffset, this.getScrollOffset())) {
778
+ this.scrollState.stableFrames++;
779
+ if (this.scrollState.stableFrames >= STABLE_FRAMES) {
780
+ this.scrollState = null;
781
+ return;
782
+ }
783
+ } else {
784
+ this.scrollState.stableFrames = 0;
785
+ if (targetChanged) {
786
+ this.scrollState.lastTargetOffset = targetOffset;
787
+ this.scrollState.behavior = "auto";
788
+ this._scrollToOffset(targetOffset, {
789
+ adjustments: void 0,
790
+ behavior: "auto"
791
+ });
792
+ }
793
+ }
794
+ this.scheduleScrollReconcile();
795
+ }
796
+ }
797
+ const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
798
+ while (low <= high) {
799
+ const middle = (low + high) / 2 | 0;
800
+ const currentValue = getCurrentValue(middle);
801
+ if (currentValue < value) {
802
+ low = middle + 1;
803
+ } else if (currentValue > value) {
804
+ high = middle - 1;
805
+ } else {
806
+ return middle;
807
+ }
808
+ }
809
+ if (low > 0) {
810
+ return low - 1;
811
+ } else {
812
+ return 0;
813
+ }
814
+ };
815
+ function calculateRange({
816
+ measurements,
817
+ outerSize,
818
+ scrollOffset,
819
+ lanes
820
+ }) {
821
+ const lastIndex = measurements.length - 1;
822
+ const getOffset = (index) => measurements[index].start;
823
+ if (measurements.length <= lanes) {
824
+ return {
825
+ startIndex: 0,
826
+ endIndex: lastIndex
827
+ };
828
+ }
829
+ let startIndex = findNearestBinarySearch(
830
+ 0,
831
+ lastIndex,
832
+ getOffset,
833
+ scrollOffset
834
+ );
835
+ let endIndex = startIndex;
836
+ if (lanes === 1) {
837
+ while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) {
838
+ endIndex++;
839
+ }
840
+ } else if (lanes > 1) {
841
+ const endPerLane = Array(lanes).fill(0);
842
+ while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
843
+ const item = measurements[endIndex];
844
+ endPerLane[item.lane] = item.end;
845
+ endIndex++;
846
+ }
847
+ const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
848
+ while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
849
+ const item = measurements[startIndex];
850
+ startPerLane[item.lane] = item.start;
851
+ startIndex--;
852
+ }
853
+ startIndex = Math.max(0, startIndex - startIndex % lanes);
854
+ endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
855
+ }
856
+ return { startIndex, endIndex };
857
+ }
858
+ export {
859
+ Virtualizer,
860
+ approxEqual,
861
+ debounce,
862
+ defaultKeyExtractor,
863
+ defaultRangeExtractor,
864
+ elementScroll,
865
+ measureElement,
866
+ memo,
867
+ notUndefined,
868
+ observeElementOffset,
869
+ observeElementRect
870
+ };
871
+ //# sourceMappingURL=index.es.js.map