@gpa-gemstone/react-table 1.2.24 → 1.2.26
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/lib/DynamicTable.d.ts +1 -1
- package/lib/DynamicTable.js +2 -2
- package/lib/Paging.d.ts +7 -0
- package/lib/Paging.js +66 -0
- package/lib/SelectTable.js +2 -2
- package/lib/Table.d.ts +2 -2
- package/lib/Table.js +4 -5
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/package.json +7 -6
package/lib/DynamicTable.d.ts
CHANGED
package/lib/DynamicTable.js
CHANGED
|
@@ -35,9 +35,9 @@ function DynamicTable(props) {
|
|
|
35
35
|
cols.push({ key: key, label: key, field: key });
|
|
36
36
|
}
|
|
37
37
|
return (React.createElement("table", { className: props.tableClass !== undefined ? props.tableClass : '', style: props.tableStyle },
|
|
38
|
-
React.createElement(Table_1.Header, { Class: props.theadClass, Style: props.theadStyle, Cols: cols, SortKey: props.sortKey, Ascending: props.ascending, Click: function (d
|
|
38
|
+
React.createElement(Table_1.Header, { Class: props.theadClass, Style: props.theadStyle, Cols: cols, SortKey: props.sortKey, Ascending: props.ascending, Click: function (d) { return handleSort(d); } }),
|
|
39
39
|
React.createElement(Table_1.Rows, { Data: props.data, Cols: cols, RowStyle: props.rowStyle, BodyStyle: props.tbodyStyle, BodyClass: props.tbodyClass, Click: function (data, e) { return props.onClick(data, e); }, Selected: props.selected, KeySelector: props.keySelector })));
|
|
40
|
-
function handleSort(data
|
|
40
|
+
function handleSort(data) {
|
|
41
41
|
if (data.colKey !== null)
|
|
42
42
|
props.onSort(data);
|
|
43
43
|
}
|
package/lib/Paging.d.ts
ADDED
package/lib/Paging.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// ******************************************************************************************************
|
|
4
|
+
// Paging.tsx - Gbtc
|
|
5
|
+
//
|
|
6
|
+
// Copyright © 2023, Grid Protection Alliance. All Rights Reserved.
|
|
7
|
+
//
|
|
8
|
+
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
9
|
+
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
10
|
+
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
11
|
+
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
12
|
+
//
|
|
13
|
+
// http://opensource.org/licenses/MIT
|
|
14
|
+
//
|
|
15
|
+
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
16
|
+
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
17
|
+
// License for the specific language governing permissions and limitations.
|
|
18
|
+
//
|
|
19
|
+
// Code Modification History:
|
|
20
|
+
// ----------------------------------------------------------------------------------------------------
|
|
21
|
+
// 08/01/2023 - C. Lackner
|
|
22
|
+
// Generated original version of source code.
|
|
23
|
+
//
|
|
24
|
+
// ******************************************************************************************************
|
|
25
|
+
var React = require("react");
|
|
26
|
+
function default_1(props) {
|
|
27
|
+
var _a = React.useState([]), pages = _a[0], setPages = _a[1];
|
|
28
|
+
var nPages = 7;
|
|
29
|
+
var minPg = React.useMemo(function () { return Math.min.apply(Math, pages); }, [pages]);
|
|
30
|
+
var maxPg = React.useMemo(function () { return Math.max.apply(Math, pages); }, [pages]);
|
|
31
|
+
React.useEffect(function () {
|
|
32
|
+
var display = [];
|
|
33
|
+
var p = Math.max(props.Current - Math.floor(nPages / 2), 1);
|
|
34
|
+
if (props.Total - p < nPages)
|
|
35
|
+
p = Math.max(props.Total - nPages + 1, 1);
|
|
36
|
+
while (p <= props.Total && display.length < nPages) {
|
|
37
|
+
display.push(p);
|
|
38
|
+
p = p + 1;
|
|
39
|
+
}
|
|
40
|
+
setPages(display);
|
|
41
|
+
}, [props.Total, props.Current]);
|
|
42
|
+
return React.createElement("ul", { className: "pagination justify-content-center" },
|
|
43
|
+
React.createElement("li", { className: "page-item" + (minPg == 1 ? 'disabled' : "") },
|
|
44
|
+
React.createElement("a", { className: "page-link", onClick: function () {
|
|
45
|
+
if (minPg > 1)
|
|
46
|
+
props.SetPage(Math.max(props.Current - nPages, 1));
|
|
47
|
+
} }, "Previous")),
|
|
48
|
+
minPg > 2 ? React.createElement(React.Fragment, null,
|
|
49
|
+
React.createElement("li", { className: "page-item" },
|
|
50
|
+
React.createElement("a", { className: "page-link", onClick: function () { return props.SetPage(1); } }, "1")),
|
|
51
|
+
React.createElement("li", { className: "page-item disabled" },
|
|
52
|
+
React.createElement("a", { className: "page-link" }, "..."))) : null,
|
|
53
|
+
pages.map(function (p) { return React.createElement("li", { className: "page-item" + (p == props.Current ? " active" : "") },
|
|
54
|
+
React.createElement("a", { className: "page-link", onClick: function () { return props.SetPage(p); } }, p)); }),
|
|
55
|
+
maxPg + 2 < props.Total ? React.createElement(React.Fragment, null,
|
|
56
|
+
React.createElement("li", { className: "page-item disabled" },
|
|
57
|
+
React.createElement("a", { className: "page-link" }, "...")),
|
|
58
|
+
React.createElement("li", { className: "page-item" },
|
|
59
|
+
React.createElement("a", { className: "page-link", onClick: function () { return props.SetPage(props.Total); } }, props.Total))) : null,
|
|
60
|
+
React.createElement("li", { className: "page-item" + (maxPg == props.Total ? 'disabled' : "") },
|
|
61
|
+
React.createElement("a", { className: "page-link", onClick: function () {
|
|
62
|
+
if (maxPg < props.Total)
|
|
63
|
+
props.SetPage(Math.min(props.Current + nPages, props.Total));
|
|
64
|
+
} }, "Next")));
|
|
65
|
+
}
|
|
66
|
+
exports.default = default_1;
|
package/lib/SelectTable.js
CHANGED
|
@@ -75,7 +75,7 @@ function SelectTable(props) {
|
|
|
75
75
|
React.useEffect(function () {
|
|
76
76
|
props.onSelection(data.filter(function (item) { return selected.findIndex(function (key) { return key === item[props.KeyField]; }) > -1; }));
|
|
77
77
|
}, [selected]);
|
|
78
|
-
function handleClick(d
|
|
78
|
+
function handleClick(d) {
|
|
79
79
|
var sIndex = selected.findIndex(function (item) { return item === d.row[props.KeyField]; });
|
|
80
80
|
if (sIndex === -1)
|
|
81
81
|
setSelected(function (od) { return __spreadArray(__spreadArray([], od, true), [d.row[props.KeyField]], false); });
|
|
@@ -96,7 +96,7 @@ function SelectTable(props) {
|
|
|
96
96
|
}
|
|
97
97
|
var tableProps = {
|
|
98
98
|
cols: __spreadArray([
|
|
99
|
-
{ key: 'gemstone-checkbox', field: props.KeyField, label: '', headerStyle: { width: '4em' }, rowStyle: { width: '4em' }, content: function (item
|
|
99
|
+
{ key: 'gemstone-checkbox', field: props.KeyField, label: '', headerStyle: { width: '4em' }, rowStyle: { width: '4em' }, content: function (item) {
|
|
100
100
|
var index = selected.findIndex(function (i) { return i === item[props.KeyField]; });
|
|
101
101
|
if (index > -1)
|
|
102
102
|
return React.createElement("div", { style: { marginTop: '16px', textAlign: 'center' } },
|
package/lib/Table.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ interface IRowProps<T> {
|
|
|
71
71
|
row: T;
|
|
72
72
|
data: T[keyof T] | null;
|
|
73
73
|
index: number;
|
|
74
|
-
}, e: React.MouseEvent<
|
|
74
|
+
}, e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
75
75
|
DragStart?: ((data: {
|
|
76
76
|
colKey: string;
|
|
77
77
|
colField?: keyof T;
|
|
@@ -93,7 +93,7 @@ interface IHeaderProps<T> {
|
|
|
93
93
|
colKey: string;
|
|
94
94
|
colField?: keyof T;
|
|
95
95
|
ascending: boolean;
|
|
96
|
-
}, event: React.MouseEvent<
|
|
96
|
+
}, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
97
97
|
}
|
|
98
98
|
export declare function Header<T>(props: IHeaderProps<T>): JSX.Element;
|
|
99
99
|
export {};
|
package/lib/Table.js
CHANGED
|
@@ -92,9 +92,8 @@ function HeaderCell(props) {
|
|
|
92
92
|
style.position = 'relative';
|
|
93
93
|
}
|
|
94
94
|
return (React.createElement("th", { style: style, onClick: function (e) { return props.Click(e); } },
|
|
95
|
-
React.createElement(
|
|
96
|
-
|
|
97
|
-
React.createElement("div", { style: { marginLeft: 25 } }, props.Label)));
|
|
95
|
+
React.createElement(RenderAngleIcon, { SortKey: props.SortKey, Key: props.DataKey, Ascending: props.Ascending }),
|
|
96
|
+
React.createElement("div", { style: { marginLeft: (props.SortKey === props.DataKey ? 25 : 0) } }, props.Label)));
|
|
98
97
|
}
|
|
99
98
|
function RenderAngleIcon(props) {
|
|
100
99
|
var AngleIcon = function (a) { return a.ascending ? gpa_symbols_1.SVGIcons.ArrowDropUp : gpa_symbols_1.SVGIcons.ArrowDropDown; };
|
|
@@ -102,6 +101,6 @@ function RenderAngleIcon(props) {
|
|
|
102
101
|
return null;
|
|
103
102
|
if (props.SortKey !== props.Key)
|
|
104
103
|
return null;
|
|
105
|
-
return React.createElement(
|
|
104
|
+
return React.createElement("div", { style: { position: 'absolute', width: 25 } },
|
|
105
|
+
React.createElement(AngleIcon, { ascending: props.Ascending }));
|
|
106
106
|
}
|
|
107
|
-
;
|
package/lib/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import Table, { TableProps, Rows, Column } from './Table';
|
|
|
2
2
|
import { SelectTable, ISelectTableProps } from './SelectTable';
|
|
3
3
|
import { SearchableTable } from './SearchableTable';
|
|
4
4
|
import { DynamicTableProps, DynamicTable } from './DynamicTable';
|
|
5
|
-
|
|
5
|
+
import Paging from './Paging';
|
|
6
|
+
export { TableProps, SelectTable, ISelectTableProps, SearchableTable, DynamicTable, DynamicTableProps, Rows, Column, Paging };
|
|
6
7
|
export default Table;
|
package/lib/index.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
//
|
|
25
25
|
// ******************************************************************************************************
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.Rows = exports.DynamicTable = exports.SearchableTable = exports.SelectTable = void 0;
|
|
27
|
+
exports.Paging = exports.Rows = exports.DynamicTable = exports.SearchableTable = exports.SelectTable = void 0;
|
|
28
28
|
var Table_1 = require("./Table");
|
|
29
29
|
Object.defineProperty(exports, "Rows", { enumerable: true, get: function () { return Table_1.Rows; } });
|
|
30
30
|
var SelectTable_1 = require("./SelectTable");
|
|
@@ -33,4 +33,6 @@ var SearchableTable_1 = require("./SearchableTable");
|
|
|
33
33
|
Object.defineProperty(exports, "SearchableTable", { enumerable: true, get: function () { return SearchableTable_1.SearchableTable; } });
|
|
34
34
|
var DynamicTable_1 = require("./DynamicTable");
|
|
35
35
|
Object.defineProperty(exports, "DynamicTable", { enumerable: true, get: function () { return DynamicTable_1.DynamicTable; } });
|
|
36
|
+
var Paging_1 = require("./Paging");
|
|
37
|
+
exports.Paging = Paging_1.default;
|
|
36
38
|
exports.default = Table_1.default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpa-gemstone/react-table",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.26",
|
|
4
4
|
"description": "Table for GPA web applications",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"test": "jest --config jestconfig.json",
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"format": "prettier --write \"src/**/*.tsx\"",
|
|
12
|
-
"lint": "
|
|
12
|
+
"lint": "eslint . --ext .ts,.tsx",
|
|
13
13
|
"prepare": "npm run build",
|
|
14
14
|
"prepublishOnly": "npm test && npm run lint",
|
|
15
15
|
"preversion": "npm run lint",
|
|
@@ -33,16 +33,17 @@
|
|
|
33
33
|
"homepage": "https://github.com/GridProtectionAlliance/gpa-gemstone#readme",
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/jest": "^27.0.0",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
|
37
|
+
"@typescript-eslint/parser": "^5.60.0",
|
|
38
|
+
"eslint": "^8.43.0",
|
|
36
39
|
"jest": "^27.0.6",
|
|
37
40
|
"prettier": "^2.3.2",
|
|
38
41
|
"ts-jest": "^27.0.4",
|
|
39
|
-
"tslint": "^6.1.3",
|
|
40
|
-
"tslint-config-prettier": "^1.18.0",
|
|
41
42
|
"typescript": "4.4.4"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@gpa-gemstone/gpa-symbols": "0.0.
|
|
45
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
45
|
+
"@gpa-gemstone/gpa-symbols": "0.0.27",
|
|
46
|
+
"@gpa-gemstone/helper-functions": "0.0.21",
|
|
46
47
|
"@types/lodash": "^4.14.171",
|
|
47
48
|
"@types/react": "^17.0.14",
|
|
48
49
|
"lodash": "^4.17.21",
|