datastake-daf 0.6.187 → 0.6.188

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.
@@ -1,35 +1,94 @@
1
- import React from 'react';
2
- import { Table } from 'antd';
3
- import PropTypes from 'prop-types'
1
+ import React from "react";
2
+ import styled from "styled-components";
3
+ import { Table } from "antd";
4
+ import PropTypes from "prop-types";
5
+ import ComponentWithFocus from "../../Dashboard/ComponentWithFocus/index.jsx";
4
6
 
5
7
  export default function StickyTable({
6
8
  size = null,
7
9
  maxHeight = 300,
10
+ containerHeight = 525,
8
11
  dataSource = [],
9
12
  columns = {},
10
13
  pagination = false,
14
+ doEmptyRows = true,
11
15
  ...props
12
16
  }) {
17
+ const data = React.useMemo(() => {
18
+ const MIN_ROWS = 4;
19
+
20
+ if (dataSource.length < MIN_ROWS) {
21
+ const paddedData = [...dataSource];
22
+ while (paddedData.length < MIN_ROWS) {
23
+ paddedData.push({ empty: true });
24
+ }
25
+ return paddedData;
26
+ }
27
+
28
+ return dataSource;
29
+ }, [dataSource]);
30
+
31
+ const Wrapper = React.useMemo(() => {
32
+ return data.length > 5 ? ComponentWithFocus : "div";
33
+ }, [data.length]);
34
+
13
35
  return (
14
- <div className="daf-sticky-table">
15
- <Table
16
- {...props}
17
- size={size}
18
- scroll
19
- sticky
20
- style={{ maxHeight }}
21
- dataSource={dataSource}
22
- columns={columns}
23
- pagination={pagination}
24
- />
25
- </div>
36
+ <Wrapper>
37
+ <Style>
38
+ <div
39
+ className="daf-table-wrapper"
40
+ style={{
41
+ maxHeight: containerHeight,
42
+ overflowY: "auto",
43
+ }}
44
+ >
45
+ <div className="daf-sticky-table">
46
+ <Table
47
+ {...props}
48
+ size={size}
49
+ scroll
50
+ sticky
51
+ style={{ maxHeight }}
52
+ dataSource={data}
53
+ columns={columns}
54
+ pagination={pagination}
55
+ />
56
+ </div>
57
+ </div>
58
+ </Style>
59
+ </Wrapper>
26
60
  );
27
61
  }
28
62
 
63
+ const Style = styled.div`
64
+ max-width: calc(100% - 48px);
65
+ margin-left: var(--size-lg);
66
+ overflow: hidden;
67
+
68
+ .daf-table {
69
+ padding: 0px;
70
+ margin-top: 0px;
71
+
72
+ .ant-tag {
73
+ text-align: center;
74
+ }
75
+ }
76
+
77
+ .daf-select-filters .filters {
78
+ padding-top: 16px;
79
+ padding-left: 0;
80
+ padding-right: 0;
81
+ }
82
+
83
+ .daf-table {
84
+ padding-top: 16px;
85
+ }
86
+ `;
87
+
29
88
  StickyTable.propTypes = {
30
89
  size: PropTypes.any,
31
90
  maxHeight: PropTypes.number,
32
91
  dataSource: PropTypes.array,
33
92
  columns: PropTypes.object,
34
93
  pagination: PropTypes.any,
35
- }
94
+ };