@infinite-table/infinite-react 7.4.0 → 7.4.2

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/index.dev.mjs CHANGED
@@ -1055,6 +1055,7 @@ var onLogIntentGlobal = (intentChannel, fn) => {
1055
1055
  });
1056
1056
  };
1057
1057
  debug.onLogIntent = onLogIntentGlobal;
1058
+ debug.isChannelEnabled = isChannelEnabled;
1058
1059
  debug.destroyAll = () => {
1059
1060
  initUsedColors();
1060
1061
  initUsedColors(debug.colors);
@@ -1327,6 +1328,13 @@ var toUpperFirst = (s) => {
1327
1328
  return s ? s.substr(0, 1).toUpperCase() + s.substr(1) : s;
1328
1329
  };
1329
1330
 
1331
+ // src/components/InfiniteTable/types/Utility.ts
1332
+ function notNullable(value) {
1333
+ if (value === null || value === void 0) return false;
1334
+ const testDummyForCompileError = value;
1335
+ return true;
1336
+ }
1337
+
1330
1338
  // src/components/utils/isControlledValue.ts
1331
1339
  function isControlledValue(value) {
1332
1340
  const controlled = value !== void 0;
@@ -1400,6 +1408,164 @@ var usePrevious = (value, initialValue) => {
1400
1408
  return ref.current;
1401
1409
  };
1402
1410
 
1411
+ // src/utils/devTools/devToolsTracks.ts
1412
+ var DevToolsTracks = {
1413
+ DataSource: {
1414
+ track: "DataSource",
1415
+ labels: {
1416
+ RemoteDataLoad: "Remote data load",
1417
+ TreeUnfilteredTreePaths: "Computing unfiltered tree paths",
1418
+ Filter: "Filter",
1419
+ Sort: "Sort",
1420
+ Group: "Group",
1421
+ LazyGroup: "Lazy group",
1422
+ Tree: "Tree",
1423
+ FlattenTree: "Flatten tree",
1424
+ Flatten: "Flatten groups",
1425
+ PrepareData: "Preparing data",
1426
+ ComputeSelectionCount: "Computing selection count",
1427
+ ComputeSelectionCountLazy: "Computing selection count (lazy)",
1428
+ PrepareRowInfo: "Preparing row info array"
1429
+ }
1430
+ },
1431
+ InfiniteTable: {
1432
+ track: "InfiniteTable",
1433
+ labels: {
1434
+ Render: "Rendering"
1435
+ }
1436
+ },
1437
+ MatrixBrain: {
1438
+ track: "Layout Computations",
1439
+ labels: {
1440
+ ComputeRenderRange: "Computing render range"
1441
+ }
1442
+ },
1443
+ ComponentState: {
1444
+ track: "ComponentState",
1445
+ labels: {
1446
+ PropUpdate: "Prop update"
1447
+ }
1448
+ }
1449
+ };
1450
+
1451
+ // src/utils/devTools/index.ts
1452
+ var DevToolsMarker = class _DevToolsMarker {
1453
+ constructor(debugId) {
1454
+ this.debugId = debugId;
1455
+ this.markerDetails = {
1456
+ label: "",
1457
+ track: "",
1458
+ trackGroup: void 0,
1459
+ color: void 0,
1460
+ details: [],
1461
+ tooltip: void 0
1462
+ };
1463
+ this.stopped = false;
1464
+ this.start = (startDetails) => {
1465
+ if (this.markerDetails.startTs) {
1466
+ return this;
1467
+ }
1468
+ const start = performance.now();
1469
+ this.markerDetails.details = startDetails?.details ?? [];
1470
+ this.markerDetails.startTs = start;
1471
+ return this;
1472
+ };
1473
+ this.end = (markerDetails = {}) => {
1474
+ if (this.stopped) {
1475
+ return this;
1476
+ }
1477
+ this.stopped = true;
1478
+ const start = markerDetails.startTs ?? this.markerDetails.startTs;
1479
+ const end = markerDetails.endTs ?? this.markerDetails.endTs ?? performance.now();
1480
+ const color = markerDetails.color || this.markerDetails.color || "primary";
1481
+ const trackGroup = markerDetails.trackGroup || this.markerDetails.trackGroup || `Infinite Table (${this.debugId})`;
1482
+ const details = [
1483
+ ...this.markerDetails.details || [],
1484
+ ...markerDetails.details || []
1485
+ ];
1486
+ const tooltip = markerDetails.tooltip || this.markerDetails.tooltip;
1487
+ const label = markerDetails.label || this.markerDetails.label || "Unknown";
1488
+ const track = markerDetails.track || this.markerDetails.track || "Unknown";
1489
+ performance.measure(label, {
1490
+ start,
1491
+ end,
1492
+ detail: {
1493
+ devtools: {
1494
+ dataType: "track-entry",
1495
+ trackGroup,
1496
+ track,
1497
+ color,
1498
+ properties: details.length > 0 ? details.map((detail) => [detail.name, detail.value]) : void 0,
1499
+ tooltipText: tooltip
1500
+ }
1501
+ }
1502
+ });
1503
+ return this;
1504
+ };
1505
+ this.debugId = debugId;
1506
+ }
1507
+ static create(debugId) {
1508
+ return new _DevToolsMarker(debugId);
1509
+ }
1510
+ get startTimestamp() {
1511
+ return this.markerDetails.startTs;
1512
+ }
1513
+ get track() {
1514
+ const self = this;
1515
+ return Object.keys(DevToolsTracks).reduce(
1516
+ (acc, track) => {
1517
+ const trackObj = {
1518
+ start: self.start,
1519
+ end: (markerDetails) => {
1520
+ return self.end({
1521
+ ...markerDetails,
1522
+ track: DevToolsTracks[track].track,
1523
+ label: markerDetails.label
1524
+ });
1525
+ },
1526
+ get label() {
1527
+ const currentTrack = DevToolsTracks[track];
1528
+ return Object.keys(currentTrack.labels).reduce(
1529
+ (labelAcc, label) => {
1530
+ const labelObj = {
1531
+ start: self.start,
1532
+ end: (markerDetails) => {
1533
+ return self.end({
1534
+ ...markerDetails,
1535
+ track: currentTrack.track,
1536
+ label: currentTrack.labels[label]
1537
+ });
1538
+ }
1539
+ };
1540
+ Object.defineProperty(labelAcc, label, {
1541
+ get: () => {
1542
+ self.markerDetails.label = currentTrack.labels[label];
1543
+ return labelObj;
1544
+ }
1545
+ });
1546
+ return labelAcc;
1547
+ },
1548
+ {}
1549
+ );
1550
+ }
1551
+ };
1552
+ Object.defineProperty(acc, track, {
1553
+ get: () => {
1554
+ const currentTrack = DevToolsTracks[track];
1555
+ self.markerDetails.track = currentTrack.track;
1556
+ return trackObj;
1557
+ }
1558
+ });
1559
+ return acc;
1560
+ },
1561
+ {}
1562
+ );
1563
+ }
1564
+ };
1565
+ function getMarker(debugId) {
1566
+ return DevToolsMarker.create(debugId);
1567
+ }
1568
+
1403
1569
  // src/components/hooks/useComponentState/index.tsx
1404
1570
  var notifyChange = (props, callbackPropName, values) => {
1405
1571
  const callbackProp = props[callbackPropName];
@@ -1656,9 +1822,10 @@ function buildManagedComponent(config) {
1656
1822
  }
1657
1823
  });
1658
1824
  if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
1659
- const logger2 = config.debugName ? dbg(
1660
- typeof config.debugName === "function" ? `${config.debugName(currentProps)}:rerender` : `${config.debugName}:rerender`
1661
- ) : dbg("rerender");
1825
+ const debugId = state.debugId;
1826
+ const marker = debugId ? getMarker(debugId).track.ComponentState.label.PropUpdate.start() : void 0;
1827
+ const debugChannelName = config.debugName ? typeof config.debugName === "function" ? `${config.debugName(currentProps)}:rerender` : `${config.debugName}:rerender` : "rerender";
1828
+ const logger2 = dbg(debugChannelName);
1662
1829
  logger2(
1663
1830
  "Triggered by new values for the following props",
1664
1831
  ...[
@@ -1666,6 +1833,25 @@ function buildManagedComponent(config) {
1666
1833
  ...Object.keys(updatedPropsToState ?? {})
1667
1834
  ]
1668
1835
  );
1836
+ if (marker) {
1837
+ marker.end({
1838
+ label: debugChannelName,
1839
+ details: [
1840
+ newMappedStateCount > 0 ? {
1841
+ name: "Updated properties",
1842
+ value: Object.keys(newMappedState).join(", ")
1843
+ } : void 0,
1844
+ updatedPropsToStateCount > 0 ? {
1845
+ name: "Updated props",
1846
+ value: Object.keys(updatedPropsToState).join(", ")
1847
+ } : void 0,
1848
+ updatedPropsToStateCount > 0 || updatedPropsToState ? {
1849
+ name: "Details",
1850
+ value: "The time for this marker is not accurate. The marker is only displayed so you can easily identify the props that triggered the rerender."
1851
+ } : void 0
1852
+ ].filter(notNullable)
1853
+ });
1854
+ }
1669
1855
  const action = {
1670
1856
  payload: {
1671
1857
  mappedState: newMappedStateCount ? newMappedState : null,
@@ -8449,28 +8635,39 @@ import { useLayoutEffect as useLayoutEffect8, useMemo as useMemo6 } from "react"
8449
8635
  import * as React39 from "react";
8450
8636
  import { flushSync } from "react-dom";
8451
8637
  import { useLayoutEffect as useLayoutEffect7, useRef as useRef14, useState as useState12 } from "react";
8638
+ var SHOULD_FLUSH_SYNC = () => false;
8452
8639
  function AvoidReactDiffFn(props) {
8453
8640
  const [children, setChildren] = useState12(props.updater.get);
8454
8641
  const rafId = useRef14(null);
8642
+ const shouldFlushSync = props.shouldFlushSync ?? SHOULD_FLUSH_SYNC;
8455
8643
  useLayoutEffect7(() => {
8456
8644
  function onChange(children2) {
8645
+ let FLUSH_SYNC = shouldFlushSync();
8457
8646
  if (props.useraf) {
8458
8647
  if (rafId.current != null) {
8459
8648
  cancelAnimationFrame(rafId.current);
8460
8649
  }
8461
8650
  rafId.current = requestAnimationFrame(() => {
8651
+ if (FLUSH_SYNC) {
8652
+ queueMicrotask(() => {
8653
+ flushSync(() => {
8654
+ setChildren(children2);
8655
+ });
8656
+ });
8657
+ } else {
8658
+ setChildren(children2);
8659
+ }
8660
+ });
8661
+ } else {
8662
+ if (FLUSH_SYNC) {
8462
8663
  queueMicrotask(() => {
8463
8664
  flushSync(() => {
8464
8665
  setChildren(children2);
8465
8666
  });
8466
8667
  });
8467
- });
8468
- } else {
8469
- queueMicrotask(() => {
8470
- flushSync(() => {
8471
- setChildren(children2);
8472
- });
8473
- });
8668
+ } else {
8669
+ setChildren(children2);
8670
+ }
8474
8671
  }
8475
8672
  }
8476
8673
  const remove = props.updater.onChange(onChange);
@@ -8480,7 +8677,7 @@ function AvoidReactDiffFn(props) {
8480
8677
  }
8481
8678
  remove();
8482
8679
  };
8483
- }, [props.updater, props.useraf]);
8680
+ }, [props.updater, props.useraf, shouldFlushSync]);
8484
8681
  return children ?? null;
