@wise/dynamic-flow-client-internal 5.15.0-experimental-76b77f2 → 5.15.0-experimental-2996a75
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/build/main.js +1104 -42
- package/build/main.mjs +1145 -83
- package/build/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +4 -4
package/build/main.js
CHANGED
|
@@ -1258,15 +1258,974 @@ var useIsElementVisible = (elementRef) => {
|
|
|
1258
1258
|
|
|
1259
1259
|
// ../renderers/src/CollectionRenderer.tsx
|
|
1260
1260
|
var import_icons = require("@transferwise/icons");
|
|
1261
|
+
|
|
1262
|
+
// ../../node_modules/.pnpm/@tanstack+react-virtual@3.13.24_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/@tanstack/react-virtual/dist/esm/index.js
|
|
1263
|
+
var React = __toESM(require("react"), 1);
|
|
1264
|
+
var import_react_dom = require("react-dom");
|
|
1265
|
+
|
|
1266
|
+
// ../../node_modules/.pnpm/@tanstack+virtual-core@3.14.0/node_modules/@tanstack/virtual-core/dist/esm/utils.js
|
|
1267
|
+
function memo(getDeps, fn, opts) {
|
|
1268
|
+
var _a;
|
|
1269
|
+
let deps = (_a = opts.initialDeps) != null ? _a : [];
|
|
1270
|
+
let result;
|
|
1271
|
+
let isInitial = true;
|
|
1272
|
+
function memoizedFunction() {
|
|
1273
|
+
var _a2, _b, _c;
|
|
1274
|
+
let depTime;
|
|
1275
|
+
if (opts.key && ((_a2 = opts.debug) == null ? void 0 : _a2.call(opts))) depTime = Date.now();
|
|
1276
|
+
const newDeps = getDeps();
|
|
1277
|
+
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
|
1278
|
+
if (!depsChanged) {
|
|
1279
|
+
return result;
|
|
1280
|
+
}
|
|
1281
|
+
deps = newDeps;
|
|
1282
|
+
let resultTime;
|
|
1283
|
+
if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now();
|
|
1284
|
+
result = fn(...newDeps);
|
|
1285
|
+
if (opts.key && ((_c = opts.debug) == null ? void 0 : _c.call(opts))) {
|
|
1286
|
+
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
1287
|
+
const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
1288
|
+
const resultFpsPercentage = resultEndTime / 16;
|
|
1289
|
+
const pad = (str, num) => {
|
|
1290
|
+
str = String(str);
|
|
1291
|
+
while (str.length < num) {
|
|
1292
|
+
str = " " + str;
|
|
1293
|
+
}
|
|
1294
|
+
return str;
|
|
1295
|
+
};
|
|
1296
|
+
console.info(
|
|
1297
|
+
`%c\u23F1 ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`,
|
|
1298
|
+
`
|
|
1299
|
+
font-size: .6rem;
|
|
1300
|
+
font-weight: bold;
|
|
1301
|
+
color: hsl(${Math.max(
|
|
1302
|
+
0,
|
|
1303
|
+
Math.min(120 - 120 * resultFpsPercentage, 120)
|
|
1304
|
+
)}deg 100% 31%);`,
|
|
1305
|
+
opts == null ? void 0 : opts.key
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) {
|
|
1309
|
+
opts.onChange(result);
|
|
1310
|
+
}
|
|
1311
|
+
isInitial = false;
|
|
1312
|
+
return result;
|
|
1313
|
+
}
|
|
1314
|
+
memoizedFunction.updateDeps = (newDeps) => {
|
|
1315
|
+
deps = newDeps;
|
|
1316
|
+
};
|
|
1317
|
+
return memoizedFunction;
|
|
1318
|
+
}
|
|
1319
|
+
function notUndefined(value, msg) {
|
|
1320
|
+
if (value === void 0) {
|
|
1321
|
+
throw new Error(`Unexpected undefined${msg ? `: ${msg}` : ""}`);
|
|
1322
|
+
} else {
|
|
1323
|
+
return value;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
var approxEqual = (a, b) => Math.abs(a - b) < 1.01;
|
|
1327
|
+
var debounce = (targetWindow, fn, ms) => {
|
|
1328
|
+
let timeoutId;
|
|
1329
|
+
return function(...args) {
|
|
1330
|
+
targetWindow.clearTimeout(timeoutId);
|
|
1331
|
+
timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
|
|
1332
|
+
};
|
|
1333
|
+
};
|
|
1334
|
+
|
|
1335
|
+
// ../../node_modules/.pnpm/@tanstack+virtual-core@3.14.0/node_modules/@tanstack/virtual-core/dist/esm/index.js
|
|
1336
|
+
var defaultKeyExtractor = (index) => index;
|
|
1337
|
+
var defaultRangeExtractor = (range) => {
|
|
1338
|
+
const start = Math.max(range.startIndex - range.overscan, 0);
|
|
1339
|
+
const end = Math.min(range.endIndex + range.overscan, range.count - 1);
|
|
1340
|
+
const arr = [];
|
|
1341
|
+
for (let i = start; i <= end; i++) {
|
|
1342
|
+
arr.push(i);
|
|
1343
|
+
}
|
|
1344
|
+
return arr;
|
|
1345
|
+
};
|
|
1346
|
+
var addEventListenerOptions = {
|
|
1347
|
+
passive: true
|
|
1348
|
+
};
|
|
1349
|
+
var observeWindowRect = (instance, cb) => {
|
|
1350
|
+
const element = instance.scrollElement;
|
|
1351
|
+
if (!element) {
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
const handler = () => {
|
|
1355
|
+
cb({ width: element.innerWidth, height: element.innerHeight });
|
|
1356
|
+
};
|
|
1357
|
+
handler();
|
|
1358
|
+
element.addEventListener("resize", handler, addEventListenerOptions);
|
|
1359
|
+
return () => {
|
|
1360
|
+
element.removeEventListener("resize", handler);
|
|
1361
|
+
};
|
|
1362
|
+
};
|
|
1363
|
+
var supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
|
|
1364
|
+
var observeWindowOffset = (instance, cb) => {
|
|
1365
|
+
const element = instance.scrollElement;
|
|
1366
|
+
if (!element) {
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
const targetWindow = instance.targetWindow;
|
|
1370
|
+
if (!targetWindow) {
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
let offset = 0;
|
|
1374
|
+
const fallback = instance.options.useScrollendEvent && supportsScrollend ? () => void 0 : debounce(
|
|
1375
|
+
targetWindow,
|
|
1376
|
+
() => {
|
|
1377
|
+
cb(offset, false);
|
|
1378
|
+
},
|
|
1379
|
+
instance.options.isScrollingResetDelay
|
|
1380
|
+
);
|
|
1381
|
+
const createHandler = (isScrolling) => () => {
|
|
1382
|
+
offset = element[instance.options.horizontal ? "scrollX" : "scrollY"];
|
|
1383
|
+
fallback();
|
|
1384
|
+
cb(offset, isScrolling);
|
|
1385
|
+
};
|
|
1386
|
+
const handler = createHandler(true);
|
|
1387
|
+
const endHandler = createHandler(false);
|
|
1388
|
+
element.addEventListener("scroll", handler, addEventListenerOptions);
|
|
1389
|
+
const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
|
|
1390
|
+
if (registerScrollendEvent) {
|
|
1391
|
+
element.addEventListener("scrollend", endHandler, addEventListenerOptions);
|
|
1392
|
+
}
|
|
1393
|
+
return () => {
|
|
1394
|
+
element.removeEventListener("scroll", handler);
|
|
1395
|
+
if (registerScrollendEvent) {
|
|
1396
|
+
element.removeEventListener("scrollend", endHandler);
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1399
|
+
};
|
|
1400
|
+
var measureElement = (element, entry, instance) => {
|
|
1401
|
+
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
1402
|
+
const box = entry.borderBoxSize[0];
|
|
1403
|
+
if (box) {
|
|
1404
|
+
const size = Math.round(
|
|
1405
|
+
box[instance.options.horizontal ? "inlineSize" : "blockSize"]
|
|
1406
|
+
);
|
|
1407
|
+
return size;
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
1411
|
+
};
|
|
1412
|
+
var windowScroll = (offset, {
|
|
1413
|
+
adjustments = 0,
|
|
1414
|
+
behavior
|
|
1415
|
+
}, instance) => {
|
|
1416
|
+
var _a, _b;
|
|
1417
|
+
const toOffset = offset + adjustments;
|
|
1418
|
+
(_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
|
|
1419
|
+
[instance.options.horizontal ? "left" : "top"]: toOffset,
|
|
1420
|
+
behavior
|
|
1421
|
+
});
|
|
1422
|
+
};
|
|
1423
|
+
var Virtualizer = class {
|
|
1424
|
+
constructor(opts) {
|
|
1425
|
+
this.unsubs = [];
|
|
1426
|
+
this.scrollElement = null;
|
|
1427
|
+
this.targetWindow = null;
|
|
1428
|
+
this.isScrolling = false;
|
|
1429
|
+
this.scrollState = null;
|
|
1430
|
+
this.measurementsCache = [];
|
|
1431
|
+
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
1432
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
1433
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
1434
|
+
this.prevLanes = void 0;
|
|
1435
|
+
this.lanesChangedFlag = false;
|
|
1436
|
+
this.lanesSettling = false;
|
|
1437
|
+
this.scrollRect = null;
|
|
1438
|
+
this.scrollOffset = null;
|
|
1439
|
+
this.scrollDirection = null;
|
|
1440
|
+
this.scrollAdjustments = 0;
|
|
1441
|
+
this.elementsCache = /* @__PURE__ */ new Map();
|
|
1442
|
+
this.now = () => {
|
|
1443
|
+
var _a2;
|
|
1444
|
+
var _a, _b, _c;
|
|
1445
|
+
return (_a2 = (_c = (_b = (_a = this.targetWindow) == null ? void 0 : _a.performance) == null ? void 0 : _b.now) == null ? void 0 : _c.call(_b)) != null ? _a2 : Date.now();
|
|
1446
|
+
};
|
|
1447
|
+
this.observer = /* @__PURE__ */ (() => {
|
|
1448
|
+
let _ro = null;
|
|
1449
|
+
const get = () => {
|
|
1450
|
+
if (_ro) {
|
|
1451
|
+
return _ro;
|
|
1452
|
+
}
|
|
1453
|
+
if (!this.targetWindow || !this.targetWindow.ResizeObserver) {
|
|
1454
|
+
return null;
|
|
1455
|
+
}
|
|
1456
|
+
return _ro = new this.targetWindow.ResizeObserver((entries) => {
|
|
1457
|
+
entries.forEach((entry) => {
|
|
1458
|
+
const run = () => {
|
|
1459
|
+
const node = entry.target;
|
|
1460
|
+
const index = this.indexFromElement(node);
|
|
1461
|
+
if (!node.isConnected) {
|
|
1462
|
+
this.observer.unobserve(node);
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
if (this.shouldMeasureDuringScroll(index)) {
|
|
1466
|
+
this.resizeItem(
|
|
1467
|
+
index,
|
|
1468
|
+
this.options.measureElement(node, entry, this)
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
1473
|
+
});
|
|
1474
|
+
});
|
|
1475
|
+
};
|
|
1476
|
+
return {
|
|
1477
|
+
disconnect: () => {
|
|
1478
|
+
var _a;
|
|
1479
|
+
(_a = get()) == null ? void 0 : _a.disconnect();
|
|
1480
|
+
_ro = null;
|
|
1481
|
+
},
|
|
1482
|
+
observe: (target) => {
|
|
1483
|
+
var _a;
|
|
1484
|
+
return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
|
|
1485
|
+
},
|
|
1486
|
+
unobserve: (target) => {
|
|
1487
|
+
var _a;
|
|
1488
|
+
return (_a = get()) == null ? void 0 : _a.unobserve(target);
|
|
1489
|
+
}
|
|
1490
|
+
};
|
|
1491
|
+
})();
|
|
1492
|
+
this.range = null;
|
|
1493
|
+
this.setOptions = (opts2) => {
|
|
1494
|
+
Object.entries(opts2).forEach(([key, value]) => {
|
|
1495
|
+
if (typeof value === "undefined") delete opts2[key];
|
|
1496
|
+
});
|
|
1497
|
+
this.options = __spreadValues({
|
|
1498
|
+
debug: false,
|
|
1499
|
+
initialOffset: 0,
|
|
1500
|
+
overscan: 1,
|
|
1501
|
+
paddingStart: 0,
|
|
1502
|
+
paddingEnd: 0,
|
|
1503
|
+
scrollPaddingStart: 0,
|
|
1504
|
+
scrollPaddingEnd: 0,
|
|
1505
|
+
horizontal: false,
|
|
1506
|
+
getItemKey: defaultKeyExtractor,
|
|
1507
|
+
rangeExtractor: defaultRangeExtractor,
|
|
1508
|
+
onChange: () => {
|
|
1509
|
+
},
|
|
1510
|
+
measureElement,
|
|
1511
|
+
initialRect: { width: 0, height: 0 },
|
|
1512
|
+
scrollMargin: 0,
|
|
1513
|
+
gap: 0,
|
|
1514
|
+
indexAttribute: "data-index",
|
|
1515
|
+
initialMeasurementsCache: [],
|
|
1516
|
+
lanes: 1,
|
|
1517
|
+
isScrollingResetDelay: 150,
|
|
1518
|
+
enabled: true,
|
|
1519
|
+
isRtl: false,
|
|
1520
|
+
useScrollendEvent: false,
|
|
1521
|
+
useAnimationFrameWithResizeObserver: false,
|
|
1522
|
+
laneAssignmentMode: "estimate"
|
|
1523
|
+
}, opts2);
|
|
1524
|
+
};
|
|
1525
|
+
this.notify = (sync) => {
|
|
1526
|
+
var _a, _b;
|
|
1527
|
+
(_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
|
|
1528
|
+
};
|
|
1529
|
+
this.maybeNotify = memo(
|
|
1530
|
+
() => {
|
|
1531
|
+
this.calculateRange();
|
|
1532
|
+
return [
|
|
1533
|
+
this.isScrolling,
|
|
1534
|
+
this.range ? this.range.startIndex : null,
|
|
1535
|
+
this.range ? this.range.endIndex : null
|
|
1536
|
+
];
|
|
1537
|
+
},
|
|
1538
|
+
(isScrolling) => {
|
|
1539
|
+
this.notify(isScrolling);
|
|
1540
|
+
},
|
|
1541
|
+
{
|
|
1542
|
+
key: "maybeNotify",
|
|
1543
|
+
debug: () => this.options.debug,
|
|
1544
|
+
initialDeps: [
|
|
1545
|
+
this.isScrolling,
|
|
1546
|
+
this.range ? this.range.startIndex : null,
|
|
1547
|
+
this.range ? this.range.endIndex : null
|
|
1548
|
+
]
|
|
1549
|
+
}
|
|
1550
|
+
);
|
|
1551
|
+
this.cleanup = () => {
|
|
1552
|
+
this.unsubs.filter(Boolean).forEach((d) => d());
|
|
1553
|
+
this.unsubs = [];
|
|
1554
|
+
this.observer.disconnect();
|
|
1555
|
+
if (this.rafId != null && this.targetWindow) {
|
|
1556
|
+
this.targetWindow.cancelAnimationFrame(this.rafId);
|
|
1557
|
+
this.rafId = null;
|
|
1558
|
+
}
|
|
1559
|
+
this.scrollState = null;
|
|
1560
|
+
this.scrollElement = null;
|
|
1561
|
+
this.targetWindow = null;
|
|
1562
|
+
};
|
|
1563
|
+
this._didMount = () => {
|
|
1564
|
+
return () => {
|
|
1565
|
+
this.cleanup();
|
|
1566
|
+
};
|
|
1567
|
+
};
|
|
1568
|
+
this._willUpdate = () => {
|
|
1569
|
+
var _a2;
|
|
1570
|
+
var _a;
|
|
1571
|
+
const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
|
|
1572
|
+
if (this.scrollElement !== scrollElement) {
|
|
1573
|
+
this.cleanup();
|
|
1574
|
+
if (!scrollElement) {
|
|
1575
|
+
this.maybeNotify();
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1578
|
+
this.scrollElement = scrollElement;
|
|
1579
|
+
if (this.scrollElement && "ownerDocument" in this.scrollElement) {
|
|
1580
|
+
this.targetWindow = this.scrollElement.ownerDocument.defaultView;
|
|
1581
|
+
} else {
|
|
1582
|
+
this.targetWindow = (_a2 = (_a = this.scrollElement) == null ? void 0 : _a.window) != null ? _a2 : null;
|
|
1583
|
+
}
|
|
1584
|
+
this.elementsCache.forEach((cached) => {
|
|
1585
|
+
this.observer.observe(cached);
|
|
1586
|
+
});
|
|
1587
|
+
this.unsubs.push(
|
|
1588
|
+
this.options.observeElementRect(this, (rect) => {
|
|
1589
|
+
this.scrollRect = rect;
|
|
1590
|
+
this.maybeNotify();
|
|
1591
|
+
})
|
|
1592
|
+
);
|
|
1593
|
+
this.unsubs.push(
|
|
1594
|
+
this.options.observeElementOffset(this, (offset, isScrolling) => {
|
|
1595
|
+
this.scrollAdjustments = 0;
|
|
1596
|
+
this.scrollDirection = isScrolling ? this.getScrollOffset() < offset ? "forward" : "backward" : null;
|
|
1597
|
+
this.scrollOffset = offset;
|
|
1598
|
+
this.isScrolling = isScrolling;
|
|
1599
|
+
if (this.scrollState) {
|
|
1600
|
+
this.scheduleScrollReconcile();
|
|
1601
|
+
}
|
|
1602
|
+
this.maybeNotify();
|
|
1603
|
+
})
|
|
1604
|
+
);
|
|
1605
|
+
this._scrollToOffset(this.getScrollOffset(), {
|
|
1606
|
+
adjustments: void 0,
|
|
1607
|
+
behavior: void 0
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
this.rafId = null;
|
|
1612
|
+
this.getSize = () => {
|
|
1613
|
+
var _a;
|
|
1614
|
+
if (!this.options.enabled) {
|
|
1615
|
+
this.scrollRect = null;
|
|
1616
|
+
return 0;
|
|
1617
|
+
}
|
|
1618
|
+
this.scrollRect = (_a = this.scrollRect) != null ? _a : this.options.initialRect;
|
|
1619
|
+
return this.scrollRect[this.options.horizontal ? "width" : "height"];
|
|
1620
|
+
};
|
|
1621
|
+
this.getScrollOffset = () => {
|
|
1622
|
+
var _a;
|
|
1623
|
+
if (!this.options.enabled) {
|
|
1624
|
+
this.scrollOffset = null;
|
|
1625
|
+
return 0;
|
|
1626
|
+
}
|
|
1627
|
+
this.scrollOffset = (_a = this.scrollOffset) != null ? _a : typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset;
|
|
1628
|
+
return this.scrollOffset;
|
|
1629
|
+
};
|
|
1630
|
+
this.getFurthestMeasurement = (measurements, index) => {
|
|
1631
|
+
const furthestMeasurementsFound = /* @__PURE__ */ new Map();
|
|
1632
|
+
const furthestMeasurements = /* @__PURE__ */ new Map();
|
|
1633
|
+
for (let m = index - 1; m >= 0; m--) {
|
|
1634
|
+
const measurement = measurements[m];
|
|
1635
|
+
if (furthestMeasurementsFound.has(measurement.lane)) {
|
|
1636
|
+
continue;
|
|
1637
|
+
}
|
|
1638
|
+
const previousFurthestMeasurement = furthestMeasurements.get(
|
|
1639
|
+
measurement.lane
|
|
1640
|
+
);
|
|
1641
|
+
if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) {
|
|
1642
|
+
furthestMeasurements.set(measurement.lane, measurement);
|
|
1643
|
+
} else if (measurement.end < previousFurthestMeasurement.end) {
|
|
1644
|
+
furthestMeasurementsFound.set(measurement.lane, true);
|
|
1645
|
+
}
|
|
1646
|
+
if (furthestMeasurementsFound.size === this.options.lanes) {
|
|
1647
|
+
break;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
return furthestMeasurements.size === this.options.lanes ? Array.from(furthestMeasurements.values()).sort((a, b) => {
|
|
1651
|
+
if (a.end === b.end) {
|
|
1652
|
+
return a.index - b.index;
|
|
1653
|
+
}
|
|
1654
|
+
return a.end - b.end;
|
|
1655
|
+
})[0] : void 0;
|
|
1656
|
+
};
|
|
1657
|
+
this.getMeasurementOptions = memo(
|
|
1658
|
+
() => [
|
|
1659
|
+
this.options.count,
|
|
1660
|
+
this.options.paddingStart,
|
|
1661
|
+
this.options.scrollMargin,
|
|
1662
|
+
this.options.getItemKey,
|
|
1663
|
+
this.options.enabled,
|
|
1664
|
+
this.options.lanes,
|
|
1665
|
+
this.options.laneAssignmentMode
|
|
1666
|
+
],
|
|
1667
|
+
(count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode) => {
|
|
1668
|
+
const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
|
|
1669
|
+
if (lanesChanged) {
|
|
1670
|
+
this.lanesChangedFlag = true;
|
|
1671
|
+
}
|
|
1672
|
+
this.prevLanes = lanes;
|
|
1673
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
1674
|
+
return {
|
|
1675
|
+
count,
|
|
1676
|
+
paddingStart,
|
|
1677
|
+
scrollMargin,
|
|
1678
|
+
getItemKey,
|
|
1679
|
+
enabled,
|
|
1680
|
+
lanes,
|
|
1681
|
+
laneAssignmentMode
|
|
1682
|
+
};
|
|
1683
|
+
},
|
|
1684
|
+
{
|
|
1685
|
+
key: false
|
|
1686
|
+
}
|
|
1687
|
+
);
|
|
1688
|
+
this.getMeasurements = memo(
|
|
1689
|
+
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
1690
|
+
({
|
|
1691
|
+
count,
|
|
1692
|
+
paddingStart,
|
|
1693
|
+
scrollMargin,
|
|
1694
|
+
getItemKey,
|
|
1695
|
+
enabled,
|
|
1696
|
+
lanes,
|
|
1697
|
+
laneAssignmentMode
|
|
1698
|
+
}, itemSizeCache) => {
|
|
1699
|
+
if (!enabled) {
|
|
1700
|
+
this.measurementsCache = [];
|
|
1701
|
+
this.itemSizeCache.clear();
|
|
1702
|
+
this.laneAssignments.clear();
|
|
1703
|
+
return [];
|
|
1704
|
+
}
|
|
1705
|
+
if (this.laneAssignments.size > count) {
|
|
1706
|
+
for (const index of this.laneAssignments.keys()) {
|
|
1707
|
+
if (index >= count) {
|
|
1708
|
+
this.laneAssignments.delete(index);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
if (this.lanesChangedFlag) {
|
|
1713
|
+
this.lanesChangedFlag = false;
|
|
1714
|
+
this.lanesSettling = true;
|
|
1715
|
+
this.measurementsCache = [];
|
|
1716
|
+
this.itemSizeCache.clear();
|
|
1717
|
+
this.laneAssignments.clear();
|
|
1718
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
1719
|
+
}
|
|
1720
|
+
if (this.measurementsCache.length === 0 && !this.lanesSettling) {
|
|
1721
|
+
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
1722
|
+
this.measurementsCache.forEach((item) => {
|
|
1723
|
+
this.itemSizeCache.set(item.key, item.size);
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
const min = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
1727
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
1728
|
+
if (this.lanesSettling && this.measurementsCache.length === count) {
|
|
1729
|
+
this.lanesSettling = false;
|
|
1730
|
+
}
|
|
1731
|
+
const measurements = this.measurementsCache.slice(0, min);
|
|
1732
|
+
const laneLastIndex = new Array(lanes).fill(
|
|
1733
|
+
void 0
|
|
1734
|
+
);
|
|
1735
|
+
for (let m = 0; m < min; m++) {
|
|
1736
|
+
const item = measurements[m];
|
|
1737
|
+
if (item) {
|
|
1738
|
+
laneLastIndex[item.lane] = m;
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
for (let i = min; i < count; i++) {
|
|
1742
|
+
const key = getItemKey(i);
|
|
1743
|
+
const cachedLane = this.laneAssignments.get(i);
|
|
1744
|
+
let lane;
|
|
1745
|
+
let start;
|
|
1746
|
+
const shouldCacheLane = laneAssignmentMode === "estimate" || itemSizeCache.has(key);
|
|
1747
|
+
if (cachedLane !== void 0 && this.options.lanes > 1) {
|
|
1748
|
+
lane = cachedLane;
|
|
1749
|
+
const prevIndex = laneLastIndex[lane];
|
|
1750
|
+
const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
|
|
1751
|
+
start = prevInLane ? prevInLane.end + this.options.gap : paddingStart + scrollMargin;
|
|
1752
|
+
} else {
|
|
1753
|
+
const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
|
|
1754
|
+
start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
|
|
1755
|
+
lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
|
|
1756
|
+
if (this.options.lanes > 1 && shouldCacheLane) {
|
|
1757
|
+
this.laneAssignments.set(i, lane);
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
const measuredSize = itemSizeCache.get(key);
|
|
1761
|
+
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
1762
|
+
const end = start + size;
|
|
1763
|
+
measurements[i] = {
|
|
1764
|
+
index: i,
|
|
1765
|
+
start,
|
|
1766
|
+
size,
|
|
1767
|
+
end,
|
|
1768
|
+
key,
|
|
1769
|
+
lane
|
|
1770
|
+
};
|
|
1771
|
+
laneLastIndex[lane] = i;
|
|
1772
|
+
}
|
|
1773
|
+
this.measurementsCache = measurements;
|
|
1774
|
+
return measurements;
|
|
1775
|
+
},
|
|
1776
|
+
{
|
|
1777
|
+
key: "getMeasurements",
|
|
1778
|
+
debug: () => this.options.debug
|
|
1779
|
+
}
|
|
1780
|
+
);
|
|
1781
|
+
this.calculateRange = memo(
|
|
1782
|
+
() => [
|
|
1783
|
+
this.getMeasurements(),
|
|
1784
|
+
this.getSize(),
|
|
1785
|
+
this.getScrollOffset(),
|
|
1786
|
+
this.options.lanes
|
|
1787
|
+
],
|
|
1788
|
+
(measurements, outerSize, scrollOffset, lanes) => {
|
|
1789
|
+
return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
|
|
1790
|
+
measurements,
|
|
1791
|
+
outerSize,
|
|
1792
|
+
scrollOffset,
|
|
1793
|
+
lanes
|
|
1794
|
+
}) : null;
|
|
1795
|
+
},
|
|
1796
|
+
{
|
|
1797
|
+
key: "calculateRange",
|
|
1798
|
+
debug: () => this.options.debug
|
|
1799
|
+
}
|
|
1800
|
+
);
|
|
1801
|
+
this.getVirtualIndexes = memo(
|
|
1802
|
+
() => {
|
|
1803
|
+
let startIndex = null;
|
|
1804
|
+
let endIndex = null;
|
|
1805
|
+
const range = this.calculateRange();
|
|
1806
|
+
if (range) {
|
|
1807
|
+
startIndex = range.startIndex;
|
|
1808
|
+
endIndex = range.endIndex;
|
|
1809
|
+
}
|
|
1810
|
+
this.maybeNotify.updateDeps([this.isScrolling, startIndex, endIndex]);
|
|
1811
|
+
return [
|
|
1812
|
+
this.options.rangeExtractor,
|
|
1813
|
+
this.options.overscan,
|
|
1814
|
+
this.options.count,
|
|
1815
|
+
startIndex,
|
|
1816
|
+
endIndex
|
|
1817
|
+
];
|
|
1818
|
+
},
|
|
1819
|
+
(rangeExtractor, overscan, count, startIndex, endIndex) => {
|
|
1820
|
+
return startIndex === null || endIndex === null ? [] : rangeExtractor({
|
|
1821
|
+
startIndex,
|
|
1822
|
+
endIndex,
|
|
1823
|
+
overscan,
|
|
1824
|
+
count
|
|
1825
|
+
});
|
|
1826
|
+
},
|
|
1827
|
+
{
|
|
1828
|
+
key: "getVirtualIndexes",
|
|
1829
|
+
debug: () => this.options.debug
|
|
1830
|
+
}
|
|
1831
|
+
);
|
|
1832
|
+
this.indexFromElement = (node) => {
|
|
1833
|
+
const attributeName = this.options.indexAttribute;
|
|
1834
|
+
const indexStr = node.getAttribute(attributeName);
|
|
1835
|
+
if (!indexStr) {
|
|
1836
|
+
console.warn(
|
|
1837
|
+
`Missing attribute name '${attributeName}={index}' on measured element.`
|
|
1838
|
+
);
|
|
1839
|
+
return -1;
|
|
1840
|
+
}
|
|
1841
|
+
return parseInt(indexStr, 10);
|
|
1842
|
+
};
|
|
1843
|
+
this.shouldMeasureDuringScroll = (index) => {
|
|
1844
|
+
var _a2;
|
|
1845
|
+
var _a;
|
|
1846
|
+
if (!this.scrollState || this.scrollState.behavior !== "smooth") {
|
|
1847
|
+
return true;
|
|
1848
|
+
}
|
|
1849
|
+
const scrollIndex = (_a2 = this.scrollState.index) != null ? _a2 : (_a = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : _a.index;
|
|
1850
|
+
if (scrollIndex !== void 0 && this.range) {
|
|
1851
|
+
const bufferSize = Math.max(
|
|
1852
|
+
this.options.overscan,
|
|
1853
|
+
Math.ceil((this.range.endIndex - this.range.startIndex) / 2)
|
|
1854
|
+
);
|
|
1855
|
+
const minIndex = Math.max(0, scrollIndex - bufferSize);
|
|
1856
|
+
const maxIndex = Math.min(
|
|
1857
|
+
this.options.count - 1,
|
|
1858
|
+
scrollIndex + bufferSize
|
|
1859
|
+
);
|
|
1860
|
+
return index >= minIndex && index <= maxIndex;
|
|
1861
|
+
}
|
|
1862
|
+
return true;
|
|
1863
|
+
};
|
|
1864
|
+
this.measureElement = (node) => {
|
|
1865
|
+
if (!node) {
|
|
1866
|
+
this.elementsCache.forEach((cached, key2) => {
|
|
1867
|
+
if (!cached.isConnected) {
|
|
1868
|
+
this.observer.unobserve(cached);
|
|
1869
|
+
this.elementsCache.delete(key2);
|
|
1870
|
+
}
|
|
1871
|
+
});
|
|
1872
|
+
return;
|
|
1873
|
+
}
|
|
1874
|
+
const index = this.indexFromElement(node);
|
|
1875
|
+
const key = this.options.getItemKey(index);
|
|
1876
|
+
const prevNode = this.elementsCache.get(key);
|
|
1877
|
+
if (prevNode !== node) {
|
|
1878
|
+
if (prevNode) {
|
|
1879
|
+
this.observer.unobserve(prevNode);
|
|
1880
|
+
}
|
|
1881
|
+
this.observer.observe(node);
|
|
1882
|
+
this.elementsCache.set(key, node);
|
|
1883
|
+
}
|
|
1884
|
+
if ((!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(index)) {
|
|
1885
|
+
this.resizeItem(index, this.options.measureElement(node, void 0, this));
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
this.resizeItem = (index, size) => {
|
|
1889
|
+
var _a2;
|
|
1890
|
+
var _a;
|
|
1891
|
+
const item = this.measurementsCache[index];
|
|
1892
|
+
if (!item) return;
|
|
1893
|
+
const itemSize = (_a2 = this.itemSizeCache.get(item.key)) != null ? _a2 : item.size;
|
|
1894
|
+
const delta = size - itemSize;
|
|
1895
|
+
if (delta !== 0) {
|
|
1896
|
+
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)) {
|
|
1897
|
+
if (this.options.debug) {
|
|
1898
|
+
console.info("correction", delta);
|
|
1899
|
+
}
|
|
1900
|
+
this._scrollToOffset(this.getScrollOffset(), {
|
|
1901
|
+
adjustments: this.scrollAdjustments += delta,
|
|
1902
|
+
behavior: void 0
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
this.pendingMeasuredCacheIndexes.push(item.index);
|
|
1906
|
+
this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size));
|
|
1907
|
+
this.notify(false);
|
|
1908
|
+
}
|
|
1909
|
+
};
|
|
1910
|
+
this.getVirtualItems = memo(
|
|
1911
|
+
() => [this.getVirtualIndexes(), this.getMeasurements()],
|
|
1912
|
+
(indexes, measurements) => {
|
|
1913
|
+
const virtualItems = [];
|
|
1914
|
+
for (let k = 0, len = indexes.length; k < len; k++) {
|
|
1915
|
+
const i = indexes[k];
|
|
1916
|
+
const measurement = measurements[i];
|
|
1917
|
+
virtualItems.push(measurement);
|
|
1918
|
+
}
|
|
1919
|
+
return virtualItems;
|
|
1920
|
+
},
|
|
1921
|
+
{
|
|
1922
|
+
key: "getVirtualItems",
|
|
1923
|
+
debug: () => this.options.debug
|
|
1924
|
+
}
|
|
1925
|
+
);
|
|
1926
|
+
this.getVirtualItemForOffset = (offset) => {
|
|
1927
|
+
const measurements = this.getMeasurements();
|
|
1928
|
+
if (measurements.length === 0) {
|
|
1929
|
+
return void 0;
|
|
1930
|
+
}
|
|
1931
|
+
return notUndefined(
|
|
1932
|
+
measurements[findNearestBinarySearch(
|
|
1933
|
+
0,
|
|
1934
|
+
measurements.length - 1,
|
|
1935
|
+
(index) => notUndefined(measurements[index]).start,
|
|
1936
|
+
offset
|
|
1937
|
+
)]
|
|
1938
|
+
);
|
|
1939
|
+
};
|
|
1940
|
+
this.getMaxScrollOffset = () => {
|
|
1941
|
+
if (!this.scrollElement) return 0;
|
|
1942
|
+
if ("scrollHeight" in this.scrollElement) {
|
|
1943
|
+
return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
|
|
1944
|
+
} else {
|
|
1945
|
+
const doc = this.scrollElement.document.documentElement;
|
|
1946
|
+
return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
|
|
1947
|
+
}
|
|
1948
|
+
};
|
|
1949
|
+
this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
|
|
1950
|
+
if (!this.scrollElement) return 0;
|
|
1951
|
+
const size = this.getSize();
|
|
1952
|
+
const scrollOffset = this.getScrollOffset();
|
|
1953
|
+
if (align === "auto") {
|
|
1954
|
+
align = toOffset >= scrollOffset + size ? "end" : "start";
|
|
1955
|
+
}
|
|
1956
|
+
if (align === "center") {
|
|
1957
|
+
toOffset += (itemSize - size) / 2;
|
|
1958
|
+
} else if (align === "end") {
|
|
1959
|
+
toOffset -= size;
|
|
1960
|
+
}
|
|
1961
|
+
const maxOffset = this.getMaxScrollOffset();
|
|
1962
|
+
return Math.max(Math.min(maxOffset, toOffset), 0);
|
|
1963
|
+
};
|
|
1964
|
+
this.getOffsetForIndex = (index, align = "auto") => {
|
|
1965
|
+
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
1966
|
+
const size = this.getSize();
|
|
1967
|
+
const scrollOffset = this.getScrollOffset();
|
|
1968
|
+
const item = this.measurementsCache[index];
|
|
1969
|
+
if (!item) return;
|
|
1970
|
+
if (align === "auto") {
|
|
1971
|
+
if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) {
|
|
1972
|
+
align = "end";
|
|
1973
|
+
} else if (item.start <= scrollOffset + this.options.scrollPaddingStart) {
|
|
1974
|
+
align = "start";
|
|
1975
|
+
} else {
|
|
1976
|
+
return [scrollOffset, align];
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
if (align === "end" && index === this.options.count - 1) {
|
|
1980
|
+
return [this.getMaxScrollOffset(), align];
|
|
1981
|
+
}
|
|
1982
|
+
const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
|
|
1983
|
+
return [
|
|
1984
|
+
this.getOffsetForAlignment(toOffset, align, item.size),
|
|
1985
|
+
align
|
|
1986
|
+
];
|
|
1987
|
+
};
|
|
1988
|
+
this.scrollToOffset = (toOffset, { align = "start", behavior = "auto" } = {}) => {
|
|
1989
|
+
const offset = this.getOffsetForAlignment(toOffset, align);
|
|
1990
|
+
const now = this.now();
|
|
1991
|
+
this.scrollState = {
|
|
1992
|
+
index: null,
|
|
1993
|
+
align,
|
|
1994
|
+
behavior,
|
|
1995
|
+
startedAt: now,
|
|
1996
|
+
lastTargetOffset: offset,
|
|
1997
|
+
stableFrames: 0
|
|
1998
|
+
};
|
|
1999
|
+
this._scrollToOffset(offset, { adjustments: void 0, behavior });
|
|
2000
|
+
this.scheduleScrollReconcile();
|
|
2001
|
+
};
|
|
2002
|
+
this.scrollToIndex = (index, {
|
|
2003
|
+
align: initialAlign = "auto",
|
|
2004
|
+
behavior = "auto"
|
|
2005
|
+
} = {}) => {
|
|
2006
|
+
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
2007
|
+
const offsetInfo = this.getOffsetForIndex(index, initialAlign);
|
|
2008
|
+
if (!offsetInfo) {
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
const [offset, align] = offsetInfo;
|
|
2012
|
+
const now = this.now();
|
|
2013
|
+
this.scrollState = {
|
|
2014
|
+
index,
|
|
2015
|
+
align,
|
|
2016
|
+
behavior,
|
|
2017
|
+
startedAt: now,
|
|
2018
|
+
lastTargetOffset: offset,
|
|
2019
|
+
stableFrames: 0
|
|
2020
|
+
};
|
|
2021
|
+
this._scrollToOffset(offset, { adjustments: void 0, behavior });
|
|
2022
|
+
this.scheduleScrollReconcile();
|
|
2023
|
+
};
|
|
2024
|
+
this.scrollBy = (delta, { behavior = "auto" } = {}) => {
|
|
2025
|
+
const offset = this.getScrollOffset() + delta;
|
|
2026
|
+
const now = this.now();
|
|
2027
|
+
this.scrollState = {
|
|
2028
|
+
index: null,
|
|
2029
|
+
align: "start",
|
|
2030
|
+
behavior,
|
|
2031
|
+
startedAt: now,
|
|
2032
|
+
lastTargetOffset: offset,
|
|
2033
|
+
stableFrames: 0
|
|
2034
|
+
};
|
|
2035
|
+
this._scrollToOffset(offset, { adjustments: void 0, behavior });
|
|
2036
|
+
this.scheduleScrollReconcile();
|
|
2037
|
+
};
|
|
2038
|
+
this.getTotalSize = () => {
|
|
2039
|
+
var _a2;
|
|
2040
|
+
var _a;
|
|
2041
|
+
const measurements = this.getMeasurements();
|
|
2042
|
+
let end;
|
|
2043
|
+
if (measurements.length === 0) {
|
|
2044
|
+
end = this.options.paddingStart;
|
|
2045
|
+
} else if (this.options.lanes === 1) {
|
|
2046
|
+
end = (_a2 = (_a = measurements[measurements.length - 1]) == null ? void 0 : _a.end) != null ? _a2 : 0;
|
|
2047
|
+
} else {
|
|
2048
|
+
const endByLane = Array(this.options.lanes).fill(null);
|
|
2049
|
+
let endIndex = measurements.length - 1;
|
|
2050
|
+
while (endIndex >= 0 && endByLane.some((val) => val === null)) {
|
|
2051
|
+
const item = measurements[endIndex];
|
|
2052
|
+
if (endByLane[item.lane] === null) {
|
|
2053
|
+
endByLane[item.lane] = item.end;
|
|
2054
|
+
}
|
|
2055
|
+
endIndex--;
|
|
2056
|
+
}
|
|
2057
|
+
end = Math.max(...endByLane.filter((val) => val !== null));
|
|
2058
|
+
}
|
|
2059
|
+
return Math.max(
|
|
2060
|
+
end - this.options.scrollMargin + this.options.paddingEnd,
|
|
2061
|
+
0
|
|
2062
|
+
);
|
|
2063
|
+
};
|
|
2064
|
+
this._scrollToOffset = (offset, {
|
|
2065
|
+
adjustments,
|
|
2066
|
+
behavior
|
|
2067
|
+
}) => {
|
|
2068
|
+
this.options.scrollToFn(offset, { behavior, adjustments }, this);
|
|
2069
|
+
};
|
|
2070
|
+
this.measure = () => {
|
|
2071
|
+
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
2072
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
2073
|
+
this.notify(false);
|
|
2074
|
+
};
|
|
2075
|
+
this.setOptions(opts);
|
|
2076
|
+
}
|
|
2077
|
+
scheduleScrollReconcile() {
|
|
2078
|
+
if (!this.targetWindow) {
|
|
2079
|
+
this.scrollState = null;
|
|
2080
|
+
return;
|
|
2081
|
+
}
|
|
2082
|
+
if (this.rafId != null) return;
|
|
2083
|
+
this.rafId = this.targetWindow.requestAnimationFrame(() => {
|
|
2084
|
+
this.rafId = null;
|
|
2085
|
+
this.reconcileScroll();
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
reconcileScroll() {
|
|
2089
|
+
if (!this.scrollState) return;
|
|
2090
|
+
const el = this.scrollElement;
|
|
2091
|
+
if (!el) return;
|
|
2092
|
+
const MAX_RECONCILE_MS = 5e3;
|
|
2093
|
+
if (this.now() - this.scrollState.startedAt > MAX_RECONCILE_MS) {
|
|
2094
|
+
this.scrollState = null;
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
const offsetInfo = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0;
|
|
2098
|
+
const targetOffset = offsetInfo ? offsetInfo[0] : this.scrollState.lastTargetOffset;
|
|
2099
|
+
const STABLE_FRAMES = 1;
|
|
2100
|
+
const targetChanged = targetOffset !== this.scrollState.lastTargetOffset;
|
|
2101
|
+
if (!targetChanged && approxEqual(targetOffset, this.getScrollOffset())) {
|
|
2102
|
+
this.scrollState.stableFrames++;
|
|
2103
|
+
if (this.scrollState.stableFrames >= STABLE_FRAMES) {
|
|
2104
|
+
this.scrollState = null;
|
|
2105
|
+
return;
|
|
2106
|
+
}
|
|
2107
|
+
} else {
|
|
2108
|
+
this.scrollState.stableFrames = 0;
|
|
2109
|
+
if (targetChanged) {
|
|
2110
|
+
this.scrollState.lastTargetOffset = targetOffset;
|
|
2111
|
+
this.scrollState.behavior = "auto";
|
|
2112
|
+
this._scrollToOffset(targetOffset, {
|
|
2113
|
+
adjustments: void 0,
|
|
2114
|
+
behavior: "auto"
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
this.scheduleScrollReconcile();
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
var findNearestBinarySearch = (low, high, getCurrentValue, value) => {
|
|
2122
|
+
while (low <= high) {
|
|
2123
|
+
const middle = (low + high) / 2 | 0;
|
|
2124
|
+
const currentValue = getCurrentValue(middle);
|
|
2125
|
+
if (currentValue < value) {
|
|
2126
|
+
low = middle + 1;
|
|
2127
|
+
} else if (currentValue > value) {
|
|
2128
|
+
high = middle - 1;
|
|
2129
|
+
} else {
|
|
2130
|
+
return middle;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
if (low > 0) {
|
|
2134
|
+
return low - 1;
|
|
2135
|
+
} else {
|
|
2136
|
+
return 0;
|
|
2137
|
+
}
|
|
2138
|
+
};
|
|
2139
|
+
function calculateRange({
|
|
2140
|
+
measurements,
|
|
2141
|
+
outerSize,
|
|
2142
|
+
scrollOffset,
|
|
2143
|
+
lanes
|
|
2144
|
+
}) {
|
|
2145
|
+
const lastIndex = measurements.length - 1;
|
|
2146
|
+
const getOffset = (index) => measurements[index].start;
|
|
2147
|
+
if (measurements.length <= lanes) {
|
|
2148
|
+
return {
|
|
2149
|
+
startIndex: 0,
|
|
2150
|
+
endIndex: lastIndex
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
let startIndex = findNearestBinarySearch(
|
|
2154
|
+
0,
|
|
2155
|
+
lastIndex,
|
|
2156
|
+
getOffset,
|
|
2157
|
+
scrollOffset
|
|
2158
|
+
);
|
|
2159
|
+
let endIndex = startIndex;
|
|
2160
|
+
if (lanes === 1) {
|
|
2161
|
+
while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) {
|
|
2162
|
+
endIndex++;
|
|
2163
|
+
}
|
|
2164
|
+
} else if (lanes > 1) {
|
|
2165
|
+
const endPerLane = Array(lanes).fill(0);
|
|
2166
|
+
while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
|
|
2167
|
+
const item = measurements[endIndex];
|
|
2168
|
+
endPerLane[item.lane] = item.end;
|
|
2169
|
+
endIndex++;
|
|
2170
|
+
}
|
|
2171
|
+
const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
|
|
2172
|
+
while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
|
|
2173
|
+
const item = measurements[startIndex];
|
|
2174
|
+
startPerLane[item.lane] = item.start;
|
|
2175
|
+
startIndex--;
|
|
2176
|
+
}
|
|
2177
|
+
startIndex = Math.max(0, startIndex - startIndex % lanes);
|
|
2178
|
+
endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
|
|
2179
|
+
}
|
|
2180
|
+
return { startIndex, endIndex };
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
// ../../node_modules/.pnpm/@tanstack+react-virtual@3.13.24_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/@tanstack/react-virtual/dist/esm/index.js
|
|
2184
|
+
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
2185
|
+
function useVirtualizerBase(_a) {
|
|
2186
|
+
var _b = _a, {
|
|
2187
|
+
useFlushSync = true
|
|
2188
|
+
} = _b, options = __objRest(_b, [
|
|
2189
|
+
"useFlushSync"
|
|
2190
|
+
]);
|
|
2191
|
+
const rerender = React.useReducer(() => ({}), {})[1];
|
|
2192
|
+
const resolvedOptions = __spreadProps(__spreadValues({}, options), {
|
|
2193
|
+
onChange: (instance2, sync) => {
|
|
2194
|
+
var _a2;
|
|
2195
|
+
if (useFlushSync && sync) {
|
|
2196
|
+
(0, import_react_dom.flushSync)(rerender);
|
|
2197
|
+
} else {
|
|
2198
|
+
rerender();
|
|
2199
|
+
}
|
|
2200
|
+
(_a2 = options.onChange) == null ? void 0 : _a2.call(options, instance2, sync);
|
|
2201
|
+
}
|
|
2202
|
+
});
|
|
2203
|
+
const [instance] = React.useState(
|
|
2204
|
+
() => new Virtualizer(resolvedOptions)
|
|
2205
|
+
);
|
|
2206
|
+
instance.setOptions(resolvedOptions);
|
|
2207
|
+
useIsomorphicLayoutEffect(() => {
|
|
2208
|
+
return instance._didMount();
|
|
2209
|
+
}, []);
|
|
2210
|
+
useIsomorphicLayoutEffect(() => {
|
|
2211
|
+
return instance._willUpdate();
|
|
2212
|
+
});
|
|
2213
|
+
return instance;
|
|
2214
|
+
}
|
|
2215
|
+
function useWindowVirtualizer(options) {
|
|
2216
|
+
return useVirtualizerBase(__spreadValues({
|
|
2217
|
+
getScrollElement: () => typeof document !== "undefined" ? window : null,
|
|
2218
|
+
observeElementRect: observeWindowRect,
|
|
2219
|
+
observeElementOffset: observeWindowOffset,
|
|
2220
|
+
scrollToFn: windowScroll,
|
|
2221
|
+
initialOffset: () => typeof document !== "undefined" ? window.scrollY : 0
|
|
2222
|
+
}, options));
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
// ../renderers/src/CollectionRenderer.tsx
|
|
1261
2226
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1262
|
-
var CollectionRendererComponent = ({
|
|
1263
|
-
|
|
1264
|
-
state,
|
|
1265
|
-
filters,
|
|
1266
|
-
search,
|
|
1267
|
-
tags,
|
|
1268
|
-
loadMore
|
|
1269
|
-
}) => {
|
|
2227
|
+
var CollectionRendererComponent = (props) => {
|
|
2228
|
+
const { state, filters, search, loading, loadMore } = props;
|
|
1270
2229
|
const endOfContentRef = (0, import_react5.useRef)(null);
|
|
1271
2230
|
const isBottomVisible = useIsElementVisible(endOfContentRef);
|
|
1272
2231
|
(0, import_react5.useEffect)(() => {
|
|
@@ -1321,44 +2280,147 @@ var CollectionRendererComponent = ({
|
|
|
1321
2280
|
JSON.stringify(filter.options)
|
|
1322
2281
|
);
|
|
1323
2282
|
}),
|
|
1324
|
-
state.type === "collection-content" ?
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
2283
|
+
state.type === "collection-content" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ContentComponent, __spreadProps(__spreadValues({}, props), { state })) : state.children,
|
|
2284
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2285
|
+
"div",
|
|
2286
|
+
{
|
|
2287
|
+
ref: endOfContentRef,
|
|
2288
|
+
style: {
|
|
2289
|
+
marginLeft: "auto",
|
|
2290
|
+
marginRight: "auto",
|
|
2291
|
+
display: "flex"
|
|
2292
|
+
},
|
|
2293
|
+
children: loading ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components15.ProcessIndicator, { size: "xs" }) : null
|
|
2294
|
+
}
|
|
2295
|
+
)
|
|
2296
|
+
] });
|
|
2297
|
+
};
|
|
2298
|
+
var ContentComponent = (props) => {
|
|
2299
|
+
const { state, tags, control } = props;
|
|
2300
|
+
const stateCount = state.sections.reduce(
|
|
2301
|
+
(total, section) => section.items.length + total + (section.title ? 1 : 0),
|
|
2302
|
+
0
|
|
2303
|
+
);
|
|
2304
|
+
const items = (0, import_react5.useMemo)(() => {
|
|
2305
|
+
return state.sections.reduce((acc, section) => {
|
|
2306
|
+
return [
|
|
2307
|
+
...acc,
|
|
2308
|
+
...section.title ? [{ type: "header", title: section.title }] : [],
|
|
2309
|
+
...section.items.map((item) => ({
|
|
2310
|
+
item,
|
|
2311
|
+
type: "item"
|
|
2312
|
+
}))
|
|
2313
|
+
];
|
|
2314
|
+
}, []);
|
|
2315
|
+
}, [stateCount]);
|
|
2316
|
+
const listRef = (0, import_react5.useRef)(null);
|
|
2317
|
+
const listOffsetRef = (0, import_react5.useRef)(0);
|
|
2318
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
2319
|
+
var _a, _b;
|
|
2320
|
+
listOffsetRef.current = (_b = (_a = listRef.current) == null ? void 0 : _a.offsetTop) != null ? _b : 0;
|
|
2321
|
+
});
|
|
2322
|
+
const virtualizer = useWindowVirtualizer({
|
|
2323
|
+
count: stateCount,
|
|
2324
|
+
estimateSize: () => 120,
|
|
2325
|
+
overscan: 10,
|
|
2326
|
+
// eslint-disable-next-line react-hooks/refs
|
|
2327
|
+
scrollMargin: listOffsetRef.current
|
|
2328
|
+
});
|
|
2329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ref: listRef, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2330
|
+
"div",
|
|
2331
|
+
{
|
|
2332
|
+
style: {
|
|
2333
|
+
height: `${virtualizer.getTotalSize()}px`,
|
|
2334
|
+
width: "100%",
|
|
2335
|
+
position: "relative"
|
|
2336
|
+
},
|
|
2337
|
+
children: virtualizer.getVirtualItems().map((item) => {
|
|
2338
|
+
const i = items[item.index];
|
|
2339
|
+
if (!i) {
|
|
2340
|
+
return null;
|
|
2341
|
+
}
|
|
2342
|
+
if (i.type === "header") {
|
|
1343
2343
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1344
|
-
|
|
2344
|
+
"div",
|
|
1345
2345
|
{
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
2346
|
+
ref: virtualizer.measureElement,
|
|
2347
|
+
"data-index": item.index,
|
|
2348
|
+
style: {
|
|
2349
|
+
position: "absolute",
|
|
2350
|
+
top: 0,
|
|
2351
|
+
left: 0,
|
|
2352
|
+
width: "100%",
|
|
2353
|
+
transform: `translateY(${item.start - virtualizer.options.scrollMargin}px)`
|
|
2354
|
+
},
|
|
2355
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Header, { title: i.title, callToAction: i.callToAction })
|
|
1354
2356
|
},
|
|
1355
|
-
|
|
2357
|
+
item.key
|
|
1356
2358
|
);
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
2359
|
+
}
|
|
2360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2361
|
+
"div",
|
|
2362
|
+
{
|
|
2363
|
+
ref: virtualizer.measureElement,
|
|
2364
|
+
"data-index": item.index,
|
|
2365
|
+
style: {
|
|
2366
|
+
position: "absolute",
|
|
2367
|
+
top: 0,
|
|
2368
|
+
left: 0,
|
|
2369
|
+
width: "100%",
|
|
2370
|
+
transform: `translateY(${item.start - virtualizer.options.scrollMargin}px)`
|
|
2371
|
+
},
|
|
2372
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ItemComponent, __spreadProps(__spreadValues({}, i.item), { parentTags: tags, control }))
|
|
2373
|
+
},
|
|
2374
|
+
item.key
|
|
2375
|
+
);
|
|
2376
|
+
})
|
|
2377
|
+
}
|
|
2378
|
+
) });
|
|
2379
|
+
};
|
|
2380
|
+
var getNavigationControl = (onClick, href) => {
|
|
2381
|
+
if (href) {
|
|
2382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components15.ListItem.Navigation, { href });
|
|
2383
|
+
}
|
|
2384
|
+
if (onClick) {
|
|
2385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components15.ListItem.Navigation, { onClick });
|
|
2386
|
+
}
|
|
2387
|
+
return null;
|
|
2388
|
+
};
|
|
2389
|
+
var ItemComponent = (props) => {
|
|
2390
|
+
var _a, _b;
|
|
2391
|
+
const {
|
|
2392
|
+
title,
|
|
2393
|
+
description,
|
|
2394
|
+
supportingValues,
|
|
2395
|
+
media,
|
|
2396
|
+
additionalInfo,
|
|
2397
|
+
inlineAlert,
|
|
2398
|
+
href,
|
|
2399
|
+
onClick,
|
|
2400
|
+
callToAction,
|
|
2401
|
+
tags,
|
|
2402
|
+
parentTags,
|
|
2403
|
+
control
|
|
2404
|
+
} = props;
|
|
2405
|
+
const controlOptions = {
|
|
2406
|
+
ctaSecondary: (_a = tags == null ? void 0 : tags.includes("cta-secondary")) != null ? _a : false,
|
|
2407
|
+
fullyInteractive: (_b = (tags == null ? void 0 : tags.includes("fully-interactive")) && (additionalInfo == null ? void 0 : additionalInfo.onClick) == null) != null ? _b : false
|
|
2408
|
+
};
|
|
2409
|
+
console.log("title", title, "onClick", onClick, "href", href, "cta", callToAction);
|
|
2410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2411
|
+
import_components15.ListItem,
|
|
2412
|
+
{
|
|
2413
|
+
title,
|
|
2414
|
+
subtitle: description,
|
|
2415
|
+
valueTitle: supportingValues == null ? void 0 : supportingValues.value,
|
|
2416
|
+
valueSubtitle: supportingValues == null ? void 0 : supportingValues.subvalue,
|
|
2417
|
+
media: getMedia(media, shouldUseAvatar(control, parentTags)),
|
|
2418
|
+
prompt: getInlineAlert(inlineAlert),
|
|
2419
|
+
additionalInfo: getAdditionalInfo(additionalInfo),
|
|
2420
|
+
control: onClick || href ? getNavigationControl(onClick, href) : getCTAControl(callToAction, controlOptions)
|
|
2421
|
+
},
|
|
2422
|
+
title
|
|
2423
|
+
);
|
|
1362
2424
|
};
|
|
1363
2425
|
var CollectionRenderer = {
|
|
1364
2426
|
canRenderType: "collection",
|