@bento-core/paginated-table 1.0.0-c3dc.0 → 1.0.0-c3dc.10
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/table/PaginatedTable.js +15 -0
- package/dist/table/state/Actions.js +7 -1
- package/dist/table/state/Reducer.js +4 -0
- package/dist/wrapper/Wrapper.js +4 -2
- package/package.json +2 -2
- package/src/table/PaginatedTable.js +19 -0
- package/src/table/state/Actions.js +6 -0
- package/src/table/state/Reducer.js +5 -0
- package/src/wrapper/Wrapper.js +13 -7
|
@@ -98,9 +98,17 @@ const PaginatedTable = _ref => {
|
|
|
98
98
|
const onRowSelectHandler = (event, row) => {
|
|
99
99
|
event.stopPropagation();
|
|
100
100
|
let selectedIds = [...table.selectedRows];
|
|
101
|
+
let hiddenSelectedIds = [...table.hiddenSelectedRows];
|
|
101
102
|
const selectedId = row[table.dataKey];
|
|
103
|
+
let hiddenSelectedId = selectedId;
|
|
104
|
+
if (table.hiddenDataKey) {
|
|
105
|
+
hiddenSelectedId = row[table.hiddenDataKey];
|
|
106
|
+
}
|
|
102
107
|
if (!row.isChecked) {
|
|
103
108
|
selectedIds.push(selectedId);
|
|
109
|
+
if (!hiddenSelectedIds.includes(hiddenSelectedId)) {
|
|
110
|
+
hiddenSelectedIds.push(hiddenSelectedId);
|
|
111
|
+
}
|
|
104
112
|
} else {
|
|
105
113
|
selectedIds = selectedIds.reduce((acc, id) => {
|
|
106
114
|
if (selectedId !== id) {
|
|
@@ -108,8 +116,15 @@ const PaginatedTable = _ref => {
|
|
|
108
116
|
}
|
|
109
117
|
return acc;
|
|
110
118
|
}, []);
|
|
119
|
+
hiddenSelectedIds = hiddenSelectedIds.reduce((acc, id) => {
|
|
120
|
+
if (hiddenSelectedId !== id) {
|
|
121
|
+
acc.push(id);
|
|
122
|
+
}
|
|
123
|
+
return acc;
|
|
124
|
+
}, []);
|
|
111
125
|
}
|
|
112
126
|
dispatch((0, _Actions.onRowSeclect)(selectedIds));
|
|
127
|
+
dispatch((0, _Actions.onRowSelectHidden)(hiddenSelectedIds));
|
|
113
128
|
};
|
|
114
129
|
const handleToggleSelectAll = (event, Ids, includeIds) => {
|
|
115
130
|
if (event.target.checked && !includeIds) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setTotalRowCount = exports.onRowsPerPageChange = exports.onRowSeclect = exports.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = exports.onChangeSortDirection = exports.actionTypes = void 0;
|
|
6
|
+
exports.setTotalRowCount = exports.onRowsPerPageChange = exports.onRowSelectHidden = exports.onRowSeclect = exports.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = exports.onChangeSortDirection = exports.actionTypes = void 0;
|
|
7
7
|
const actionTypes = {
|
|
8
8
|
VIEW_COLUMN_CHANGE: 'VIEW_COLUMN_CHANGE',
|
|
9
9
|
ON_COLUMN_SORT: 'ON_COLUMN_SORT',
|
|
@@ -11,6 +11,7 @@ const actionTypes = {
|
|
|
11
11
|
ON_ROWS_PER_PAGE_CHANGE: 'ON_ROWS_PER_PAGE_CHANGE',
|
|
12
12
|
ON_PAGE_CHANGE: 'ON_PAGE_CHANGE',
|
|
13
13
|
ON_ROW_SELECT: 'ON_ROW_SELECT',
|
|
14
|
+
ON_ROW_SELECT_HIDDEN: 'ON_ROW_SELECT_HIDDEN',
|
|
14
15
|
SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
|
|
15
16
|
ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE'
|
|
16
17
|
};
|
|
@@ -50,6 +51,11 @@ const onRowSeclect = rows => ({
|
|
|
50
51
|
payload: rows
|
|
51
52
|
});
|
|
52
53
|
exports.onRowSeclect = onRowSeclect;
|
|
54
|
+
const onRowSelectHidden = rows => ({
|
|
55
|
+
type: actionTypes.ON_ROW_SELECT_HIDDEN,
|
|
56
|
+
payload: rows
|
|
57
|
+
});
|
|
58
|
+
exports.onRowSelectHidden = onRowSelectHidden;
|
|
53
59
|
const setTotalRowCount = count => ({
|
|
54
60
|
type: actionTypes.SET_TOTAL_ROW_COUNT,
|
|
55
61
|
payload: count
|
|
@@ -36,6 +36,10 @@ const reducer = (state, action) => {
|
|
|
36
36
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
37
37
|
selectedRows: payload
|
|
38
38
|
});
|
|
39
|
+
case _Actions.actionTypes.ON_ROW_SELECT_HIDDEN:
|
|
40
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
41
|
+
hiddenSelectedRows: payload
|
|
42
|
+
});
|
|
39
43
|
case _Actions.actionTypes.ON_PAGE_AND_TOTAL_COUNT_CHANGE:
|
|
40
44
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
41
45
|
totalRowCount: payload.totalRowCount,
|
package/dist/wrapper/Wrapper.js
CHANGED
|
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _core = require("@material-ui/core");
|
|
9
9
|
var _ButtonView = _interopRequireDefault(require("./components/ButtonView"));
|
|
10
10
|
var _TextFieldView = _interopRequireDefault(require("./components/TextFieldView"));
|
|
11
|
+
var _TooltipView = _interopRequireDefault(require("./components/TooltipView"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -77,7 +78,8 @@ const Text = _ref2 => {
|
|
|
77
78
|
const ViewComponent = props => {
|
|
78
79
|
const {
|
|
79
80
|
type,
|
|
80
|
-
|
|
81
|
+
CustomViewElem,
|
|
82
|
+
tooltipCofig
|
|
81
83
|
} = props;
|
|
82
84
|
switch (type) {
|
|
83
85
|
case types.BUTTON:
|
|
@@ -91,7 +93,7 @@ const ViewComponent = props => {
|
|
|
91
93
|
case types.TEXT_INPUT:
|
|
92
94
|
return /*#__PURE__*/_react.default.createElement(_TextFieldView.default, props);
|
|
93
95
|
case types.CUSTOM_ELEM:
|
|
94
|
-
return
|
|
96
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(CustomViewElem, null), tooltipCofig && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props));
|
|
95
97
|
default:
|
|
96
98
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
97
99
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/paginated-table",
|
|
3
|
-
"version": "1.0.0-c3dc.
|
|
3
|
+
"version": "1.0.0-c3dc.10",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@bento-core/cart": "1.0.1-ccdihub.7",
|
|
19
|
-
"@bento-core/table": "1.0.0-c3dc.
|
|
19
|
+
"@bento-core/table": "^1.0.0-c3dc.10",
|
|
20
20
|
"@bento-core/tool-tip": "^1.0.0",
|
|
21
21
|
"@bento-core/util": "^1.0.0"
|
|
22
22
|
},
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
onColumnSort,
|
|
10
10
|
onPageAndTotalCountChange,
|
|
11
11
|
onColumnViewChange,
|
|
12
|
+
onRowSelectHidden,
|
|
12
13
|
} from './state/Actions';
|
|
13
14
|
import { TableContext } from './ContextProvider';
|
|
14
15
|
import reducer from './state/Reducer';
|
|
@@ -83,9 +84,19 @@ const PaginatedTable = ({
|
|
|
83
84
|
const onRowSelectHandler = (event, row) => {
|
|
84
85
|
event.stopPropagation();
|
|
85
86
|
let selectedIds = [...table.selectedRows];
|
|
87
|
+
let hiddenSelectedIds = [...table.hiddenSelectedRows];
|
|
88
|
+
|
|
86
89
|
const selectedId = row[table.dataKey];
|
|
90
|
+
let hiddenSelectedId = selectedId;
|
|
91
|
+
if (table.hiddenDataKey) {
|
|
92
|
+
hiddenSelectedId = row[table.hiddenDataKey];
|
|
93
|
+
}
|
|
94
|
+
|
|
87
95
|
if (!row.isChecked) {
|
|
88
96
|
selectedIds.push(selectedId);
|
|
97
|
+
if (!hiddenSelectedIds.includes(hiddenSelectedId)) {
|
|
98
|
+
hiddenSelectedIds.push(hiddenSelectedId);
|
|
99
|
+
}
|
|
89
100
|
} else {
|
|
90
101
|
selectedIds = selectedIds.reduce((acc, id) => {
|
|
91
102
|
if (selectedId !== id) {
|
|
@@ -93,8 +104,16 @@ const PaginatedTable = ({
|
|
|
93
104
|
}
|
|
94
105
|
return acc;
|
|
95
106
|
}, []);
|
|
107
|
+
|
|
108
|
+
hiddenSelectedIds = hiddenSelectedIds.reduce((acc, id) => {
|
|
109
|
+
if (hiddenSelectedId !== id) {
|
|
110
|
+
acc.push(id);
|
|
111
|
+
}
|
|
112
|
+
return acc;
|
|
113
|
+
}, []);
|
|
96
114
|
}
|
|
97
115
|
dispatch(onRowSeclect(selectedIds));
|
|
116
|
+
dispatch(onRowSelectHidden(hiddenSelectedIds));
|
|
98
117
|
};
|
|
99
118
|
|
|
100
119
|
const handleToggleSelectAll = (event, Ids, includeIds) => {
|
|
@@ -5,6 +5,7 @@ export const actionTypes = {
|
|
|
5
5
|
ON_ROWS_PER_PAGE_CHANGE: 'ON_ROWS_PER_PAGE_CHANGE',
|
|
6
6
|
ON_PAGE_CHANGE: 'ON_PAGE_CHANGE',
|
|
7
7
|
ON_ROW_SELECT: 'ON_ROW_SELECT',
|
|
8
|
+
ON_ROW_SELECT_HIDDEN: 'ON_ROW_SELECT_HIDDEN',
|
|
8
9
|
SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
|
|
9
10
|
ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
|
|
10
11
|
};
|
|
@@ -44,6 +45,11 @@ export const onRowSeclect = (rows) => ({
|
|
|
44
45
|
payload: rows,
|
|
45
46
|
});
|
|
46
47
|
|
|
48
|
+
export const onRowSelectHidden = (rows) => ({
|
|
49
|
+
type: actionTypes.ON_ROW_SELECT_HIDDEN,
|
|
50
|
+
payload: rows,
|
|
51
|
+
});
|
|
52
|
+
|
|
47
53
|
export const setTotalRowCount = (count) => ({
|
|
48
54
|
type: actionTypes.SET_TOTAL_ROW_COUNT,
|
|
49
55
|
payload: count,
|
|
@@ -30,6 +30,11 @@ const reducer = (state, action) => {
|
|
|
30
30
|
...state,
|
|
31
31
|
selectedRows: payload,
|
|
32
32
|
};
|
|
33
|
+
case actionTypes.ON_ROW_SELECT_HIDDEN:
|
|
34
|
+
return {
|
|
35
|
+
...state,
|
|
36
|
+
hiddenSelectedRows: payload,
|
|
37
|
+
};
|
|
33
38
|
case actionTypes.ON_PAGE_AND_TOTAL_COUNT_CHANGE:
|
|
34
39
|
return {
|
|
35
40
|
...state,
|
package/src/wrapper/Wrapper.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from '@material-ui/core';
|
|
8
8
|
import ButtonView from './components/ButtonView';
|
|
9
9
|
import TextFieldView from './components/TextFieldView';
|
|
10
|
+
import ToolTipView from './components/TooltipView';
|
|
10
11
|
|
|
11
12
|
export const types = {
|
|
12
13
|
BUTTON: 'BUTTON',
|
|
@@ -45,7 +46,7 @@ const Text = ({
|
|
|
45
46
|
}) => (
|
|
46
47
|
<span className={clsName} type={tag}>
|
|
47
48
|
{text}
|
|
48
|
-
{
|
|
49
|
+
{Component && <Component />}
|
|
49
50
|
</span>
|
|
50
51
|
);
|
|
51
52
|
|
|
@@ -55,7 +56,7 @@ const Text = ({
|
|
|
55
56
|
* @returns custom component based on configuration
|
|
56
57
|
*/
|
|
57
58
|
export const ViewComponent = (props) => {
|
|
58
|
-
const { type,
|
|
59
|
+
const { type, CustomViewElem, tooltipCofig } = props;
|
|
59
60
|
switch (type) {
|
|
60
61
|
case types.BUTTON:
|
|
61
62
|
return (<ButtonView {...props} />);
|
|
@@ -68,7 +69,12 @@ export const ViewComponent = (props) => {
|
|
|
68
69
|
case types.TEXT_INPUT:
|
|
69
70
|
return <TextFieldView {...props} />;
|
|
70
71
|
case types.CUSTOM_ELEM:
|
|
71
|
-
return
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
<CustomViewElem />
|
|
75
|
+
{tooltipCofig && (<ToolTipView {...props} />)}
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
72
78
|
default:
|
|
73
79
|
return <></>;
|
|
74
80
|
}
|
|
@@ -129,10 +135,10 @@ const CustomLayout = (props) => {
|
|
|
129
135
|
{
|
|
130
136
|
container.text
|
|
131
137
|
&& (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
<p>
|
|
139
|
+
<span>{container.textTitle}</span>
|
|
140
|
+
{container.text}
|
|
141
|
+
</p>
|
|
136
142
|
)
|
|
137
143
|
}
|
|
138
144
|
{container.items.map((item) => (
|