@equinor/apollo-components 3.1.2-rowfix.16 → 3.1.2-rowfix.17

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/dist/index.js CHANGED
@@ -663,7 +663,7 @@ function TableHeader({ table, sticky }) {
663
663
  // src/DataTable/DataTable.tsx
664
664
  var import_eds_core_react18 = require("@equinor/eds-core-react");
665
665
  var import_react_table3 = require("@tanstack/react-table");
666
- var import_react6 = require("react");
666
+ var import_react7 = require("react");
667
667
  var import_styled_components16 = __toESM(require("styled-components"));
668
668
 
669
669
  // src/DataTable/components/BasicTable.tsx
@@ -924,6 +924,7 @@ function TableBanner({
924
924
 
925
925
  // src/DataTable/components/VirtualTableBody.tsx
926
926
  var import_react_virtual = require("@tanstack/react-virtual");
927
+ var import_react5 = require("react");
927
928
 
928
929
  // src/DataTable/components/PaddingRow.tsx
929
930
  var import_eds_core_react17 = require("@equinor/eds-core-react");
@@ -987,11 +988,15 @@ function VirtualTableBody({
987
988
  ]
988
989
  });
989
990
  }
991
+ var Memo_VirtualTableBody = (0, import_react5.memo)(
992
+ VirtualTableBody,
993
+ (prev, next) => prev.containerRef.current === next.containerRef.current
994
+ );
990
995
 
991
996
  // src/DataTable/hooks/useFetchMoreOnBottomReached.tsx
992
- var import_react5 = require("react");
997
+ var import_react6 = require("react");
993
998
  function useFetchMoreOnBottomReached(tableContainerRef, infiniteScrollConfig) {
994
- const fetchMoreOnBottomReached = (0, import_react5.useCallback)(
999
+ const fetchMoreOnBottomReached = (0, import_react6.useCallback)(
995
1000
  (tableContainer) => {
996
1001
  if (!infiniteScrollConfig)
997
1002
  return;
@@ -1005,11 +1010,11 @@ function useFetchMoreOnBottomReached(tableContainerRef, infiniteScrollConfig) {
1005
1010
  },
1006
1011
  [infiniteScrollConfig]
1007
1012
  );
1008
- const onTableContainerScroll = (0, import_react5.useCallback)(
1013
+ const onTableContainerScroll = (0, import_react6.useCallback)(
1009
1014
  (event) => fetchMoreOnBottomReached(event.target),
1010
1015
  [fetchMoreOnBottomReached]
1011
1016
  );
1012
- (0, import_react5.useEffect)(() => {
1017
+ (0, import_react6.useEffect)(() => {
1013
1018
  if (!infiniteScrollConfig)
1014
1019
  return;
1015
1020
  fetchMoreOnBottomReached(tableContainerRef.current);
@@ -1037,14 +1042,14 @@ var DataTableWrapper = import_styled_components16.default.div`
1037
1042
  }
1038
1043
  `;
1039
1044
  function DataTable(props) {
1040
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1045
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1041
1046
  const { columns, data, bannerConfig, cellConfig, sorting } = props;
1042
- const [internalColumnVisibility, setInternalColumnVisibility] = (0, import_react6.useState)({});
1047
+ const [internalColumnVisibility, setInternalColumnVisibility] = (0, import_react7.useState)({});
1043
1048
  const [columnVisibility, setColumnVisibility] = [
1044
1049
  ((_a = props.columnVisibility) == null ? void 0 : _a.state) ?? internalColumnVisibility,
1045
1050
  ((_b = props.columnVisibility) == null ? void 0 : _b.onChange) ?? setInternalColumnVisibility
1046
1051
  ];
1047
- const [internalGlobalFilterState, setInternalGlobalFilterState] = (0, import_react6.useState)("");
1052
+ const [internalGlobalFilterState, setInternalGlobalFilterState] = (0, import_react7.useState)("");
1048
1053
  const [globalFilterState, setGlobalFilterState] = [
1049
1054
  ((_c = props.globalFilter) == null ? void 0 : _c.state) ?? internalGlobalFilterState,
1050
1055
  ((_d = props.globalFilter) == null ? void 0 : _d.onChange) ?? setInternalGlobalFilterState
@@ -1053,17 +1058,17 @@ function DataTable(props) {
1053
1058
  function enableGlobalFilter(value) {
1054
1059
  return enableOrUndefined(shouldEnableGlobalFilter, value);
1055
1060
  }
1056
- const [internalSortingState, setInternalSortingState] = (0, import_react6.useState)([]);
1061
+ const [internalSortingState, setInternalSortingState] = (0, import_react7.useState)([]);
1057
1062
  const [sortingState, setSortingState] = [
1058
1063
  ((_f = props.sorting) == null ? void 0 : _f.state) ?? internalSortingState,
1059
1064
  ((_g = props.sorting) == null ? void 0 : _g.onChange) ?? setInternalSortingState
1060
1065
  ];
1061
- const [internalRowSelectionState, setInternalRowSelectionState] = (0, import_react6.useState)({});
1066
+ const [internalRowSelectionState, setInternalRowSelectionState] = (0, import_react7.useState)({});
1062
1067
  const [rowSelectionState, setRowSelectionState] = [
1063
1068
  ((_h = props.rowSelection) == null ? void 0 : _h.state) ?? internalRowSelectionState,
1064
1069
  ((_i = props.rowSelection) == null ? void 0 : _i.onChange) ?? setInternalRowSelectionState
1065
1070
  ];
1066
- const [internalExpandedState, setInternalExpandedState] = (0, import_react6.useState)({});
1071
+ const [internalExpandedState, setInternalExpandedState] = (0, import_react7.useState)({});
1067
1072
  const [expandedState, setExpandedState] = [
1068
1073
  ((_j = props.expansion) == null ? void 0 : _j.state) ?? internalExpandedState,
1069
1074
  ((_k = props.expansion) == null ? void 0 : _k.onChange) ?? setInternalExpandedState
@@ -1106,25 +1111,25 @@ function DataTable(props) {
1106
1111
  getSubRows: props == null ? void 0 : props.getSubRows,
1107
1112
  getRowId: props == null ? void 0 : props.getRowId
1108
1113
  });
1109
- (0, import_react6.useEffect)(() => {
1114
+ (0, import_react7.useEffect)(() => {
1110
1115
  var _a2;
1111
1116
  if ((_a2 = props.expansion) == null ? void 0 : _a2.expandAllByDefault) {
1112
1117
  table.toggleAllRowsExpanded();
1113
1118
  }
1114
1119
  }, [table, (_p = props.expansion) == null ? void 0 : _p.expandAllByDefault]);
1115
1120
  const { isLoading, rowConfig } = props;
1116
- const tableContainerRef = (0, import_react6.useRef)(null);
1121
+ const tableContainerRef = (0, import_react7.useRef)(null);
1117
1122
  console.log("DataTable", { container: tableContainerRef.current });
1118
1123
  const onTableContainerScroll = useFetchMoreOnBottomReached(
1119
1124
  tableContainerRef,
1120
1125
  props.infiniteScroll
1121
1126
  );
1122
- const [hasRef, setHasRef] = (0, import_react6.useState)(false);
1123
- (0, import_react6.useEffect)(() => {
1127
+ const [hasRef, setHasRef] = (0, import_react7.useState)(false);
1128
+ (0, import_react7.useEffect)(() => {
1124
1129
  var _a2;
1125
1130
  console.log((_a2 = tableContainerRef.current) == null ? void 0 : _a2.toString());
1126
1131
  setHasRef(Boolean(tableContainerRef.current));
1127
- }, [(_q = tableContainerRef.current) == null ? void 0 : _q.toString()]);
1132
+ }, [tableContainerRef.current === null]);
1128
1133
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(DataTableWrapper, {
1129
1134
  height: props == null ? void 0 : props.height,
1130
1135
  width: props == null ? void 0 : props.width,
@@ -1138,9 +1143,9 @@ function DataTable(props) {
1138
1143
  }),
1139
1144
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", {
1140
1145
  ...props.tableContainerProps,
1141
- className: "--table-container " + (((_r = props.tableContainerProps) == null ? void 0 : _r.className) ?? ""),
1146
+ className: "--table-container " + (((_q = props.tableContainerProps) == null ? void 0 : _q.className) ?? ""),
1142
1147
  style: { contain: "strict" },
1143
- onScroll: ((_s = props.tableContainerProps) == null ? void 0 : _s.onScroll) ?? onTableContainerScroll,
1148
+ onScroll: ((_r = props.tableContainerProps) == null ? void 0 : _r.onScroll) ?? onTableContainerScroll,
1144
1149
  ref: (node) => {
1145
1150
  var _a2;
1146
1151
  console.log({ node });
package/dist/index.mjs CHANGED
@@ -881,6 +881,7 @@ function TableBanner({
881
881
 
882
882
  // src/DataTable/components/VirtualTableBody.tsx
883
883
  import { useVirtualizer } from "@tanstack/react-virtual";
884
+ import { memo } from "react";
884
885
 
885
886
  // src/DataTable/components/PaddingRow.tsx
886
887
  import { Table as Table8 } from "@equinor/eds-core-react";
@@ -944,6 +945,10 @@ function VirtualTableBody({
944
945
  ]
945
946
  });
946
947
  }
948
+ var Memo_VirtualTableBody = memo(
949
+ VirtualTableBody,
950
+ (prev, next) => prev.containerRef.current === next.containerRef.current
951
+ );
947
952
 
948
953
  // src/DataTable/hooks/useFetchMoreOnBottomReached.tsx
949
954
  import { useCallback, useEffect as useEffect2 } from "react";
@@ -994,7 +999,7 @@ var DataTableWrapper = styled16.div`
994
999
  }
995
1000
  `;
996
1001
  function DataTable(props) {
997
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1002
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
998
1003
  const { columns, data, bannerConfig, cellConfig, sorting } = props;
999
1004
  const [internalColumnVisibility, setInternalColumnVisibility] = useState5({});
1000
1005
  const [columnVisibility, setColumnVisibility] = [
@@ -1081,7 +1086,7 @@ function DataTable(props) {
1081
1086
  var _a2;
1082
1087
  console.log((_a2 = tableContainerRef.current) == null ? void 0 : _a2.toString());
1083
1088
  setHasRef(Boolean(tableContainerRef.current));
1084
- }, [(_q = tableContainerRef.current) == null ? void 0 : _q.toString()]);
1089
+ }, [tableContainerRef.current === null]);
1085
1090
  return /* @__PURE__ */ jsxs11(DataTableWrapper, {
1086
1091
  height: props == null ? void 0 : props.height,
1087
1092
  width: props == null ? void 0 : props.width,
@@ -1095,9 +1100,9 @@ function DataTable(props) {
1095
1100
  }),
1096
1101
  /* @__PURE__ */ jsx19("div", {
1097
1102
  ...props.tableContainerProps,
1098
- className: "--table-container " + (((_r = props.tableContainerProps) == null ? void 0 : _r.className) ?? ""),
1103
+ className: "--table-container " + (((_q = props.tableContainerProps) == null ? void 0 : _q.className) ?? ""),
1099
1104
  style: { contain: "strict" },
1100
- onScroll: ((_s = props.tableContainerProps) == null ? void 0 : _s.onScroll) ?? onTableContainerScroll,
1105
+ onScroll: ((_r = props.tableContainerProps) == null ? void 0 : _r.onScroll) ?? onTableContainerScroll,
1101
1106
  ref: (node) => {
1102
1107
  var _a2;
1103
1108
  console.log({ node });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "3.1.2-rowfix.16",
3
+ "version": "3.1.2-rowfix.17",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",