schummar-table 0.3.0 → 0.3.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/dist/cjs/components/cell.js +8 -4
- package/dist/cjs/components/useCommonClasses.d.ts +1 -1
- package/dist/cjs/components/useCommonClasses.js +6 -3
- package/dist/esm/components/cell.js +9 -5
- package/dist/esm/components/useCommonClasses.d.ts +1 -1
- package/dist/esm/components/useCommonClasses.js +6 -3
- package/package.json +9 -9
|
@@ -15,13 +15,17 @@ exports.Cell = (0, react_1.memo)(function Cell({ itemId, rowIndex }) {
|
|
|
15
15
|
const column = state.useState((state) => state.activeColumns.find((column) => column.id === columnId), [columnId]);
|
|
16
16
|
const item = state.useState((state) => state.activeItemsById.get(itemId), [itemId]);
|
|
17
17
|
const classes = state.useState('props.classes');
|
|
18
|
-
|
|
18
|
+
let wrapCell = state.useState('props.wrapCell');
|
|
19
19
|
if (!column || !item)
|
|
20
20
|
return null;
|
|
21
21
|
(_b = (_a = state.getState().props).debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'render cell', itemId, columnId);
|
|
22
22
|
const className = (0, helpers_1.c)((0, row_1.calcClassName)(classes, rowIndex), (0, row_1.calcClassName)(column === null || column === void 0 ? void 0 : column.classes, rowIndex));
|
|
23
23
|
const content = column.renderCell(column.value(item), item);
|
|
24
|
-
if (wrapCell)
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (!wrapCell && typeof content === 'string') {
|
|
25
|
+
wrapCell = (content) => ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, helpers_1.c)(commonClasses.cell, className) }, { children: (0, jsx_runtime_1.jsx)("span", Object.assign({ className: (0, helpers_1.c)(commonClasses.text) }, { children: content }), void 0) }), void 0));
|
|
26
|
+
}
|
|
27
|
+
else if (!wrapCell) {
|
|
28
|
+
wrapCell = (content) => (0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, helpers_1.c)(commonClasses.cell, className) }, { children: content }), void 0);
|
|
29
|
+
}
|
|
30
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: wrapCell(content, item) }, void 0);
|
|
27
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useCommonClasses: (props?: any) => import("@material-ui/styles").ClassNameMap<"table" | "cell" | "sticky" | "headerCell" | "cellFill" | "firstCell" | "headerFill" | "deferredPlaceholder">;
|
|
1
|
+
export declare const useCommonClasses: (props?: any) => import("@material-ui/styles").ClassNameMap<"table" | "text" | "cell" | "sticky" | "headerCell" | "cellFill" | "firstCell" | "headerFill" | "deferredPlaceholder">;
|
|
@@ -4,13 +4,11 @@ exports.useCommonClasses = void 0;
|
|
|
4
4
|
const core_1 = require("@material-ui/core");
|
|
5
5
|
const cell = (theme) => ({
|
|
6
6
|
padding: theme.spacing(0.1, 1),
|
|
7
|
-
display: '
|
|
8
|
-
gridAutoFlow: 'column',
|
|
7
|
+
display: 'flex',
|
|
9
8
|
alignItems: 'center',
|
|
10
9
|
borderBottom: `1px solid ${theme.palette.grey[200]}`,
|
|
11
10
|
whiteSpace: 'nowrap',
|
|
12
11
|
overflow: 'hidden',
|
|
13
|
-
textOverflow: 'ellipsis',
|
|
14
12
|
});
|
|
15
13
|
exports.useCommonClasses = (0, core_1.makeStyles)((theme) => ({
|
|
16
14
|
table: {
|
|
@@ -43,4 +41,9 @@ exports.useCommonClasses = (0, core_1.makeStyles)((theme) => ({
|
|
|
43
41
|
display: 'grid',
|
|
44
42
|
justifyContent: 'center',
|
|
45
43
|
},
|
|
44
|
+
text: {
|
|
45
|
+
minWidth: 0,
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
textOverflow: 'ellipsis',
|
|
48
|
+
},
|
|
46
49
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
import { useColumnContext, useTableContext } from '..';
|
|
4
4
|
import { c } from '../misc/helpers';
|
|
@@ -12,13 +12,17 @@ export const Cell = memo(function Cell({ itemId, rowIndex }) {
|
|
|
12
12
|
const column = state.useState((state) => state.activeColumns.find((column) => column.id === columnId), [columnId]);
|
|
13
13
|
const item = state.useState((state) => state.activeItemsById.get(itemId), [itemId]);
|
|
14
14
|
const classes = state.useState('props.classes');
|
|
15
|
-
|
|
15
|
+
let wrapCell = state.useState('props.wrapCell');
|
|
16
16
|
if (!column || !item)
|
|
17
17
|
return null;
|
|
18
18
|
(_b = (_a = state.getState().props).debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'render cell', itemId, columnId);
|
|
19
19
|
const className = c(calcClassName(classes, rowIndex), calcClassName(column === null || column === void 0 ? void 0 : column.classes, rowIndex));
|
|
20
20
|
const content = column.renderCell(column.value(item), item);
|
|
21
|
-
if (wrapCell)
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (!wrapCell && typeof content === 'string') {
|
|
22
|
+
wrapCell = (content) => (_jsx("div", Object.assign({ className: c(commonClasses.cell, className) }, { children: _jsx("span", Object.assign({ className: c(commonClasses.text) }, { children: content }), void 0) }), void 0));
|
|
23
|
+
}
|
|
24
|
+
else if (!wrapCell) {
|
|
25
|
+
wrapCell = (content) => _jsx("div", Object.assign({ className: c(commonClasses.cell, className) }, { children: content }), void 0);
|
|
26
|
+
}
|
|
27
|
+
return _jsx(_Fragment, { children: wrapCell(content, item) }, void 0);
|
|
24
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useCommonClasses: (props?: any) => import("@material-ui/styles").ClassNameMap<"table" | "cell" | "sticky" | "headerCell" | "cellFill" | "firstCell" | "headerFill" | "deferredPlaceholder">;
|
|
1
|
+
export declare const useCommonClasses: (props?: any) => import("@material-ui/styles").ClassNameMap<"table" | "text" | "cell" | "sticky" | "headerCell" | "cellFill" | "firstCell" | "headerFill" | "deferredPlaceholder">;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { makeStyles } from '@material-ui/core';
|
|
2
2
|
const cell = (theme) => ({
|
|
3
3
|
padding: theme.spacing(0.1, 1),
|
|
4
|
-
display: '
|
|
5
|
-
gridAutoFlow: 'column',
|
|
4
|
+
display: 'flex',
|
|
6
5
|
alignItems: 'center',
|
|
7
6
|
borderBottom: `1px solid ${theme.palette.grey[200]}`,
|
|
8
7
|
whiteSpace: 'nowrap',
|
|
9
8
|
overflow: 'hidden',
|
|
10
|
-
textOverflow: 'ellipsis',
|
|
11
9
|
});
|
|
12
10
|
export const useCommonClasses = makeStyles((theme) => ({
|
|
13
11
|
table: {
|
|
@@ -40,4 +38,9 @@ export const useCommonClasses = makeStyles((theme) => ({
|
|
|
40
38
|
display: 'grid',
|
|
41
39
|
justifyContent: 'center',
|
|
42
40
|
},
|
|
41
|
+
text: {
|
|
42
|
+
minWidth: 0,
|
|
43
|
+
overflow: 'hidden',
|
|
44
|
+
textOverflow: 'ellipsis',
|
|
45
|
+
},
|
|
43
46
|
}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "schummar-table",
|
|
3
3
|
"repository": "schummar/schummar-table",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"schummar-state": ">=0.0.36"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@testing-library/react": "^12.1.
|
|
45
|
+
"@testing-library/react": "^12.1.2",
|
|
46
46
|
"@types/react": "*",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
48
|
-
"@typescript-eslint/parser": "^4.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
48
|
+
"@typescript-eslint/parser": "^5.4.0",
|
|
49
49
|
"ava": "^3.15.0",
|
|
50
|
-
"eslint": "^
|
|
51
|
-
"global-jsdom": "^8.
|
|
50
|
+
"eslint": "^8.2.0",
|
|
51
|
+
"global-jsdom": "^8.3.0",
|
|
52
52
|
"immer": "*",
|
|
53
|
-
"jsdom": "^
|
|
53
|
+
"jsdom": "^18.1.0",
|
|
54
54
|
"npm-run-all": "^4.1.5",
|
|
55
55
|
"nyc": "^15.1.0",
|
|
56
56
|
"prettier": "^2.4.1",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"react-dom": "^17.0.2",
|
|
59
59
|
"rimraf": "^3.0.2",
|
|
60
60
|
"schummar-state": "*",
|
|
61
|
-
"ts-node": "^
|
|
62
|
-
"typescript": "^4.
|
|
61
|
+
"ts-node": "^10.4.0",
|
|
62
|
+
"typescript": "^4.5.2"
|
|
63
63
|
},
|
|
64
64
|
"files": [
|
|
65
65
|
"dist"
|