8485
8682
  }
8486
8683
  var AvoidReactDiff = React39.memo(AvoidReactDiffFn);
@@ -9809,14 +10006,26 @@ var GridCellForReact = class {
9809
10006
  constructor(debugId, cellInfo) {
9810
10007
  this.element = null;
9811
10008
  this.mounted = false;
10009
+ this.IS_UPDATED_WHILE_SCROLLING = false;
9812
10010
  this.mountSubscription = buildSubscriptionCallback();
10011
+ this.isUpdatedWhileScrolling = () => {
10012
+ return this.IS_UPDATED_WHILE_SCROLLING;
10013
+ };
9813
10014
  const count = CELL_COUNT_BY_DEBUG_ID.get(debugId) ?? 0;
9814
10015
  const key = `${debugId}:GridCellReact:${count}`;
9815
10016
  CELL_COUNT_BY_DEBUG_ID.set(debugId, count + 1);
9816
10017
  this.debugId = key;
9817
10018
  this.cellInfo = cellInfo;
9818
10019
  this.updater = buildSubscriptionCallback();
9819
- this.node = /* @__PURE__ */ React40.createElement(AvoidReactDiff, { key, name: key, updater: this.updater });
10020
+ this.node = /* @__PURE__ */ React40.createElement(
10021
+ AvoidReactDiff,
10022
+ {
10023
+ key,
10024
+ name: key,
10025
+ updater: this.updater,
10026
+ shouldFlushSync: this.isUpdatedWhileScrolling
10027
+ }
10028
+ );
9820
10029
  this.ref = (htmlElement) => {
9821
10030
  this.element = htmlElement;
9822
10031
  if (htmlElement) {
@@ -9848,7 +10057,8 @@ var GridCellForReact = class {
9848
10057
  getNode() {
9849
10058
  return this.node;
9850
10059
  }
9851
- update(content, additionalInfo) {
10060
+ update(content, additionalInfo, scrollingObjectParam) {
10061
+ this.IS_UPDATED_WHILE_SCROLLING = scrollingObjectParam ? scrollingObjectParam.scrolling : false;
9852
10062
  this.updater(content);
9853
10063
  this.cellInfo = additionalInfo;
9854
10064
  }
@@ -10140,14 +10350,14 @@ var GridCellManager = class extends Logger {
10140
10350
  }
10141
10351
  this.addCellToMatrix(cell, cellPos);
10142
10352
  }
10143
- renderNodeAtCell(node, cell, cellPos, additionalInfo) {
10353
+ renderNodeAtCell(node, cell, cellPos, additionalInfo, scrollingObjectParam) {
10144
10354
  const currentCellAtPos = this.getCellAt(cellPos);
10145
10355
  if (currentCellAtPos && currentCellAtPos !== cell) {
10146
10356
  this.detachCellAt(cellPos);
10147
10357
  }
10148
10358
  this.pool.attachCell(cell);
10149
10359
  this.setCellPositionInMatrix(cell, cellPos);
10150
- cell.update(node, additionalInfo);
10360
+ cell.update(node, additionalInfo, scrollingObjectParam);
10151
10361
  return cell;
10152
10362
  }
10153
10363
  getCellPosition(cell) {
@@ -10730,6 +10940,9 @@ var columnOffsetAtIndex2 = stripVar(InternalVars.columnOffsetAtIndex);
10730
10940
  var columnOffsetAtIndexWhileReordering2 = stripVar(
10731
10941
  InternalVars.columnOffsetAtIndexWhileReordering
10732
10942
  );
10943
+ var SCROLLING_OBJECT_PARAM_FLYWEIGHT = {
10944
+ scrolling: false
10945
+ };
10733
10946
  var GridRenderer = class extends Logger {
10734
10947
  constructor(brain, debugId) {
10735
10948
  debugId = debugId || "ReactHeadlessTableRenderer";
@@ -11884,11 +12097,13 @@ var GridRenderer = class extends Logger {
11884
12097
  }
11885
12098
  return;
11886
12099
  }
12100
+ SCROLLING_OBJECT_PARAM_FLYWEIGHT.scrolling = this.scrolling;
11887
12101
  this.cellManager.renderNodeAtCell(
11888
12102
  renderedNode,
11889
12103
  cell,
11890
12104
  [rowIndex, colIndex],
11891
- cellAdditionalInfo
12105
+ cellAdditionalInfo,
12106
+ SCROLLING_OBJECT_PARAM_FLYWEIGHT
11892
12107
  );
11893
12108
  this.updateElementPosition(cell, { hidden, rowspan, colspan });
11894
12109
  return;
@@ -18771,163 +18986,6 @@ function finishRowInfoReducersFor(params) {
18771
18986
  return results;
18772
18987
  }
18773
18988
 
18774
- // src/utils/devTools/index.ts
18775
- var DevToolsMarker = class _DevToolsMarker {
18776
- constructor(debugId) {
18777
- this.debugId = debugId;
18778
- this.markerDetails = {
18779
- label: "",
18780
- track: "",
18781
- trackGroup: void 0,
18782
- color: void 0,
18783
- details: [],
18784
- tooltip: void 0
18785
- };
18786
- this.stopped = false;
18787
- this.start = (startDetails) => {
18788
- if (this.markerDetails.startTs) {
18789
- return this;
18790
- }
18791
- const start = performance.now();
18792
- this.markerDetails.details = startDetails?.details ?? [];
18793
- this.markerDetails.startTs = start;
18794
- return this;
18795
- };
18796
- this.end = (markerDetails = {}) => {
18797
- if (this.stopped) {
18798
- return this;
18799
- }
18800
- this.stopped = true;
18801
- const start = markerDetails.startTs ?? this.markerDetails.startTs;
18802
- const end = markerDetails.endTs ?? this.markerDetails.endTs ?? performance.now();
18803
- const color = markerDetails.color || this.markerDetails.color || "primary";
18804
- const trackGroup = markerDetails.trackGroup || this.markerDetails.trackGroup || `Infinite Table (${this.debugId})`;
18805
- const details = [
18806
- ...this.markerDetails.details || [],
18807
- ...markerDetails.details || []
18808
- ];
18809
- const tooltip = markerDetails.tooltip || this.markerDetails.tooltip;
18810
- const label = markerDetails.label || this.markerDetails.label || "Unknown";
18811
- const track = markerDetails.track || this.markerDetails.track || "Unknown";
18812
- performance.measure(label, {
18813
- start,
18814
- end,
18815
- detail: {
18816
- devtools: {
18817
- dataType: "track-entry",
18818
- trackGroup,
18819
- track,
18820
- color,
18821
- properties: details.length > 0 ? details.map((detail) => [detail.name, detail.value]) : void 0,
18822
- tooltipText: tooltip
18823
- }
18824
- }
18825
- });
18826
- return this;
18827
- };
18828
- this.debugId = debugId;
18829
- }
18830
- static create(debugId) {
18831
- return new _DevToolsMarker(debugId);
18832
- }
18833
- get startTimestamp() {
18834
- return this.markerDetails.startTs;
18835
- }
18836
- get track() {
18837
- const self = this;
18838
- return Object.keys(DevToolsTracks).reduce(
18839
- (acc, track) => {
18840
- const trackObj = {
18841
- start: self.start,
18842
- end: (markerDetails) => {
18843
- return self.end({
18844
- ...markerDetails,
18845
- track: DevToolsTracks[track].track,
18846
- label: markerDetails.label
18847
- });
18848
- },
18849
- get label() {
18850
- const currentTrack = DevToolsTracks[track];
18851
- return Object.keys(currentTrack.labels).reduce(
18852
- (labelAcc, label) => {
18853
- const labelObj = {
18854
- start: self.start,
18855
- end: (markerDetails) => {
18856
- return self.end({
18857
- ...markerDetails,
18858
- track: currentTrack.track,
18859
- label: currentTrack.labels[label]
18860
- });
18861
- }
18862
- };
18863
- Object.defineProperty(labelAcc, label, {
18864
- get: () => {
18865
- self.markerDetails.label = currentTrack.labels[label];
18866
- return labelObj;
18867
- }
18868
- });
18869
- return labelAcc;
18870
- },
18871
- {}
18872
- );
18873
- }
18874
- };
18875
- Object.defineProperty(acc, track, {
18876
- get: () => {
18877
- const currentTrack = DevToolsTracks[track];
18878
- self.markerDetails.track = currentTrack.track;
18879
- return trackObj;
18880
- }
18881
- });
18882
- return acc;
18883
- },
18884
- {}
18885
- );
18886
- }
18887
- };
18888
- var DevToolsTracks = {
18889
- DataSource: {
18890
- track: "DataSource",
18891
- labels: {
18892
- RemoteDataLoad: "Remote data load",
18893
- TreeUnfilteredTreePaths: "Computing unfiltered tree paths",
18894
- Filter: "Filter",
18895
- Sort: "Sort",
18896
- Group: "Group",
18897
- LazyGroup: "Lazy group",
18898
- Tree: "Tree",
18899
- FlattenTree: "Flatten tree",
18900
- Flatten: "Flatten groups",
18901
- PrepareData: "Preparing data",
18902
- ComputeSelectionCount: "Computing selection count",
18903
- ComputeSelectionCountLazy: "Computing selection count (lazy)",
18904
- PrepareRowInfo: "Preparing row info array"
18905
- }
18906
- },
18907
- InfiniteTable: {
18908
- track: "InfiniteTable",
18909
- labels: {
18910
- Render: "Rendering"
18911
- }
18912
- },
18913
- MatrixBrain: {
18914
- track: "Layout Computations",
18915
- labels: {
18916
- ComputeRenderRange: "Computing render range"
18917
- }
18918
- }
18919
- };
18920
- function getMarker(debugId) {
18921
- return DevToolsMarker.create(debugId);
18922
- }
18923
-
18924
- // src/components/InfiniteTable/types/Utility.ts
18925
- function notNullable(value) {
18926
- if (value === null || value === void 0) return false;
18927
- const testDummyForCompileError = value;
18928
- return true;
18929
- }
18930
-
18931
18989
  // src/components/DataSource/state/reducer.ts
18932
18990
  function cleanupEmptyFilterValues(filterValue, filterTypes) {
18933
18991
  if (!filterValue) {
@@ -22389,6 +22447,9 @@ function isSortInfoForColumn(sortInfo, col) {
22389
22447
  }
22390
22448
  var InfiniteTableApiImpl = class {
22391
22449
  constructor(context) {
22450
+ this.getVisibleRenderRange = () => {
22451
+ return this.getState().brain.getRenderRange();
22452
+ };
22392
22453
  this.hideFilterOperatorMenu = () => {
22393
22454
  this.actions.filterOperatorMenuVisibleForColumnId = null;
22394
22455
  };
@@ -25634,7 +25695,7 @@ var useLicense = (licenseKey = "") => {
25634
25695
  }
25635
25696
  let valid2 = isValidLicense(licenseKey, {
25636
25697
  publishedAt: 1624970570587,
25637
- version: "7.4.0"
25698
+ version: "7.4.2"
25638
25699
  });
25639
25700
  if (!licenseKey && !valid2 && isInsidePlayground) {
25640
25701
  return true;