@symply.io/basic-components 1.1.1 → 1.1.2-beta.1
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/.gitignore +2 -1
- package/BasicTable/TableBody.js +21 -21
- package/BasicTable/index.js +10 -2
- package/BasicTable/useScroll.d.ts +2 -2
- package/BasicTable/useScroll.js +11 -6
- package/package.json +4 -2
package/.gitignore
CHANGED
package/BasicTable/TableBody.js
CHANGED
@@ -17,7 +17,7 @@ import TableBodyRow from "./TableBodyRow";
|
|
17
17
|
function BasicTableBody(props, ref) {
|
18
18
|
var rows = props.rows, columns = props.columns, rowHeight = props.rowHeight, forFrozen = props.forFrozen, noDataText = props.noDataText, onRowClick = props.onRowClick;
|
19
19
|
var theme = useTheme();
|
20
|
-
return (_jsx(Grid, __assign({ item: true, sx: {
|
20
|
+
return (_jsx(Grid, __assign({ ref: ref, item: true, sx: {
|
21
21
|
maxHeight: "41vh",
|
22
22
|
overflowY: "auto",
|
23
23
|
display: "block",
|
@@ -26,25 +26,25 @@ function BasicTableBody(props, ref) {
|
|
26
26
|
"&::-webkit-scrollbar": {
|
27
27
|
width: forFrozen ? 0 : "initial"
|
28
28
|
}
|
29
|
-
} }, { children:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
29
|
+
} }, { children: rows && rows.length > 0 ? (rows.map(function (row, index) {
|
30
|
+
return (_jsx(TableBodyRow, { row: row, rows: rows, rowHeight: rowHeight, forFrozen: forFrozen, columns: columns, onRowClick: onRowClick }, "BasicTable_".concat(index)));
|
31
|
+
})) : (_jsx(Grid, __assign({ container: true, justifyContent: "space-around", alignItems: "center", wrap: "nowrap", sx: {
|
32
|
+
height: rowHeight || theme.spacing(7.5),
|
33
|
+
borderBottomWidth: "thin",
|
34
|
+
borderBottomColor: "#e5e5e5",
|
35
|
+
borderBottomStyle: "solid",
|
36
|
+
padding: theme.spacing(0.5, 0),
|
37
|
+
minHeight: theme.spacing(5),
|
38
|
+
"& :nth-of-last-type(1)": {
|
39
|
+
borderBottom: "none"
|
40
|
+
},
|
41
|
+
"& input": {
|
42
|
+
fontSize: "0.9rem",
|
43
|
+
fontWeight: 600
|
44
|
+
}
|
45
|
+
} }, { children: _jsx(Grid, __assign({ item: true, xs: 4, md: 3, lg: 2, textAlign: "center", sx: {
|
46
|
+
paddingLeft: theme.spacing(0.625),
|
47
|
+
paddingRight: theme.spacing(0.625)
|
48
|
+
} }, { children: noDataText })) }))) })));
|
49
49
|
}
|
50
50
|
export default forwardRef(BasicTableBody);
|
package/BasicTable/index.js
CHANGED
@@ -29,11 +29,19 @@ function BasicTable(props) {
|
|
29
29
|
var canFreeze = useMemo(function () { return isUpMd && (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && fronzenColsCount > 0; }, [fronzenColsCount, isUpMd, rows.length]);
|
30
30
|
var _g = useScroll({
|
31
31
|
canFreeze: canFreeze
|
32
|
-
}),
|
32
|
+
}), fixedRef = _g.fixedRef, dynamicRef = _g.dynamicRef, frozenWidth = _g.frozenWidth, setFrozenWidth = _g.setFrozenWidth;
|
33
33
|
useEffect(function () {
|
34
34
|
if (columns) {
|
35
35
|
var frozenCols = columns.filter(function (col) { return col.canBeFrozen; });
|
36
|
-
var initialFrozenWidth_1 = frozenCols.reduce(function (
|
36
|
+
var initialFrozenWidth_1 = frozenCols.reduce(function (fronzenWith, col) {
|
37
|
+
var _a = col.minWidth, minWidth = _a === void 0 ? 120 : _a, _b = col.width, width = _b === void 0 ? 120 : _b;
|
38
|
+
if (minWidth > width) {
|
39
|
+
return fronzenWith + minWidth;
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
return fronzenWith + width;
|
43
|
+
}
|
44
|
+
}, 1);
|
37
45
|
setFrozenWidth(function (fw) {
|
38
46
|
if (fw !== initialFrozenWidth_1) {
|
39
47
|
return initialFrozenWidth_1;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { UseScrollProps } from "./types";
|
3
3
|
declare function useScroll(props: UseScrollProps): {
|
4
|
-
frozenWidth: number;
|
5
|
-
setFrozenWidth: import("react").Dispatch<import("react").SetStateAction<number>>;
|
6
4
|
fixedRef: import("react").RefObject<HTMLDivElement>;
|
7
5
|
dynamicRef: import("react").RefObject<HTMLDivElement>;
|
6
|
+
frozenWidth: number;
|
7
|
+
setFrozenWidth: import("react").Dispatch<import("react").SetStateAction<number>>;
|
8
8
|
};
|
9
9
|
export default useScroll;
|
package/BasicTable/useScroll.js
CHANGED
@@ -61,16 +61,21 @@ function useScroll(props) {
|
|
61
61
|
if (dynamicRef === null || dynamicRef === void 0 ? void 0 : dynamicRef.current) {
|
62
62
|
dynamicRef.current.addEventListener("mouseover", bindEventDynamic);
|
63
63
|
}
|
64
|
+
resetFrozenWidth();
|
64
65
|
}
|
65
66
|
}, [
|
66
|
-
|
67
|
-
bindEventFixed,
|
67
|
+
fixedRef,
|
68
68
|
canFreeze,
|
69
69
|
dynamicRef,
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
bindEventFixed,
|
71
|
+
bindEventDynamic,
|
72
|
+
resetFrozenWidth
|
73
73
|
]);
|
74
|
-
return {
|
74
|
+
return {
|
75
|
+
fixedRef: fixedRef,
|
76
|
+
dynamicRef: dynamicRef,
|
77
|
+
frozenWidth: frozenWidth,
|
78
|
+
setFrozenWidth: setFrozenWidth
|
79
|
+
};
|
75
80
|
}
|
76
81
|
export default useScroll;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@symply.io/basic-components",
|
3
|
-
"version": "1.1.1",
|
3
|
+
"version": "1.1.2-beta.1",
|
4
4
|
"description": "Basic and reusable components for all frontend of Symply apps",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -67,7 +67,9 @@
|
|
67
67
|
"@types/react-dom": "17.0.9"
|
68
68
|
},
|
69
69
|
"scripts": {
|
70
|
-
"build": "./node_modules/.bin/tsc"
|
70
|
+
"build": "./node_modules/.bin/tsc",
|
71
|
+
"storybook": "cd storybook && yarn storybook",
|
72
|
+
"build-storybook": "cd storybook && yarn build-storybook"
|
71
73
|
},
|
72
74
|
"files": [
|
73
75
|
"*.js",
|