@trackunit/react-table 0.0.159 → 0.0.160

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.cjs.js CHANGED
@@ -643,6 +643,13 @@ const useTable = (_a) => {
643
643
  const [columnOrder, setColumnOrder] = React.useState(((_c = reactTableProps.state) === null || _c === void 0 ? void 0 : _c.columnOrder) || (initialState === null || initialState === void 0 ? void 0 : initialState.columnOrder) || []);
644
644
  const [sorting, setSorting] = React.useState(((_d = reactTableProps.state) === null || _d === void 0 ? void 0 : _d.sorting) || (initialState === null || initialState === void 0 ? void 0 : initialState.sorting) || []);
645
645
  const [columnSizing, setColumnSizing] = React.useState(((_e = reactTableProps.state) === null || _e === void 0 ? void 0 : _e.columnSizing) || (initialState === null || initialState === void 0 ? void 0 : initialState.columnSizing) || {});
646
+ const isFirstRender = reactComponents.useIsFirstRender();
647
+ const tableColumnRef = React.useRef(columns);
648
+ React.useEffect(() => {
649
+ if (process.env.NODE_ENV !== "production") {
650
+ if (!isFirstRender && tableColumnRef.current !== columns) ;
651
+ }
652
+ }, [isFirstRender, columns]);
646
653
  React.useEffect(() => {
647
654
  if (initialState && Object.keys(initialState || {}).length > 0) {
648
655
  setColumnVisibility(Object.keys(initialState.columnVisibility || {}).length > 0
@@ -673,9 +680,10 @@ const useTable = (_a) => {
673
680
  onTableStateChange(state);
674
681
  }
675
682
  }, [onTableStateChange, state]);
676
- return {
677
- table,
678
- };
683
+ const memoizedTable = React.useMemo(() => {
684
+ return { table };
685
+ }, [table]);
686
+ return memoizedTable;
679
687
  };
680
688
 
681
689
  //TODO: find a more appropriate place for this file
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
3
- import { MenuItem, Icon, Text, Button, useOverflowItems, MoreMenu, MenuList, IconButton, Card, EmptyState, Spinner, Tooltip, Popover, PopoverTrigger, PopoverContent } from '@trackunit/react-components';
3
+ import { MenuItem, Icon, Text, Button, useOverflowItems, MoreMenu, MenuList, IconButton, Card, EmptyState, Spinner, Tooltip, Popover, PopoverTrigger, PopoverContent, useIsFirstRender } from '@trackunit/react-components';
4
4
  import * as React from 'react';
5
5
  import { useMemo, Children, cloneElement, useCallback, useEffect, useRef, useState } from 'react';
6
6
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
@@ -618,6 +618,13 @@ const useTable = (_a) => {
618
618
  const [columnOrder, setColumnOrder] = useState(((_c = reactTableProps.state) === null || _c === void 0 ? void 0 : _c.columnOrder) || (initialState === null || initialState === void 0 ? void 0 : initialState.columnOrder) || []);
619
619
  const [sorting, setSorting] = useState(((_d = reactTableProps.state) === null || _d === void 0 ? void 0 : _d.sorting) || (initialState === null || initialState === void 0 ? void 0 : initialState.sorting) || []);
620
620
  const [columnSizing, setColumnSizing] = useState(((_e = reactTableProps.state) === null || _e === void 0 ? void 0 : _e.columnSizing) || (initialState === null || initialState === void 0 ? void 0 : initialState.columnSizing) || {});
621
+ const isFirstRender = useIsFirstRender();
622
+ const tableColumnRef = useRef(columns);
623
+ useEffect(() => {
624
+ if (process.env.NODE_ENV !== "production") {
625
+ if (!isFirstRender && tableColumnRef.current !== columns) ;
626
+ }
627
+ }, [isFirstRender, columns]);
621
628
  useEffect(() => {
622
629
  if (initialState && Object.keys(initialState || {}).length > 0) {
623
630
  setColumnVisibility(Object.keys(initialState.columnVisibility || {}).length > 0
@@ -648,9 +655,10 @@ const useTable = (_a) => {
648
655
  onTableStateChange(state);
649
656
  }
650
657
  }, [onTableStateChange, state]);
651
- return {
652
- table,
653
- };
658
+ const memoizedTable = useMemo(() => {
659
+ return { table };
660
+ }, [table]);
661
+ return memoizedTable;
654
662
  };
655
663
 
656
664
  //TODO: find a more appropriate place for this file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table",
3
- "version": "0.0.159",
3
+ "version": "0.0.160",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -17,7 +17,7 @@
17
17
  "react-dnd": "14.0.5",
18
18
  "react-dnd-html5-backend": "14.1.0",
19
19
  "jest-fetch-mock": "^3.0.3",
20
- "@tanstack/react-virtual": "3.0.0-beta.66",
20
+ "@tanstack/react-virtual": "3.0.0-beta.68",
21
21
  "@trackunit/react-core-contexts-api": "*",
22
22
  "@trackunit/css-class-variance-utilities": "*",
23
23
  "@trackunit/ui-icons": "*",