@digdir/designsystemet-react 0.55.1-alpha.0 → 0.56.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.
Files changed (48) hide show
  1. package/dist/cjs/components/Chip/Chip.module.css.js +1 -1
  2. package/dist/cjs/components/DropdownMenu/DropdownMenu.js +2 -2
  3. package/dist/cjs/components/Popover/Popover.js +2 -2
  4. package/dist/cjs/components/Popover/PopoverContent.js +2 -2
  5. package/dist/cjs/components/Tooltip/Tooltip.js +1 -1
  6. package/dist/cjs/components/form/Checkbox/Checkbox.js +2 -2
  7. package/dist/cjs/components/form/Combobox/Combobox.js +19 -4
  8. package/dist/cjs/components/form/Radio/Radio.js +2 -2
  9. package/dist/cjs/components/form/Search/Search.js +1 -1
  10. package/dist/cjs/node_modules/@floating-ui/react/dist/floating-ui.react.js +1 -1
  11. package/dist/cjs/node_modules/@floating-ui/{react/node_modules/@floating-ui/react-dom → react-dom}/dist/floating-ui.react-dom.js +2 -2
  12. package/dist/cjs/node_modules/@tanstack/react-virtual/{build/lib → dist/esm}/index.js +18 -32
  13. package/dist/cjs/node_modules/@tanstack/virtual-core/dist/esm/index.js +606 -0
  14. package/dist/cjs/node_modules/@tanstack/virtual-core/dist/esm/utils.js +60 -0
  15. package/dist/cjs/react-css-modules.css +76 -79
  16. package/dist/esm/components/Chip/Chip.module.css.js +1 -1
  17. package/dist/esm/components/DropdownMenu/DropdownMenu.js +2 -2
  18. package/dist/esm/components/Popover/Popover.js +2 -2
  19. package/dist/esm/components/Popover/PopoverContent.js +2 -2
  20. package/dist/esm/components/Tooltip/Tooltip.js +1 -1
  21. package/dist/esm/components/form/Checkbox/Checkbox.js +2 -2
  22. package/dist/esm/components/form/Combobox/Combobox.js +19 -4
  23. package/dist/esm/components/form/Radio/Radio.js +2 -2
  24. package/dist/esm/components/form/Search/Search.js +1 -1
  25. package/dist/esm/node_modules/@floating-ui/react/dist/floating-ui.react.js +2 -2
  26. package/dist/esm/node_modules/@floating-ui/{react/node_modules/@floating-ui/react-dom → react-dom}/dist/floating-ui.react-dom.js +4 -4
  27. package/dist/esm/node_modules/@tanstack/react-virtual/dist/esm/index.js +43 -0
  28. package/dist/esm/node_modules/@tanstack/virtual-core/dist/esm/index.js +595 -0
  29. package/dist/esm/node_modules/@tanstack/virtual-core/dist/esm/utils.js +56 -0
  30. package/dist/esm/react-css-modules.css +76 -79
  31. package/dist/types/components/DropdownMenu/DropdownMenu.d.ts +1 -6
  32. package/dist/types/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  33. package/dist/types/components/Popover/Popover.d.ts +1 -6
  34. package/dist/types/components/Popover/Popover.d.ts.map +1 -1
  35. package/dist/types/components/form/Checkbox/Checkbox.d.ts.map +1 -1
  36. package/dist/types/components/form/Combobox/Combobox.d.ts.map +1 -1
  37. package/dist/types/components/form/Radio/Radio.d.ts.map +1 -1
  38. package/dist/types/components/form/Search/Search.d.ts.map +1 -1
  39. package/package.json +3 -3
  40. package/dist/cjs/node_modules/@tanstack/react-virtual/build/lib/_virtual/_rollupPluginBabelHelpers.js +0 -29
  41. package/dist/cjs/node_modules/@tanstack/virtual-core/build/lib/_virtual/_rollupPluginBabelHelpers.js +0 -29
  42. package/dist/cjs/node_modules/@tanstack/virtual-core/build/lib/index.js +0 -607
  43. package/dist/cjs/node_modules/@tanstack/virtual-core/build/lib/utils.js +0 -62
  44. package/dist/esm/node_modules/@tanstack/react-virtual/build/lib/_virtual/_rollupPluginBabelHelpers.js +0 -27
  45. package/dist/esm/node_modules/@tanstack/react-virtual/build/lib/index.js +0 -57
  46. package/dist/esm/node_modules/@tanstack/virtual-core/build/lib/_virtual/_rollupPluginBabelHelpers.js +0 -27
  47. package/dist/esm/node_modules/@tanstack/virtual-core/build/lib/index.js +0 -596
  48. package/dist/esm/node_modules/@tanstack/virtual-core/build/lib/utils.js +0 -58
