@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.mjs
CHANGED
|
@@ -305,7 +305,7 @@ var recursivelyRemoveNullish = (element) => {
|
|
|
305
305
|
};
|
|
306
306
|
|
|
307
307
|
// src/dynamicFlow/useWiseToCoreProps.tsx
|
|
308
|
-
import { useMemo as
|
|
308
|
+
import { useMemo as useMemo3 } from "react";
|
|
309
309
|
|
|
310
310
|
// src/dynamicFlow/telemetry/getLogEvent.ts
|
|
311
311
|
var getLogEvent = (onLog) => (level, message, extra) => {
|
|
@@ -1088,7 +1088,7 @@ var getInlineAlertOrValidation = (validationState, inlineAlert) => {
|
|
|
1088
1088
|
var CheckboxInputRenderer_default = CheckboxInputRenderer;
|
|
1089
1089
|
|
|
1090
1090
|
// ../renderers/src/CollectionRenderer.tsx
|
|
1091
|
-
import { Chips, Input, InputGroup, ListItem as ListItem6 } from "@transferwise/components";
|
|
1091
|
+
import { Chips, Input, InputGroup, ListItem as ListItem6, ProcessIndicator } from "@transferwise/components";
|
|
1092
1092
|
|
|
1093
1093
|
// ../renderers/src/utils/listItem/getAdditionalInfo.tsx
|
|
1094
1094
|
import { ListItem as ListItem4 } from "@transferwise/components";
|
|
@@ -1164,7 +1164,7 @@ var shouldUseAvatar = (control, tags) => {
|
|
|
1164
1164
|
};
|
|
1165
1165
|
|
|
1166
1166
|
// ../renderers/src/CollectionRenderer.tsx
|
|
1167
|
-
import { useEffect as
|
|
1167
|
+
import { useEffect as useEffect6, useLayoutEffect as useLayoutEffect2, useMemo, useRef as useRef2 } from "react";
|
|
1168
1168
|
|
|
1169
1169
|
// ../renderers/src/step/StepFooter.tsx
|
|
1170
1170
|
import { Button as Button3 } from "@transferwise/components";
|
|
@@ -1240,18 +1240,977 @@ var useIsElementVisible = (elementRef) => {
|
|
|
1240
1240
|
|
|
1241
1241
|
// ../renderers/src/CollectionRenderer.tsx
|
|
1242
1242
|
import { Search } from "@transferwise/icons";
|
|
1243
|
+
|
|
1244
|
+
// ../../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
|
|
1245
|
+
import * as React from "react";
|
|
1246
|
+
import { flushSync } from "react-dom";
|
|
1247
|
+
|
|
1248
|
+
// ../../node_modules/.pnpm/@tanstack+virtual-core@3.14.0/node_modules/@tanstack/virtual-core/dist/esm/utils.js
|
|
1249
|
+
function memo(getDeps, fn, opts) {
|
|
1250
|
+
var _a;
|
|
1251
|
+
let deps = (_a = opts.initialDeps) != null ? _a : [];
|
|
1252
|
+
let result;
|
|
1253
|
+
let isInitial = true;
|
|
1254
|
+
function memoizedFunction() {
|
|
1255
|
+
var _a2, _b, _c;
|
|
1256
|
+
let depTime;
|
|
1257
|
+
if (opts.key && ((_a2 = opts.debug) == null ? void 0 : _a2.call(opts))) depTime = Date.now();
|
|
1258
|
+
const newDeps = getDeps();
|
|
1259
|
+
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
|
1260
|
+
if (!depsChanged) {
|
|
1261
|
+
return result;
|
|
1262
|
+
}
|
|
1263
|
+
deps = newDeps;
|
|
1264
|
+
let resultTime;
|
|
1265
|
+
if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now();
|
|
1266
|
+
result = fn(...newDeps);
|
|
1267
|
+
if (opts.key && ((_c = opts.debug) == null ? void 0 : _c.call(opts))) {
|
|
1268
|
+
const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
1269
|
+
const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
1270
|
+
const resultFpsPercentage = resultEndTime / 16;
|
|
1271
|
+
const pad = (str, num) => {
|
|
1272
|
+
str = String(str);
|
|
1273
|
+
while (str.length < num) {
|
|
1274
|
+
str = " " + str;
|
|
1275
|
+
}
|
|
1276
|
+
return str;
|
|
1277
|
+
};
|
|
1278
|
+
console.info(
|
|
1279
|
+
`%c\u23F1 ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`,
|
|
1280
|
+
`
|
|
1281
|
+
font-size: .6rem;
|
|
1282
|
+
font-weight: bold;
|
|
1283
|
+
color: hsl(${Math.max(
|
|
1284
|
+
0,
|
|
1285
|
+
Math.min(120 - 120 * resultFpsPercentage, 120)
|
|
1286
|
+
)}deg 100% 31%);`,
|
|
1287
|
+
opts == null ? void 0 : opts.key
|
|
1288
|
+
);
|
|
1289
|
+
}
|
|
1290
|
+
if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) {
|
|
1291
|
+
opts.onChange(result);
|
|
1292
|
+
}
|
|
1293
|
+
isInitial = false;
|
|
1294
|
+
return result;
|
|
1295
|
+
}
|
|
1296
|
+
memoizedFunction.updateDeps = (newDeps) => {
|
|
1297
|
+
deps = newDeps;
|
|
1298
|
+
};
|
|
1299
|
+
return memoizedFunction;
|
|
1300
|
+
}
|
|
1301
|
+
function notUndefined(value, msg) {
|
|
1302
|
+
if (value === void 0) {
|
|
1303
|
+
throw new Error(`Unexpected undefined${msg ? `: ${msg}` : ""}`);
|
|
1304
|
+
} else {
|
|
1305
|
+
return value;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
var approxEqual = (a, b) => Math.abs(a - b) < 1.01;
|
|
1309
|
+
var debounce = (targetWindow, fn, ms) => {
|
|
1310
|
+
let timeoutId;
|
|
1311
|
+
return function(...args) {
|
|
1312
|
+
targetWindow.clearTimeout(timeoutId);
|
|
1313
|
+
timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
|
|
1314
|
+
};
|
|
1315
|
+
};
|
|
1316
|
+
|
|
1317
|
+
// ../../node_modules/.pnpm/@tanstack+virtual-core@3.14.0/node_modules/@tanstack/virtual-core/dist/esm/index.js
|
|
1318
|
+
var defaultKeyExtractor = (index) => index;
|
|
1319
|
+
var defaultRangeExtractor = (range) => {
|
|
1320
|
+
const start = Math.max(range.startIndex - range.overscan, 0);
|
|
1321
|
+
const end = Math.min(range.endIndex + range.overscan, range.count - 1);
|
|
1322
|
+
const arr = [];
|
|
1323
|
+
for (let i = start; i <= end; i++) {
|
|
1324
|
+
arr.push(i);
|
|
1325
|
+
}
|
|
1326
|
+
return arr;
|
|
1327
|
+
};
|
|
1328
|
+
var addEventListenerOptions = {
|
|
1329
|
+
passive: true
|
|
1330
|
+
};
|
|
1331
|
+
var observeWindowRect = (instance, cb) => {
|
|
1332
|
+
const element = instance.scrollElement;
|
|
1333
|
+
if (!element) {
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
const handler = () => {
|
|
1337
|
+
cb({ width: element.innerWidth, height: element.innerHeight });
|
|
1338
|
+
};
|
|
1339
|
+
handler();
|
|
1340
|
+
element.addEventListener("resize", handler, addEventListenerOptions);
|
|
1341
|
+
return () => {
|
|
1342
|
+
element.removeEventListener("resize", handler);
|
|
1343
|
+
};
|
|
1344
|
+
};
|
|
1345
|
+
var supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
|
|
1346
|
+
var observeWindowOffset = (instance, cb) => {
|
|
1347
|
+
const element = instance.scrollElement;
|
|
1348
|
+
if (!element) {
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
const targetWindow = instance.targetWindow;
|
|
1352
|
+
if (!targetWindow) {
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
let offset = 0;
|
|
1356
|
+
const fallback = instance.options.useScrollendEvent && supportsScrollend ? () => void 0 : debounce(
|
|
1357
|
+
targetWindow,
|
|
1358
|
+
() => {
|
|
1359
|
+
cb(offset, false);
|
|
1360
|
+
},
|
|
1361
|
+
instance.options.isScrollingResetDelay
|
|
1362
|
+
);
|
|
1363
|
+
const createHandler = (isScrolling) => () => {
|
|
1364
|
+
offset = element[instance.options.horizontal ? "scrollX" : "scrollY"];
|
|
1365
|
+
fallback();
|
|
1366
|
+
cb(offset, isScrolling);
|
|
1367
|
+
};
|
|
1368
|
+
const handler = createHandler(true);
|
|
1369
|
+
const endHandler = createHandler(false);
|
|
1370
|
+
element.addEventListener("scroll", handler, addEventListenerOptions);
|
|
1371
|
+
const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
|
|
1372
|
+
if (registerScrollendEvent) {
|
|
1373
|
+
element.addEventListener("scrollend", endHandler, addEventListenerOptions);
|
|
1374
|
+
}
|
|
1375
|
+
return () => {
|
|
1376
|
+
element.removeEventListener("scroll", handler);
|
|
1377
|
+
if (registerScrollendEvent) {
|
|
1378
|
+
element.removeEventListener("scrollend", endHandler);
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
};
|
|
1382
|
+
var measureElement = (element, entry, instance) => {
|
|
1383
|
+
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
1384
|
+
const box = entry.borderBoxSize[0];
|
|
1385
|
+
if (box) {
|
|
1386
|
+
const size = Math.round(
|
|
1387
|
+
box[instance.options.horizontal ? "inlineSize" : "blockSize"]
|
|
1388
|
+
);
|
|
1389
|
+
return size;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
1393
|
+
};
|
|
1394
|
+
var windowScroll = (offset, {
|
|
1395
|
+
adjustments = 0,
|
|
1396
|
+
behavior
|
|
1397
|
+
}, instance) => {
|
|
1398
|
+
var _a, _b;
|
|
1399
|
+
const toOffset = offset + adjustments;
|
|
1400
|
+
(_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
|
|
1401
|
+
[instance.options.horizontal ? "left" : "top"]: toOffset,
|
|
1402
|
+
behavior
|
|
1403
|
+
});
|
|
1404
|
+
};
|
|
1405
|
+
var Virtualizer = class {
|
|
1406
|
+
constructor(opts) {
|
|
1407
|
+
this.unsubs = [];
|
|
1408
|
+
this.scrollElement = null;
|
|
1409
|
+
this.targetWindow = null;
|
|
1410
|
+
this.isScrolling = false;
|
|
1411
|
+
this.scrollState = null;
|
|
1412
|
+
this.measurementsCache = [];
|
|
1413
|
+
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
1414
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
1415
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
1416
|
+
this.prevLanes = void 0;
|
|
1417
|
+
this.lanesChangedFlag = false;
|
|
1418
|
+
this.lanesSettling = false;
|
|
1419
|
+
this.scrollRect = null;
|
|
1420
|
+
this.scrollOffset = null;
|
|
1421
|
+
this.scrollDirection = null;
|
|
1422
|
+
this.scrollAdjustments = 0;
|
|
1423
|
+
this.elementsCache = /* @__PURE__ */ new Map();
|
|
1424
|
+
this.now = () => {
|
|
1425
|
+
var _a2;
|
|
1426
|
+
var _a, _b, _c;
|
|
1427
|
+
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();
|
|
1428
|
+
};
|
|
1429
|
+
this.observer = /* @__PURE__ */ (() => {
|
|
1430
|
+
let _ro = null;
|
|
1431
|
+
const get = () => {
|
|
1432
|
+
if (_ro) {
|
|
1433
|
+
return _ro;
|
|
1434
|
+
}
|
|
1435
|
+
if (!this.targetWindow || !this.targetWindow.ResizeObserver) {
|
|
1436
|
+
return null;
|
|
1437
|
+
}
|
|
1438
|
+
return _ro = new this.targetWindow.ResizeObserver((entries) => {
|
|
1439
|
+
entries.forEach((entry) => {
|
|
1440
|
+
const run = () => {
|
|
1441
|
+
const node = entry.target;
|
|
1442
|
+
const index = this.indexFromElement(node);
|
|
1443
|
+
if (!node.isConnected) {
|
|
1444
|
+
this.observer.unobserve(node);
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
if (this.shouldMeasureDuringScroll(index)) {
|
|
1448
|
+
this.resizeItem(
|
|
1449
|
+
index,
|
|
1450
|
+
this.options.measureElement(node, entry, this)
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
1455
|
+
});
|
|
1456
|
+
});
|
|
1457
|
+
};
|
|
1458
|
+
return {
|
|
1459
|
+
disconnect: () => {
|
|
1460
|
+
var _a;
|
|
1461
|
+
(_a = get()) == null ? void 0 : _a.disconnect();
|
|
1462
|
+
_ro = null;
|
|
1463
|
+
},
|
|
1464
|
+
observe: (target) => {
|
|
1465
|
+
var _a;
|
|
1466
|
+
return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
|
|
1467
|
+
},
|
|
1468
|
+
unobserve: (target) => {
|
|
1469
|
+
var _a;
|
|
1470
|
+
return (_a = get()) == null ? void 0 : _a.unobserve(target);
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
})();
|
|
1474
|
+
this.range = null;
|
|
1475
|
+
this.setOptions = (opts2) => {
|
|
1476
|
+
Object.entries(opts2).forEach(([key, value]) => {
|
|
1477
|
+
if (typeof value === "undefined") delete opts2[key];
|
|
1478
|
+
});
|
|
1479
|
+
this.options = __spreadValues({
|
|
1480
|
+
debug: false,
|
|
1481
|
+
initialOffset: 0,
|
|
1482
|
+
overscan: 1,
|
|
1483
|
+
paddingStart: 0,
|
|
1484
|
+
paddingEnd: 0,
|
|
1485
|
+
scrollPaddingStart: 0,
|
|
1486
|
+
scrollPaddingEnd: 0,
|
|
1487
|
+
horizontal: false,
|
|
1488
|
+
getItemKey: defaultKeyExtractor,
|
|
1489
|
+
rangeExtractor: defaultRangeExtractor,
|
|
1490
|
+
onChange: () => {
|
|
1491
|
+
},
|
|
1492
|
+
measureElement,
|
|
1493
|
+
initialRect: { width: 0, height: 0 },
|
|
1494
|
+
scrollMargin: 0,
|
|
1495
|
+
gap: 0,
|
|
1496
|
+
indexAttribute: "data-index",
|
|
1497
|
+
initialMeasurementsCache: [],
|
|
1498
|
+
lanes: 1,
|
|
1499
|
+
isScrollingResetDelay: 150,
|
|
1500
|
+
enabled: true,
|
|
1501
|
+
isRtl: false,
|
|
1502
|
+
useScrollendEvent: false,
|
|
1503
|
+
useAnimationFrameWithResizeObserver: false,
|
|
1504
|
+
laneAssignmentMode: "estimate"
|
|
1505
|
+
}, opts2);
|
|
1506
|
+
};
|
|
1507
|
+
this.notify = (sync) => {
|
|
1508
|
+
var _a, _b;
|
|
1509
|
+
(_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
|
|
1510
|
+
};
|
|
1511
|
+
this.maybeNotify = memo(
|
|
1512
|
+
() => {
|
|
1513
|
+
this.calculateRange();
|
|
1514
|
+
return [
|
|
1515
|
+
this.isScrolling,
|
|
1516
|
+
this.range ? this.range.startIndex : null,
|
|
1517
|
+
this.range ? this.range.endIndex : null
|
|
1518
|
+
];
|
|
1519
|
+
},
|
|
1520
|
+
(isScrolling) => {
|
|
1521
|
+
this.notify(isScrolling);
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
key: "maybeNotify",
|
|
1525
|
+
debug: () => this.options.debug,
|
|
1526
|
+
initialDeps: [
|
|
1527
|
+
this.isScrolling,
|
|
1528
|
+
this.range ? this.range.startIndex : null,
|
|
1529
|
+
this.range ? this.range.endIndex : null
|
|
1530
|
+
]
|
|
1531
|
+
}
|
|
1532
|
+
);
|
|
1533
|
+
this.cleanup = () => {
|
|
1534
|
+
this.unsubs.filter(Boolean).forEach((d) => d());
|
|
1535
|
+
this.unsubs = [];
|
|
1536
|
+
this.observer.disconnect();
|
|
1537
|
+
if (this.rafId != null && this.targetWindow) {
|
|
1538
|
+
this.targetWindow.cancelAnimationFrame(this.rafId);
|
|
1539
|
+
this.rafId = null;
|
|
1540
|
+
}
|
|
1541
|
+
this.scrollState = null;
|
|
1542
|
+
this.scrollElement = null;
|
|
1543
|
+
this.targetWindow = null;
|
|
1544
|
+
};
|
|
1545
|
+
this._didMount = () => {
|
|
1546
|
+
return () => {
|
|
1547
|
+
this.cleanup();
|
|
1548
|
+
};
|
|
1549
|
+
};
|
|
1550
|
+
this._willUpdate = () => {
|
|
1551
|
+
var _a2;
|
|
1552
|
+
var _a;
|
|
1553
|
+
const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
|
|
1554
|
+
if (this.scrollElement !== scrollElement) {
|
|
1555
|
+
this.cleanup();
|
|
1556
|
+
if (!scrollElement) {
|
|
1557
|
+
this.maybeNotify();
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
this.scrollElement = scrollElement;
|
|
1561
|
+
if (this.scrollElement && "ownerDocument" in this.scrollElement) {
|
|
1562
|
+
this.targetWindow = this.scrollElement.ownerDocument.defaultView;
|
|
1563
|
+
} else {
|
|
1564
|
+
this.targetWindow = (_a2 = (_a = this.scrollElement) == null ? void 0 : _a.window) != null ? _a2 : null;
|
|
1565
|
+
}
|
|
1566
|
+
this.elementsCache.forEach((cached) => {
|
|
1567
|
+
this.observer.observe(cached);
|
|
1568
|
+
});
|
|
1569
|
+
this.unsubs.push(
|
|
1570
|
+
this.options.observeElementRect(this, (rect) => {
|
|
1571
|
+
this.scrollRect = rect;
|
|
1572
|
+
this.maybeNotify();
|
|
1573
|
+
})
|
|
1574
|
+
);
|
|
1575
|
+
this.unsubs.push(
|
|
1576
|
+
this.options.observeElementOffset(this, (offset, isScrolling) => {
|
|
1577
|
+
this.scrollAdjustments = 0;
|
|
1578
|
+
this.scrollDirection = isScrolling ? this.getScrollOffset() < offset ? "forward" : "backward" : null;
|
|
1579
|
+
this.scrollOffset = offset;
|
|
1580
|
+
this.isScrolling = isScrolling;
|
|
1581
|
+
if (this.scrollState) {
|
|
1582
|
+
this.scheduleScrollReconcile();
|
|
1583
|
+
}
|
|
1584
|
+
this.maybeNotify();
|
|
1585
|
+
})
|
|
1586
|
+
);
|
|
1587
|
+
this._scrollToOffset(this.getScrollOffset(), {
|
|
1588
|
+
adjustments: void 0,
|
|
1589
|
+
behavior: void 0
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
};
|
|
1593
|
+
this.rafId = null;
|
|
1594
|
+
this.getSize = () => {
|
|
1595
|
+
var _a;
|
|
1596
|
+
if (!this.options.enabled) {
|
|
1597
|
+
this.scrollRect = null;
|
|
1598
|
+
return 0;
|
|
1599
|
+
}
|
|
1600
|
+
this.scrollRect = (_a = this.scrollRect) != null ? _a : this.options.initialRect;
|
|
1601
|
+
return this.scrollRect[this.options.horizontal ? "width" : "height"];
|
|
1602
|
+
};
|
|
1603
|
+
this.getScrollOffset = () => {
|
|
1604
|
+
var _a;
|
|
1605
|
+
if (!this.options.enabled) {
|
|
1606
|
+
this.scrollOffset = null;
|
|
1607
|
+
return 0;
|
|
1608
|
+
}
|
|
1609
|
+
this.scrollOffset = (_a = this.scrollOffset) != null ? _a : typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset;
|
|
1610
|
+
return this.scrollOffset;
|
|
1611
|
+
};
|
|
1612
|
+
this.getFurthestMeasurement = (measurements, index) => {
|
|
1613
|
+
const furthestMeasurementsFound = /* @__PURE__ */ new Map();
|
|
1614
|
+
const furthestMeasurements = /* @__PURE__ */ new Map();
|
|
1615
|
+
for (let m = index - 1; m >= 0; m--) {
|
|
1616
|
+
const measurement = measurements[m];
|
|
1617
|
+
if (furthestMeasurementsFound.has(measurement.lane)) {
|
|
1618
|
+
continue;
|
|
1619
|
+
}
|
|
1620
|
+
const previousFurthestMeasurement = furthestMeasurements.get(
|
|
1621
|
+
measurement.lane
|
|
1622
|
+
);
|
|
1623
|
+
if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) {
|
|
1624
|
+
furthestMeasurements.set(measurement.lane, measurement);
|
|
1625
|
+
} else if (measurement.end < previousFurthestMeasurement.end) {
|
|
1626
|
+
furthestMeasurementsFound.set(measurement.lane, true);
|
|
1627
|
+
}
|
|
1628
|
+
if (furthestMeasurementsFound.size === this.options.lanes) {
|
|
1629
|
+
break;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
return furthestMeasurements.size === this.options.lanes ? Array.from(furthestMeasurements.values()).sort((a, b) => {
|
|
1633
|
+
if (a.end === b.end) {
|
|
1634
|
+
return a.index - b.index;
|
|
1635
|
+
}
|
|
1636
|
+
return a.end - b.end;
|
|
1637
|
+
})[0] : void 0;
|
|
1638
|
+
};
|
|
1639
|
+
this.getMeasurementOptions = memo(
|
|
1640
|
+
() => [
|
|
1641
|
+
this.options.count,
|
|
1642
|
+
this.options.paddingStart,
|
|
1643
|
+
this.options.scrollMargin,
|
|
1644
|
+
this.options.getItemKey,
|
|
1645
|
+
this.options.enabled,
|
|
1646
|
+
this.options.lanes,
|
|
1647
|
+
this.options.laneAssignmentMode
|
|
1648
|
+
],
|
|
1649
|
+
(count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode) => {
|
|
1650
|
+
const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
|
|
1651
|
+
if (lanesChanged) {
|
|
1652
|
+
this.lanesChangedFlag = true;
|
|
1653
|
+
}
|
|
1654
|
+
this.prevLanes = lanes;
|
|
1655
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
1656
|
+
return {
|
|
1657
|
+
count,
|
|
1658
|
+
paddingStart,
|
|
1659
|
+
scrollMargin,
|
|
1660
|
+
getItemKey,
|
|
1661
|
+
enabled,
|
|
1662
|
+
lanes,
|
|
1663
|
+
laneAssignmentMode
|
|
1664
|
+
};
|
|
1665
|
+
},
|
|
1666
|
+
{
|
|
1667
|
+
key: false
|
|
1668
|
+
}
|
|
1669
|
+
);
|
|
1670
|
+
this.getMeasurements = memo(
|
|
1671
|
+
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
1672
|
+
({
|
|
1673
|
+
count,
|
|
1674
|
+
paddingStart,
|
|
1675
|
+
scrollMargin,
|
|
1676
|
+
getItemKey,
|
|
1677
|
+
enabled,
|
|
1678
|
+
lanes,
|
|
1679
|
+
laneAssignmentMode
|
|
1680
|
+
}, itemSizeCache) => {
|
|
1681
|
+
if (!enabled) {
|
|
1682
|
+
this.measurementsCache = [];
|
|
1683
|
+
this.itemSizeCache.clear();
|
|
1684
|
+
this.laneAssignments.clear();
|
|
1685
|
+
return [];
|
|
1686
|
+
}
|
|
1687
|
+
if (this.laneAssignments.size > count) {
|
|
1688
|
+
for (const index of this.laneAssignments.keys()) {
|
|
1689
|
+
if (index >= count) {
|
|
1690
|
+
this.laneAssignments.delete(index);
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
if (this.lanesChangedFlag) {
|
|
1695
|
+
this.lanesChangedFlag = false;
|
|
1696
|
+
this.lanesSettling = true;
|
|
1697
|
+
this.measurementsCache = [];
|
|
1698
|
+
this.itemSizeCache.clear();
|
|
1699
|
+
this.laneAssignments.clear();
|
|
1700
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
1701
|
+
}
|
|
1702
|
+
if (this.measurementsCache.length === 0 && !this.lanesSettling) {
|
|
1703
|
+
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
1704
|
+
this.measurementsCache.forEach((item) => {
|
|
1705
|
+
this.itemSizeCache.set(item.key, item.size);
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
const min = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
1709
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
1710
|
+
if (this.lanesSettling && this.measurementsCache.length === count) {
|
|
1711
|
+
this.lanesSettling = false;
|
|
1712
|
+
}
|
|
1713
|
+
const measurements = this.measurementsCache.slice(0, min);
|
|
1714
|
+
const laneLastIndex = new Array(lanes).fill(
|
|
1715
|
+
void 0
|
|
1716
|
+
);
|
|
1717
|
+
for (let m = 0; m < min; m++) {
|
|
1718
|
+
const item = measurements[m];
|
|
1719
|
+
if (item) {
|
|
1720
|
+
laneLastIndex[item.lane] = m;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
for (let i = min; i < count; i++) {
|
|
1724
|
+
const key = getItemKey(i);
|
|
1725
|
+
const cachedLane = this.laneAssignments.get(i);
|
|
1726
|
+
let lane;
|
|
1727
|
+
let start;
|
|
1728
|
+
const shouldCacheLane = laneAssignmentMode === "estimate" || itemSizeCache.has(key);
|
|
1729
|
+
if (cachedLane !== void 0 && this.options.lanes > 1) {
|
|
1730
|
+
lane = cachedLane;
|
|
1731
|
+
const prevIndex = laneLastIndex[lane];
|
|
1732
|
+
const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
|
|
1733
|
+
start = prevInLane ? prevInLane.end + this.options.gap : paddingStart + scrollMargin;
|
|
1734
|
+
} else {
|
|
1735
|
+
const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
|
|
1736
|
+
start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
|
|
1737
|
+
lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
|
|
1738
|
+
if (this.options.lanes > 1 && shouldCacheLane) {
|
|
1739
|
+
this.laneAssignments.set(i, lane);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
const measuredSize = itemSizeCache.get(key);
|
|
1743
|
+
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
1744
|
+
const end = start + size;
|
|
1745
|
+
measurements[i] = {
|
|
1746
|
+
index: i,
|
|
1747
|
+
start,
|
|
1748
|
+
size,
|
|
1749
|
+
end,
|
|
1750
|
+
key,
|
|
1751
|
+
lane
|
|
1752
|
+
};
|
|
1753
|
+
laneLastIndex[lane] = i;
|
|
1754
|
+
}
|
|
1755
|
+
this.measurementsCache = measurements;
|
|
1756
|
+
return measurements;
|
|
1757
|
+
},
|
|
1758
|
+
{
|
|
1759
|
+
key: "getMeasurements",
|
|
1760
|
+
debug: () => this.options.debug
|
|
1761
|
+
}
|
|
1762
|
+
);
|
|
1763
|
+
this.calculateRange = memo(
|
|
1764
|
+
() => [
|
|
1765
|
+
this.getMeasurements(),
|
|
1766
|
+
this.getSize(),
|
|
1767
|
+
this.getScrollOffset(),
|
|
1768
|
+
this.options.lanes
|
|
1769
|
+
],
|
|
1770
|
+
(measurements, outerSize, scrollOffset, lanes) => {
|
|
1771
|
+
return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
|
|
1772
|
+
measurements,
|
|
1773
|
+
outerSize,
|
|
1774
|
+
scrollOffset,
|
|
1775
|
+
lanes
|
|
1776
|
+
}) : null;
|
|
1777
|
+
},
|
|
1778
|
+
{
|
|
1779
|
+
key: "calculateRange",
|
|
1780
|
+
debug: () => this.options.debug
|
|
1781
|
+
}
|
|
1782
|
+
);
|
|
1783
|
+
this.getVirtualIndexes = memo(
|
|
1784
|
+
() => {
|
|
1785
|
+
let startIndex = null;
|
|
1786
|
+
let endIndex = null;
|
|
1787
|
+
const range = this.calculateRange();
|
|
1788
|
+
if (range) {
|
|
1789
|
+
startIndex = range.startIndex;
|
|
1790
|
+
endIndex = range.endIndex;
|
|
1791
|
+
}
|
|
1792
|
+
this.maybeNotify.updateDeps([this.isScrolling, startIndex, endIndex]);
|
|
1793
|
+
return [
|
|
1794
|
+
this.options.rangeExtractor,
|
|
1795
|
+
this.options.overscan,
|
|
1796
|
+
this.options.count,
|
|
1797
|
+
startIndex,
|
|
1798
|
+
endIndex
|
|
1799
|
+
];
|
|
1800
|
+
},
|
|
1801
|
+
(rangeExtractor, overscan, count, startIndex, endIndex) => {
|
|
1802
|
+
return startIndex === null || endIndex === null ? [] : rangeExtractor({
|
|
1803
|
+
startIndex,
|
|
1804
|
+
endIndex,
|
|
1805
|
+
overscan,
|
|
1806
|
+
count
|
|
1807
|
+
});
|
|
1808
|
+
},
|
|
1809
|
+
{
|
|
1810
|
+
key: "getVirtualIndexes",
|
|
1811
|
+
debug: () => this.options.debug
|
|
1812
|
+
}
|
|
1813
|
+
);
|
|
1814
|
+
this.indexFromElement = (node) => {
|
|
1815
|
+
const attributeName = this.options.indexAttribute;
|
|
1816
|
+
const indexStr = node.getAttribute(attributeName);
|
|
1817
|
+
if (!indexStr) {
|
|
1818
|
+
console.warn(
|
|
1819
|
+
`Missing attribute name '${attributeName}={index}' on measured element.`
|
|
1820
|
+
);
|
|
1821
|
+
return -1;
|
|
1822
|
+
}
|
|
1823
|
+
return parseInt(indexStr, 10);
|
|
1824
|
+
};
|
|
1825
|
+
this.shouldMeasureDuringScroll = (index) => {
|
|
1826
|
+
var _a2;
|
|
1827
|
+
var _a;
|
|
1828
|
+
if (!this.scrollState || this.scrollState.behavior !== "smooth") {
|
|
1829
|
+
return true;
|
|
1830
|
+
}
|
|
1831
|
+
const scrollIndex = (_a2 = this.scrollState.index) != null ? _a2 : (_a = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : _a.index;
|
|
1832
|
+
if (scrollIndex !== void 0 && this.range) {
|
|
1833
|
+
const bufferSize = Math.max(
|
|
1834
|
+
this.options.overscan,
|
|
1835
|
+
Math.ceil((this.range.endIndex - this.range.startIndex) / 2)
|
|
1836
|
+
);
|
|
1837
|
+
const minIndex = Math.max(0, scrollIndex - bufferSize);
|
|
1838
|
+
const maxIndex = Math.min(
|
|
1839
|
+
this.options.count - 1,
|
|
1840
|
+
scrollIndex + bufferSize
|
|
1841
|
+
);
|
|
1842
|
+
return index >= minIndex && index <= maxIndex;
|
|
1843
|
+
}
|
|
1844
|
+
return true;
|
|
1845
|
+
};
|
|
1846
|
+
this.measureElement = (node) => {
|
|
1847
|
+
if (!node) {
|
|
1848
|
+
this.elementsCache.forEach((cached, key2) => {
|
|
1849
|
+
if (!cached.isConnected) {
|
|
1850
|
+
this.observer.unobserve(cached);
|
|
1851
|
+
this.elementsCache.delete(key2);
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
return;
|
|
1855
|
+
}
|
|
1856
|
+
const index = this.indexFromElement(node);
|
|
1857
|
+
const key = this.options.getItemKey(index);
|
|
1858
|
+
const prevNode = this.elementsCache.get(key);
|
|
1859
|
+
if (prevNode !== node) {
|
|
1860
|
+
if (prevNode) {
|
|
1861
|
+
this.observer.unobserve(prevNode);
|
|
1862
|
+
}
|
|
1863
|
+
this.observer.observe(node);
|
|
1864
|
+
this.elementsCache.set(key, node);
|
|
1865
|
+
}
|
|
1866
|
+
if ((!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(index)) {
|
|
1867
|
+
this.resizeItem(index, this.options.measureElement(node, void 0, this));
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
this.resizeItem = (index, size) => {
|
|
1871
|
+
var _a2;
|
|
1872
|
+
var _a;
|
|
1873
|
+
const item = this.measurementsCache[index];
|
|
1874
|
+
if (!item) return;
|
|
1875
|
+
const itemSize = (_a2 = this.itemSizeCache.get(item.key)) != null ? _a2 : item.size;
|
|
1876
|
+
const delta = size - itemSize;
|
|
1877
|
+
if (delta !== 0) {
|
|
1878
|
+
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)) {
|
|
1879
|
+
if (this.options.debug) {
|
|
1880
|
+
console.info("correction", delta);
|
|
1881
|
+
}
|
|
1882
|
+
this._scrollToOffset(this.getScrollOffset(), {
|
|
1883
|
+
adjustments: this.scrollAdjustments += delta,
|
|
1884
|
+
behavior: void 0
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
this.pendingMeasuredCacheIndexes.push(item.index);
|
|
1888
|
+
this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size));
|
|
1889
|
+
this.notify(false);
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
this.getVirtualItems = memo(
|
|
1893
|
+
() => [this.getVirtualIndexes(), this.getMeasurements()],
|
|
1894
|
+
(indexes, measurements) => {
|
|
1895
|
+
const virtualItems = [];
|
|
1896
|
+
for (let k = 0, len = indexes.length; k < len; k++) {
|
|
1897
|
+
const i = indexes[k];
|
|
1898
|
+
const measurement = measurements[i];
|
|
1899
|
+
virtualItems.push(measurement);
|
|
1900
|
+
}
|
|
1901
|
+
return virtualItems;
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
key: "getVirtualItems",
|
|
1905
|
+
debug: () => this.options.debug
|
|
1906
|
+
}
|
|
1907
|
+
);
|
|
1908
|
+
this.getVirtualItemForOffset = (offset) => {
|
|
1909
|
+
const measurements = this.getMeasurements();
|
|
1910
|
+
if (measurements.length === 0) {
|
|
1911
|
+
return void 0;
|
|
1912
|
+
}
|
|
1913
|
+
return notUndefined(
|
|
1914
|
+
measurements[findNearestBinarySearch(
|
|
1915
|
+
0,
|
|
1916
|
+
measurements.length - 1,
|
|
1917
|
+
(index) => notUndefined(measurements[index]).start,
|
|
1918
|
+
offset
|
|
1919
|
+
)]
|
|
1920
|
+
);
|
|
1921
|
+
};
|
|
1922
|
+
this.getMaxScrollOffset = () => {
|
|
1923
|
+
if (!this.scrollElement) return 0;
|
|
1924
|
+
if ("scrollHeight" in this.scrollElement) {
|
|
1925
|
+
return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
|
|
1926
|
+
} else {
|
|
1927
|
+
const doc = this.scrollElement.document.documentElement;
|
|
1928
|
+
return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1931
|
+
this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
|
|
1932
|
+
if (!this.scrollElement) return 0;
|
|
1933
|
+
const size = this.getSize();
|
|
1934
|
+
const scrollOffset = this.getScrollOffset();
|
|
1935
|
+
if (align === "auto") {
|
|
1936
|
+
align = toOffset >= scrollOffset + size ? "end" : "start";
|
|
1937
|
+
}
|
|
1938
|
+
if (align === "center") {
|
|
1939
|
+
toOffset += (itemSize - size) / 2;
|
|
1940
|
+
} else if (align === "end") {
|
|
1941
|
+
toOffset -= size;
|
|
1942
|
+
}
|
|
1943
|
+
const maxOffset = this.getMaxScrollOffset();
|
|
1944
|
+
return Math.max(Math.min(maxOffset, toOffset), 0);
|
|
1945
|
+
};
|
|
1946
|
+
this.getOffsetForIndex = (index, align = "auto") => {
|
|
1947
|
+
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
1948
|
+
const size = this.getSize();
|
|
1949
|
+
const scrollOffset = this.getScrollOffset();
|
|
1950
|
+
const item = this.measurementsCache[index];
|
|
1951
|
+
if (!item) return;
|
|
1952
|
+
if (align === "auto") {
|
|
1953
|
+
if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) {
|
|
1954
|
+
align = "end";
|
|
1955
|
+
} else if (item.start <= scrollOffset + this.options.scrollPaddingStart) {
|
|
1956
|
+
align = "start";
|
|
1957
|
+
} else {
|
|
1958
|
+
return [scrollOffset, align];
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
if (align === "end" && index === this.options.count - 1) {
|
|
1962
|
+
return [this.getMaxScrollOffset(), align];
|
|
1963
|
+
}
|
|
1964
|
+
const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
|
|
1965
|
+
return [
|
|
1966
|
+
this.getOffsetForAlignment(toOffset, align, item.size),
|
|
1967
|
+
align
|
|
1968
|
+
];
|
|
1969
|
+
};
|
|
1970
|
+
this.scrollToOffset = (toOffset, { align = "start", behavior = "auto" } = {}) => {
|
|
1971
|
+
const offset = this.getOffsetForAlignment(toOffset, align);
|
|
1972
|
+
const now = this.now();
|
|
1973
|
+
this.scrollState = {
|
|
1974
|
+
index: null,
|
|
1975
|
+
align,
|
|
1976
|
+
behavior,
|
|
1977
|
+
startedAt: now,
|
|
1978
|
+
lastTargetOffset: offset,
|
|
1979
|
+
stableFrames: 0
|
|
1980
|
+
};
|
|
1981
|
+
this._scrollToOffset(offset, { adjustments: void 0, behavior });
|
|
1982
|
+
this.scheduleScrollReconcile();
|
|
1983
|
+
};
|
|
1984
|
+
this.scrollToIndex = (index, {
|
|
1985
|
+
align: initialAlign = "auto",
|
|
1986
|
+
behavior = "auto"
|
|
1987
|
+
} = {}) => {
|
|
1988
|
+
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
1989
|
+
const offsetInfo = this.getOffsetForIndex(index, initialAlign);
|
|
1990
|
+
if (!offsetInfo) {
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
const [offset, align] = offsetInfo;
|
|
1994
|
+
const now = this.now();
|
|
1995
|
+
this.scrollState = {
|
|
1996
|
+
index,
|
|
1997
|
+
align,
|
|
1998
|
+
behavior,
|
|
1999
|
+
startedAt: now,
|
|
2000
|
+
lastTargetOffset: offset,
|
|
2001
|
+
stableFrames: 0
|
|
2002
|
+
};
|
|
2003
|
+
this._scrollToOffset(offset, { adjustments: void 0, behavior });
|
|
2004
|
+
this.scheduleScrollReconcile();
|
|
2005
|
+
};
|
|
2006
|
+
this.scrollBy = (delta, { behavior = "auto" } = {}) => {
|
|
2007
|
+
const offset = this.getScrollOffset() + delta;
|
|
2008
|
+
const now = this.now();
|
|
2009
|
+
this.scrollState = {
|
|
2010
|
+
index: null,
|
|
2011
|
+
align: "start",
|
|
2012
|
+
behavior,
|
|
2013
|
+
startedAt: now,
|
|
2014
|
+
lastTargetOffset: offset,
|
|
2015
|
+
stableFrames: 0
|
|
2016
|
+
};
|
|
2017
|
+
this._scrollToOffset(offset, { adjustments: void 0, behavior });
|
|
2018
|
+
this.scheduleScrollReconcile();
|
|
2019
|
+
};
|
|
2020
|
+
this.getTotalSize = () => {
|
|
2021
|
+
var _a2;
|
|
2022
|
+
var _a;
|
|
2023
|
+
const measurements = this.getMeasurements();
|
|
2024
|
+
let end;
|
|
2025
|
+
if (measurements.length === 0) {
|
|
2026
|
+
end = this.options.paddingStart;
|
|
2027
|
+
} else if (this.options.lanes === 1) {
|
|
2028
|
+
end = (_a2 = (_a = measurements[measurements.length - 1]) == null ? void 0 : _a.end) != null ? _a2 : 0;
|
|
2029
|
+
} else {
|
|
2030
|
+
const endByLane = Array(this.options.lanes).fill(null);
|
|
2031
|
+
let endIndex = measurements.length - 1;
|
|
2032
|
+
while (endIndex >= 0 && endByLane.some((val) => val === null)) {
|
|
2033
|
+
const item = measurements[endIndex];
|
|
2034
|
+
if (endByLane[item.lane] === null) {
|
|
2035
|
+
endByLane[item.lane] = item.end;
|
|
2036
|
+
}
|
|
2037
|
+
endIndex--;
|
|
2038
|
+
}
|
|
2039
|
+
end = Math.max(...endByLane.filter((val) => val !== null));
|
|
2040
|
+
}
|
|
2041
|
+
return Math.max(
|
|
2042
|
+
end - this.options.scrollMargin + this.options.paddingEnd,
|
|
2043
|
+
0
|
|
2044
|
+
);
|
|
2045
|
+
};
|
|
2046
|
+
this._scrollToOffset = (offset, {
|
|
2047
|
+
adjustments,
|
|
2048
|
+
behavior
|
|
2049
|
+
}) => {
|
|
2050
|
+
this.options.scrollToFn(offset, { behavior, adjustments }, this);
|
|
2051
|
+
};
|
|
2052
|
+
this.measure = () => {
|
|
2053
|
+
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
2054
|
+
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
2055
|
+
this.notify(false);
|
|
2056
|
+
};
|
|
2057
|
+
this.setOptions(opts);
|
|
2058
|
+
}
|
|
2059
|
+
scheduleScrollReconcile() {
|
|
2060
|
+
if (!this.targetWindow) {
|
|
2061
|
+
this.scrollState = null;
|
|
2062
|
+
return;
|
|
2063
|
+
}
|
|
2064
|
+
if (this.rafId != null) return;
|
|
2065
|
+
this.rafId = this.targetWindow.requestAnimationFrame(() => {
|
|
2066
|
+
this.rafId = null;
|
|
2067
|
+
this.reconcileScroll();
|
|
2068
|
+
});
|
|
2069
|
+
}
|
|
2070
|
+
reconcileScroll() {
|
|
2071
|
+
if (!this.scrollState) return;
|
|
2072
|
+
const el = this.scrollElement;
|
|
2073
|
+
if (!el) return;
|
|
2074
|
+
const MAX_RECONCILE_MS = 5e3;
|
|
2075
|
+
if (this.now() - this.scrollState.startedAt > MAX_RECONCILE_MS) {
|
|
2076
|
+
this.scrollState = null;
|
|
2077
|
+
return;
|
|
2078
|
+
}
|
|
2079
|
+
const offsetInfo = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0;
|
|
2080
|
+
const targetOffset = offsetInfo ? offsetInfo[0] : this.scrollState.lastTargetOffset;
|
|
2081
|
+
const STABLE_FRAMES = 1;
|
|
2082
|
+
const targetChanged = targetOffset !== this.scrollState.lastTargetOffset;
|
|
2083
|
+
if (!targetChanged && approxEqual(targetOffset, this.getScrollOffset())) {
|
|
2084
|
+
this.scrollState.stableFrames++;
|
|
2085
|
+
if (this.scrollState.stableFrames >= STABLE_FRAMES) {
|
|
2086
|
+
this.scrollState = null;
|
|
2087
|
+
return;
|
|
2088
|
+
}
|
|
2089
|
+
} else {
|
|
2090
|
+
this.scrollState.stableFrames = 0;
|
|
2091
|
+
if (targetChanged) {
|
|
2092
|
+
this.scrollState.lastTargetOffset = targetOffset;
|
|
2093
|
+
this.scrollState.behavior = "auto";
|
|
2094
|
+
this._scrollToOffset(targetOffset, {
|
|
2095
|
+
adjustments: void 0,
|
|
2096
|
+
behavior: "auto"
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
this.scheduleScrollReconcile();
|
|
2101
|
+
}
|
|
2102
|
+
};
|
|
2103
|
+
var findNearestBinarySearch = (low, high, getCurrentValue, value) => {
|
|
2104
|
+
while (low <= high) {
|
|
2105
|
+
const middle = (low + high) / 2 | 0;
|
|
2106
|
+
const currentValue = getCurrentValue(middle);
|
|
2107
|
+
if (currentValue < value) {
|
|
2108
|
+
low = middle + 1;
|
|
2109
|
+
} else if (currentValue > value) {
|
|
2110
|
+
high = middle - 1;
|
|
2111
|
+
} else {
|
|
2112
|
+
return middle;
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
if (low > 0) {
|
|
2116
|
+
return low - 1;
|
|
2117
|
+
} else {
|
|
2118
|
+
return 0;
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
function calculateRange({
|
|
2122
|
+
measurements,
|
|
2123
|
+
outerSize,
|
|
2124
|
+
scrollOffset,
|
|
2125
|
+
lanes
|
|
2126
|
+
}) {
|
|
2127
|
+
const lastIndex = measurements.length - 1;
|
|
2128
|
+
const getOffset = (index) => measurements[index].start;
|
|
2129
|
+
if (measurements.length <= lanes) {
|
|
2130
|
+
return {
|
|
2131
|
+
startIndex: 0,
|
|
2132
|
+
endIndex: lastIndex
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
let startIndex = findNearestBinarySearch(
|
|
2136
|
+
0,
|
|
2137
|
+
lastIndex,
|
|
2138
|
+
getOffset,
|
|
2139
|
+
scrollOffset
|
|
2140
|
+
);
|
|
2141
|
+
let endIndex = startIndex;
|
|
2142
|
+
if (lanes === 1) {
|
|
2143
|
+
while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) {
|
|
2144
|
+
endIndex++;
|
|
2145
|
+
}
|
|
2146
|
+
} else if (lanes > 1) {
|
|
2147
|
+
const endPerLane = Array(lanes).fill(0);
|
|
2148
|
+
while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
|
|
2149
|
+
const item = measurements[endIndex];
|
|
2150
|
+
endPerLane[item.lane] = item.end;
|
|
2151
|
+
endIndex++;
|
|
2152
|
+
}
|
|
2153
|
+
const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
|
|
2154
|
+
while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
|
|
2155
|
+
const item = measurements[startIndex];
|
|
2156
|
+
startPerLane[item.lane] = item.start;
|
|
2157
|
+
startIndex--;
|
|
2158
|
+
}
|
|
2159
|
+
startIndex = Math.max(0, startIndex - startIndex % lanes);
|
|
2160
|
+
endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
|
|
2161
|
+
}
|
|
2162
|
+
return { startIndex, endIndex };
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
// ../../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
|
|
2166
|
+
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
2167
|
+
function useVirtualizerBase(_a) {
|
|
2168
|
+
var _b = _a, {
|
|
2169
|
+
useFlushSync = true
|
|
2170
|
+
} = _b, options = __objRest(_b, [
|
|
2171
|
+
"useFlushSync"
|
|
2172
|
+
]);
|
|
2173
|
+
const rerender = React.useReducer(() => ({}), {})[1];
|
|
2174
|
+
const resolvedOptions = __spreadProps(__spreadValues({}, options), {
|
|
2175
|
+
onChange: (instance2, sync) => {
|
|
2176
|
+
var _a2;
|
|
2177
|
+
if (useFlushSync && sync) {
|
|
2178
|
+
flushSync(rerender);
|
|
2179
|
+
} else {
|
|
2180
|
+
rerender();
|
|
2181
|
+
}
|
|
2182
|
+
(_a2 = options.onChange) == null ? void 0 : _a2.call(options, instance2, sync);
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2185
|
+
const [instance] = React.useState(
|
|
2186
|
+
() => new Virtualizer(resolvedOptions)
|
|
2187
|
+
);
|
|
2188
|
+
instance.setOptions(resolvedOptions);
|
|
2189
|
+
useIsomorphicLayoutEffect(() => {
|
|
2190
|
+
return instance._didMount();
|
|
2191
|
+
}, []);
|
|
2192
|
+
useIsomorphicLayoutEffect(() => {
|
|
2193
|
+
return instance._willUpdate();
|
|
2194
|
+
});
|
|
2195
|
+
return instance;
|
|
2196
|
+
}
|
|
2197
|
+
function useWindowVirtualizer(options) {
|
|
2198
|
+
return useVirtualizerBase(__spreadValues({
|
|
2199
|
+
getScrollElement: () => typeof document !== "undefined" ? window : null,
|
|
2200
|
+
observeElementRect: observeWindowRect,
|
|
2201
|
+
observeElementOffset: observeWindowOffset,
|
|
2202
|
+
scrollToFn: windowScroll,
|
|
2203
|
+
initialOffset: () => typeof document !== "undefined" ? window.scrollY : 0
|
|
2204
|
+
}, options));
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
// ../renderers/src/CollectionRenderer.tsx
|
|
1243
2208
|
import { Fragment as Fragment2, jsx as jsx27, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1244
|
-
var CollectionRendererComponent = ({
|
|
1245
|
-
|
|
1246
|
-
state,
|
|
1247
|
-
filters,
|
|
1248
|
-
search,
|
|
1249
|
-
tags,
|
|
1250
|
-
loadMore
|
|
1251
|
-
}) => {
|
|
2209
|
+
var CollectionRendererComponent = (props) => {
|
|
2210
|
+
const { state, filters, search, loading, loadMore } = props;
|
|
1252
2211
|
const endOfContentRef = useRef2(null);
|
|
1253
2212
|
const isBottomVisible = useIsElementVisible(endOfContentRef);
|
|
1254
|
-
|
|
2213
|
+
useEffect6(() => {
|
|
1255
2214
|
if (isBottomVisible) {
|
|
1256
2215
|
loadMore == null ? void 0 : loadMore();
|
|
1257
2216
|
}
|
|
@@ -1303,44 +2262,147 @@ var CollectionRendererComponent = ({
|
|
|
1303
2262
|
JSON.stringify(filter.options)
|
|
1304
2263
|
);
|
|
1305
2264
|
}),
|
|
1306
|
-
state.type === "collection-content" ?
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
2265
|
+
state.type === "collection-content" ? /* @__PURE__ */ jsx27(ContentComponent, __spreadProps(__spreadValues({}, props), { state })) : state.children,
|
|
2266
|
+
/* @__PURE__ */ jsx27(
|
|
2267
|
+
"div",
|
|
2268
|
+
{
|
|
2269
|
+
ref: endOfContentRef,
|
|
2270
|
+
style: {
|
|
2271
|
+
marginLeft: "auto",
|
|
2272
|
+
marginRight: "auto",
|
|
2273
|
+
display: "flex"
|
|
2274
|
+
},
|
|
2275
|
+
children: loading ? /* @__PURE__ */ jsx27(ProcessIndicator, { size: "xs" }) : null
|
|
2276
|
+
}
|
|
2277
|
+
)
|
|
2278
|
+
] });
|
|
2279
|
+
};
|
|
2280
|
+
var ContentComponent = (props) => {
|
|
2281
|
+
const { state, tags, control } = props;
|
|
2282
|
+
const stateCount = state.sections.reduce(
|
|
2283
|
+
(total, section) => section.items.length + total + (section.title ? 1 : 0),
|
|
2284
|
+
0
|
|
2285
|
+
);
|
|
2286
|
+
const items = useMemo(() => {
|
|
2287
|
+
return state.sections.reduce((acc, section) => {
|
|
2288
|
+
return [
|
|
2289
|
+
...acc,
|
|
2290
|
+
...section.title ? [{ type: "header", title: section.title }] : [],
|
|
2291
|
+
...section.items.map((item) => ({
|
|
2292
|
+
item,
|
|
2293
|
+
type: "item"
|
|
2294
|
+
}))
|
|
2295
|
+
];
|
|
2296
|
+
}, []);
|
|
2297
|
+
}, [stateCount]);
|
|
2298
|
+
const listRef = useRef2(null);
|
|
2299
|
+
const listOffsetRef = useRef2(0);
|
|
2300
|
+
useLayoutEffect2(() => {
|
|
2301
|
+
var _a, _b;
|
|
2302
|
+
listOffsetRef.current = (_b = (_a = listRef.current) == null ? void 0 : _a.offsetTop) != null ? _b : 0;
|
|
2303
|
+
});
|
|
2304
|
+
const virtualizer = useWindowVirtualizer({
|
|
2305
|
+
count: stateCount,
|
|
2306
|
+
estimateSize: () => 120,
|
|
2307
|
+
overscan: 10,
|
|
2308
|
+
// eslint-disable-next-line react-hooks/refs
|
|
2309
|
+
scrollMargin: listOffsetRef.current
|
|
2310
|
+
});
|
|
2311
|
+
return /* @__PURE__ */ jsx27("div", { ref: listRef, children: /* @__PURE__ */ jsx27(
|
|
2312
|
+
"div",
|
|
2313
|
+
{
|
|
2314
|
+
style: {
|
|
2315
|
+
height: `${virtualizer.getTotalSize()}px`,
|
|
2316
|
+
width: "100%",
|
|
2317
|
+
position: "relative"
|
|
2318
|
+
},
|
|
2319
|
+
children: virtualizer.getVirtualItems().map((item) => {
|
|
2320
|
+
const i = items[item.index];
|
|
2321
|
+
if (!i) {
|
|
2322
|
+
return null;
|
|
2323
|
+
}
|
|
2324
|
+
if (i.type === "header") {
|
|
1325
2325
|
return /* @__PURE__ */ jsx27(
|
|
1326
|
-
|
|
2326
|
+
"div",
|
|
1327
2327
|
{
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
2328
|
+
ref: virtualizer.measureElement,
|
|
2329
|
+
"data-index": item.index,
|
|
2330
|
+
style: {
|
|
2331
|
+
position: "absolute",
|
|
2332
|
+
top: 0,
|
|
2333
|
+
left: 0,
|
|
2334
|
+
width: "100%",
|
|
2335
|
+
transform: `translateY(${item.start - virtualizer.options.scrollMargin}px)`
|
|
2336
|
+
},
|
|
2337
|
+
children: /* @__PURE__ */ jsx27(Header, { title: i.title, callToAction: i.callToAction })
|
|
1336
2338
|
},
|
|
1337
|
-
|
|
2339
|
+
item.key
|
|
1338
2340
|
);
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
2341
|
+
}
|
|
2342
|
+
return /* @__PURE__ */ jsx27(
|
|
2343
|
+
"div",
|
|
2344
|
+
{
|
|
2345
|
+
ref: virtualizer.measureElement,
|
|
2346
|
+
"data-index": item.index,
|
|
2347
|
+
style: {
|
|
2348
|
+
position: "absolute",
|
|
2349
|
+
top: 0,
|
|
2350
|
+
left: 0,
|
|
2351
|
+
width: "100%",
|
|
2352
|
+
transform: `translateY(${item.start - virtualizer.options.scrollMargin}px)`
|
|
2353
|
+
},
|
|
2354
|
+
children: /* @__PURE__ */ jsx27(ItemComponent, __spreadProps(__spreadValues({}, i.item), { parentTags: tags, control }))
|
|
2355
|
+
},
|
|
2356
|
+
item.key
|
|
2357
|
+
);
|
|
2358
|
+
})
|
|
2359
|
+
}
|
|
2360
|
+
) });
|
|
2361
|
+
};
|
|
2362
|
+
var getNavigationControl = (onClick, href) => {
|
|
2363
|
+
if (href) {
|
|
2364
|
+
return /* @__PURE__ */ jsx27(ListItem6.Navigation, { href });
|
|
2365
|
+
}
|
|
2366
|
+
if (onClick) {
|
|
2367
|
+
return /* @__PURE__ */ jsx27(ListItem6.Navigation, { onClick });
|
|
2368
|
+
}
|
|
2369
|
+
return null;
|
|
2370
|
+
};
|
|
2371
|
+
var ItemComponent = (props) => {
|
|
2372
|
+
var _a, _b;
|
|
2373
|
+
const {
|
|
2374
|
+
title,
|
|
2375
|
+
description,
|
|
2376
|
+
supportingValues,
|
|
2377
|
+
media,
|
|
2378
|
+
additionalInfo,
|
|
2379
|
+
inlineAlert,
|
|
2380
|
+
href,
|
|
2381
|
+
onClick,
|
|
2382
|
+
callToAction,
|
|
2383
|
+
tags,
|
|
2384
|
+
parentTags,
|
|
2385
|
+
control
|
|
2386
|
+
} = props;
|
|
2387
|
+
const controlOptions = {
|
|
2388
|
+
ctaSecondary: (_a = tags == null ? void 0 : tags.includes("cta-secondary")) != null ? _a : false,
|
|
2389
|
+
fullyInteractive: (_b = (tags == null ? void 0 : tags.includes("fully-interactive")) && (additionalInfo == null ? void 0 : additionalInfo.onClick) == null) != null ? _b : false
|
|
2390
|
+
};
|
|
2391
|
+
console.log("title", title, "onClick", onClick, "href", href, "cta", callToAction);
|
|
2392
|
+
return /* @__PURE__ */ jsx27(
|
|
2393
|
+
ListItem6,
|
|
2394
|
+
{
|
|
2395
|
+
title,
|
|
2396
|
+
subtitle: description,
|
|
2397
|
+
valueTitle: supportingValues == null ? void 0 : supportingValues.value,
|
|
2398
|
+
valueSubtitle: supportingValues == null ? void 0 : supportingValues.subvalue,
|
|
2399
|
+
media: getMedia(media, shouldUseAvatar(control, parentTags)),
|
|
2400
|
+
prompt: getInlineAlert(inlineAlert),
|
|
2401
|
+
additionalInfo: getAdditionalInfo(additionalInfo),
|
|
2402
|
+
control: onClick || href ? getNavigationControl(onClick, href) : getCTAControl(callToAction, controlOptions)
|
|
2403
|
+
},
|
|
2404
|
+
title
|
|
2405
|
+
);
|
|
1344
2406
|
};
|
|
1345
2407
|
var CollectionRenderer = {
|
|
1346
2408
|
canRenderType: "collection",
|
|
@@ -1491,7 +2553,7 @@ import { ListItem as ListItem7 } from "@transferwise/components";
|
|
|
1491
2553
|
|
|
1492
2554
|
// ../renderers/src/DecisionRenderer/DecisionWrapper.tsx
|
|
1493
2555
|
import { Header as Header3, SearchInput } from "@transferwise/components";
|
|
1494
|
-
import { useState as
|
|
2556
|
+
import { useState as useState6 } from "react";
|
|
1495
2557
|
import { useIntl as useIntl5 } from "react-intl";
|
|
1496
2558
|
|
|
1497
2559
|
// ../renderers/src/messages/filter.messages.ts
|
|
@@ -1637,7 +2699,7 @@ var UnfilteredDecisionList = (_a) => {
|
|
|
1637
2699
|
};
|
|
1638
2700
|
var FilteredDecisionList = (props) => {
|
|
1639
2701
|
const { formatMessage } = useIntl5();
|
|
1640
|
-
const [query, setQuery] =
|
|
2702
|
+
const [query, setQuery] = useState6("");
|
|
1641
2703
|
const { control, options, renderDecisionList: renderDecisionList2 } = props;
|
|
1642
2704
|
const filteredOptions = (query == null ? void 0 : query.length) > 0 ? filterAndSortDecisionOptions(options, query) : options;
|
|
1643
2705
|
const isGrouped = isGroupedDecision(options);
|
|
@@ -1754,7 +2816,7 @@ var external_confirmation_messages_default = defineMessages6({
|
|
|
1754
2816
|
|
|
1755
2817
|
// ../renderers/src/ExternalConfirmationRenderer.tsx
|
|
1756
2818
|
import { useIntl as useIntl6 } from "react-intl";
|
|
1757
|
-
import { useEffect as
|
|
2819
|
+
import { useEffect as useEffect7 } from "react";
|
|
1758
2820
|
import { Fragment as Fragment6, jsx as jsx35, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1759
2821
|
var ExternalConfirmationRenderer = {
|
|
1760
2822
|
canRenderType: "external-confirmation",
|
|
@@ -1767,7 +2829,7 @@ function ExternalConfirmationRendererComponent({
|
|
|
1767
2829
|
onCancel
|
|
1768
2830
|
}) {
|
|
1769
2831
|
const { formatMessage } = useIntl6();
|
|
1770
|
-
|
|
2832
|
+
useEffect7(() => {
|
|
1771
2833
|
open();
|
|
1772
2834
|
}, []);
|
|
1773
2835
|
return /* @__PURE__ */ jsx35(
|
|
@@ -1881,7 +2943,7 @@ var HeadingRenderer_default = HeadingRenderer;
|
|
|
1881
2943
|
|
|
1882
2944
|
// ../renderers/src/ImageRenderer/UrlImage.tsx
|
|
1883
2945
|
import { Image } from "@transferwise/components";
|
|
1884
|
-
import { useEffect as
|
|
2946
|
+
import { useEffect as useEffect8, useState as useState7 } from "react";
|
|
1885
2947
|
|
|
1886
2948
|
// ../renderers/src/utils/api-utils.ts
|
|
1887
2949
|
function isRelativePath(url = "") {
|
|
@@ -1900,8 +2962,8 @@ function UrlImage({
|
|
|
1900
2962
|
uri,
|
|
1901
2963
|
httpClient
|
|
1902
2964
|
}) {
|
|
1903
|
-
const [imageSource, setImageSource] =
|
|
1904
|
-
|
|
2965
|
+
const [imageSource, setImageSource] = useState7("");
|
|
2966
|
+
useEffect8(() => {
|
|
1905
2967
|
if (!uri.startsWith("urn:")) {
|
|
1906
2968
|
void getImageSource(httpClient, uri).then(setImageSource);
|
|
1907
2969
|
}
|
|
@@ -1967,7 +3029,7 @@ import {
|
|
|
1967
3029
|
Illustration,
|
|
1968
3030
|
isIllustrationSupport3D
|
|
1969
3031
|
} from "@wise/art";
|
|
1970
|
-
import { useState as
|
|
3032
|
+
import { useState as useState8 } from "react";
|
|
1971
3033
|
|
|
1972
3034
|
// ../renderers/src/ImageRenderer/isAnimated.ts
|
|
1973
3035
|
var isAnimated = (uri) => {
|
|
@@ -2017,7 +3079,7 @@ function UrnIllustration({
|
|
|
2017
3079
|
size,
|
|
2018
3080
|
uri
|
|
2019
3081
|
}) {
|
|
2020
|
-
const [has3DFailed, setHas3DFailed] =
|
|
3082
|
+
const [has3DFailed, setHas3DFailed] = useState8(false);
|
|
2021
3083
|
const illustrationSize = getIllustrationSize(size);
|
|
2022
3084
|
const illustrationName = getIllustrationName(uri);
|
|
2023
3085
|
const illustration3DName = getIllustration3DName(uri);
|
|
@@ -2312,7 +3374,7 @@ var mapAvatarMediaSize = (size) => {
|
|
|
2312
3374
|
|
|
2313
3375
|
// ../renderers/src/ModalLayoutRenderer.tsx
|
|
2314
3376
|
import { Button as Button5, Modal as Modal2 } from "@transferwise/components";
|
|
2315
|
-
import { useState as
|
|
3377
|
+
import { useState as useState9 } from "react";
|
|
2316
3378
|
import { jsx as jsx52, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2317
3379
|
var ModalLayoutRenderer = {
|
|
2318
3380
|
canRenderType: "modal-layout",
|
|
@@ -2320,7 +3382,7 @@ var ModalLayoutRenderer = {
|
|
|
2320
3382
|
};
|
|
2321
3383
|
var ModalLayoutRenderer_default = ModalLayoutRenderer;
|
|
2322
3384
|
function DFModal({ content, margin, trigger }) {
|
|
2323
|
-
const [visible, setVisible] =
|
|
3385
|
+
const [visible, setVisible] = useState9(false);
|
|
2324
3386
|
const { children, title } = content;
|
|
2325
3387
|
return /* @__PURE__ */ jsxs13("div", { className: getMargin(margin), children: [
|
|
2326
3388
|
/* @__PURE__ */ jsx52(Button5, { v2: true, priority: "tertiary", block: true, onClick: () => setVisible(true), children: trigger.title }),
|
|
@@ -2350,7 +3412,7 @@ var ModalRenderer = {
|
|
|
2350
3412
|
|
|
2351
3413
|
// ../renderers/src/MoneyInputRenderer.tsx
|
|
2352
3414
|
import { MoneyInput } from "@transferwise/components";
|
|
2353
|
-
import { useEffect as
|
|
3415
|
+
import { useEffect as useEffect9 } from "react";
|
|
2354
3416
|
import { useIntl as useIntl7 } from "react-intl";
|
|
2355
3417
|
import { jsx as jsx54 } from "react/jsx-runtime";
|
|
2356
3418
|
var groupingTags2 = Object.keys(group_messages_default).filter((key) => key !== "all");
|
|
@@ -2373,7 +3435,7 @@ function MoneyInputRendererComponent(props) {
|
|
|
2373
3435
|
onAmountChange,
|
|
2374
3436
|
onCurrencyChange
|
|
2375
3437
|
} = props;
|
|
2376
|
-
|
|
3438
|
+
useEffect9(() => {
|
|
2377
3439
|
if (!isValidIndex(selectedCurrencyIndex, currencies.length)) {
|
|
2378
3440
|
onCurrencyChange(0);
|
|
2379
3441
|
}
|
|
@@ -2515,7 +3577,7 @@ function InlineComponent(props) {
|
|
|
2515
3577
|
|
|
2516
3578
|
// ../renderers/src/MultiSelectInputRenderer/DefaultComponent.tsx
|
|
2517
3579
|
import { SelectInput, SelectInputOptionContent } from "@transferwise/components";
|
|
2518
|
-
import { useState as
|
|
3580
|
+
import { useState as useState10 } from "react";
|
|
2519
3581
|
import { useIntl as useIntl8 } from "react-intl";
|
|
2520
3582
|
|
|
2521
3583
|
// ../renderers/src/messages/multi-select.messages.ts
|
|
@@ -2532,7 +3594,7 @@ var multi_select_messages_default = defineMessages7({
|
|
|
2532
3594
|
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
2533
3595
|
function DefaultComponent(props) {
|
|
2534
3596
|
const { formatMessage } = useIntl8();
|
|
2535
|
-
const [stagedIndices, setStagedIndices] =
|
|
3597
|
+
const [stagedIndices, setStagedIndices] = useState10();
|
|
2536
3598
|
const {
|
|
2537
3599
|
id,
|
|
2538
3600
|
autoComplete,
|
|
@@ -2952,7 +4014,7 @@ var ProgressRenderer = {
|
|
|
2952
4014
|
var import_classnames6 = __toESM(require_classnames());
|
|
2953
4015
|
import { Button as Button7, Header as Header6, InlineAlert as InlineAlert3, Modal as Modal4, NavigationOption } from "@transferwise/components";
|
|
2954
4016
|
import { Plus } from "@transferwise/icons";
|
|
2955
|
-
import { useState as
|
|
4017
|
+
import { useState as useState11 } from "react";
|
|
2956
4018
|
import { useIntl as useIntl10 } from "react-intl";
|
|
2957
4019
|
|
|
2958
4020
|
// ../renderers/src/messages/repeatable.messages.ts
|
|
@@ -3001,7 +4063,7 @@ function Repeatable(props) {
|
|
|
3001
4063
|
onRemove
|
|
3002
4064
|
} = props;
|
|
3003
4065
|
const { formatMessage } = useIntl10();
|
|
3004
|
-
const [openModalType, setOpenModalType] =
|
|
4066
|
+
const [openModalType, setOpenModalType] = useState11(null);
|
|
3005
4067
|
const onAddItem = () => {
|
|
3006
4068
|
onAdd();
|
|
3007
4069
|
setOpenModalType("add");
|
|
@@ -3220,7 +4282,7 @@ var ReviewRenderer_default = ReviewRenderer2;
|
|
|
3220
4282
|
|
|
3221
4283
|
// ../renderers/src/SearchRenderer/BlockSearchRendererComponent.tsx
|
|
3222
4284
|
import { Input as Input5, InputGroup as InputGroup4, List, ListItem as ListItem11, Markdown as Markdown5 } from "@transferwise/components";
|
|
3223
|
-
import { useState as
|
|
4285
|
+
import { useState as useState12 } from "react";
|
|
3224
4286
|
import { useIntl as useIntl13 } from "react-intl";
|
|
3225
4287
|
|
|
3226
4288
|
// ../renderers/src/messages/search.messages.ts
|
|
@@ -3282,7 +4344,7 @@ function BlockSearchRendererComponent({
|
|
|
3282
4344
|
trackEvent,
|
|
3283
4345
|
onChange
|
|
3284
4346
|
}) {
|
|
3285
|
-
const [hasSearched, setHasSearched] =
|
|
4347
|
+
const [hasSearched, setHasSearched] = useState12(false);
|
|
3286
4348
|
const { formatMessage } = useIntl13();
|
|
3287
4349
|
return /* @__PURE__ */ jsxs20("div", { className: getMargin(margin), children: [
|
|
3288
4350
|
/* @__PURE__ */ jsx68(FieldInput_default, { id, description: "", validation: void 0, help: "", label: title, children: /* @__PURE__ */ jsx68(InputGroup4, { addonStart: { content: /* @__PURE__ */ jsx68(Search2, { size: 24 }) }, children: /* @__PURE__ */ jsx68(
|
|
@@ -3363,7 +4425,7 @@ var BlockSearchRendererComponent_default = BlockSearchRendererComponent;
|
|
|
3363
4425
|
// ../renderers/src/SearchRenderer/InlineSearchRendererComponent.tsx
|
|
3364
4426
|
import { Markdown as Markdown6, Typeahead } from "@transferwise/components";
|
|
3365
4427
|
import { Search as Search3 } from "@transferwise/icons";
|
|
3366
|
-
import { useState as
|
|
4428
|
+
import { useState as useState13 } from "react";
|
|
3367
4429
|
import { useIntl as useIntl14 } from "react-intl";
|
|
3368
4430
|
import { jsx as jsx69 } from "react/jsx-runtime";
|
|
3369
4431
|
function InlineSearchRenderer({
|
|
@@ -3376,7 +4438,7 @@ function InlineSearchRenderer({
|
|
|
3376
4438
|
title,
|
|
3377
4439
|
trackEvent
|
|
3378
4440
|
}) {
|
|
3379
|
-
const [hasSearched, setHasSearched] =
|
|
4441
|
+
const [hasSearched, setHasSearched] = useState13(false);
|
|
3380
4442
|
const intl = useIntl14();
|
|
3381
4443
|
return /* @__PURE__ */ jsx69("div", { className: getMargin(margin), children: /* @__PURE__ */ jsx69(FieldInput_default, { id, description: "", validation: void 0, help: "", label: title, children: /* @__PURE__ */ jsx69(
|
|
3382
4444
|
Typeahead,
|
|
@@ -3536,7 +4598,7 @@ function RadioInputRendererComponent(props) {
|
|
|
3536
4598
|
|
|
3537
4599
|
// ../renderers/src/SelectInputRenderer/TabInputRendererComponent.tsx
|
|
3538
4600
|
import { Tabs } from "@transferwise/components";
|
|
3539
|
-
import { useEffect as
|
|
4601
|
+
import { useEffect as useEffect10 } from "react";
|
|
3540
4602
|
import { Fragment as Fragment11, jsx as jsx73, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3541
4603
|
function TabInputRendererComponent(props) {
|
|
3542
4604
|
const {
|
|
@@ -3551,7 +4613,7 @@ function TabInputRendererComponent(props) {
|
|
|
3551
4613
|
validationState,
|
|
3552
4614
|
onSelect
|
|
3553
4615
|
} = props;
|
|
3554
|
-
|
|
4616
|
+
useEffect10(() => {
|
|
3555
4617
|
if (!isValidIndex2(selectedIndex, options.length)) {
|
|
3556
4618
|
onSelect(0);
|
|
3557
4619
|
}
|
|
@@ -3664,7 +4726,7 @@ function SelectInputRendererComponent(props) {
|
|
|
3664
4726
|
}
|
|
3665
4727
|
|
|
3666
4728
|
// ../renderers/src/SelectInputRenderer/SegmentedInputRendererComponent.tsx
|
|
3667
|
-
import { useEffect as
|
|
4729
|
+
import { useEffect as useEffect11 } from "react";
|
|
3668
4730
|
import { SegmentedControl } from "@transferwise/components";
|
|
3669
4731
|
import { Fragment as Fragment13, jsx as jsx75, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
3670
4732
|
function SegmentedInputRendererComponent(props) {
|
|
@@ -3679,7 +4741,7 @@ function SegmentedInputRendererComponent(props) {
|
|
|
3679
4741
|
validationState,
|
|
3680
4742
|
onSelect
|
|
3681
4743
|
} = props;
|
|
3682
|
-
|
|
4744
|
+
useEffect11(() => {
|
|
3683
4745
|
if (!isValidIndex3(selectedIndex, options.length)) {
|
|
3684
4746
|
onSelect(0);
|
|
3685
4747
|
}
|
|
@@ -3835,12 +4897,12 @@ var StatusListRenderer_default = StatusListRenderer;
|
|
|
3835
4897
|
|
|
3836
4898
|
// ../renderers/src/utils/useCustomTheme.ts
|
|
3837
4899
|
import { useTheme } from "@wise/components-theming";
|
|
3838
|
-
import { useEffect as
|
|
4900
|
+
import { useEffect as useEffect12, useMemo as useMemo2 } from "react";
|
|
3839
4901
|
var ThemeRequiredEventName = "Theme Required";
|
|
3840
4902
|
var useCustomTheme = (theme, trackEvent) => {
|
|
3841
4903
|
const theming = useTheme();
|
|
3842
|
-
const previousTheme =
|
|
3843
|
-
|
|
4904
|
+
const previousTheme = useMemo2(() => theming.theme, []);
|
|
4905
|
+
useEffect12(() => {
|
|
3844
4906
|
theming.setTheme(theme);
|
|
3845
4907
|
trackEvent(ThemeRequiredEventName, { theme });
|
|
3846
4908
|
return theme !== previousTheme ? () => {
|
|
@@ -4021,7 +5083,7 @@ function StepRendererComponent(props) {
|
|
|
4021
5083
|
|
|
4022
5084
|
// ../renderers/src/TabsRenderer.tsx
|
|
4023
5085
|
import { Chips as Chips2, SegmentedControl as SegmentedControl2, Tabs as Tabs2 } from "@transferwise/components";
|
|
4024
|
-
import { useState as
|
|
5086
|
+
import { useState as useState14 } from "react";
|
|
4025
5087
|
import { jsx as jsx86, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
4026
5088
|
var TabsRenderer = {
|
|
4027
5089
|
canRenderType: "tabs",
|
|
@@ -4040,7 +5102,7 @@ var TabsRenderer = {
|
|
|
4040
5102
|
}
|
|
4041
5103
|
};
|
|
4042
5104
|
function TabsRendererComponent({ uid, margin, tabs }) {
|
|
4043
|
-
const [selectedIndex, setSelectedIndex] =
|
|
5105
|
+
const [selectedIndex, setSelectedIndex] = useState14(0);
|
|
4044
5106
|
return /* @__PURE__ */ jsx86("div", { className: getMargin(margin), children: /* @__PURE__ */ jsx86(
|
|
4045
5107
|
Tabs2,
|
|
4046
5108
|
{
|
|
@@ -4061,7 +5123,7 @@ function TabsRendererComponent({ uid, margin, tabs }) {
|
|
|
4061
5123
|
}
|
|
4062
5124
|
function SegmentedTabsRendererComponent({ uid, margin, tabs }) {
|
|
4063
5125
|
var _a;
|
|
4064
|
-
const [selectedIndex, setSelectedIndex] =
|
|
5126
|
+
const [selectedIndex, setSelectedIndex] = useState14(0);
|
|
4065
5127
|
return /* @__PURE__ */ jsxs35("div", { className: getMargin(margin), children: [
|
|
4066
5128
|
/* @__PURE__ */ jsx86(
|
|
4067
5129
|
SegmentedControl2,
|
|
@@ -4083,7 +5145,7 @@ function SegmentedTabsRendererComponent({ uid, margin, tabs }) {
|
|
|
4083
5145
|
}
|
|
4084
5146
|
function ChipsTabsRendererComponent({ margin, tabs }) {
|
|
4085
5147
|
var _a;
|
|
4086
|
-
const [selectedIndex, setSelectedIndex] =
|
|
5148
|
+
const [selectedIndex, setSelectedIndex] = useState14(0);
|
|
4087
5149
|
return /* @__PURE__ */ jsxs35("div", { className: getMargin(margin), children: [
|
|
4088
5150
|
/* @__PURE__ */ jsx86("div", { className: "chips-container", children: /* @__PURE__ */ jsx86(
|
|
4089
5151
|
Chips2,
|
|
@@ -4326,7 +5388,7 @@ var LargeUploadRenderer = {
|
|
|
4326
5388
|
|
|
4327
5389
|
// ../renderers/src/UpsellRenderer.tsx
|
|
4328
5390
|
import { Nudge } from "@transferwise/components";
|
|
4329
|
-
import { useState as
|
|
5391
|
+
import { useState as useState15 } from "react";
|
|
4330
5392
|
import { jsx as jsx90 } from "react/jsx-runtime";
|
|
4331
5393
|
var UpsellRenderer = {
|
|
4332
5394
|
canRenderType: "upsell",
|
|
@@ -4334,7 +5396,7 @@ var UpsellRenderer = {
|
|
|
4334
5396
|
};
|
|
4335
5397
|
function UpsellRendererComponent(props) {
|
|
4336
5398
|
const { text, callToAction, media, margin, onDismiss } = props;
|
|
4337
|
-
const [isVisible, setIsVisible] =
|
|
5399
|
+
const [isVisible, setIsVisible] = useState15(true);
|
|
4338
5400
|
return isVisible ? /* @__PURE__ */ jsx90(
|
|
4339
5401
|
Nudge,
|
|
4340
5402
|
{
|
|
@@ -4624,9 +5686,9 @@ var useWiseToCoreProps = (props) => {
|
|
|
4624
5686
|
onLog
|
|
4625
5687
|
} = props;
|
|
4626
5688
|
const httpClient = useWiseHttpClient(customFetch);
|
|
4627
|
-
const mergedRenderers =
|
|
4628
|
-
const logEvent =
|
|
4629
|
-
const trackEvent =
|
|
5689
|
+
const mergedRenderers = useMemo3(() => getMergedRenderers(props), [renderers]);
|
|
5690
|
+
const logEvent = useMemo3(() => getLogEvent(onLog), [onLog]);
|
|
5691
|
+
const trackEvent = useMemo3(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
|
|
4630
5692
|
const onCopy = useOnCopy();
|
|
4631
5693
|
return __spreadProps(__spreadValues({}, props), {
|
|
4632
5694
|
httpClient,
|