@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.js CHANGED
@@ -1129,6 +1129,7 @@ var onLogIntentGlobal = (intentChannel, fn) => {
1129
1129
  });
1130
1130
  };
1131
1131
  debug.onLogIntent = onLogIntentGlobal;
1132
+ debug.isChannelEnabled = isChannelEnabled;
1132
1133
  debug.destroyAll = () => {
1133
1134
  initUsedColors();
1134
1135
  initUsedColors(debug.colors);
@@ -1387,6 +1388,13 @@ var toUpperFirst = (s) => {
1387
1388
  return s ? s.substr(0, 1).toUpperCase() + s.substr(1) : s;
1388
1389
  };
1389
1390
 
1391
+ // src/components/InfiniteTable/types/Utility.ts
1392
+ function notNullable(value) {
1393
+ if (value === null || value === void 0) return false;
1394
+ const testDummyForCompileError = value;
1395
+ return true;
1396
+ }
1397
+
1390
1398
  // src/components/utils/isControlledValue.ts
1391
1399
  function isControlledValue(value) {
1392
1400
  const controlled = value !== void 0;
@@ -1460,6 +1468,164 @@ var usePrevious = (value, initialValue) => {
1460
1468
  return ref.current;
1461
1469
  };
1462
1470
 
1471
+ // src/utils/devTools/devToolsTracks.ts
1472
+ var DevToolsTracks = {
1473
+ DataSource: {
1474
+ track: "DataSource",
1475
+ labels: {
1476
+ RemoteDataLoad: "Remote data load",
1477
+ TreeUnfilteredTreePaths: "Computing unfiltered tree paths",
1478
+ Filter: "Filter",
1479
+ Sort: "Sort",
1480
+ Group: "Group",
1481
+ LazyGroup: "Lazy group",
1482
+ Tree: "Tree",
1483
+ FlattenTree: "Flatten tree",
1484
+ Flatten: "Flatten groups",
1485
+ PrepareData: "Preparing data",
1486
+ ComputeSelectionCount: "Computing selection count",
1487
+ ComputeSelectionCountLazy: "Computing selection count (lazy)",
1488
+ PrepareRowInfo: "Preparing row info array"
1489
+ }
1490
+ },
1491
+ InfiniteTable: {
1492
+ track: "InfiniteTable",
1493
+ labels: {
1494
+ Render: "Rendering"
1495
+ }
1496
+ },
1497
+ MatrixBrain: {
1498
+ track: "Layout Computations",
1499
+ labels: {
1500
+ ComputeRenderRange: "Computing render range"
1501
+ }
1502
+ },
1503
+ ComponentState: {
1504
+ track: "ComponentState",
1505
+ labels: {
1506
+ PropUpdate: "Prop update"
1507
+ }
1508
+ }
1509
+ };
1510
+
1511
+ // src/utils/devTools/index.ts
1512
+ var DevToolsMarker = class _DevToolsMarker {
1513
+ constructor(debugId) {
1514
+ this.debugId = debugId;
1515
+ this.markerDetails = {
1516
+ label: "",
1517
+ track: "",
1518
+ trackGroup: void 0,
1519
+ color: void 0,
1520
+ details: [],
1521
+ tooltip: void 0
1522
+ };
1523
+ this.stopped = false;
1524
+ this.start = (startDetails) => {
1525
+ if (this.markerDetails.startTs) {
1526
+ return this;
1527
+ }
1528
+ const start = performance.now();
1529
+ this.markerDetails.details = startDetails?.details ?? [];
1530
+ this.markerDetails.startTs = start;
1531
+ return this;
1532
+ };
1533
+ this.end = (markerDetails = {}) => {
1534
+ if (this.stopped) {
1535
+ return this;
1536
+ }
1537
+ this.stopped = true;
1538
+ const start = markerDetails.startTs ?? this.markerDetails.startTs;
1539
+ const end = markerDetails.endTs ?? this.markerDetails.endTs ?? performance.now();
1540
+ const color = markerDetails.color || this.markerDetails.color || "primary";
1541
+ const trackGroup = markerDetails.trackGroup || this.markerDetails.trackGroup || `Infinite Table (${this.debugId})`;
1542
+ const details = [
1543
+ ...this.markerDetails.details || [],
1544
+ ...markerDetails.details || []
1545
+ ];
1546
+ const tooltip = markerDetails.tooltip || this.markerDetails.tooltip;
1547
+ const label = markerDetails.label || this.markerDetails.label || "Unknown";
1548
+ const track = markerDetails.track || this.markerDetails.track || "Unknown";
1549
+ performance.measure(label, {
1550
+ start,
1551
+ end,
1552
+ detail: {
1553
+ devtools: {
1554
+ dataType: "track-entry",
1555
+ trackGroup,
1556
+ track,
1557
+ color,
1558
+ properties: details.length > 0 ? details.map((detail) => [detail.name, detail.value]) : void 0,
1559
+ tooltipText: tooltip
1560
+ }
1561
+ }
1562
+ });
1563
+ return this;
1564
+ };
1565
+ this.debugId = debugId;
1566
+ }
1567
+ static create(debugId) {
1568
+ return new _DevToolsMarker(debugId);
1569
+ }
1570
+ get startTimestamp() {
1571
+ return this.markerDetails.startTs;
1572
+ }
1573
+ get track() {
1574
+ const self = this;
1575
+ return Object.keys(DevToolsTracks).reduce(
1576
+ (acc, track) => {
1577
+ const trackObj = {
1578
+ start: self.start,
1579
+ end: (markerDetails) => {
1580
+ return self.end({
1581
+ ...markerDetails,
1582
+ track: DevToolsTracks[track].track,
1583
+ label: markerDetails.label
1584
+ });
1585
+ },
1586
+ get label() {
1587
+ const currentTrack = DevToolsTracks[track];
1588
+ return Object.keys(currentTrack.labels).reduce(
1589
+ (labelAcc, label) => {
1590
+ const labelObj = {
1591
+ start: self.start,
1592
+ end: (markerDetails) => {
1593
+ return self.end({
1594
+ ...markerDetails,
1595
+ track: currentTrack.track,
1596
+ label: currentTrack.labels[label]
1597
+ });
1598
+ }
1599
+ };
1600
+ Object.defineProperty(labelAcc, label, {
1601
+ get: () => {
1602
+ self.markerDetails.label = currentTrack.labels[label];
1603
+ return labelObj;
1604
+ }
1605
+ });
1606
+ return labelAcc;
1607
+ },
1608
+ {}
1609
+ );
1610
+ }
1611
+ };
1612
+ Object.defineProperty(acc, track, {
1613
+ get: () => {
1614
+ const currentTrack = DevToolsTracks[track];
1615
+ self.markerDetails.track = currentTrack.track;
1616
+ return trackObj;
1617
+ }
1618
+ });
1619
+ return acc;
1620
+ },
1621
+ {}
1622
+ );
1623
+ }
1624
+ };
1625
+ function getMarker(debugId) {
1626
+ return DevToolsMarker.create(debugId);
1627
+ }
1628
+
1463
1629
  // src/components/hooks/useComponentState/index.tsx
1464
1630
  var notifyChange = (props, callbackPropName, values) => {
1465
1631
  const callbackProp = props[callbackPropName];
@@ -1716,9 +1882,10 @@ function buildManagedComponent(config) {
1716
1882
  }
1717
1883
  });
1718
1884
  if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
1719
- const logger2 = config.debugName ? dbg(
1720
- typeof config.debugName === "function" ? `${config.debugName(currentProps)}:rerender` : `${config.debugName}:rerender`
1721
- ) : dbg("rerender");
1885
+ const debugId = state.debugId;
1886
+ const marker = debugId ? getMarker(debugId).track.ComponentState.label.PropUpdate.start() : void 0;
1887
+ const debugChannelName = config.debugName ? typeof config.debugName === "function" ? `${config.debugName(currentProps)}:rerender` : `${config.debugName}:rerender` : "rerender";
1888
+ const logger2 = dbg(debugChannelName);
1722
1889
  logger2(
1723
1890
  "Triggered by new values for the following props",
1724
1891
  ...[
@@ -1726,6 +1893,25 @@ function buildManagedComponent(config) {
1726
1893
  ...Object.keys(updatedPropsToState ?? {})
1727
1894
  ]
1728
1895
  );
1896
+ if (marker) {
1897
+ marker.end({
1898
+ label: debugChannelName,
1899
+ details: [
1900
+ newMappedStateCount > 0 ? {
1901
+ name: "Updated properties",
1902
+ value: Object.keys(newMappedState).join(", ")
1903
+ } : void 0,
1904
+ updatedPropsToStateCount > 0 ? {
1905
+ name: "Updated props",
1906
+ value: Object.keys(updatedPropsToState).join(", ")
1907
+ } : void 0,
1908
+ updatedPropsToStateCount > 0 || updatedPropsToState ? {
1909
+ name: "Details",
1910
+ 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."
1911
+ } : void 0
1912
+ ].filter(notNullable)
1913
+ });
1914
+ }
1729
1915
  const action = {
1730
1916
  payload: {
1731
1917
  mappedState: newMappedStateCount ? newMappedState : null,
@@ -8509,28 +8695,39 @@ var import_react27 = require("react");
8509
8695
  var React39 = __toESM(require("react"));
8510
8696
  var import_react_dom = require("react-dom");
8511
8697
  var import_react26 = require("react");
8698
+ var SHOULD_FLUSH_SYNC = () => false;
8512
8699
  function AvoidReactDiffFn(props) {
8513
8700
  const [children, setChildren] = (0, import_react26.useState)(props.updater.get);
8514
8701
  const rafId = (0, import_react26.useRef)(null);
8702
+ const shouldFlushSync = props.shouldFlushSync ?? SHOULD_FLUSH_SYNC;
8515
8703
  (0, import_react26.useLayoutEffect)(() => {
8516
8704
  function onChange(children2) {
8705
+ let FLUSH_SYNC = shouldFlushSync();
8517
8706
  if (props.useraf) {
8518
8707
  if (rafId.current != null) {
8519
8708
  cancelAnimationFrame(rafId.current);
8520
8709
  }
8521
8710
  rafId.current = requestAnimationFrame(() => {
8711
+ if (FLUSH_SYNC) {
8712
+ queueMicrotask(() => {
8713
+ (0, import_react_dom.flushSync)(() => {
8714
+ setChildren(children2);
8715
+ });
8716
+ });
8717
+ } else {
8718
+ setChildren(children2);
8719
+ }
8720
+ });
8721
+ } else {
8722
+ if (FLUSH_SYNC) {
8522
8723
  queueMicrotask(() => {
8523
8724
  (0, import_react_dom.flushSync)(() => {
8524
8725
  setChildren(children2);
8525
8726
  });
8526
8727
  });
8527
- });
8528
- } else {
8529
- queueMicrotask(() => {
8530
- (0, import_react_dom.flushSync)(() => {
8531
- setChildren(children2);
8532
- });
8533
- });
8728
+ } else {
8729
+ setChildren(children2);
8730
+ }
8534
8731
  }
8535
8732
  }
8536
8733
  const remove = props.updater.onChange(onChange);
@@ -8540,7 +8737,7 @@ function AvoidReactDiffFn(props) {
8540
8737
  }
8541
8738
  remove();
8542
8739
  };
8543
- }, [props.updater, props.useraf]);
8740
+ }, [props.updater, props.useraf, shouldFlushSync]);
8544
8741
  return children ?? null;
