@longline/aqua-ui 1.0.126 → 1.0.128
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.
|
@@ -4,5 +4,5 @@ import { IColumnProps } from './Column';
|
|
|
4
4
|
interface IProps extends IListViewProps {
|
|
5
5
|
columns: IColumnProps[];
|
|
6
6
|
}
|
|
7
|
-
declare const Body:
|
|
7
|
+
declare const Body: React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLElement>>;
|
|
8
8
|
export { Body };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Selector } from '../../inputs/Selector';
|
|
3
|
-
var Body = function (props) {
|
|
3
|
+
var Body = React.forwardRef(function (props, ref) {
|
|
4
4
|
return (React.createElement("tbody", null, Array.isArray(props.data) && props.data.map(function (row, index) {
|
|
5
5
|
return React.createElement("tr", { key: index,
|
|
6
6
|
// Set classnames for tr; styles are in Table.
|
|
@@ -16,9 +16,11 @@ var Body = function (props) {
|
|
|
16
16
|
React.createElement("span", { className: "label" }, props.narrow && col.name),
|
|
17
17
|
React.createElement("span", { className: "content" },
|
|
18
18
|
" ",
|
|
19
|
-
col.children(row))
|
|
19
|
+
col.children(row)),
|
|
20
|
+
index == props.columns.length - 1 &&
|
|
21
|
+
React.createElement("div", { style: { position: 'absolute', top: 0, right: 0 }, ref: (props.active == row ? ref : null) }));
|
|
20
22
|
}),
|
|
21
23
|
props.columnsEditable && React.createElement("td", null));
|
|
22
24
|
})));
|
|
23
|
-
};
|
|
25
|
+
});
|
|
24
26
|
export { Body };
|
|
@@ -26,6 +26,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
26
26
|
};
|
|
27
27
|
import * as React from 'react';
|
|
28
28
|
import styled, { css } from 'styled-components';
|
|
29
|
+
import { usePopper } from 'react-popper';
|
|
29
30
|
import { Header } from './Header';
|
|
30
31
|
import { Body } from './Body';
|
|
31
32
|
import { darken } from '../../helper/darken';
|
|
@@ -36,57 +37,49 @@ import { Anchor } from '../../containers/Anchor';
|
|
|
36
37
|
var HEADER_HEIGHT = 48;
|
|
37
38
|
var TableBase = function (_a) {
|
|
38
39
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
39
|
-
var scrollPos = React.useRef(0);
|
|
40
|
-
var wrapperRef = React.useRef(null);
|
|
41
40
|
var innerRef = React.useRef(null);
|
|
42
41
|
var auxRef = React.useRef(null);
|
|
43
42
|
var activeColumns = props.columns.filter(function (c) { return c.active; });
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
43
|
+
var _b = React.useState(null), activeRef = _b[0], setActiveRef = _b[1];
|
|
44
|
+
var _c = usePopper(activeRef, auxRef.current, {
|
|
45
|
+
placement: 'right-start',
|
|
46
|
+
modifiers: [
|
|
47
|
+
{
|
|
48
|
+
name: 'offset',
|
|
49
|
+
options: {
|
|
50
|
+
offset: [0, 16],
|
|
51
|
+
},
|
|
52
|
+
}, {
|
|
53
|
+
name: 'flip',
|
|
54
|
+
enabled: false
|
|
55
|
+
}, {
|
|
56
|
+
name: 'preventOverflow',
|
|
57
|
+
options: {
|
|
58
|
+
boundary: innerRef.current,
|
|
59
|
+
tether: false,
|
|
60
|
+
padding: { top: HEADER_HEIGHT }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}), styles = _c.styles, attributes = _c.attributes, update = _c.update;
|
|
64
65
|
React.useEffect(function () {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return function () { return resizeObserver.disconnect(); };
|
|
70
|
-
}, []);
|
|
71
|
-
var handleScroll = function () {
|
|
72
|
-
if (innerRef.current == null)
|
|
73
|
-
return;
|
|
74
|
-
setAuxPosition(innerRef.current.scrollTop);
|
|
75
|
-
};
|
|
76
|
-
return (React.createElement(Wrapper, { "$dark": props.dark, ref: wrapperRef },
|
|
66
|
+
if (update)
|
|
67
|
+
update();
|
|
68
|
+
}, [props.active]);
|
|
69
|
+
return (React.createElement(Wrapper, { "$dark": props.dark },
|
|
77
70
|
props.columnsMode &&
|
|
78
71
|
React.createElement(Anchor, { right: "32px", top: "64px" },
|
|
79
72
|
React.createElement(ColumnsManager, { columns: props.columns, onChange: props.onChangeColumns, onClose: props.onCloseColumns, onReset: props.onResetColumns })),
|
|
80
73
|
(!Array.isArray(props.data) || props.data.length == 0) &&
|
|
81
74
|
React.createElement(NoData, { dark: props.dark, component: props.noData }),
|
|
82
|
-
React.createElement(AuxHolder, { ref: auxRef, style: { visibility: (props.active && props.aux && Array.isArray(props.data) && props.data.includes(props.active)) ? 'visible' : 'hidden' } }, (props.active && props.aux && Array.isArray(props.data) && props.data.includes(props.active)) && React.cloneElement(props.aux, { value: props.active })),
|
|
83
|
-
React.createElement(Inner, {
|
|
75
|
+
React.createElement(AuxHolder, __assign({ ref: auxRef, style: __assign({ visibility: (props.active && props.aux && Array.isArray(props.data) && props.data.includes(props.active)) ? 'visible' : 'hidden' }, styles.popper) }, attributes.popper), (props.active && props.aux && Array.isArray(props.data) && props.data.includes(props.active)) && React.cloneElement(props.aux, { value: props.active })),
|
|
76
|
+
React.createElement(Inner, { ref: innerRef },
|
|
84
77
|
React.createElement("table", { className: className },
|
|
85
78
|
props.noheader != true && React.createElement(Header, __assign({}, props, { columns: activeColumns, onOpenColumns: props.onOpenColumns })),
|
|
86
|
-
React.createElement(Body, __assign({}, props, { columns: activeColumns })))),
|
|
79
|
+
React.createElement(Body, __assign({ ref: setActiveRef }, props, { columns: activeColumns })))),
|
|
87
80
|
props.total && Array.isArray(props.data) && React.createElement(Total, { value: props.data.length, singular: props.singular, plural: props.plural })));
|
|
88
81
|
};
|
|
89
|
-
var AuxHolder = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n
|
|
82
|
+
var AuxHolder = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n z-index: 1;\n"], ["\n z-index: 1;\n"])));
|
|
90
83
|
var Wrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // Size and position. A table fills its container.\n position: relative;\n width: 100%;\n height: 100%;\n background-color: ", ";\n"], ["\n // Size and position. A table fills its container.\n position: relative;\n width: 100%;\n height: 100%;\n background-color: ", ";\n"])), function (p) { return p.$dark ? p.theme.colors.primary[3] : p.theme.colors.neutral[100]; });
|
|
91
84
|
var Inner = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n overflow-y: auto;\n"], ["\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n overflow-y: auto;\n"])));
|
|
92
85
|
var TableStyled = styled(TableBase)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n position: absolute;\n box-sizing: border-box;\n left: 0;\n top: 0;\n width: 100%;\n border-collapse: collapse; \n table-layout: fixed; \n padding-bottom: 48px;\n\n // Grid:\n display: grid;\n grid-template-rows: ", "px;\n grid-auto-rows: ", "px;\n\n // Convert column widths a string suitable for grid template:\n grid-template-columns: ", ";\n\n // Appearance:\n font: ", ";\n color: ", ";\n background-color: ", ";\n\n // <thead>, <tbody> and <tr> must not participate in CSS grid:\n tr, tbody, thead { display: contents; }\n\n // <tr>,<th>,<td> must be styled here, once, because otherwise \n // styled-components would create too many classes.\n tr {\n position: relative;\n }\n tr.clickable {\n cursor: pointer;\n }\n\n // Optional row hover effect:\n ", "\n\n // Striped rows:\n ", "\n\n // General styles for both TD and TH:\n th, td {\n position: relative;\n box-sizing: border-box;\n white-space: nowrap;\n text-align: left;\n user-select: none;\n outline: none;\n padding-left: 16px;\n padding-right: 16px; \n\n // th, td use flexbox to vertical-align content:\n display: flex;\n align-items: center;\n justify-content: left;\n\n // Underline.\n &:after {\n content: '';\n position: absolute;\n left: 0;\n bottom: 0;\n right: 0;\n height: 1px;\n transition: background-color ", "ms ease-in-out;\n } \n }\n\n th {\n // Position and size:\n position: sticky;\n top: 0;\n z-index: 100;\n gap: 8px;\n justify-content: space-between;\n // Appearance\n background: ", ";\n &.sort {\n background: ", ";\n }\n &:after { \n background-color: ", "; \n }\n // Header shadow:\n ", "\n }\n // td bottom border color:\n td {\n &:after {\n background-color: ", ";\n } \n }\n // Active row TDs:\n tr.active td {\n background-color: ", ";\n }\n // Last column has double right margin:\n td:last-child {\n padding-right: 32px;\n }\n // Last row has no bottom border:\n tr:last-child td {\n &:after {\n visibility: hidden;\n } \n }\n // Spans in td/th are ellipsized:\n td > span, th > span {\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n // Grid:\n ", "\n\n // If onColumns is present, remove last column header's hover underline:\n // Also remove last gridline.\n ", "\n\n // Change styles for table to be vertically oriented:\n ", "\n"], ["\n position: absolute;\n box-sizing: border-box;\n left: 0;\n top: 0;\n width: 100%;\n border-collapse: collapse; \n table-layout: fixed; \n padding-bottom: 48px;\n\n // Grid:\n display: grid;\n grid-template-rows: ", "px;\n grid-auto-rows: ", "px;\n\n // Convert column widths a string suitable for grid template:\n grid-template-columns: ", ";\n\n // Appearance:\n font: ", ";\n color: ", ";\n background-color: ", ";\n\n // <thead>, <tbody> and <tr> must not participate in CSS grid:\n tr, tbody, thead { display: contents; }\n\n // <tr>,<th>,<td> must be styled here, once, because otherwise \n // styled-components would create too many classes.\n tr {\n position: relative;\n }\n tr.clickable {\n cursor: pointer;\n }\n\n // Optional row hover effect:\n ", "\n\n // Striped rows:\n ", "\n\n // General styles for both TD and TH:\n th, td {\n position: relative;\n box-sizing: border-box;\n white-space: nowrap;\n text-align: left;\n user-select: none;\n outline: none;\n padding-left: 16px;\n padding-right: 16px; \n\n // th, td use flexbox to vertical-align content:\n display: flex;\n align-items: center;\n justify-content: left;\n\n // Underline.\n &:after {\n content: '';\n position: absolute;\n left: 0;\n bottom: 0;\n right: 0;\n height: 1px;\n transition: background-color ", "ms ease-in-out;\n } \n }\n\n th {\n // Position and size:\n position: sticky;\n top: 0;\n z-index: 100;\n gap: 8px;\n justify-content: space-between;\n // Appearance\n background: ", ";\n &.sort {\n background: ", ";\n }\n &:after { \n background-color: ", "; \n }\n // Header shadow:\n ", "\n }\n // td bottom border color:\n td {\n &:after {\n background-color: ", ";\n } \n }\n // Active row TDs:\n tr.active td {\n background-color: ", ";\n }\n // Last column has double right margin:\n td:last-child {\n padding-right: 32px;\n }\n // Last row has no bottom border:\n tr:last-child td {\n &:after {\n visibility: hidden;\n } \n }\n // Spans in td/th are ellipsized:\n td > span, th > span {\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n // Grid:\n ", "\n\n // If onColumns is present, remove last column header's hover underline:\n // Also remove last gridline.\n ", "\n\n // Change styles for table to be vertically oriented:\n ", "\n"])), HEADER_HEIGHT, function (p) { return p.rowHeight; }, function (p) {
|