@infinite-table/infinite-react 0.3.11 → 0.3.12

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.d.ts CHANGED
@@ -1648,6 +1648,7 @@ declare type ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT
1648
1648
  }) => COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE;
1649
1649
  getReducerActions?: (dispatch: React$1.Dispatch<any>) => T_ACTIONS;
1650
1650
  getParentState?: () => T_PARENT_STATE;
1651
+ cleanup?: (state: COMPONENT_MAPPED_STATE & COMPONENT_SETUP_STATE & COMPONENT_DERIVED_STATE) => void;
1651
1652
  onControlledPropertyChange?: (name: string, newValue: any, oldValue: any) => void | ((value: any, oldValue: any) => any);
1652
1653
  };
1653
1654
  declare function getComponentStateRoot<T_PROPS, COMPONENT_MAPPED_STATE extends object, COMPONENT_SETUP_STATE extends object = {}, COMPONENT_DERIVED_STATE extends object = {}, T_ACTIONS = {}, T_PARENT_STATE = {}>(config: ComponentStateRootConfig<T_PROPS, COMPONENT_MAPPED_STATE, COMPONENT_SETUP_STATE, COMPONENT_DERIVED_STATE, T_ACTIONS, T_PARENT_STATE>): React$1.NamedExoticComponent<T_PROPS & {
package/index.esm.js CHANGED
@@ -3188,6 +3188,9 @@ var ReactHeadlessTableRenderer = class extends Logger {
3188
3188
  }
3189
3189
  };
3190
3190
  this.destroy = () => {
3191
+ if (this.destroyed) {
3192
+ return;
3193
+ }
3191
3194
  this.destroyed = true;
3192
3195
  this.reset();
3193
3196
  this.onDestroy();
@@ -3887,6 +3890,12 @@ function getComponentStateRoot(config) {
3887
3890
  }
3888
3891
  }
3889
3892
  });
3893
+ useEffect8(() => {
3894
+ return () => {
3895
+ var _a2;
3896
+ (_a2 = config.cleanup) == null ? void 0 : _a2.call(config, getComponentState());
3897
+ };
3898
+ }, []);
3890
3899
  return /* @__PURE__ */ createElement9(Context.Provider, {
3891
3900
  value: contextValue
3892
3901
  }, props.children);
@@ -9468,7 +9477,7 @@ var useLicense = (licenseKey = "") => {
9468
9477
  const valid = useMemo12(() => {
9469
9478
  let valid2 = isValidLicense(licenseKey, {
9470
9479
  publishedAt: 1624970570587,
9471
- version: "0.3.11"
9480
+ version: "0.3.12"
9472
9481
  });
9473
9482
  if (!licenseKey && !valid2 && isInsidePlayground) {
9474
9483
  return true;
@@ -9812,6 +9821,19 @@ function getGroupRenderStrategy(options) {
9812
9821
  }
9813
9822
  return "multi-column";
9814
9823
  }
9824
+ var cleanupState = (state) => {
9825
+ state.brain.destroy();
9826
+ state.headerBrain.destroy();
9827
+ state.renderer.destroy();
9828
+ state.onRenderUpdater.destroy();
9829
+ state.domRef.current = null;
9830
+ state.scrollerDOMRef.current = null;
9831
+ state.portalDOMRef.current = null;
9832
+ state.onRowHeightCSSVarChange.destroy();
9833
+ state.onColumnHeaderHeightCSSVarChange.destroy();
9834
+ state.pinnedEndScrollListener.destroy();
9835
+ state.pinnedStartScrollListener.destroy();
9836
+ };
9815
9837
  var mapPropsToState2 = (params) => {
9816
9838
  var _a, _b;
9817
9839
  const { props, state, oldState, parentState } = params;
@@ -9848,6 +9870,7 @@ var InfiniteTableRoot = getComponentStateRoot({
9848
9870
  initSetupState: initSetupState2,
9849
9871
  forwardProps: forwardProps3,
9850
9872
  mapPropsToState: mapPropsToState2,
9873
+ cleanup: cleanupState,
9851
9874
  allowedControlledPropOverrides: {
9852
9875
  rowHeight: true,
9853
9876
  columnHeaderHeight: true
package/index.js CHANGED
@@ -3180,6 +3180,9 @@ var ReactHeadlessTableRenderer = class extends Logger {
3180
3180
  }
3181
3181
  };
3182
3182
  this.destroy = () => {
3183
+ if (this.destroyed) {
3184
+ return;
3185
+ }
3183
3186
  this.destroyed = true;
3184
3187
  this.reset();
3185
3188
  this.onDestroy();
@@ -3862,6 +3865,12 @@ function getComponentStateRoot(config) {
3862
3865
  }
3863
3866
  }
3864
3867
  });
3868
+ (0, import_react14.useEffect)(() => {
3869
+ return () => {
3870
+ var _a2;
3871
+ (_a2 = config.cleanup) == null ? void 0 : _a2.call(config, getComponentState());
3872
+ };
3873
+ }, []);
3865
3874
  return /* @__PURE__ */ React13.createElement(Context.Provider, {
3866
3875
  value: contextValue
3867
3876
  }, props.children);
@@ -9384,7 +9393,7 @@ var useLicense = (licenseKey = "") => {
9384
9393
  const valid = (0, import_react43.useMemo)(() => {
9385
9394
  let valid2 = isValidLicense(licenseKey, {
9386
9395
  publishedAt: 1624970570587,
9387
- version: "0.3.11"
9396
+ version: "0.3.12"
9388
9397
  });
9389
9398
  if (!licenseKey && !valid2 && isInsidePlayground) {
9390
9399
  return true;
@@ -9728,6 +9737,19 @@ function getGroupRenderStrategy(options) {
9728
9737
  }
9729
9738
  return "multi-column";
9730
9739
  }
9740
+ var cleanupState = (state) => {
9741
+ state.brain.destroy();
9742
+ state.headerBrain.destroy();
9743
+ state.renderer.destroy();
9744
+ state.onRenderUpdater.destroy();
9745
+ state.domRef.current = null;
9746
+ state.scrollerDOMRef.current = null;
9747
+ state.portalDOMRef.current = null;
9748
+ state.onRowHeightCSSVarChange.destroy();
9749
+ state.onColumnHeaderHeightCSSVarChange.destroy();
9750
+ state.pinnedEndScrollListener.destroy();
9751
+ state.pinnedStartScrollListener.destroy();
9752
+ };
9731
9753
  var mapPropsToState2 = (params) => {
9732
9754
  var _a, _b;
9733
9755
  const { props, state, oldState, parentState } = params;
@@ -9764,6 +9786,7 @@ var InfiniteTableRoot = getComponentStateRoot({
9764
9786
  initSetupState: initSetupState2,
9765
9787
  forwardProps: forwardProps3,
9766
9788
  mapPropsToState: mapPropsToState2,
9789
+ cleanup: cleanupState,
9767
9790
  allowedControlledPropOverrides: {
9768
9791
  rowHeight: true,
9769
9792
  columnHeaderHeight: true
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@infinite-table/infinite-react",
3
3
  "description": "Infinite Table for React",
4
- "version": "0.3.11",
4
+ "version": "0.3.12",
5
5
  "main": "index.js",
6
6
  "module": "index.esm.js",
7
7
  "typings": "index.d.ts",
@@ -14,5 +14,5 @@
14
14
  },
15
15
  "license": "Commercial & Open Source",
16
16
  "//": "will be updated at build time",
17
- "publishedAt": 1654702620822
17
+ "publishedAt": 1654765155370
18
18
  }