8545
8742
  }
8546
8743
  var AvoidReactDiff = React39.memo(AvoidReactDiffFn);
@@ -9869,14 +10066,26 @@ var GridCellForReact = class {
9869
10066
  constructor(debugId, cellInfo) {
9870
10067
  this.element = null;
9871
10068
  this.mounted = false;
10069
+ this.IS_UPDATED_WHILE_SCROLLING = false;
9872
10070
  this.mountSubscription = buildSubscriptionCallback();
10071
+ this.isUpdatedWhileScrolling = () => {
10072
+ return this.IS_UPDATED_WHILE_SCROLLING;
10073
+ };
9873
10074
  const count = CELL_COUNT_BY_DEBUG_ID.get(debugId) ?? 0;
9874
10075
  const key = `${debugId}:GridCellReact:${count}`;
9875
10076
  CELL_COUNT_BY_DEBUG_ID.set(debugId, count + 1);
9876
10077
  this.debugId = key;
9877
10078
  this.cellInfo = cellInfo;
9878
10079
  this.updater = buildSubscriptionCallback();
9879
- this.node = /* @__PURE__ */ React40.createElement(AvoidReactDiff, { key, name: key, updater: this.updater });
10080
+ this.node = /* @__PURE__ */ React40.createElement(
10081
+ AvoidReactDiff,
10082
+ {
10083
+ key,
10084
+ name: key,
10085
+ updater: this.updater,
10086
+ shouldFlushSync: this.isUpdatedWhileScrolling
10087
+ }
10088
+ );
9880
10089
  this.ref = (htmlElement) => {
9881
10090
  this.element = htmlElement;
9882
10091
  if (htmlElement) {
@@ -9908,7 +10117,8 @@ var GridCellForReact = class {
9908
10117
  getNode() {
9909
10118
  return this.node;
9910
10119
  }
9911
- update(content, additionalInfo) {
10120
+ update(content, additionalInfo, scrollingObjectParam) {
10121
+ this.IS_UPDATED_WHILE_SCROLLING = scrollingObjectParam ? scrollingObjectParam.scrolling : false;
9912
10122
  this.updater(content);
9913
10123
  this.cellInfo = additionalInfo;
9914
10124
  }
@@ -10200,14 +10410,14 @@ var GridCellManager = class extends Logger {
10200
10410
  }
10201
10411
  this.addCellToMatrix(cell, cellPos);
10202
10412
  }
10203
- renderNodeAtCell(node, cell, cellPos, additionalInfo) {
10413
+ renderNodeAtCell(node, cell, cellPos, additionalInfo, scrollingObjectParam) {
10204
10414
  const currentCellAtPos = this.getCellAt(cellPos);
10205
10415
  if (currentCellAtPos && currentCellAtPos !== cell) {
10206
10416
  this.detachCellAt(cellPos);
10207
10417
  }
10208
10418
  this.pool.attachCell(cell);
10209
10419
  this.setCellPositionInMatrix(cell, cellPos);
10210
- cell.update(node, additionalInfo);
10420
+ cell.update(node, additionalInfo, scrollingObjectParam);
10211
10421
  return cell;
10212
10422
  }
10213
10423
  getCellPosition(cell) {
@@ -10790,6 +11000,9 @@ var columnOffsetAtIndex2 = stripVar(InternalVars.columnOffsetAtIndex);
10790
11000
  var columnOffsetAtIndexWhileReordering2 = stripVar(
10791
11001
  InternalVars.columnOffsetAtIndexWhileReordering
10792
11002
  );
11003
+ var SCROLLING_OBJECT_PARAM_FLYWEIGHT = {
11004
+ scrolling: false
11005
+ };
10793
11006
  var GridRenderer = class extends Logger {
10794
11007
  constructor(brain, debugId) {
10795
11008
  debugId = debugId || "ReactHeadlessTableRenderer";
@@ -11944,11 +12157,13 @@ var GridRenderer = class extends Logger {
11944
12157
  }
11945
12158
  return;
11946
12159
  }
12160
+ SCROLLING_OBJECT_PARAM_FLYWEIGHT.scrolling = this.scrolling;
11947
12161
  this.cellManager.renderNodeAtCell(
11948
12162
  renderedNode,
11949
12163
  cell,
11950
12164
  [rowIndex, colIndex],
11951
- cellAdditionalInfo
12165
+ cellAdditionalInfo,
12166
+ SCROLLING_OBJECT_PARAM_FLYWEIGHT
11952
12167
  );
11953
12168
  this.updateElementPosition(cell, { hidden, rowspan, colspan });
11954
12169
  return;
@@ -18831,163 +19046,6 @@ function finishRowInfoReducersFor(params) {
18831
19046
  return results;
18832
19047
  }
18833
19048
 
18834
- // src/utils/devTools/index.ts
18835
- var DevToolsMarker = class _DevToolsMarker {
18836
- constructor(debugId) {
18837
- this.debugId = debugId;
18838
- this.markerDetails = {
18839
- label: "",
18840
- track: "",
18841
- trackGroup: void 0,
18842
- color: void 0,
18843
- details: [],
18844
- tooltip: void 0
18845
- };
18846
- this.stopped = false;
18847
- this.start = (startDetails) => {
18848
- if (this.markerDetails.startTs) {
18849
- return this;
18850
- }
18851
- const start = performance.now();
18852
- this.markerDetails.details = startDetails?.details ?? [];
18853
- this.markerDetails.startTs = start;
18854
- return this;
18855
- };
18856
- this.end = (markerDetails = {}) => {
18857
- if (this.stopped) {
18858
- return this;
18859
- }
18860
- this.stopped = true;
18861
- const start = markerDetails.startTs ?? this.markerDetails.startTs;
18862
- const end = markerDetails.endTs ?? this.markerDetails.endTs ?? performance.now();
18863
- const color = markerDetails.color || this.markerDetails.color || "primary";
18864
- const trackGroup = markerDetails.trackGroup || this.markerDetails.trackGroup || `Infinite Table (${this.debugId})`;
18865
- const details = [
18866
- ...this.markerDetails.details || [],
18867
- ...markerDetails.details || []
18868
- ];
18869
- const tooltip = markerDetails.tooltip || this.markerDetails.tooltip;
18870
- const label = markerDetails.label || this.markerDetails.label || "Unknown";
18871
- const track = markerDetails.track || this.markerDetails.track || "Unknown";
18872
- performance.measure(label, {
18873
- start,
18874
- end,
18875
- detail: {
18876
- devtools: {
18877
- dataType: "track-entry",
18878
- trackGroup,
18879
- track,
18880
- color,
18881
- properties: details.length > 0 ? details.map((detail) => [detail.name, detail.value]) : void 0,
18882
- tooltipText: tooltip
18883
- }
18884
- }
18885
- });
18886
- return this;
18887
- };
18888
- this.debugId = debugId;
18889
- }
18890
- static create(debugId) {
18891
- return new _DevToolsMarker(debugId);
18892
- }
18893
- get startTimestamp() {
18894
- return this.markerDetails.startTs;
18895
- }
18896
- get track() {
18897
- const self = this;
18898
- return Object.keys(DevToolsTracks).reduce(
18899
- (acc, track) => {
18900
- const trackObj = {
18901
- start: self.start,
18902
- end: (markerDetails) => {
18903
- return self.end({
18904
- ...markerDetails,
18905
- track: DevToolsTracks[track].track,
18906
- label: markerDetails.label
18907
- });
18908
- },
18909
- get label() {
18910
- const currentTrack = DevToolsTracks[track];
18911
- return Object.keys(currentTrack.labels).reduce(
18912
- (labelAcc, label) => {
18913
- const labelObj = {
18914
- start: self.start,
18915
- end: (markerDetails) => {
18916
- return self.end({
18917
- ...markerDetails,
18918
- track: currentTrack.track,
18919
- label: currentTrack.labels[label]
18920
- });
18921
- }
18922
- };
18923
- Object.defineProperty(labelAcc, label, {
18924
- get: () => {
18925
- self.markerDetails.label = currentTrack.labels[label];
18926
- return labelObj;
18927
- }
18928
- });
18929
- return labelAcc;
18930
- },
18931
- {}
18932
- );
18933
- }
18934
- };
18935
- Object.defineProperty(acc, track, {
18936
- get: () => {
18937
- const currentTrack = DevToolsTracks[track];
18938
- self.markerDetails.track = currentTrack.track;
18939
- return trackObj;
18940
- }
18941
- });
18942
- return acc;
18943
- },
18944
- {}
18945
- );
18946
- }
18947
- };
18948
- var DevToolsTracks = {
18949
- DataSource: {
18950
- track: "DataSource",
18951
- labels: {
18952
- RemoteDataLoad: "Remote data load",
18953
- TreeUnfilteredTreePaths: "Computing unfiltered tree paths",
18954
- Filter: "Filter",
18955
- Sort: "Sort",
18956
- Group: "Group",
18957
- LazyGroup: "Lazy group",
18958
- Tree: "Tree",
18959
- FlattenTree: "Flatten tree",
18960
- Flatten: "Flatten groups",
18961
- PrepareData: "Preparing data",
18962
- ComputeSelectionCount: "Computing selection count",
18963
- ComputeSelectionCountLazy: "Computing selection count (lazy)",
18964
- PrepareRowInfo: "Preparing row info array"
18965
- }
18966
- },
18967
- InfiniteTable: {
18968
- track: "InfiniteTable",
18969
- labels: {
18970
- Render: "Rendering"
18971
- }
18972
- },
18973
- MatrixBrain: {
18974
- track: "Layout Computations",
18975
- labels: {
18976
- ComputeRenderRange: "Computing render range"
18977
- }
18978
- }
18979
- };
18980
- function getMarker(debugId) {
18981
- return DevToolsMarker.create(debugId);
18982
- }
18983
-
18984
- // src/components/InfiniteTable/types/Utility.ts
18985
- function notNullable(value) {
18986
- if (value === null || value === void 0) return false;
18987
- const testDummyForCompileError = value;
18988
- return true;
18989
- }
18990
-
18991
19049
  // src/components/DataSource/state/reducer.ts
18992
19050
  function cleanupEmptyFilterValues(filterValue, filterTypes) {
18993
19051
  if (!filterValue) {
@@ -22444,6 +22502,9 @@ function isSortInfoForColumn(sortInfo, col) {
22444
22502
  }
22445
22503
  var InfiniteTableApiImpl = class {
22446
22504
  constructor(context) {
22505
+ this.getVisibleRenderRange = () => {
22506
+ return this.getState().brain.getRenderRange();
22507
+ };
22447
22508
  this.hideFilterOperatorMenu = () => {
22448
22509
  this.actions.filterOperatorMenuVisibleForColumnId = null;
22449
22510
  };
@@ -25685,7 +25746,7 @@ var useLicense = (licenseKey = "") => {
25685
25746
  }
25686
25747
  let valid2 = isValidLicense(licenseKey, {
25687
25748
  publishedAt: 1624970570587,
25688
- version: "7.4.0"
25749
+ version: "7.4.2"
25689
25750
  });
25690
25751
  if (!licenseKey && !valid2 && isInsidePlayground) {
25691
25752
  return true;