@cloudtower/eagle 0.29.1 → 0.29.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.
@@ -5,6 +5,7 @@ import { ColumnTitle, TableLoading } from './TableWidget.js';
5
5
  export { EmptyRowMenu, KitTableContext } from './TableWidget.js';
6
6
  import { Table as Table$2 } from 'antd';
7
7
  import cs from 'classnames';
8
+ import { isNil } from 'lodash';
8
9
  import React__default, { useRef, useMemo } from 'react';
9
10
 
10
11
  var __defProp = Object.defineProperty;
@@ -31,9 +32,9 @@ const TableContainerStyle = "E_tc97u5y";
31
32
  const tableStyleCover = "E_tfzf37v";
32
33
  const Table = props => {
33
34
  const {
34
- loading,
35
+ loading = false,
35
36
  error,
36
- dataSource,
37
+ dataSource: _dataSource,
37
38
  columns,
38
39
  onSorterChange,
39
40
  onRowClick,
@@ -51,7 +52,7 @@ const Table = props => {
51
52
  onRow
52
53
  } = props;
53
54
  const orderRef = useRef(null);
54
- const hasScrollBard = useTableBodyHasScrollBar(wrapper, dataSource);
55
+ const hasScrollBard = useTableBodyHasScrollBar(wrapper, _dataSource);
55
56
  const _columns = useMemo(() => columns.map(column => {
56
57
  const _column = __spreadValues({}, column);
57
58
  if (_column.sorter && typeof _column.title !== "function") {
@@ -65,6 +66,21 @@ const Table = props => {
65
66
  }
66
67
  return _column;
67
68
  }), [columns]);
69
+ const dataSource = useMemo(() => {
70
+ if (!isNil(error) || loading) {
71
+ return [];
72
+ }
73
+ return _dataSource != null ? _dataSource : [];
74
+ }, [_dataSource, error, loading]);
75
+ const emptyText = useMemo(() => {
76
+ if (loading) {
77
+ return "";
78
+ }
79
+ if (!isNil(error)) {
80
+ return error;
81
+ }
82
+ return empty;
83
+ }, [empty, error, loading]);
68
84
  return /* @__PURE__ */React__default.createElement("div", {
69
85
  className: cx(TableContainerStyle, "table-container", !hasScrollBard && "no-scroll-bar")
70
86
  }, /* @__PURE__ */React__default.createElement(Table$2, {
@@ -75,9 +91,9 @@ const Table = props => {
75
91
  indicator: initLoading ? /* @__PURE__ */React__default.createElement(TableLoading, null) : /* @__PURE__ */React__default.createElement(Loading, null)
76
92
  },
77
93
  locale: {
78
- emptyText: error || /* @__PURE__ */React__default.createElement(React__default.Fragment, null, loading ? "" : empty)
94
+ emptyText
79
95
  },
80
- dataSource: dataSource || [],
96
+ dataSource,
81
97
  pagination: pagination || false,
82
98
  columns: _columns,
83
99
  components,