@infinite-table/infinite-react 7.4.1 → 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
@@ -1388,6 +1388,13 @@ var toUpperFirst = (s) => {
1388
1388
  return s ? s.substr(0, 1).toUpperCase() + s.substr(1) : s;
1389
1389
  };
1390
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
+
1391
1398
  // src/components/utils/isControlledValue.ts
1392
1399
  function isControlledValue(value) {
1393
1400
  const controlled = value !== void 0;
@@ -1461,6 +1468,164 @@ var usePrevious = (value, initialValue) => {
1461
1468
  return ref.current;
1462
1469
  };
1463
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
+
1464
1629
  // src/components/hooks/useComponentState/index.tsx
1465
1630
  var notifyChange = (props, callbackPropName, values) => {
1466
1631
  const callbackProp = props[callbackPropName];
@@ -1717,9 +1882,10 @@ function buildManagedComponent(config) {
1717
1882
  }
1718
1883
  });
1719
1884
  if (updatedPropsToStateCount > 0 || newMappedStateCount > 0) {
1720
- const logger2 = config.debugName ? dbg(
1721
- typeof config.debugName === "function" ? `${config.debugName(currentProps)}:rerender` : `${config.debugName}:rerender`
1722
- ) : 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);
1723
1889
  logger2(
1724
1890
  "Triggered by new values for the following props",
1725
1891
  ...[
@@ -1727,6 +1893,25 @@ function buildManagedComponent(config) {
1727
1893
  ...Object.keys(updatedPropsToState ?? {})
1728
1894
  ]
1729
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
+ }
1730
1915
  const action = {
1731
1916
  payload: {
1732
1917
  mappedState: newMappedStateCount ? newMappedState : null,
@@ -8510,28 +8695,39 @@ var import_react27 = require("react");
8510
8695
  var React39 = __toESM(require("react"));
8511
8696
  var import_react_dom = require("react-dom");
8512
8697
  var import_react26 = require("react");
8698
+ var SHOULD_FLUSH_SYNC = () => false;
8513
8699
  function AvoidReactDiffFn(props) {
8514
8700
  const [children, setChildren] = (0, import_react26.useState)(props.updater.get);
8515
8701
  const rafId = (0, import_react26.useRef)(null);
8702
+ const shouldFlushSync = props.shouldFlushSync ?? SHOULD_FLUSH_SYNC;
8516
8703
  (0, import_react26.useLayoutEffect)(() => {
8517
8704
  function onChange(children2) {
8705
+ let FLUSH_SYNC = shouldFlushSync();
8518
8706
  if (props.useraf) {
8519
8707
  if (rafId.current != null) {
8520
8708
  cancelAnimationFrame(rafId.current);
8521
8709
  }
8522
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) {
8523
8723
  queueMicrotask(() => {
8524
8724
  (0, import_react_dom.flushSync)(() => {
8525
8725
  setChildren(children2);
8526
8726
  });
8527
8727
  });
8528
- });
8529
- } else {
8530
- queueMicrotask(() => {
8531
- (0, import_react_dom.flushSync)(() => {
8532
- setChildren(children2);
8533
- });
8534
- });
8728
+ } else {
8729
+ setChildren(children2);
8730
+ }
8535
8731
  }
8536
8732
  }
8537
8733
  const remove = props.updater.onChange(onChange);
@@ -8541,7 +8737,7 @@ function AvoidReactDiffFn(props) {
8541
8737
  }
8542
8738
  remove();
8543
8739
  };
8544
- }, [props.updater, props.useraf]);
8740
+ }, [props.updater, props.useraf, shouldFlushSync]);
8545
8741
  return children ?? null;
8546
8742
  }
8547
8743
  var AvoidReactDiff = React39.memo(AvoidReactDiffFn);
