@gpa-gemstone/react-table 1.2.58 → 1.2.59
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/Table/Table.js +1 -1
- package/package.json +56 -56
- package/lib/AdjustableTable/Column.d.ts +0 -20
- package/lib/AdjustableTable/Column.js +0 -77
- package/lib/AdjustableTable/Table.d.ts +0 -3
- package/lib/AdjustableTable/Table.js +0 -470
- package/lib/AdjustableTable/Types.d.ts +0 -148
- package/lib/AdjustableTable/Types.js +0 -24
- package/lib/DynamicTable.d.ts +0 -37
- package/lib/DynamicTable.js +0 -44
- package/lib/FilterableTable/BooleanFilter.d.ts +0 -26
- package/lib/FilterableTable/BooleanFilter.js +0 -68
- package/lib/FilterableTable/DateTimeFilters.d.ts +0 -10
- package/lib/FilterableTable/DateTimeFilters.js +0 -321
- package/lib/FilterableTable/EnumFilter.d.ts +0 -37
- package/lib/FilterableTable/EnumFilter.js +0 -89
- package/lib/FilterableTable/FilterableColumn.d.ts +0 -20
- package/lib/FilterableTable/FilterableColumn.js +0 -34
- package/lib/FilterableTable/FilterableTable.d.ts +0 -12
- package/lib/FilterableTable/FilterableTable.js +0 -95
- package/lib/FilterableTable/NumberFilter.d.ts +0 -19
- package/lib/FilterableTable/NumberFilter.js +0 -160
- package/lib/FilterableTable/TextFilter.d.ts +0 -14
- package/lib/FilterableTable/TextFilter.js +0 -78
- package/lib/SearchableTable.d.ts +0 -15
- package/lib/SearchableTable.js +0 -40
- package/lib/SelectTable.d.ts +0 -19
- package/lib/SelectTable.js +0 -102
- package/lib/Table.d.ts +0 -99
- package/lib/Table.js +0 -94
package/lib/Table.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export interface Column<T> {
|
|
3
|
-
key: string;
|
|
4
|
-
label: string | React.ReactNode;
|
|
5
|
-
field?: keyof T;
|
|
6
|
-
headerStyle?: React.CSSProperties;
|
|
7
|
-
rowStyle?: React.CSSProperties;
|
|
8
|
-
content?(item: T, key: string, field: keyof T | undefined, style: React.CSSProperties, index: number): React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
export interface TableProps<T> {
|
|
11
|
-
/**
|
|
12
|
-
* List of Collumns in this Table
|
|
13
|
-
*/
|
|
14
|
-
cols: Column<T>[];
|
|
15
|
-
/**
|
|
16
|
-
* List of T objects used to generate rows
|
|
17
|
-
*/
|
|
18
|
-
data: T[];
|
|
19
|
-
onClick?: (data: {
|
|
20
|
-
colKey: string;
|
|
21
|
-
colField?: keyof T;
|
|
22
|
-
row: T;
|
|
23
|
-
data: T[keyof T] | null;
|
|
24
|
-
index: number;
|
|
25
|
-
}, event: any) => void;
|
|
26
|
-
/**
|
|
27
|
-
* Key of the collumn to sort by
|
|
28
|
-
*/
|
|
29
|
-
sortKey: string;
|
|
30
|
-
/**
|
|
31
|
-
* Boolen to indicate whether the sort is ascending or descending
|
|
32
|
-
*/
|
|
33
|
-
ascending: boolean;
|
|
34
|
-
onSort(data: {
|
|
35
|
-
colKey: string;
|
|
36
|
-
colField?: keyof T;
|
|
37
|
-
ascending: boolean;
|
|
38
|
-
}, event: any): void;
|
|
39
|
-
tableClass?: string;
|
|
40
|
-
tableStyle?: React.CSSProperties;
|
|
41
|
-
theadStyle?: React.CSSProperties;
|
|
42
|
-
theadClass?: string;
|
|
43
|
-
tbodyStyle?: React.CSSProperties;
|
|
44
|
-
tbodyClass?: string;
|
|
45
|
-
selected?(data: T): boolean;
|
|
46
|
-
onDragStart?: ((data: {
|
|
47
|
-
colKey: string;
|
|
48
|
-
colField?: keyof T;
|
|
49
|
-
row: T;
|
|
50
|
-
data: T[keyof T] | null;
|
|
51
|
-
index: number;
|
|
52
|
-
}, e: any) => void);
|
|
53
|
-
rowStyle?: React.CSSProperties;
|
|
54
|
-
keySelector?: (data: T) => string;
|
|
55
|
-
/**
|
|
56
|
-
* Optional Element to display in the last row of the Table
|
|
57
|
-
* use this for displaying warnings when the Table content gets cut off
|
|
58
|
-
*/
|
|
59
|
-
lastRow?: string | React.ReactNode;
|
|
60
|
-
}
|
|
61
|
-
export default function Table<T>(props: TableProps<T>): JSX.Element;
|
|
62
|
-
interface IRowProps<T> {
|
|
63
|
-
Data: T[];
|
|
64
|
-
Cols: Column<T>[];
|
|
65
|
-
RowStyle?: React.CSSProperties;
|
|
66
|
-
BodyStyle?: React.CSSProperties;
|
|
67
|
-
BodyClass?: string;
|
|
68
|
-
Click: (data: {
|
|
69
|
-
colKey: string;
|
|
70
|
-
colField?: keyof T;
|
|
71
|
-
row: T;
|
|
72
|
-
data: T[keyof T] | null;
|
|
73
|
-
index: number;
|
|
74
|
-
}, e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
75
|
-
DragStart?: ((data: {
|
|
76
|
-
colKey: string;
|
|
77
|
-
colField?: keyof T;
|
|
78
|
-
row: T;
|
|
79
|
-
data: T[keyof T] | null;
|
|
80
|
-
index: number;
|
|
81
|
-
}, e: any) => void);
|
|
82
|
-
Selected?: ((data: T) => boolean);
|
|
83
|
-
KeySelector?: (data: T) => string;
|
|
84
|
-
}
|
|
85
|
-
export declare function Rows<T>(props: IRowProps<T>): JSX.Element | null;
|
|
86
|
-
interface IHeaderProps<T> {
|
|
87
|
-
Class?: string;
|
|
88
|
-
Style?: React.CSSProperties;
|
|
89
|
-
Cols: Column<T>[];
|
|
90
|
-
SortKey: string;
|
|
91
|
-
Ascending: boolean;
|
|
92
|
-
Click: (data: {
|
|
93
|
-
colKey: string;
|
|
94
|
-
colField?: keyof T;
|
|
95
|
-
ascending: boolean;
|
|
96
|
-
}, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
97
|
-
}
|
|
98
|
-
export declare function Header<T>(props: IHeaderProps<T>): JSX.Element;
|
|
99
|
-
export {};
|
package/lib/Table.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// Table.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2018, Grid Protection Alliance. All Rights Reserved.
|
|
6
|
-
//
|
|
7
|
-
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
8
|
-
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
9
|
-
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
10
|
-
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
11
|
-
//
|
|
12
|
-
// http://opensource.org/licenses/MIT
|
|
13
|
-
//
|
|
14
|
-
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
15
|
-
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
16
|
-
// License for the specific language governing permissions and limitations.
|
|
17
|
-
//
|
|
18
|
-
// Code Modification History:
|
|
19
|
-
// ----------------------------------------------------------------------------------------------------
|
|
20
|
-
// 08/02/2018 - Billy Ernest
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
//
|
|
23
|
-
// ******************************************************************************************************
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.default = Table;
|
|
26
|
-
exports.Rows = Rows;
|
|
27
|
-
exports.Header = Header;
|
|
28
|
-
const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
29
|
-
const React = require("react");
|
|
30
|
-
function Table(props) {
|
|
31
|
-
return (React.createElement("table", { className: props.tableClass !== undefined ? props.tableClass : '', style: props.tableStyle },
|
|
32
|
-
React.createElement(Header, { Class: props.theadClass, Style: props.theadStyle, Cols: props.cols, SortKey: props.sortKey, Ascending: props.ascending, Click: (d, e) => handleSort(d, e) }),
|
|
33
|
-
React.createElement(Rows, { DragStart: props.onDragStart, Data: props.data, Cols: props.cols, RowStyle: props.rowStyle, BodyStyle: props.tbodyStyle, BodyClass: props.tbodyClass, Click: (data, e) => (props.onClick === undefined ? null : props.onClick(data, e)), Selected: props.selected, KeySelector: props.keySelector }),
|
|
34
|
-
props.lastRow !== undefined ? React.createElement("tr", { style: (props.rowStyle !== undefined) ? Object.assign({}, props.rowStyle) : {}, key: -1 }, props.lastRow) : null));
|
|
35
|
-
function handleSort(data, event) {
|
|
36
|
-
if (data.colKey !== null)
|
|
37
|
-
props.onSort(data, event);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function Rows(props) {
|
|
41
|
-
if (props.Data.length === 0)
|
|
42
|
-
return null;
|
|
43
|
-
const rows = props.Data.map((item, rowIndex) => {
|
|
44
|
-
const cells = props.Cols.map((colData) => {
|
|
45
|
-
return React.createElement(Cell, { key: colData.key, Style: colData.rowStyle, DataKey: colData.key, DataField: colData.field, Object: item, RowIndex: rowIndex, Content: colData.content, Click: (data, e) => props.Click(data, e), DragStart: props.DragStart });
|
|
46
|
-
});
|
|
47
|
-
const style = (props.RowStyle !== undefined) ? Object.assign({}, props.RowStyle) : {};
|
|
48
|
-
if (style.cursor === undefined)
|
|
49
|
-
style.cursor = 'pointer';
|
|
50
|
-
if (props.Selected !== undefined && props.Selected(item))
|
|
51
|
-
style.backgroundColor = 'yellow';
|
|
52
|
-
function ToKey(index, data) {
|
|
53
|
-
if (props.KeySelector === undefined)
|
|
54
|
-
return index.toString();
|
|
55
|
-
return props.KeySelector(data);
|
|
56
|
-
}
|
|
57
|
-
return (React.createElement("tr", { style: style, key: ToKey(rowIndex, item) }, cells));
|
|
58
|
-
});
|
|
59
|
-
return (React.createElement("tbody", { style: props.BodyStyle, className: props.BodyClass }, rows));
|
|
60
|
-
}
|
|
61
|
-
function Cell(props) {
|
|
62
|
-
const css = (props.Style !== undefined) ? Object.assign({}, props.Style) : {};
|
|
63
|
-
if (props.DragStart !== undefined)
|
|
64
|
-
css.cursor = "grab";
|
|
65
|
-
const getFieldValue = () => props.DataField !== undefined ? props.Object[props.DataField] : null;
|
|
66
|
-
const getFieldContent = () => props.Content !== undefined ? props.Content(props.Object, props.DataKey, props.DataField, css, props.RowIndex) : getFieldValue();
|
|
67
|
-
return (React.createElement("td", { style: css, onClick: (e) => props.Click({ colKey: props.DataKey, colField: props.DataField, row: props.Object, data: getFieldValue(), index: props.RowIndex }, e), draggable: props.DragStart !== undefined, onDragStart: (e) => { if (props.DragStart !== undefined)
|
|
68
|
-
props.DragStart({ colKey: props.DataKey, colField: props.DataField, row: props.Object, data: getFieldValue(), index: props.RowIndex }, e); } }, getFieldContent()));
|
|
69
|
-
}
|
|
70
|
-
function Header(props) {
|
|
71
|
-
return (React.createElement("thead", { className: props.Class, style: props.Style },
|
|
72
|
-
React.createElement("tr", null, props.Cols.map((col) => React.createElement(HeaderCell, { key: col.key, HeaderStyle: col.headerStyle, DataKey: col.key, Click: (e) => props.Click({ colKey: col.key, colField: col.field, ascending: props.Ascending }, e), Label: col.label, SortKey: props.SortKey, Ascending: props.Ascending })))));
|
|
73
|
-
}
|
|
74
|
-
function HeaderCell(props) {
|
|
75
|
-
const style = (props.HeaderStyle !== undefined) ? props.HeaderStyle : {};
|
|
76
|
-
if (style.cursor === undefined && props.DataKey !== null) {
|
|
77
|
-
style.cursor = 'pointer';
|
|
78
|
-
}
|
|
79
|
-
if (style.position === undefined) {
|
|
80
|
-
style.position = 'relative';
|
|
81
|
-
}
|
|
82
|
-
return (React.createElement("th", { style: style, onClick: (e) => props.Click(e) },
|
|
83
|
-
React.createElement(RenderAngleIcon, { SortKey: props.SortKey, Key: props.DataKey, Ascending: props.Ascending }),
|
|
84
|
-
React.createElement("div", { style: { marginLeft: (props.SortKey === props.DataKey ? 25 : 0) } }, props.Label)));
|
|
85
|
-
}
|
|
86
|
-
function RenderAngleIcon(props) {
|
|
87
|
-
const AngleIcon = (a) => a.ascending ? gpa_symbols_1.SVGIcons.ArrowDropUp : gpa_symbols_1.SVGIcons.ArrowDropDown;
|
|
88
|
-
if (props.SortKey === null)
|
|
89
|
-
return null;
|
|
90
|
-
if (props.SortKey !== props.Key)
|
|
91
|
-
return null;
|
|
92
|
-
return React.createElement("div", { style: { position: 'absolute', width: 25 } },
|
|
93
|
-
React.createElement(AngleIcon, { ascending: props.Ascending }));
|
|
94
|
-
}
|