trotl-table 1.0.77 → 1.0.79

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/Table.cjs.js CHANGED
@@ -9677,6 +9677,7 @@ function TableInner({
9677
9677
  customColumns = [],
9678
9678
  groupDefaultOpen = false,
9679
9679
  showIcons = true,
9680
+ timeoutLoading = 5,
9680
9681
  t
9681
9682
  }) {
9682
9683
  let translate;
@@ -10249,6 +10250,20 @@ function TableInner({
10249
10250
  return map;
10250
10251
  }, [sortedGroupedData, groupKey]);
10251
10252
  const [tableDataFlat, setTableDataFlat] = React.useState([]);
10253
+ const [loadingTimeoutReached, setLoadingTimeoutReached] = React.useState(false);
10254
+ React.useEffect(() => {
10255
+ if (tableDataFlat.length > 0) {
10256
+ setLoadingTimeoutReached(false);
10257
+ return undefined;
10258
+ }
10259
+ const timeoutSeconds = Number(timeoutLoading) && Number(timeoutLoading) >= 0 ? Number(timeoutLoading) : 5;
10260
+ const timerId = window.setTimeout(() => {
10261
+ setLoadingTimeoutReached(true);
10262
+ }, timeoutSeconds * 1000);
10263
+ return () => {
10264
+ window.clearTimeout(timerId);
10265
+ };
10266
+ }, [tableDataFlat.length, timeoutLoading]);
10252
10267
  const flattened = React.useMemo(() => {
10253
10268
  const items = [];
10254
10269
  // Use the sortedGroupedData here so the flattened list reflects current sorting and filtering
@@ -11182,7 +11197,14 @@ function TableInner({
11182
11197
  }, "\u2699\uFE0F") : translate("action")))), /*#__PURE__*/React.createElement("div", {
11183
11198
  className: "main-table",
11184
11199
  ref: listRef
11185
- }, tableDataFlat.length === 0 ? /*#__PURE__*/React.createElement(DotsLoading.default, null) : /*#__PURE__*/React.createElement(AutoSizer, null, ({
11200
+ }, tableDataFlat.length === 0 && !loadingTimeoutReached ? /*#__PURE__*/React.createElement(DotsLoading.default, null) : tableDataFlat.length === 0 && loadingTimeoutReached ? /*#__PURE__*/React.createElement("div", {
11201
+ className: "table-empty",
11202
+ style: {
11203
+ padding: 24,
11204
+ textAlign: 'center',
11205
+ color: '#666'
11206
+ }
11207
+ }, translate("noData")) : /*#__PURE__*/React.createElement(AutoSizer, null, ({
11186
11208
  height,
11187
11209
  width
11188
11210
  }) => /*#__PURE__*/React.createElement(List, {