@smart-react-components/ui 2.0.0-alpha-35 → 2.0.0-alpha-36
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/Table/TableContainer.js +27 -2
- package/Table/Td.d.ts +6 -2
- package/Table/Td.js +9 -1
- package/Table/index.d.ts +0 -2
- package/Table/index.js +0 -2
- package/package.json +1 -1
package/Table/TableContainer.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const element_props_1 = __importDefault(require("@smart-react-components/core/element-props"));
|
|
7
|
+
const useChangeEffect_1 = __importDefault(require("@smart-react-components/core/hooks/useChangeEffect"));
|
|
7
8
|
const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
|
|
8
9
|
const dom_1 = require("@smart-react-components/core/util/dom");
|
|
9
10
|
const react_1 = __importDefault(require("react"));
|
|
@@ -24,6 +25,7 @@ const TableContainer = props => {
|
|
|
24
25
|
let left = 0;
|
|
25
26
|
let leftZIndex = x + 1;
|
|
26
27
|
const xEls = el.current.querySelectorAll('table:first-child > * > tr > *');
|
|
28
|
+
const yEls = el.current.querySelectorAll('table:first-child > thead > tr');
|
|
27
29
|
if (x > 0 && xEls.length > 0) {
|
|
28
30
|
if (props.hasInternalScroll) {
|
|
29
31
|
styled += 'overflow-x: auto;';
|
|
@@ -32,13 +34,12 @@ const TableContainer = props => {
|
|
|
32
34
|
styled += `
|
|
33
35
|
> table > * > tr > *:nth-child(${i + 1}) {
|
|
34
36
|
left: ${left}px;
|
|
35
|
-
z-index: ${leftZIndex--}
|
|
37
|
+
${(!y || yEls.length === 0) ? `z-index: ${leftZIndex--};` : ''}
|
|
36
38
|
}
|
|
37
39
|
`;
|
|
38
40
|
left += xEls[i].offsetWidth;
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
const yEls = el.current.querySelectorAll('table:first-child > thead > tr');
|
|
42
43
|
if (y > 0 && yEls.length > 0) {
|
|
43
44
|
if (props.hasInternalScroll) {
|
|
44
45
|
styled += 'overflow-y: auto;';
|
|
@@ -53,6 +54,25 @@ const TableContainer = props => {
|
|
|
53
54
|
`;
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
if ((x > 0 && xEls.length > 0)
|
|
58
|
+
&& (y > 0 && yEls.length > 0)) {
|
|
59
|
+
for (let i = 1; i <= x; i++) {
|
|
60
|
+
styled += `
|
|
61
|
+
> table > tbody > tr > *:nth-child(${i}) {
|
|
62
|
+
z-index: ${i};
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
const headEls = el.current.querySelectorAll('table:first-child > thead > tr > *');
|
|
67
|
+
let zIndex = x + 1;
|
|
68
|
+
for (let i = headEls.length; i > 0; i--) {
|
|
69
|
+
styled += `
|
|
70
|
+
> table > thead > tr > *:nth-child(${i}) {
|
|
71
|
+
z-index: ${zIndex++};
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
56
76
|
setStyled(styled);
|
|
57
77
|
};
|
|
58
78
|
react_1.default.useEffect(() => {
|
|
@@ -62,6 +82,9 @@ const TableContainer = props => {
|
|
|
62
82
|
(0, dom_1.removeEventListener)(window, ['resize'], handleResize);
|
|
63
83
|
};
|
|
64
84
|
}, []);
|
|
85
|
+
(0, useChangeEffect_1.default)(() => {
|
|
86
|
+
handleResize();
|
|
87
|
+
}, [props.children]);
|
|
65
88
|
return (react_1.default.createElement(TableContainerElement_1.default, Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default]), props.elementProps, { ref: el, styled: styled }), props.children));
|
|
66
89
|
};
|
|
67
90
|
TableContainer.defaultProps = {
|
|
@@ -69,5 +92,7 @@ TableContainer.defaultProps = {
|
|
|
69
92
|
flex: '1 1 auto',
|
|
70
93
|
hasInternalScroll: true,
|
|
71
94
|
minHeight: 1,
|
|
95
|
+
stickyX: 1,
|
|
96
|
+
stickyY: 1,
|
|
72
97
|
};
|
|
73
98
|
exports.default = TableContainer;
|
package/Table/Td.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { StyledProps } from '@smart-react-components/core/styled-props';
|
|
2
|
+
interface Props extends StyledProps {
|
|
3
|
+
isEmpty?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: import("styled-components").StyledComponent<"td", any, StyledProps & Props, never>;
|
|
6
|
+
export default _default;
|
package/Table/Td.js
CHANGED
|
@@ -4,4 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Td_1 = __importDefault(require("@smart-react-components/core/Element/Td"));
|
|
7
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
exports.default = (0, styled_components_1.default)(Td_1.default).attrs(({ isEmpty }) => (Object.assign({}, (isEmpty && { children: react_1.default.createElement(react_1.default.Fragment, null, "\u00A0") }))))(({ isEmpty }) => `
|
|
10
|
+
${isEmpty
|
|
11
|
+
? `
|
|
12
|
+
user-select: none;
|
|
13
|
+
`
|
|
14
|
+
: ''}
|
|
15
|
+
`);
|
package/Table/index.d.ts
CHANGED
|
@@ -14,8 +14,6 @@ export interface Props extends IntrinsicStyledProps, Partial<ResponsiveProp<'siz
|
|
|
14
14
|
isStriped?: boolean;
|
|
15
15
|
palette?: PaletteProp;
|
|
16
16
|
shape?: ShapeProp;
|
|
17
|
-
stickyX?: number;
|
|
18
|
-
stickyY?: number;
|
|
19
17
|
stripedOrientation?: TableStripedOrientation;
|
|
20
18
|
}
|
|
21
19
|
declare const Table: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLTableElement>>;
|
package/Table/index.js
CHANGED