@gpa-gemstone/react-table 1.2.57 → 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.
Files changed (36) hide show
  1. package/lib/ConfigurableTable/ConfigurableColumn.d.ts +11 -0
  2. package/lib/{SearchableTable.js → ConfigurableTable/ConfigurableColumn.js} +7 -16
  3. package/lib/ConfigurableTable/ConfigurableTable.d.ts +25 -0
  4. package/lib/ConfigurableTable/ConfigurableTable.js +189 -0
  5. package/lib/Filters/BooleanFilter.d.ts +26 -0
  6. package/lib/Filters/BooleanFilter.js +68 -0
  7. package/lib/Filters/DateTimeFilters.d.ts +10 -0
  8. package/lib/Filters/DateTimeFilters.js +321 -0
  9. package/lib/Filters/EnumFilter.d.ts +37 -0
  10. package/lib/Filters/EnumFilter.js +89 -0
  11. package/lib/Filters/NumberFilter.d.ts +19 -0
  12. package/lib/Filters/NumberFilter.js +160 -0
  13. package/lib/Filters/TextFilter.d.ts +14 -0
  14. package/lib/Filters/TextFilter.js +78 -0
  15. package/lib/Table/Column.d.ts +19 -0
  16. package/lib/Table/Column.js +73 -0
  17. package/lib/Table/FilterableColumn.d.ts +20 -0
  18. package/lib/Table/FilterableColumn.js +74 -0
  19. package/lib/Table/Table.d.ts +3 -0
  20. package/lib/Table/Table.js +498 -0
  21. package/lib/{AdjustableTable/Table.d.ts → Table/Types.d.ts} +72 -4
  22. package/lib/{DynamicTable.js → Table/Types.js} +3 -23
  23. package/lib/index.d.ts +7 -14
  24. package/lib/index.js +13 -19
  25. package/package.json +8 -4
  26. package/lib/AdjustableTable/AdjustableColumn.d.ts +0 -18
  27. package/lib/AdjustableTable/AdjustableColumn.js +0 -187
  28. package/lib/AdjustableTable/Column.d.ts +0 -59
  29. package/lib/AdjustableTable/Column.js +0 -98
  30. package/lib/AdjustableTable/Table.js +0 -488
  31. package/lib/DynamicTable.d.ts +0 -37
  32. package/lib/SearchableTable.d.ts +0 -15
  33. package/lib/SelectTable.d.ts +0 -19
  34. package/lib/SelectTable.js +0 -102
  35. package/lib/Table.d.ts +0 -99
  36. 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
- }