@cloudtower/eagle 0.29.5 → 0.29.7

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.
@@ -0,0 +1,57 @@
1
+ import React__default from 'react';
2
+ import useElementsSize from '../../hooks/useElementsSize.js';
3
+
4
+ const TableSkeleton = props => {
5
+ const {
6
+ rows: _rowLength,
7
+ scrollY = false,
8
+ headerHeight = 48,
9
+ itemHeight: _itemHeight
10
+ } = props;
11
+ const sizes = useElementsSize({
12
+ loading: ".ant-table-container .ant-table-content .ant-table-tbody",
13
+ scrollYLoading: ".ant-table-container .ant-table-tbody"
14
+ }, {});
15
+ const itemSizes = useElementsSize({
16
+ loading: ".ant-table-container .ant-table-content .ant-table-tbody > tr:not(:first-child)",
17
+ scrollYLoading: ".ant-table-container .ant-table-tbody > tr:not(:first-child)"
18
+ }, {});
19
+ const itemHeight = (_itemHeight != null ? _itemHeight : itemSizes[scrollY ? "scrollYLoading" : "loading"].height) || 40;
20
+ const rowLength = (_rowLength != null ? _rowLength : Math.ceil(sizes[scrollY ? "scrollYLoading" : "loading"].height / itemHeight)) || 20;
21
+ const rows = Array.from({
22
+ length: rowLength
23
+ }, (r, i) => i);
24
+ return /* @__PURE__ */React__default.createElement("div", {
25
+ className: `${TableLoadingStyle} table-loading`
26
+ }, /* @__PURE__ */React__default.createElement("div", {
27
+ className: "table-loading-header table-loading-item",
28
+ style: {
29
+ height: headerHeight
30
+ }
31
+ }, /* @__PURE__ */React__default.createElement("div", {
32
+ className: "checkbox-loading"
33
+ }), /* @__PURE__ */React__default.createElement("div", {
34
+ className: "td-loading"
35
+ }), /* @__PURE__ */React__default.createElement("div", {
36
+ className: "td-loading"
37
+ }), /* @__PURE__ */React__default.createElement("div", {
38
+ className: "td-loading"
39
+ })), rows.map(i => /* @__PURE__ */React__default.createElement("div", {
40
+ key: i,
41
+ className: "table-loading-item",
42
+ style: {
43
+ height: itemHeight
44
+ }
45
+ }, /* @__PURE__ */React__default.createElement("div", {
46
+ className: "checkbox-loading"
47
+ }), /* @__PURE__ */React__default.createElement("div", {
48
+ className: "td-loading"
49
+ }), /* @__PURE__ */React__default.createElement("div", {
50
+ className: "td-loading"
51
+ }), /* @__PURE__ */React__default.createElement("div", {
52
+ className: "td-loading"
53
+ }))));
54
+ };
55
+ const TableLoadingStyle = "E_t1g36k2w";
56
+
57
+ export { TableSkeleton };
@@ -1,12 +1,12 @@
1
1
  import { cx } from '@linaria/core';
2
- import Loading from '../Loading/index.js';
3
2
  import { useTableBodyHasScrollBar } from './common.js';
4
- import { ColumnTitle, TableLoading } from './TableWidget.js';
5
- export { EmptyRowMenu, KitTableContext } from './TableWidget.js';
3
+ import { ColumnTitle } from './TableWidget.js';
4
+ export { EmptyRowMenu, KitTableContext, TableLoading } from './TableWidget.js';
6
5
  import { Table as Table$2 } from 'antd';
7
6
  import cs from 'classnames';
8
7
  import { isNil } from 'lodash';
9
8
  import React__default, { useRef, useMemo } from 'react';
9
+ import { TableSkeleton } from './TableSkeleton.js';
10
10
 
11
11
  var __defProp = Object.defineProperty;
12
12
  var __defProps = Object.defineProperties;
@@ -31,6 +31,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
31
31
  const TableContainerStyle = "E_tc97u5y";
32
32
  const tableStyleCover = "E_tfzf37v";