@@ -9870,14 +10066,26 @@ var GridCellForReact = class {
9870
10066
  constructor(debugId, cellInfo) {
9871
10067
  this.element = null;
9872
10068
  this.mounted = false;
10069
+ this.IS_UPDATED_WHILE_SCROLLING = false;
9873
10070
  this.mountSubscription = buildSubscriptionCallback();
10071
+ this.isUpdatedWhileScrolling = () => {
10072
+ return this.IS_UPDATED_WHILE_SCROLLING;
10073
+ };
9874
10074
  const count = CELL_COUNT_BY_DEBUG_ID.get(debugId) ?? 0;
9875
10075
  const key = `${debugId}:GridCellReact:${count}`;
9876
10076
  CELL_COUNT_BY_DEBUG_ID.set(debugId, count + 1);
9877
10077
  this.debugId = key;
9878
10078
  this.cellInfo = cellInfo;
9879
10079
  this.updater = buildSubscriptionCallback();
9880
- 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
+ );
9881
10089
  this.ref = (htmlElement) => {
9882
10090
  this.element = htmlElement;
9883
10091
  if (htmlElement) {
@@ -9909,7 +10117,8 @@ var GridCellForReact = class {
9909
10117
  getNode() {
9910
10118
  return this.node;
9911
10119
  }
9912
- update(content, additionalInfo) {
10120
+ update(content, additionalInfo, scrollingObjectParam) {
10121
+ this.IS_UPDATED_WHILE_SCROLLING = scrollingObjectParam ? scrollingObjectParam.scrolling : false;
9913
10122
  this.updater(content);
9914
10123
  this.cellInfo = additionalInfo;
9915
10124
  }
@@ -10201,14 +10410,14 @@ var GridCellManager = class extends Logger {
10201
10410
  }
10202
10411
  this.addCellToMatrix(cell, cellPos);
10203
10412
  }
10204
- renderNodeAtCell(node, cell, cellPos, additionalInfo) {
10413
+ renderNodeAtCell(node, cell, cellPos, additionalInfo, scrollingObjectParam) {
10205
10414
  const currentCellAtPos = this.getCellAt(cellPos);
10206
10415
  if (currentCellAtPos && currentCellAtPos !== cell) {
10207
10416
  this.detachCellAt(cellPos);
10208
10417
  }
10209
10418
  this.pool.attachCell(cell);
10210
10419
  this.setCellPositionInMatrix(cell, cellPos);
10211
- cell.update(node, additionalInfo);
10420
+ cell.update(node, additionalInfo, scrollingObjectParam);
10212
10421
  return cell;
10213
10422
  }
10214
10423
  getCellPosition(cell) {
@@ -10791,6 +11000,9 @@ var columnOffsetAtIndex2 = stripVar(InternalVars.columnOffsetAtIndex);
10791
11000
  var columnOffsetAtIndexWhileReordering2 = stripVar(
10792
11001
  InternalVars.columnOffsetAtIndexWhileReordering
10793
11002
  );
11003
+ var SCROLLING_OBJECT_PARAM_FLYWEIGHT = {
11004
+ scrolling: false
11005
+ };
10794
11006
  var GridRenderer = class extends Logger {
10795
11007
  constructor(brain, debugId) {
10796
11008
  debugId = debugId || "ReactHeadlessTableRenderer";
@@ -11945,11 +12157,13 @@ var GridRenderer = class extends Logger {
11945
12157
  }
11946
12158
  return;
11947
12159
  }
12160
+ SCROLLING_OBJECT_PARAM_FLYWEIGHT.scrolling = this.scrolling;
11948
12161
  this.cellManager.renderNodeAtCell(
11949
12162
  renderedNode,
11950
12163
  cell,
11951
12164
  [rowIndex, colIndex],
11952
- cellAdditionalInfo
12165
+ cellAdditionalInfo,
12166
+ SCROLLING_OBJECT_PARAM_FLYWEIGHT
11953
12167
  );
11954
12168
  this.updateElementPosition(cell, { hidden, rowspan, colspan });
11955
12169
  return;
@@ -18832,165 +19046,6 @@ function finishRowInfoReducersFor(params) {
18832
19046
  return results;
18833
19047
  }
18834
19048
 
18835
- // src/utils/devTools/devToolsTracks.ts
18836
- var DevToolsTracks = {
18837
- DataSource: {
18838
- track: "DataSource",
18839
- labels: {
18840
- RemoteDataLoad: "Remote data load",
18841
- TreeUnfilteredTreePaths: "Computing unfiltered tree paths",
18842
- Filter: "Filter",
18843
- Sort: "Sort",
18844
- Group: "Group",
18845
- LazyGroup: "Lazy group",
18846
- Tree: "Tree",
18847
- FlattenTree: "Flatten tree",
18848
- Flatten: "Flatten groups",
18849
- PrepareData: "Preparing data",
18850
- ComputeSelectionCount: "Computing selection count",
18851
- ComputeSelectionCountLazy: "Computing selection count (lazy)",
18852
- PrepareRowInfo: "Preparing row info array"
18853
- }
18854
- },
18855
- InfiniteTable: {
18856
- track: "InfiniteTable",
18857
- labels: {
18858
- Render: "Rendering"
18859
- }
18860
- },
18861
- MatrixBrain: {
18862
- track: "Layout Computations",
18863
- labels: {
18864
- ComputeRenderRange: "Computing render range"
18865
- }
18866
- }
18867
- };
18868
-
18869
- // src/utils/devTools/index.ts
18870
- var DevToolsMarker = class _DevToolsMarker {
18871
- constructor(debugId) {
18872
- this.debugId = debugId;
18873
- this.markerDetails = {
18874
- label: "",
18875
- track: "",
18876
- trackGroup: void 0,
18877
- color: void 0,
18878
- details: [],
18879
- tooltip: void 0
18880
- };
18881
- this.stopped = false;
18882
- this.start = (startDetails) => {
18883
- if (this.markerDetails.startTs) {
18884
- return this;
18885
- }
18886
- const start = performance.now();
18887
- this.markerDetails.details = startDetails?.details ?? [];
18888
- this.markerDetails.startTs = start;
18889
- return this;
18890
- };
18891
- this.end = (markerDetails = {}) => {
18892
- if (this.stopped) {
18893
- return this;
18894
- }
18895
- this.stopped = true;
18896
- const start = markerDetails.startTs ?? this.markerDetails.startTs;
18897
- const end = markerDetails.endTs ?? this.markerDetails.endTs ?? performance.now();
18898
- const color = markerDetails.color || this.markerDetails.color || "primary";
18899
- const trackGroup = markerDetails.trackGroup || this.markerDetails.trackGroup || `Infinite Table (${this.debugId})`;
18900
- const details = [
18901
- ...this.markerDetails.details || [],
18902
- ...markerDetails.details || []
18903
- ];
18904
- const tooltip = markerDetails.tooltip || this.markerDetails.tooltip;
18905
- const label = markerDetails.label || this.markerDetails.label || "Unknown";
18906
- const track = markerDetails.track || this.markerDetails.track || "Unknown";
18907
- performance.measure(label, {
18908
- start,
18909
- end,
18910
- detail: {
18911
- devtools: {
18912
- dataType: "track-entry",
18913
- trackGroup,
18914
- track,
18915
- color,
18916
- properties: details.length > 0 ? details.map((detail) => [detail.name, detail.value]) : void 0,
18917
- tooltipText: tooltip
18918
- }
18919
- }
18920
- });
18921
- return this;
18922
- };
18923
- this.debugId = debugId;
18924
- }
18925
- static create(debugId) {
18926
- return new _DevToolsMarker(debugId);
18927
- }
18928
- get startTimestamp() {
18929
- return this.markerDetails.startTs;
18930
- }
18931
- get track() {
18932
- const self = this;
18933
- return Object.keys(DevToolsTracks).reduce(
18934
- (acc, track) => {
18935
- const trackObj = {
18936
- start: self.start,
18937
- end: (markerDetails) => {
18938
- return self.end({
18939
- ...markerDetails,
18940
- track: DevToolsTracks[track].track,
18941
- label: markerDetails.label
18942
- });
18943
- },
18944
- get label() {
18945
- const currentTrack = DevToolsTracks[track];
18946
- return Object.keys(currentTrack.labels).reduce(
18947
- (labelAcc, label) => {
18948
- const labelObj = {
18949
- start: self.start,
18950
- end: (markerDetails) => {
18951
- return self.end({
18952
- ...markerDetails,
18953
- track: currentTrack.track,
18954
- label: currentTrack.labels[label]
18955
- });
18956
- }
18957
- };
18958
- Object.defineProperty(labelAcc, label, {
18959
- get: () => {
18960
- self.markerDetails.label = currentTrack.labels[label];
18961
- return labelObj;
18962
- }
18963
- });
18964
- return labelAcc;
18965
- },
18966
- {}
18967
- );
18968
- }
18969
- };
18970
- Object.defineProperty(acc, track, {
18971
- get: () => {
18972
- const currentTrack = DevToolsTracks[track];
18973
- self.markerDetails.track = currentTrack.track;
18974
- return trackObj;
18975
- }
18976
- });
18977
- return acc;
18978
- },
18979
- {}
18980
- );
18981
- }
18982
- };
18983
- function getMarker(debugId) {
18984
- return DevToolsMarker.create(debugId);
18985
- }
18986
-
18987
- // src/components/InfiniteTable/types/Utility.ts
18988
- function notNullable(value) {
18989
- if (value === null || value === void 0) return false;
18990
- const testDummyForCompileError = value;
18991
- return true;
18992
- }
18993
-
18994
19049
  // src/components/DataSource/state/reducer.ts
18995
19050
  function cleanupEmptyFilterValues(filterValue, filterTypes) {
18996
19051
  if (!filterValue) {
@@ -22447,6 +22502,9 @@ function isSortInfoForColumn(sortInfo, col) {
22447
22502
  }
22448
22503
  var InfiniteTableApiImpl = class {
22449
22504
  constructor(context) {
22505
+ this.getVisibleRenderRange = () => {
22506
+ return this.getState().brain.getRenderRange();
22507
+ };
22450
22508
  this.hideFilterOperatorMenu = () => {
22451
22509
  this.actions.filterOperatorMenuVisibleForColumnId = null;
22452
22510
  };
@@ -25688,7 +25746,7 @@ var useLicense = (licenseKey = "") => {
25688
25746
  }
25689
25747
  let valid2 = isValidLicense(licenseKey, {
25690
25748
  publishedAt: 1624970570587,
25691
- version: "7.4.1"
25749
+ version: "7.4.2"
25692
25750
  });
25693
25751
  if (!licenseKey && !valid2 && isInsidePlayground) {
25694
25752
  return true;