lkd-web-kit 0.7.26 → 0.7.28
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/dist/node_modules/@tanstack/virtual-core/dist/esm/index.cjs +67 -9
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +67 -9
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.cjs +6 -2
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +6 -2
- package/package.json +11 -11
|
@@ -128,7 +128,11 @@ class Virtualizer {
|
|
|
128
128
|
this.isScrolling = false;
|
|
129
129
|
this.measurementsCache = [];
|
|
130
130
|
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
131
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
131
132
|
this.pendingMeasuredCacheIndexes = [];
|
|
133
|
+
this.prevLanes = void 0;
|
|
134
|
+
this.lanesChangedFlag = false;
|
|
135
|
+
this.lanesSettling = false;
|
|
132
136
|
this.scrollRect = null;
|
|
133
137
|
this.scrollOffset = null;
|
|
134
138
|
this.scrollDirection = null;
|
|
@@ -327,47 +331,99 @@ class Virtualizer {
|
|
|
327
331
|
this.options.paddingStart,
|
|
328
332
|
this.options.scrollMargin,
|
|
329
333
|
this.options.getItemKey,
|
|
330
|
-
this.options.enabled
|
|
334
|
+
this.options.enabled,
|
|
335
|
+
this.options.lanes
|
|
331
336
|
],
|
|
332
|
-
(count, paddingStart, scrollMargin, getItemKey, enabled) => {
|
|
337
|
+
(count, paddingStart, scrollMargin, getItemKey, enabled, lanes) => {
|
|
338
|
+
const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
|
|
339
|
+
if (lanesChanged) {
|
|
340
|
+
this.lanesChangedFlag = true;
|
|
341
|
+
}
|
|
342
|
+
this.prevLanes = lanes;
|
|
333
343
|
this.pendingMeasuredCacheIndexes = [];
|
|
334
344
|
return {
|
|
335
345
|
count,
|
|
336
346
|
paddingStart,
|
|
337
347
|
scrollMargin,
|
|
338
348
|
getItemKey,
|
|
339
|
-
enabled
|
|
349
|
+
enabled,
|
|
350
|
+
lanes
|
|
340
351
|
};
|
|
341
352
|
},
|
|
342
353
|
{
|
|
343
|
-
key: false
|
|
354
|
+
key: false,
|
|
355
|
+
skipInitialOnChange: true,
|
|
356
|
+
onChange: () => {
|
|
357
|
+
this.notify(this.isScrolling);
|
|
358
|
+
}
|
|
344
359
|
}
|
|
345
360
|
);
|
|
346
361
|
this.getMeasurements = utils.memo(
|
|
347
362
|
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
348
|
-
({ count, paddingStart, scrollMargin, getItemKey, enabled }, itemSizeCache) => {
|
|
363
|
+
({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes }, itemSizeCache) => {
|
|
349
364
|
if (!enabled) {
|
|
350
365
|
this.measurementsCache = [];
|
|
351
366
|
this.itemSizeCache.clear();
|
|
367
|
+
this.laneAssignments.clear();
|
|
352
368
|
return [];
|
|
353
369
|
}
|
|
370
|
+
if (this.laneAssignments.size > count) {
|
|
371
|
+
for (const index of this.laneAssignments.keys()) {
|
|
372
|
+
if (index >= count) {
|
|
373
|
+
this.laneAssignments.delete(index);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (this.lanesChangedFlag) {
|
|
378
|
+
this.lanesChangedFlag = false;
|
|
379
|
+
this.lanesSettling = true;
|
|
380
|
+
this.measurementsCache = [];
|
|
381
|
+
this.itemSizeCache.clear();
|
|
382
|
+
this.laneAssignments.clear();
|
|
383
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
384
|
+
}
|
|
354
385
|
if (this.measurementsCache.length === 0) {
|
|
355
386
|
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
356
387
|
this.measurementsCache.forEach((item) => {
|
|
357
388
|
this.itemSizeCache.set(item.key, item.size);
|
|
358
389
|
});
|
|
359
390
|
}
|
|
360
|
-
const min = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
391
|
+
const min = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
361
392
|
this.pendingMeasuredCacheIndexes = [];
|
|
393
|
+
if (this.lanesSettling && this.measurementsCache.length === count) {
|
|
394
|
+
this.lanesSettling = false;
|
|
395
|
+
}
|
|
362
396
|
const measurements = this.measurementsCache.slice(0, min);
|
|
397
|
+
const laneLastIndex = new Array(lanes).fill(
|
|
398
|
+
void 0
|
|
399
|
+
);
|
|
400
|
+
for (let m = 0; m < min; m++) {
|
|
401
|
+
const item = measurements[m];
|
|
402
|
+
if (item) {
|
|
403
|
+
laneLastIndex[item.lane] = m;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
363
406
|
for (let i = min; i < count; i++) {
|
|
364
407
|
const key = getItemKey(i);
|
|
365
|
-
const
|
|
366
|
-
|
|
408
|
+
const cachedLane = this.laneAssignments.get(i);
|
|
409
|
+
let lane;
|
|
410
|
+
let start;
|
|
411
|
+
if (cachedLane !== void 0 && this.options.lanes > 1) {
|
|
412
|
+
lane = cachedLane;
|
|
413
|
+
const prevIndex = laneLastIndex[lane];
|
|
414
|
+
const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
|
|
415
|
+
start = prevInLane ? prevInLane.end + this.options.gap : paddingStart + scrollMargin;
|
|
416
|
+
} else {
|
|
417
|
+
const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
|
|
418
|
+
start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
|
|
419
|
+
lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
|
|
420
|
+
if (this.options.lanes > 1) {
|
|
421
|
+
this.laneAssignments.set(i, lane);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
367
424
|
const measuredSize = itemSizeCache.get(key);
|
|
368
425
|
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
369
426
|
const end = start + size;
|
|
370
|
-
const lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
|
|
371
427
|
measurements[i] = {
|
|
372
428
|
index: i,
|
|
373
429
|
start,
|
|
@@ -376,6 +432,7 @@ class Virtualizer {
|
|
|
376
432
|
key,
|
|
377
433
|
lane
|
|
378
434
|
};
|
|
435
|
+
laneLastIndex[lane] = i;
|
|
379
436
|
}
|
|
380
437
|
this.measurementsCache = measurements;
|
|
381
438
|
return measurements;
|
|
@@ -669,6 +726,7 @@ class Virtualizer {
|
|
|
669
726
|
};
|
|
670
727
|
this.measure = () => {
|
|
671
728
|
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
729
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
672
730
|
this.notify(false);
|
|
673
731
|
};
|
|
674
732
|
this.setOptions(opts);
|
|
@@ -124,7 +124,11 @@ class Virtualizer {
|
|
|
124
124
|
this.isScrolling = false;
|
|
125
125
|
this.measurementsCache = [];
|
|
126
126
|
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
127
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
127
128
|
this.pendingMeasuredCacheIndexes = [];
|
|
129
|
+
this.prevLanes = void 0;
|
|
130
|
+
this.lanesChangedFlag = false;
|
|
131
|
+
this.lanesSettling = false;
|
|
128
132
|
this.scrollRect = null;
|
|
129
133
|
this.scrollOffset = null;
|
|
130
134
|
this.scrollDirection = null;
|
|
@@ -323,47 +327,99 @@ class Virtualizer {
|
|
|
323
327
|
this.options.paddingStart,
|
|
324
328
|
this.options.scrollMargin,
|
|
325
329
|
this.options.getItemKey,
|
|
326
|
-
this.options.enabled
|
|
330
|
+
this.options.enabled,
|
|
331
|
+
this.options.lanes
|
|
327
332
|
],
|
|
328
|
-
(count, paddingStart, scrollMargin, getItemKey, enabled) => {
|
|
333
|
+
(count, paddingStart, scrollMargin, getItemKey, enabled, lanes) => {
|
|
334
|
+
const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
|
|
335
|
+
if (lanesChanged) {
|
|
336
|
+
this.lanesChangedFlag = true;
|
|
337
|
+
}
|
|
338
|
+
this.prevLanes = lanes;
|
|
329
339
|
this.pendingMeasuredCacheIndexes = [];
|
|
330
340
|
return {
|
|
331
341
|
count,
|
|
332
342
|
paddingStart,
|
|
333
343
|
scrollMargin,
|
|
334
344
|
getItemKey,
|
|
335
|
-
enabled
|
|
345
|
+
enabled,
|
|
346
|
+
lanes
|
|
336
347
|
};
|
|
337
348
|
},
|
|
338
349
|
{
|
|
339
|
-
key: false
|
|
350
|
+
key: false,
|
|
351
|
+
skipInitialOnChange: true,
|
|
352
|
+
onChange: () => {
|
|
353
|
+
this.notify(this.isScrolling);
|
|
354
|
+
}
|
|
340
355
|
}
|
|
341
356
|
);
|
|
342
357
|
this.getMeasurements = memo(
|
|
343
358
|
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
344
|
-
({ count, paddingStart, scrollMargin, getItemKey, enabled }, itemSizeCache) => {
|
|
359
|
+
({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes }, itemSizeCache) => {
|
|
345
360
|
if (!enabled) {
|
|
346
361
|
this.measurementsCache = [];
|
|
347
362
|
this.itemSizeCache.clear();
|
|
363
|
+
this.laneAssignments.clear();
|
|
348
364
|
return [];
|
|
349
365
|
}
|
|
366
|
+
if (this.laneAssignments.size > count) {
|
|
367
|
+
for (const index of this.laneAssignments.keys()) {
|
|
368
|
+
if (index >= count) {
|
|
369
|
+
this.laneAssignments.delete(index);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (this.lanesChangedFlag) {
|
|
374
|
+
this.lanesChangedFlag = false;
|
|
375
|
+
this.lanesSettling = true;
|
|
376
|
+
this.measurementsCache = [];
|
|
377
|
+
this.itemSizeCache.clear();
|
|
378
|
+
this.laneAssignments.clear();
|
|
379
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
380
|
+
}
|
|
350
381
|
if (this.measurementsCache.length === 0) {
|
|
351
382
|
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
352
383
|
this.measurementsCache.forEach((item) => {
|
|
353
384
|
this.itemSizeCache.set(item.key, item.size);
|
|
354
385
|
});
|
|
355
386
|
}
|
|
356
|
-
const min = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
387
|
+
const min = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
357
388
|
this.pendingMeasuredCacheIndexes = [];
|
|
389
|
+
if (this.lanesSettling && this.measurementsCache.length === count) {
|
|
390
|
+
this.lanesSettling = false;
|
|
391
|
+
}
|
|
358
392
|
const measurements = this.measurementsCache.slice(0, min);
|
|
393
|
+
const laneLastIndex = new Array(lanes).fill(
|
|
394
|
+
void 0
|
|
395
|
+
);
|
|
396
|
+
for (let m = 0; m < min; m++) {
|
|
397
|
+
const item = measurements[m];
|
|
398
|
+
if (item) {
|
|
399
|
+
laneLastIndex[item.lane] = m;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
359
402
|
for (let i = min; i < count; i++) {
|
|
360
403
|
const key = getItemKey(i);
|
|
361
|
-
const
|
|
362
|
-
|
|
404
|
+
const cachedLane = this.laneAssignments.get(i);
|
|
405
|
+
let lane;
|
|
406
|
+
let start;
|
|
407
|
+
if (cachedLane !== void 0 && this.options.lanes > 1) {
|
|
408
|
+
lane = cachedLane;
|
|
409
|
+
const prevIndex = laneLastIndex[lane];
|
|
410
|
+
const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
|
|
411
|
+
start = prevInLane ? prevInLane.end + this.options.gap : paddingStart + scrollMargin;
|
|
412
|
+
} else {
|
|
413
|
+
const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
|
|
414
|
+
start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
|
|
415
|
+
lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
|
|
416
|
+
if (this.options.lanes > 1) {
|
|
417
|
+
this.laneAssignments.set(i, lane);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
363
420
|
const measuredSize = itemSizeCache.get(key);
|
|
364
421
|
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
365
422
|
const end = start + size;
|
|
366
|
-
const lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
|
|
367
423
|
measurements[i] = {
|
|
368
424
|
index: i,
|
|
369
425
|
start,
|
|
@@ -372,6 +428,7 @@ class Virtualizer {
|
|
|
372
428
|
key,
|
|
373
429
|
lane
|
|
374
430
|
};
|
|
431
|
+
laneLastIndex[lane] = i;
|
|
375
432
|
}
|
|
376
433
|
this.measurementsCache = measurements;
|
|
377
434
|
return measurements;
|
|
@@ -665,6 +722,7 @@ class Virtualizer {
|
|
|
665
722
|
};
|
|
666
723
|
this.measure = () => {
|
|
667
724
|
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
725
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
668
726
|
this.notify(false);
|
|
669
727
|
};
|
|
670
728
|
this.setOptions(opts);
|
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
function memo(getDeps, fn, opts) {
|
|
6
6
|
let deps = opts.initialDeps ?? [];
|
|
7
7
|
let result;
|
|
8
|
+
let isInitial = true;
|
|
8
9
|
function memoizedFunction() {
|
|
9
|
-
var _a, _b, _c
|
|
10
|
+
var _a, _b, _c;
|
|
10
11
|
let depTime;
|
|
11
12
|
if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
|
|
12
13
|
const newDeps = getDeps();
|
|
@@ -41,7 +42,10 @@ function memo(getDeps, fn, opts) {
|
|
|
41
42
|
opts == null ? void 0 : opts.key
|
|
42
43
|
);
|
|
43
44
|
}
|
|
44
|
-
(
|
|
45
|
+
if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) {
|
|
46
|
+
opts.onChange(result);
|
|
47
|
+
}
|
|
48
|
+
isInitial = false;
|
|
45
49
|
return result;
|
|
46
50
|
}
|
|
47
51
|
memoizedFunction.updateDeps = (newDeps) => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function memo(getDeps, fn, opts) {
|
|
2
2
|
let deps = opts.initialDeps ?? [];
|
|
3
3
|
let result;
|
|
4
|
+
let isInitial = true;
|
|
4
5
|
function memoizedFunction() {
|
|
5
|
-
var _a, _b, _c
|
|
6
|
+
var _a, _b, _c;
|
|
6
7
|
let depTime;
|
|
7
8
|
if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
|
|
8
9
|
const newDeps = getDeps();
|
|
@@ -37,7 +38,10 @@ function memo(getDeps, fn, opts) {
|
|
|
37
38
|
opts == null ? void 0 : opts.key
|
|
38
39
|
);
|
|
39
40
|
}
|
|
40
|
-
(
|
|
41
|
+
if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) {
|
|
42
|
+
opts.onChange(result);
|
|
43
|
+
}
|
|
44
|
+
isInitial = false;
|
|
41
45
|
return result;
|
|
42
46
|
}
|
|
43
47
|
memoizedFunction.updateDeps = (newDeps) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkd-web-kit",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.28",
|
|
4
4
|
"description": "A template for creating React component libraries with Vite.",
|
|
5
5
|
"author": "LKD",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,21 +45,21 @@
|
|
|
45
45
|
"vitest": "^3.2.4"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@mantine/core": "^8.3.
|
|
49
|
-
"@mantine/dates": "^8.3.
|
|
50
|
-
"@mantine/hooks": "^8.3.
|
|
51
|
-
"@mantine/notifications": "^8.3.
|
|
52
|
-
"@tanstack/react-query": "^5.90.
|
|
48
|
+
"@mantine/core": "^8.3.12",
|
|
49
|
+
"@mantine/dates": "^8.3.12",
|
|
50
|
+
"@mantine/hooks": "^8.3.12",
|
|
51
|
+
"@mantine/notifications": "^8.3.12",
|
|
52
|
+
"@tanstack/react-query": "^5.90.16",
|
|
53
53
|
"clsx": "^2.1.1",
|
|
54
|
-
"ky": "^1.14.
|
|
55
|
-
"next": "^16.
|
|
54
|
+
"ky": "^1.14.2",
|
|
55
|
+
"next": "^16.1.1",
|
|
56
56
|
"react": "^19.2.3",
|
|
57
57
|
"react-dom": "^19.2.3",
|
|
58
|
-
"react-hook-form": "^7.
|
|
58
|
+
"react-hook-form": "^7.71.0",
|
|
59
59
|
"react-query-kit": "^3.3.2",
|
|
60
|
-
"zod": "^4.
|
|
60
|
+
"zod": "^4.3.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@tanstack/react-virtual": "^3.13.
|
|
63
|
+
"@tanstack/react-virtual": "^3.13.13"
|
|
64
64
|
}
|
|
65
65
|
}
|