33
33
  const Table = props => {
34
+ var _a;
34
35
  const {
35
36
  loading = false,
36
37
  error,
@@ -45,11 +46,13 @@ const Table = props => {
45
46
  rowSelection,
46
47
  empty,
47
48
  tableLayout = "fixed",
48
- initLoading,
49
+ // FIXME Should be removed at 0.30.x
50
+ initLoading = false,
49
51
  rowKey,
50
52
  wrapper,
51
53
  pagination,
52
- onRow
54
+ onRow,
55
+ skeletonProps
53
56
  } = props;
54
57
  const orderRef = useRef(null);
55
58
  const hasScrollBard = useTableBodyHasScrollBar(wrapper, _dataSource);
@@ -67,7 +70,10 @@ const Table = props => {
67
70
  return _column;
68
71
  }), [columns]);
69
72
  const dataSource = useMemo(() => {
70
- if (!isNil(error) || loading) {
73
+ if (loading) {
74
+ return _dataSource;
75
+ }
76
+ if (!isNil(error)) {
71
77
  return [];
72
78
  }
73
79
  return _dataSource != null ? _dataSource : [];
@@ -84,11 +90,13 @@ const Table = props => {
84
90
  return /* @__PURE__ */React__default.createElement("div", {
85
91
  className: cx(TableContainerStyle, "table-container", !hasScrollBard && "no-scroll-bar")
86
92
  }, /* @__PURE__ */React__default.createElement(Table$2, {
87
- className: cs(tableStyleCover, !(dataSource == null ? void 0 : dataSource.length) && "empty-table", initLoading && "table-init-loading", rowSelection && "has-selection"),
93
+ className: cs(tableStyleCover, !(dataSource == null ? void 0 : dataSource.length) && "empty-table", rowSelection && "has-selection"),
88
94
  bordered,
89
95
  loading: {
90
- spinning: loading,
91
- indicator: initLoading ? /* @__PURE__ */React__default.createElement(TableLoading, null) : /* @__PURE__ */React__default.createElement(Loading, null)
96
+ spinning: loading || initLoading,
97
+ indicator: /* @__PURE__ */React__default.createElement(TableSkeleton, __spreadValues({
98
+ scrollY: !!((_a = props.scroll) == null ? void 0 : _a.y)
99
+ }, skeletonProps))
92
100
  },
93
101
  locale: {
94
102
  emptyText
@@ -119,4 +127,4 @@ const Table = props => {
119
127
  };
120
128
  var Table$1 = Table;
121
129
 
122
- export { ColumnTitle, TableLoading, Table$1 as default, tableStyleCover, useTableBodyHasScrollBar };
130
+ export { ColumnTitle, TableSkeleton, Table$1 as default, tableStyleCover, useTableBodyHasScrollBar };
package/dist/esm/index.js CHANGED
@@ -97,6 +97,7 @@ export { SidebarMenu } from './core/SidebarMenu/SidebarMenu.js';
97
97
  export { CircleProgress } from './core/StepProgress/index.js';
98
98
  export { CannotOperationInfo, CommonContent, ContentWrapper, Desc, Description, Divider, Dot, ErrorSpan, ExpandArrow, FieldTitle, FormField, FormItemDiv, FormSectionTitle, FormWrapper, FullView, HorizontalWizardModalCompactStyle, HorizontalWizardModalLooseStyle, InfoAlert, InputStyle, KitInputStyle, LeftEndInputStyle, LeftEndSelectStyle, LightDesc, LoadingWrapper, ModalBody, ModalWrapper, NameTag, NormalAlert, NoticeAlert, OperationWraper, RadioDesc, RightEndInputStyle, RightEndSelectStyle, SelectOptionDisabledText, TagSpan, TertiaryText, WarningAlert, WizardBody, radioStyle } from './core/Styled/index.js';
99
99
  export { useTableBodyHasScrollBar } from './core/Table/common.js';
100
+ export { TableSkeleton } from './core/Table/TableSkeleton.js';
100
101
  export { ColumnTitle, EmptyRowMenu, KitTableContext, TableLoading } from './core/Table/TableWidget.js';
101
102
  export { ValidateTriggerType } from './core/TableForm/types.js';
102
103
  export { Typo } from './core/Typo/index.js';