@@ -1,607 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
5
- var utils = require('./utils.js');
6
-
7
- /**
8
- * virtual-core
9
- *
10
- * Copyright (c) TanStack
11
- *
12
- * This source code is licensed under the MIT license found in the
13
- * LICENSE.md file in the root directory of this source tree.
14
- *
15
- * @license MIT
16
- */
17
-
18
- //
19
-
20
- //
21
-
22
- var defaultKeyExtractor = function defaultKeyExtractor(index) {
23
- return index;
24
- };
25
- var defaultRangeExtractor = function defaultRangeExtractor(range) {
26
- var start = Math.max(range.startIndex - range.overscan, 0);
27
- var end = Math.min(range.endIndex + range.overscan, range.count - 1);
28
- var arr = [];
29
- for (var _i = start; _i <= end; _i++) {
30
- arr.push(_i);
31
- }
32
- return arr;
33
- };
34
- var observeElementRect = function observeElementRect(instance, cb) {
35
- var element = instance.scrollElement;
36
- if (!element) {
37
- return;
38
- }
39
- var handler = function handler(rect) {
40
- var width = rect.width,
41
- height = rect.height;
42
- cb({
43
- width: Math.round(width),
44
- height: Math.round(height)
45
- });
46
- };
47
- handler(element.getBoundingClientRect());
48
- var observer = new ResizeObserver(function (entries) {
49
- var entry = entries[0];
50
- if (entry != null && entry.borderBoxSize) {
51
- var box = entry.borderBoxSize[0];
52
- if (box) {
53
- handler({
54
- width: box.inlineSize,
55
- height: box.blockSize
56
- });
57
- return;
58
- }
59
- }
60
- handler(element.getBoundingClientRect());
61
- });
62
- observer.observe(element, {
63
- box: 'border-box'
64
- });
65
- return function () {
66
- observer.unobserve(element);
67
- };
68
- };
69
- var observeElementOffset = function observeElementOffset(instance, cb) {
70
- var element = instance.scrollElement;
71
- if (!element) {
72
- return;
73
- }
74
- var handler = function handler() {
75
- cb(element[instance.options.horizontal ? 'scrollLeft' : 'scrollTop']);
76
- };
77
- handler();
78
- element.addEventListener('scroll', handler, {
79
- passive: true
80
- });
81
- return function () {
82
- element.removeEventListener('scroll', handler);
83
- };
84
- };
85
- var measureElement = function measureElement(element, entry, instance) {
86
- if (entry != null && entry.borderBoxSize) {
87
- var box = entry.borderBoxSize[0];
88
- if (box) {
89
- var size = Math.round(box[instance.options.horizontal ? 'inlineSize' : 'blockSize']);
90
- return size;
91
- }
92
- }
93
- return Math.round(element.getBoundingClientRect()[instance.options.horizontal ? 'width' : 'height']);
94
- };
95
- var elementScroll = function elementScroll(offset, _ref2, instance) {
96
- var _instance$scrollEleme3, _instance$scrollEleme4;
97
- var _ref2$adjustments = _ref2.adjustments,
98
- adjustments = _ref2$adjustments === void 0 ? 0 : _ref2$adjustments,
99
- behavior = _ref2.behavior;
100
- var toOffset = offset + adjustments;
101
- (_instance$scrollEleme3 = instance.scrollElement) == null || _instance$scrollEleme3.scrollTo == null || _instance$scrollEleme3.scrollTo((_instance$scrollEleme4 = {}, _instance$scrollEleme4[instance.options.horizontal ? 'left' : 'top'] = toOffset, _instance$scrollEleme4.behavior = behavior, _instance$scrollEleme4));
102
- };
103
- var Virtualizer = function Virtualizer(_opts) {
104
- var _this = this;
105
- this.unsubs = [];
106
- this.scrollElement = null;
107
- this.isScrolling = false;
108
- this.isScrollingTimeoutId = null;
109
- this.scrollToIndexTimeoutId = null;
110
- this.measurementsCache = [];
111
- this.itemSizeCache = new Map();
112
- this.pendingMeasuredCacheIndexes = [];
113
- this.scrollDirection = null;
114
- this.scrollAdjustments = 0;
115
- this.measureElementCache = new Map();
116
- this.observer = function () {
117
- var _ro = null;
118
- var get = function get() {
119
- if (_ro) {
120
- return _ro;
121
- } else if (typeof ResizeObserver !== 'undefined') {
122
- return _ro = new ResizeObserver(function (entries) {
123
- entries.forEach(function (entry) {
124
- _this._measureElement(entry.target, entry);
125
- });
126
- });
127
- } else {
128
- return null;
129
- }
130
- };
131
- return {
132
- disconnect: function disconnect() {
133
- var _get;
134
- return (_get = get()) == null ? void 0 : _get.disconnect();
135
- },
136
- observe: function observe(target) {
137
- var _get2;
138
- return (_get2 = get()) == null ? void 0 : _get2.observe(target, {
139
- box: 'border-box'
140
- });
141
- },
142
- unobserve: function unobserve(target) {
143
- var _get3;
144
- return (_get3 = get()) == null ? void 0 : _get3.unobserve(target);
145
- }
146
- };
147
- }();
148
- this.range = null;
149
- this.setOptions = function (opts) {
150
- Object.entries(opts).forEach(function (_ref3) {
151
- var key = _ref3[0],
152
- value = _ref3[1];
153
- if (typeof value === 'undefined') delete opts[key];
154
- });
155
- _this.options = _rollupPluginBabelHelpers.extends({
156
- debug: false,
157
- initialOffset: 0,
158
- overscan: 1,
159
- paddingStart: 0,
160
- paddingEnd: 0,
161
- scrollPaddingStart: 0,
162
- scrollPaddingEnd: 0,
163
- horizontal: false,
164
- getItemKey: defaultKeyExtractor,
165
- rangeExtractor: defaultRangeExtractor,
166
- onChange: function onChange() {},
167
- measureElement: measureElement,
168
- initialRect: {
169
- width: 0,
170
- height: 0
171
- },
172
- scrollMargin: 0,
173
- scrollingDelay: 150,
174
- indexAttribute: 'data-index',
175
- initialMeasurementsCache: [],
176
- lanes: 1
177
- }, opts);
178
- };
179
- this.notify = function (sync) {
180
- _this.options.onChange == null || _this.options.onChange(_this, sync);
181
- };
182
- this.maybeNotify = utils.memo(function () {
183
- _this.calculateRange();
184
- return [_this.isScrolling, _this.range ? _this.range.startIndex : null, _this.range ? _this.range.endIndex : null];
185
- }, function (isScrolling) {
186
- _this.notify(isScrolling);
187
- }, {
188
- key: process.env.NODE_ENV !== 'production' && 'maybeNotify',
189
- debug: function debug() {
190
- return _this.options.debug;
191
- },
192
- initialDeps: [this.isScrolling, this.range ? this.range.startIndex : null, this.range ? this.range.endIndex : null]
193
- });
194
- this.cleanup = function () {
195
- _this.unsubs.filter(Boolean).forEach(function (d) {
196
- return d();
197
- });
198
- _this.unsubs = [];
199
- _this.scrollElement = null;
200
- };
201
- this._didMount = function () {
202
- _this.measureElementCache.forEach(_this.observer.observe);
203
- return function () {
204
- _this.observer.disconnect();
205
- _this.cleanup();
206
- };
207
- };
208
- this._willUpdate = function () {
209
- var scrollElement = _this.options.getScrollElement();
210
- if (_this.scrollElement !== scrollElement) {
211
- _this.cleanup();
212
- _this.scrollElement = scrollElement;
213
- _this._scrollToOffset(_this.scrollOffset, {
214
- adjustments: undefined,
215
- behavior: undefined
216
- });
217
- _this.unsubs.push(_this.options.observeElementRect(_this, function (rect) {
218
- _this.scrollRect = rect;
219
- _this.maybeNotify();
220
- }));
221
- _this.unsubs.push(_this.options.observeElementOffset(_this, function (offset) {
222
- _this.scrollAdjustments = 0;
223
- if (_this.scrollOffset === offset) {
224
- return;
225
- }
226
- if (_this.isScrollingTimeoutId !== null) {
227
- clearTimeout(_this.isScrollingTimeoutId);
228
- _this.isScrollingTimeoutId = null;
229
- }
230
- _this.isScrolling = true;
231
- _this.scrollDirection = _this.scrollOffset < offset ? 'forward' : 'backward';
232
- _this.scrollOffset = offset;
233
- _this.maybeNotify();
234
- _this.isScrollingTimeoutId = setTimeout(function () {
235
- _this.isScrollingTimeoutId = null;
236
- _this.isScrolling = false;
237
- _this.scrollDirection = null;
238
- _this.maybeNotify();
239
- }, _this.options.scrollingDelay);
240
- }));
241
- }
242
- };
243
- this.getSize = function () {
244
- return _this.scrollRect[_this.options.horizontal ? 'width' : 'height'];
245
- };
246
- this.memoOptions = utils.memo(function () {
247
- return [_this.options.count, _this.options.paddingStart, _this.options.scrollMargin, _this.options.getItemKey];
248
- }, function (count, paddingStart, scrollMargin, getItemKey) {
249
- _this.pendingMeasuredCacheIndexes = [];
250
- return {
251
- count: count,
252
- paddingStart: paddingStart,
253
- scrollMargin: scrollMargin,
254
- getItemKey: getItemKey
255
- };
256
- }, {
257
- key: false
258
- });
259
- this.getFurthestMeasurement = function (measurements, index) {
260
- var furthestMeasurementsFound = new Map();
261
- var furthestMeasurements = new Map();
262
- for (var m = index - 1; m >= 0; m--) {
263
- var measurement = measurements[m];
264
- if (furthestMeasurementsFound.has(measurement.lane)) {
265
- continue;
266
- }
267
- var previousFurthestMeasurement = furthestMeasurements.get(measurement.lane);
268
- if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) {
269
- furthestMeasurements.set(measurement.lane, measurement);
270
- } else if (measurement.end < previousFurthestMeasurement.end) {
271
- furthestMeasurementsFound.set(measurement.lane, true);
272
- }
273
- if (furthestMeasurementsFound.size === _this.options.lanes) {
274
- break;
275
- }
276
- }
277
- return furthestMeasurements.size === _this.options.lanes ? Array.from(furthestMeasurements.values()).sort(function (a, b) {
278
- return a.end - b.end;
279
- })[0] : undefined;
280
- };
281
- this.getMeasurements = utils.memo(function () {
282
- return [_this.memoOptions(), _this.itemSizeCache];
283
- }, function (_ref4, itemSizeCache) {
284
- var count = _ref4.count,
285
- paddingStart = _ref4.paddingStart,
286
- scrollMargin = _ref4.scrollMargin,
287
- getItemKey = _ref4.getItemKey;
288
- var min = _this.pendingMeasuredCacheIndexes.length > 0 ? Math.min.apply(Math, _this.pendingMeasuredCacheIndexes) : 0;
289
- _this.pendingMeasuredCacheIndexes = [];
290
- var measurements = _this.measurementsCache.slice(0, min);
291
- for (var _i2 = min; _i2 < count; _i2++) {
292
- var key = getItemKey(_i2);
293
- var furthestMeasurement = _this.options.lanes === 1 ? measurements[_i2 - 1] : _this.getFurthestMeasurement(measurements, _i2);
294
- var start = furthestMeasurement ? furthestMeasurement.end : paddingStart + scrollMargin;
295
- var measuredSize = itemSizeCache.get(key);
296
- var size = typeof measuredSize === 'number' ? measuredSize : _this.options.estimateSize(_i2);
297
- var end = start + size;
298
- var lane = furthestMeasurement ? furthestMeasurement.lane : _i2 % _this.options.lanes;
299
- measurements[_i2] = {
300
- index: _i2,
301
- start: start,
302
- size: size,
303
- end: end,
304
- key: key,
305
- lane: lane
306
- };
307
- }
308
- _this.measurementsCache = measurements;
309
- return measurements;
310
- }, {
311
- key: process.env.NODE_ENV !== 'production' && 'getMeasurements',
312
- debug: function debug() {
313
- return _this.options.debug;
314
- }
315
- });
316
- this.calculateRange = utils.memo(function () {
317
- return [_this.getMeasurements(), _this.getSize(), _this.scrollOffset];
318
- }, function (measurements, outerSize, scrollOffset) {
319
- return _this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
320
- measurements: measurements,
321
- outerSize: outerSize,
322
- scrollOffset: scrollOffset
323
- }) : null;
324
- }, {
325
- key: process.env.NODE_ENV !== 'production' && 'calculateRange',
326
- debug: function debug() {
327
- return _this.options.debug;
328
- }
329
- });
330
- this.getIndexes = utils.memo(function () {
331
- return [_this.options.rangeExtractor, _this.calculateRange(), _this.options.overscan, _this.options.count];
332
- }, function (rangeExtractor, range, overscan, count) {
333
- return range === null ? [] : rangeExtractor(_rollupPluginBabelHelpers.extends({}, range, {
334
- overscan: overscan,
335
- count: count
336
- }));
337
- }, {
338
- key: process.env.NODE_ENV !== 'production' && 'getIndexes',
339
- debug: function debug() {
340
- return _this.options.debug;
341
- }
342
- });
343
- this.indexFromElement = function (node) {
344
- var attributeName = _this.options.indexAttribute;
345
- var indexStr = node.getAttribute(attributeName);
346
- if (!indexStr) {
347
- console.warn("Missing attribute name '" + attributeName + "={index}' on measured element.");
348
- return -1;
349
- }
350
- return parseInt(indexStr, 10);
351
- };
352
- this._measureElement = function (node, entry) {
353
- var item = _this.measurementsCache[_this.indexFromElement(node)];
354
- if (!item || !node.isConnected) {
355
- _this.measureElementCache.forEach(function (cached, key) {
356
- if (cached === node) {
357
- _this.observer.unobserve(node);
358
- _this.measureElementCache["delete"](key);
359
- }
360
- });
361
- return;
362
- }
363
- var prevNode = _this.measureElementCache.get(item.key);
364
- if (prevNode !== node) {
365
- if (prevNode) {
366
- _this.observer.unobserve(prevNode);
367
- }
368
- _this.observer.observe(node);
369
- _this.measureElementCache.set(item.key, node);
370
- }
371
- var measuredItemSize = _this.options.measureElement(node, entry, _this);
372
- _this.resizeItem(item, measuredItemSize);
373
- };
374
- this.resizeItem = function (item, size) {
375
- var _this$itemSizeCache$g;
376
- var itemSize = (_this$itemSizeCache$g = _this.itemSizeCache.get(item.key)) != null ? _this$itemSizeCache$g : item.size;
377
- var delta = size - itemSize;
378
- if (delta !== 0) {
379
- if (item.start < _this.scrollOffset) {
380
- if (process.env.NODE_ENV !== 'production' && _this.options.debug) {
381
- console.info('correction', delta);
382
- }
383
- _this._scrollToOffset(_this.scrollOffset, {
384
- adjustments: _this.scrollAdjustments += delta,
385
- behavior: undefined
386
- });
387
- }
388
- _this.pendingMeasuredCacheIndexes.push(item.index);
389
- _this.itemSizeCache = new Map(_this.itemSizeCache.set(item.key, size));
390
- _this.notify(false);
391
- }
392
- };
393
- this.measureElement = function (node) {
394
- if (!node) {
395
- return;
396
- }
397
- _this._measureElement(node, undefined);
398
- };
399
- this.getVirtualItems = utils.memo(function () {
400
- return [_this.getIndexes(), _this.getMeasurements()];
401
- }, function (indexes, measurements) {
402
- var virtualItems = [];
403
- for (var k = 0, len = indexes.length; k < len; k++) {
404
- var _i3 = indexes[k];
405
- var measurement = measurements[_i3];
406
- virtualItems.push(measurement);
407
- }
408
- return virtualItems;
409
- }, {
410
- key: process.env.NODE_ENV !== 'production' && 'getIndexes',
411
- debug: function debug() {
412
- return _this.options.debug;
413
- }
414
- });
415
- this.getVirtualItemForOffset = function (offset) {
416
- var measurements = _this.getMeasurements();
417
- return utils.notUndefined(measurements[findNearestBinarySearch(0, measurements.length - 1, function (index) {
418
- return utils.notUndefined(measurements[index]).start;
419
- }, offset)]);
420
- };
421
- this.getOffsetForAlignment = function (toOffset, align) {
422
- var size = _this.getSize();
423
- if (align === 'auto') {
424
- if (toOffset <= _this.scrollOffset) {
425
- align = 'start';
426
- } else if (toOffset >= _this.scrollOffset + size) {
427
- align = 'end';
428
- } else {
429
- align = 'start';
430
- }
431
- }
432
- if (align === 'start') {
433
- toOffset = toOffset;
434
- } else if (align === 'end') {
435
- toOffset = toOffset - size;
436
- } else if (align === 'center') {
437
- toOffset = toOffset - size / 2;
438
- }
439
- var scrollSizeProp = _this.options.horizontal ? 'scrollWidth' : 'scrollHeight';
440
- var scrollSize = _this.scrollElement ? 'document' in _this.scrollElement ? _this.scrollElement.document.documentElement[scrollSizeProp] : _this.scrollElement[scrollSizeProp] : 0;
441
- var maxOffset = scrollSize - _this.getSize();
442
- return Math.max(Math.min(maxOffset, toOffset), 0);
443
- };
444
- this.getOffsetForIndex = function (index, align) {
445
- if (align === void 0) {
446
- align = 'auto';
447
- }
448
- index = Math.max(0, Math.min(index, _this.options.count - 1));
449
- var measurement = utils.notUndefined(_this.getMeasurements()[index]);
450
- if (align === 'auto') {
451
- if (measurement.end >= _this.scrollOffset + _this.getSize() - _this.options.scrollPaddingEnd) {
452
- align = 'end';
453
- } else if (measurement.start <= _this.scrollOffset + _this.options.scrollPaddingStart) {
454
- align = 'start';
455
- } else {
456
- return [_this.scrollOffset, align];
457
- }
458
- }
459
- var toOffset = align === 'end' ? measurement.end + _this.options.scrollPaddingEnd : measurement.start - _this.options.scrollPaddingStart;
460
- return [_this.getOffsetForAlignment(toOffset, align), align];
461
- };
462
- this.isDynamicMode = function () {
463
- return _this.measureElementCache.size > 0;
464
- };
465
- this.cancelScrollToIndex = function () {
466
- if (_this.scrollToIndexTimeoutId !== null) {
467
- clearTimeout(_this.scrollToIndexTimeoutId);
468
- _this.scrollToIndexTimeoutId = null;
469
- }
470
- };
471
- this.scrollToOffset = function (toOffset, _temp) {
472
- var _ref5 = _temp === void 0 ? {} : _temp,
473
- _ref5$align = _ref5.align,
474
- align = _ref5$align === void 0 ? 'start' : _ref5$align,
475
- behavior = _ref5.behavior;
476
- _this.cancelScrollToIndex();
477
- if (behavior === 'smooth' && _this.isDynamicMode()) {
478
- console.warn('The `smooth` scroll behavior is not fully supported with dynamic size.');
479
- }
480
- _this._scrollToOffset(_this.getOffsetForAlignment(toOffset, align), {
481
- adjustments: undefined,
482
- behavior: behavior
483
- });
484
- };
485
- this.scrollToIndex = function (index, _temp2) {
486
- var _ref6 = _temp2 === void 0 ? {} : _temp2,
487
- _ref6$align = _ref6.align,
488
- initialAlign = _ref6$align === void 0 ? 'auto' : _ref6$align,
489
- behavior = _ref6.behavior;
490
- index = Math.max(0, Math.min(index, _this.options.count - 1));
491
- _this.cancelScrollToIndex();
492
- if (behavior === 'smooth' && _this.isDynamicMode()) {
493
- console.warn('The `smooth` scroll behavior is not fully supported with dynamic size.');
494
- }
495
- var _this$getOffsetForInd = _this.getOffsetForIndex(index, initialAlign),
496
- toOffset = _this$getOffsetForInd[0],
497
- align = _this$getOffsetForInd[1];
498
- _this._scrollToOffset(toOffset, {
499
- adjustments: undefined,
500
- behavior: behavior
501
- });
502
- if (behavior !== 'smooth' && _this.isDynamicMode()) {
503
- _this.scrollToIndexTimeoutId = setTimeout(function () {
504
- _this.scrollToIndexTimeoutId = null;
505
- var elementInDOM = _this.measureElementCache.has(_this.options.getItemKey(index));
506
- if (elementInDOM) {
507
- var _this$getOffsetForInd2 = _this.getOffsetForIndex(index, align),
508
- _toOffset = _this$getOffsetForInd2[0];
509
- if (!utils.approxEqual(_toOffset, _this.scrollOffset)) {
510
- _this.scrollToIndex(index, {
511
- align: align,
512
- behavior: behavior
513
- });
514
- }
515
- } else {
516
- _this.scrollToIndex(index, {
517
- align: align,
518
- behavior: behavior
519
- });
520
- }
521
- });
522
- }
523
- };
524
- this.scrollBy = function (delta, _temp3) {
525
- var _ref7 = _temp3 === void 0 ? {} : _temp3,
526
- behavior = _ref7.behavior;
527
- _this.cancelScrollToIndex();
528
- if (behavior === 'smooth' && _this.isDynamicMode()) {
529
- console.warn('The `smooth` scroll behavior is not fully supported with dynamic size.');
530
- }
531
- _this._scrollToOffset(_this.scrollOffset + delta, {
532
- adjustments: undefined,
533
- behavior: behavior
534
- });
535
- };
536
- this.getTotalSize = function () {
537
- var _this$getMeasurements;
538
- return (((_this$getMeasurements = _this.getMeasurements()[_this.options.count - 1]) == null ? void 0 : _this$getMeasurements.end) || _this.options.paddingStart) - _this.options.scrollMargin + _this.options.paddingEnd;
539
- };
540
- this._scrollToOffset = function (offset, _ref8) {
541
- var adjustments = _ref8.adjustments,
542
- behavior = _ref8.behavior;
543
- _this.options.scrollToFn(offset, {
544
- behavior: behavior,
545
- adjustments: adjustments
546
- }, _this);
547
- };
548
- this.measure = function () {
549
- _this.itemSizeCache = new Map();
550
- _this.notify(false);
551
- };
552
- this.setOptions(_opts);
553
- this.scrollRect = this.options.initialRect;
554
- this.scrollOffset = this.options.initialOffset;
555
- this.measurementsCache = this.options.initialMeasurementsCache;
556
- this.measurementsCache.forEach(function (item) {
557
- _this.itemSizeCache.set(item.key, item.size);
558
- });
559
- this.maybeNotify();
560
- };
561
- var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCurrentValue, value) {
562
- while (low <= high) {
563
- var middle = (low + high) / 2 | 0;
564
- var currentValue = getCurrentValue(middle);
565
- if (currentValue < value) {
566
- low = middle + 1;
567
- } else if (currentValue > value) {
568
- high = middle - 1;
569
- } else {
570
- return middle;
571
- }
572
- }
573
- if (low > 0) {
574
- return low - 1;
575
- } else {
576
- return 0;
577
- }
578
- };
579
- function calculateRange(_ref9) {
580
- var measurements = _ref9.measurements,
581
- outerSize = _ref9.outerSize,
582
- scrollOffset = _ref9.scrollOffset;
583
- var count = measurements.length - 1;
584
- var getOffset = function getOffset(index) {
585
- return measurements[index].start;
586
- };
587
- var startIndex = findNearestBinarySearch(0, count, getOffset, scrollOffset);
588
- var endIndex = startIndex;
589
- while (endIndex < count && measurements[endIndex].end < scrollOffset + outerSize) {
590
- endIndex++;
591
- }
592
- return {
593
- startIndex: startIndex,
594
- endIndex: endIndex
595
- };
596
- }
597
-
598
- exports.approxEqual = utils.approxEqual;
599
- exports.memo = utils.memo;
600
- exports.notUndefined = utils.notUndefined;
601
- exports.Virtualizer = Virtualizer;
602
- exports.defaultKeyExtractor = defaultKeyExtractor;
603
- exports.defaultRangeExtractor = defaultRangeExtractor;
604
- exports.elementScroll = elementScroll;
605
- exports.measureElement = measureElement;
606
- exports.observeElementOffset = observeElementOffset;
607
- exports.observeElementRect = observeElementRect;
@@ -1,62 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- /**
5
- * virtual-core
6
- *
7
- * Copyright (c) TanStack
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE.md file in the root directory of this source tree.
11
- *
12
- * @license MIT
13
- */
14
- function memo(getDeps, fn, opts) {
15
- var _opts$initialDeps;
16
- var deps = (_opts$initialDeps = opts.initialDeps) != null ? _opts$initialDeps : [];
17
- var result;
18
- return function () {
19
- var depTime;
20
- if (opts.key && opts.debug != null && opts.debug()) depTime = Date.now();
21
- var newDeps = getDeps();
22
- var depsChanged = newDeps.length !== deps.length || newDeps.some(function (dep, index) {
23
- return deps[index] !== dep;
24
- });
25
- if (!depsChanged) {
26
- return result;
27
- }
28
- deps = newDeps;
29
- var resultTime;
30
- if (opts.key && opts.debug != null && opts.debug()) resultTime = Date.now();
31
- result = fn.apply(void 0, newDeps);
32
- if (opts.key && opts.debug != null && opts.debug()) {
33
- var depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
34
- var resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
35
- var resultFpsPercentage = resultEndTime / 16;
36
- var pad = function pad(str, num) {
37
- str = String(str);
38
- while (str.length < num) {
39
- str = ' ' + str;
40
- }
41
- return str;
42
- };
43
- console.info("%c\u23F1 " + pad(resultEndTime, 5) + " /" + pad(depEndTime, 5) + " ms", "\n font-size: .6rem;\n font-weight: bold;\n color: hsl(" + Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120)) + "deg 100% 31%);", opts == null ? void 0 : opts.key);
44
- }
45
- opts == null || opts.onChange == null || opts.onChange(result);
46
- return result;
47
- };
48
- }
49
- function notUndefined(value, msg) {
50
- if (value === undefined) {
51
- throw new Error("Unexpected undefined" + (msg ? ": " + msg : ''));
52
- } else {
53
- return value;
54
- }
55
- }
56
- var approxEqual = function approxEqual(a, b) {
57
- return Math.abs(a - b) < 1;
58
- };
59
-
60
- exports.approxEqual = approxEqual;
61
- exports.memo = memo;
62
- exports.notUndefined = notUndefined;
@@ -1,27 +0,0 @@
1
- 'use client';
2
- /**
3
- * react-virtual
4
- *
5
- * Copyright (c) TanStack
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE.md file in the root directory of this source tree.
9
- *
10
- * @license MIT
11
- */
12
- function _extends() {
13
- _extends = Object.assign ? Object.assign.bind() : function (target) {
14
- for (var i = 1; i < arguments.length; i++) {
15
- var source = arguments[i];
16
- for (var key in source) {
17
- if (Object.prototype.hasOwnProperty.call(source, key)) {
18
- target[key] = source[key];
19
- }
20
- }
21
- }
22
- return target;
23
- };
24
- return _extends.apply(this, arguments);
25
- }
26
-
27
- export { _extends as extends };