@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.
- package/README.md +6 -10
- package/dist/cjs/core/Table/index.js +21 -5
- package/dist/cjs/stats1.html +1 -1
- package/dist/components.css +2004 -2004
- package/dist/esm/core/Table/index.js +21 -5
- package/dist/esm/stats1.html +1 -1
- package/dist/stories/docs/core/KitStoreProvider.stories.d.ts +23 -0
- package/dist/stories/docs/core/Table.stories.d.ts +47 -16
- package/dist/style.css +1752 -1752
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -25,32 +25,28 @@ initParrotI18n();
|
|
|
25
25
|
// Set Up Providers
|
|
26
26
|
ReactDOM.render(
|
|
27
27
|
<React.StrictMode>
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
<UIKitProvider>
|
|
32
|
-
</KitStoreProvider>
|
|
28
|
+
<UIKitProvider>
|
|
29
|
+
<App />
|
|
30
|
+
<UIKitProvider>
|
|
33
31
|
</React.StrictMode>,
|
|
34
32
|
document.getElementById("root") as HTMLElement
|
|
35
33
|
);
|
|
36
34
|
```
|
|
37
35
|
|
|
38
36
|
```tsx
|
|
39
|
-
import {
|
|
37
|
+
import { Button } from "@cloudtower/eagle";
|
|
40
38
|
import React, { useContext } from "react";
|
|
41
39
|
|
|
42
40
|
const App = () => {
|
|
43
|
-
// Use Component
|
|
44
|
-
const kit = useUIKit();
|
|
45
41
|
return (
|
|
46
42
|
<div>
|
|
47
|
-
<
|
|
43
|
+
<Button
|
|
48
44
|
onClick={() => {
|
|
49
45
|
alert("hello");
|
|
50
46
|
}}
|
|
51
47
|
>
|
|
52
48
|
say hello
|
|
53
|
-
</
|
|
49
|
+
</Button>
|
|
54
50
|
</div>
|
|
55
51
|
);
|
|
56
52
|
};
|
|
@@ -8,6 +8,7 @@ var common = require('./common.js');
|
|
|
8
8
|
var TableWidget = require('./TableWidget.js');
|
|
9
9
|
var antd = require('antd');
|
|
10
10
|
var cs = require('classnames');
|
|
11
|
+
var _ = require('lodash');
|
|
11
12
|
var React = require('react');
|
|
12
13
|
|
|
13
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -39,9 +40,9 @@ const TableContainerStyle = "E_tc97u5y";
|
|
|
39
40
|
const tableStyleCover = "E_tfzf37v";
|
|
40
41
|
const Table = props => {
|
|
41
42
|
const {
|
|
42
|
-
loading,
|
|
43
|
+
loading = false,
|
|
43
44
|
error,
|
|
44
|
-
dataSource,
|
|
45
|
+
dataSource: _dataSource,
|
|
45
46
|
columns,
|
|
46
47
|
onSorterChange,
|
|
47
48
|
onRowClick,
|
|
@@ -59,7 +60,7 @@ const Table = props => {
|
|
|
59
60
|
onRow
|
|
60
61
|
} = props;
|
|
61
62
|
const orderRef = React.useRef(null);
|
|
62
|
-
const hasScrollBard = common.useTableBodyHasScrollBar(wrapper,
|
|
63
|
+
const hasScrollBard = common.useTableBodyHasScrollBar(wrapper, _dataSource);
|
|
63
64
|
const _columns = React.useMemo(() => columns.map(column => {
|
|
64
65
|
const _column = __spreadValues({}, column);
|
|
65
66
|
if (_column.sorter && typeof _column.title !== "function") {
|
|
@@ -73,6 +74,21 @@ const Table = props => {
|
|
|
73
74
|
}
|
|
74
75
|
return _column;
|
|
75
76
|
}), [columns]);
|
|
77
|
+
const dataSource = React.useMemo(() => {
|
|
78
|
+
if (!_.isNil(error) || loading) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return _dataSource != null ? _dataSource : [];
|
|
82
|
+
}, [_dataSource, error, loading]);
|
|
83
|
+
const emptyText = React.useMemo(() => {
|
|
84
|
+
if (loading) {
|
|
85
|
+
return "";
|
|
86
|
+
}
|
|
87
|
+
if (!_.isNil(error)) {
|
|
88
|
+
return error;
|
|
89
|
+
}
|
|
90
|
+
return empty;
|
|
91
|
+
}, [empty, error, loading]);
|
|
76
92
|
return /* @__PURE__ */React__default.default.createElement("div", {
|
|
77
93
|
className: core.cx(TableContainerStyle, "table-container", !hasScrollBard && "no-scroll-bar")
|
|
78
94
|
}, /* @__PURE__ */React__default.default.createElement(antd.Table, {
|
|
@@ -83,9 +99,9 @@ const Table = props => {
|
|
|
83
99
|
indicator: initLoading ? /* @__PURE__ */React__default.default.createElement(TableWidget.TableLoading, null) : /* @__PURE__ */React__default.default.createElement(index, null)
|
|
84
100
|
},
|
|
85
101
|
locale: {
|
|
86
|
-
emptyText
|
|
102
|
+
emptyText
|
|
87
103
|
},
|
|
88
|
-
dataSource
|
|
104
|
+
dataSource,
|
|
89
105
|
pagination: pagination || false,
|
|
90
106
|
columns: _columns,
|
|
91
107
|
components,
|