@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
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as ReactTableProps from '../Table/Types';
|
|
3
|
-
import { Search } from '@gpa-gemstone/react-interactive';
|
|
4
|
-
interface IProps<T> extends ReactTableProps.ITable<T> {
|
|
5
|
-
SetFilter: (filters: Search.IFilter<T>[]) => void;
|
|
6
|
-
DefaultFilter?: Search.IFilter<T>[];
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Table with Filters in the column headers
|
|
10
|
-
*/
|
|
11
|
-
export default function FilterableTable<T>(props: React.PropsWithChildren<IProps<T>>): JSX.Element;
|
|
12
|
-
export {};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// FilterableTable.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2022, 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
|
-
// 03/02/2022 - C. Lackner
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
// ******************************************************************************************************
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.default = FilterableTable;
|
|
25
|
-
const React = require("react");
|
|
26
|
-
const Table_1 = require("../Table/Table");
|
|
27
|
-
const Column_1 = require("../Table/Column");
|
|
28
|
-
const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
29
|
-
const BooleanFilter_1 = require("./BooleanFilter");
|
|
30
|
-
const TextFilter_1 = require("./TextFilter");
|
|
31
|
-
const EnumFilter_1 = require("./EnumFilter");
|
|
32
|
-
const NumberFilter_1 = require("./NumberFilter");
|
|
33
|
-
const DateTimeFilters_1 = require("./DateTimeFilters");
|
|
34
|
-
const helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
35
|
-
const FilterableColumn_1 = require("./FilterableColumn");
|
|
36
|
-
// ToDo: This whole structure is kinda gross, this should live in react-table so we don't have to map FilterableColumn -> Column -> HeaderWrapper
|
|
37
|
-
/**
|
|
38
|
-
* Table with Filters in the column headers
|
|
39
|
-
*/
|
|
40
|
-
function FilterableTable(props) {
|
|
41
|
-
const [filters, setFilters] = React.useState((props.DefaultFilter === undefined ? [] : props.DefaultFilter));
|
|
42
|
-
const [guid] = React.useState((0, helper_functions_1.CreateGuid)());
|
|
43
|
-
function updateFilters(flts, fld) {
|
|
44
|
-
setFilters((fls) => {
|
|
45
|
-
const otherFilters = fls.filter(item => item.FieldName !== fld);
|
|
46
|
-
return otherFilters.concat(flts);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
React.useEffect(() => { props.SetFilter(filters); }, [filters]);
|
|
50
|
-
return (React.createElement(Table_1.Table, Object.assign({}, props), React.Children.map(props.children, (element) => {
|
|
51
|
-
var _a, _b, _c, _d, _e, _f;
|
|
52
|
-
if (!React.isValidElement(element))
|
|
53
|
-
return null;
|
|
54
|
-
if (!(0, FilterableColumn_1.IsFilterableColumnProps)(element.props))
|
|
55
|
-
return null;
|
|
56
|
-
return (React.createElement(Column_1.Column, Object.assign({}, element.props),
|
|
57
|
-
React.createElement(Header, { Label: (_a = element.props) === null || _a === void 0 ? void 0 : _a.children, Filter: filters.filter(f => { var _a, _b; return f.FieldName === ((_b = (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field) === null || _b === void 0 ? void 0 : _b.toString()); }), SetFilter: (f) => { var _a; return updateFilters(f, (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field); }, Field: (_b = element.props) === null || _b === void 0 ? void 0 : _b.Field, Type: (_c = element.props) === null || _c === void 0 ? void 0 : _c.Type, Options: (_d = element.props) === null || _d === void 0 ? void 0 : _d.Enum, ExpandedLabel: (_e = element.props) === null || _e === void 0 ? void 0 : _e.ExpandedLabel, Guid: guid, Unit: (_f = element.props) === null || _f === void 0 ? void 0 : _f.Unit })));
|
|
58
|
-
})));
|
|
59
|
-
}
|
|
60
|
-
// Table column header details
|
|
61
|
-
function Header(props) {
|
|
62
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
63
|
-
const [show, setShow] = React.useState(false);
|
|
64
|
-
return React.createElement(React.Fragment, null,
|
|
65
|
-
React.createElement("div", { onMouseEnter: () => setShow(true), onMouseLeave: () => setShow(false) },
|
|
66
|
-
React.createElement("div", { style: { marginRight: 25 } }, props.Label),
|
|
67
|
-
props.Type !== undefined ? React.createElement(React.Fragment, null,
|
|
68
|
-
React.createElement("div", { style: { width: 25, position: 'absolute', right: 12, top: 12 } }, props.Filter.length > 0 ? React.createElement(gpa_symbols_1.ReactIcons.Filter, null) : null),
|
|
69
|
-
React.createElement("div", { style: {
|
|
70
|
-
maxHeight: window.innerHeight * 0.50,
|
|
71
|
-
overflowY: 'auto',
|
|
72
|
-
padding: '10 5',
|
|
73
|
-
display: show ? 'block' : 'none',
|
|
74
|
-
position: 'absolute',
|
|
75
|
-
backgroundColor: '#fff',
|
|
76
|
-
boxShadow: '0px 8px 16px 0px rgba(0,0,0,0.2)',
|
|
77
|
-
zIndex: 401,
|
|
78
|
-
minWidth: 'calc(100% - 50px)',
|
|
79
|
-
marginLeft: -25
|
|
80
|
-
}, "data-tableid": props.Guid, onClick: (evt) => { evt.preventDefault(); evt.stopPropagation(); } },
|
|
81
|
-
React.createElement("table", { style: { margin: 0 } },
|
|
82
|
-
React.createElement("tbody", null,
|
|
83
|
-
((props.ExpandedLabel !== null) && (props.ExpandedLabel !== "") && (props.ExpandedLabel !== undefined)) ?
|
|
84
|
-
React.createElement("tr", null,
|
|
85
|
-
React.createElement("th", { colSpan: props.Type === 'boolean' ? 2 : 1 },
|
|
86
|
-
React.createElement("label", null, props.ExpandedLabel)))
|
|
87
|
-
: null,
|
|
88
|
-
props.Type === 'boolean' ? React.createElement(BooleanFilter_1.BooleanFilter, { SetFilter: props.SetFilter, Filter: props.Filter, FieldName: (_b = (_a = props.Field) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '' }) : null,
|
|
89
|
-
props.Type === 'string' ? React.createElement(TextFilter_1.TextFilter, { SetFilter: props.SetFilter, Filter: props.Filter, FieldName: (_d = (_c = props.Field) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : '' }) : null,
|
|
90
|
-
props.Type === 'enum' && props.Options !== undefined ? React.createElement(EnumFilter_1.EnumFilter, { FieldName: (_f = (_e = props.Field) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : '', Filter: props.Filter, SetFilter: props.SetFilter, Options: props.Options }) : null,
|
|
91
|
-
props.Type === 'date' ? React.createElement(DateTimeFilters_1.DateFilter, { FieldName: (_h = (_g = props.Field) === null || _g === void 0 ? void 0 : _g.toString()) !== null && _h !== void 0 ? _h : '', Filter: props.Filter, SetFilter: props.SetFilter }) : null,
|
|
92
|
-
props.Type === 'time' ? React.createElement(DateTimeFilters_1.TimeFilter, { FieldName: (_k = (_j = props.Field) === null || _j === void 0 ? void 0 : _j.toString()) !== null && _k !== void 0 ? _k : '', Filter: props.Filter, SetFilter: props.SetFilter }) : null,
|
|
93
|
-
props.Type === 'number' ? React.createElement(NumberFilter_1.NumberFilter, { FieldName: (_m = (_l = props.Field) === null || _l === void 0 ? void 0 : _l.toString()) !== null && _m !== void 0 ? _m : '', Filter: props.Filter, SetFilter: props.SetFilter, Unit: props.Unit }) : null,
|
|
94
|
-
props.Type === 'datetime' ? React.createElement(DateTimeFilters_1.DateTimeFilter, { FieldName: (_p = (_o = props.Field) === null || _o === void 0 ? void 0 : _o.toString()) !== null && _p !== void 0 ? _p : '', Filter: props.Filter, SetFilter: props.SetFilter }) : null)))) : null));
|
|
95
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Search } from '@gpa-gemstone/react-interactive';
|
|
2
|
-
interface IProps<T> {
|
|
3
|
-
SetFilter: (evt: Search.IFilter<T>[]) => void;
|
|
4
|
-
Filter: Search.IFilter<T>[];
|
|
5
|
-
FieldName: string;
|
|
6
|
-
Unit?: IUnit[];
|
|
7
|
-
}
|
|
8
|
-
export interface IUnit {
|
|
9
|
-
label: string;
|
|
10
|
-
GetValue: (value: number) => number;
|
|
11
|
-
GetFilter: (filter: number) => number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param props
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export declare function NumberFilter<T>(props: IProps<T>): JSX.Element;
|
|
19
|
-
export {};
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NumberFilter = NumberFilter;
|
|
4
|
-
// ******************************************************************************************************
|
|
5
|
-
// NumberFilter.tsx - Gbtc
|
|
6
|
-
//
|
|
7
|
-
// Copyright © 2022, Grid Protection Alliance. All Rights Reserved.
|
|
8
|
-
//
|
|
9
|
-
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
10
|
-
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
11
|
-
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
12
|
-
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
13
|
-
//
|
|
14
|
-
// http://opensource.org/licenses/MIT
|
|
15
|
-
//
|
|
16
|
-
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
17
|
-
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
18
|
-
// License for the specific language governing permissions and limitations.
|
|
19
|
-
//
|
|
20
|
-
// Code Modification History:
|
|
21
|
-
// ----------------------------------------------------------------------------------------------------
|
|
22
|
-
// 03/02/2022 - C Lackner
|
|
23
|
-
// Generated original version of source code.
|
|
24
|
-
// ******************************************************************************************************
|
|
25
|
-
const React = require("react");
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param props
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
function NumberFilter(props) {
|
|
32
|
-
var _a, _b, _c, _d, _e;
|
|
33
|
-
const [value, setValue] = React.useState('');
|
|
34
|
-
const [secondValue, setSecondValue] = React.useState('');
|
|
35
|
-
const [operator, setOperator] = React.useState('less than');
|
|
36
|
-
const [unitIndex, setUnitIndex] = React.useState(0);
|
|
37
|
-
React.useEffect(() => {
|
|
38
|
-
if (props.Filter.length === 0) {
|
|
39
|
-
setValue('');
|
|
40
|
-
setSecondValue('');
|
|
41
|
-
}
|
|
42
|
-
if (props.Filter.length > 1) {
|
|
43
|
-
const f1 = props.Filter.find(f => f.Operator === '>' || f.Operator === '>=');
|
|
44
|
-
if (f1 == null)
|
|
45
|
-
setValue('');
|
|
46
|
-
else
|
|
47
|
-
setValue(f1.SearchText);
|
|
48
|
-
const f2 = props.Filter.find(f => f.Operator === '<' || f.Operator === '<=');
|
|
49
|
-
if (f2 == null)
|
|
50
|
-
setSecondValue('');
|
|
51
|
-
else
|
|
52
|
-
setSecondValue(f2.SearchText);
|
|
53
|
-
}
|
|
54
|
-
if (props.Filter.length === 1) {
|
|
55
|
-
setSecondValue('');
|
|
56
|
-
if (props.Filter[0].Operator === '>' || props.Filter[0].Operator === '>=')
|
|
57
|
-
setOperator('greater than');
|
|
58
|
-
else if (props.Filter[0].Operator === '=')
|
|
59
|
-
setOperator('equal to');
|
|
60
|
-
else
|
|
61
|
-
setOperator('less than');
|
|
62
|
-
setValue(props.Filter[0].SearchText);
|
|
63
|
-
}
|
|
64
|
-
}, [props.Filter]);
|
|
65
|
-
React.useEffect(() => {
|
|
66
|
-
let handle = null;
|
|
67
|
-
if (value === '' && secondValue === '' && props.Filter.length !== 0)
|
|
68
|
-
handle = setTimeout(() => props.SetFilter([]), 500);
|
|
69
|
-
if (value === '' && secondValue === '')
|
|
70
|
-
return () => { if (handle !== null)
|
|
71
|
-
clearTimeout(handle); };
|
|
72
|
-
if (operator === 'between')
|
|
73
|
-
handle = setTimeout(() => props.SetFilter([
|
|
74
|
-
{
|
|
75
|
-
FieldName: props.FieldName,
|
|
76
|
-
IsPivotColumn: false,
|
|
77
|
-
Operator: '>=',
|
|
78
|
-
Type: 'number',
|
|
79
|
-
SearchText: value
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
FieldName: props.FieldName,
|
|
83
|
-
IsPivotColumn: false,
|
|
84
|
-
Operator: '<=',
|
|
85
|
-
Type: 'number',
|
|
86
|
-
SearchText: secondValue
|
|
87
|
-
}
|
|
88
|
-
]), 500);
|
|
89
|
-
else
|
|
90
|
-
handle = setTimeout(() => props.SetFilter([{
|
|
91
|
-
FieldName: props.FieldName,
|
|
92
|
-
IsPivotColumn: false,
|
|
93
|
-
Operator: transformSymbol(operator),
|
|
94
|
-
Type: 'number',
|
|
95
|
-
SearchText: value
|
|
96
|
-
}]), 500);
|
|
97
|
-
return () => { if (handle !== null)
|
|
98
|
-
clearTimeout(handle); };
|
|
99
|
-
}, [operator, value, secondValue]);
|
|
100
|
-
function transformSymbol(s) {
|
|
101
|
-
if (s === 'less than')
|
|
102
|
-
return '<';
|
|
103
|
-
if (s === 'greater than')
|
|
104
|
-
return '>';
|
|
105
|
-
return '=';
|
|
106
|
-
}
|
|
107
|
-
const hasUnit = props.Unit !== undefined && unitIndex >= 0 && unitIndex < props.Unit.length;
|
|
108
|
-
return React.createElement(React.Fragment, null,
|
|
109
|
-
React.createElement("tr", { onClick: (evt) => { evt.preventDefault(); } },
|
|
110
|
-
React.createElement("td", null,
|
|
111
|
-
React.createElement("select", { className: 'form-control', value: operator, onChange: (evt) => {
|
|
112
|
-
const v = evt.target.value;
|
|
113
|
-
setOperator(v);
|
|
114
|
-
} },
|
|
115
|
-
React.createElement("option", { value: 'less than' },
|
|
116
|
-
"Less than (",
|
|
117
|
-
'<',
|
|
118
|
-
")"),
|
|
119
|
-
React.createElement("option", { value: 'equal to' }, "Equal to (=)"),
|
|
120
|
-
React.createElement("option", { value: 'greater than' },
|
|
121
|
-
"Greater than (",
|
|
122
|
-
'>',
|
|
123
|
-
")"),
|
|
124
|
-
React.createElement("option", { value: 'between' }, "In range")))),
|
|
125
|
-
React.createElement("tr", { onClick: (evt) => { evt.preventDefault(); } },
|
|
126
|
-
React.createElement("td", null,
|
|
127
|
-
React.createElement("input", { type: 'number', className: 'form-control', value: props.Unit !== undefined && hasUnit ? (_a = props.Unit[unitIndex].GetValue(parseFloat(value)).toString()) !== null && _a !== void 0 ? _a : '' : value, onChange: (evt) => {
|
|
128
|
-
let v = evt.target.value;
|
|
129
|
-
if (props.Unit !== undefined && unitIndex >= 0 && unitIndex < props.Unit.length) {
|
|
130
|
-
v = props.Unit[unitIndex].GetFilter(parseFloat(v)).toString();
|
|
131
|
-
}
|
|
132
|
-
setValue(v);
|
|
133
|
-
} })),
|
|
134
|
-
props.Unit !== undefined ?
|
|
135
|
-
React.createElement("td", null,
|
|
136
|
-
React.createElement("select", { className: 'form-control', value: (_c = (_b = props.Unit[unitIndex]) === null || _b === void 0 ? void 0 : _b.label) !== null && _c !== void 0 ? _c : '', onChange: (evt) => {
|
|
137
|
-
var _a, _b;
|
|
138
|
-
const v = evt.target.value;
|
|
139
|
-
setUnitIndex((_b = (_a = props.Unit) === null || _a === void 0 ? void 0 : _a.findIndex(u => u.label === v)) !== null && _b !== void 0 ? _b : -1);
|
|
140
|
-
} }, props.Unit.map((u) => React.createElement("option", { value: u.label, key: u.label }, u.label)))) : null),
|
|
141
|
-
operator === 'between' ? React.createElement(React.Fragment, null,
|
|
142
|
-
React.createElement("tr", { onClick: (evt) => { evt.preventDefault(); } },
|
|
143
|
-
React.createElement("td", null, "and")),
|
|
144
|
-
React.createElement("tr", { onClick: (evt) => { evt.preventDefault(); } },
|
|
145
|
-
React.createElement("td", null,
|
|
146
|
-
React.createElement("input", { type: 'number', className: 'form-control', value: props.Unit !== undefined && hasUnit ? props.Unit[unitIndex].GetValue(parseFloat(secondValue)).toString() : secondValue, onChange: (evt) => {
|
|
147
|
-
let v = evt.target.value;
|
|
148
|
-
if (props.Unit !== undefined && unitIndex >= 0 && unitIndex < props.Unit.length) {
|
|
149
|
-
v = props.Unit[unitIndex].GetFilter(parseFloat(v)).toString();
|
|
150
|
-
}
|
|
151
|
-
setSecondValue(v);
|
|
152
|
-
} }))),
|
|
153
|
-
props.Unit !== undefined ?
|
|
154
|
-
React.createElement("td", null,
|
|
155
|
-
React.createElement("select", { className: 'form-control', value: (_e = (_d = props.Unit[unitIndex]) === null || _d === void 0 ? void 0 : _d.label) !== null && _e !== void 0 ? _e : '', onChange: (evt) => {
|
|
156
|
-
var _a, _b;
|
|
157
|
-
const v = evt.target.value;
|
|
158
|
-
setUnitIndex((_b = (_a = props.Unit) === null || _a === void 0 ? void 0 : _a.findIndex(u => u.label === v)) !== null && _b !== void 0 ? _b : -1);
|
|
159
|
-
} }, props.Unit.map((u) => React.createElement("option", { value: u.label, key: u.label }, u.label)))) : null) : null);
|
|
160
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Search } from '@gpa-gemstone/react-interactive';
|
|
2
|
-
interface IProps<T> {
|
|
3
|
-
SetFilter: (evt: Search.IFilter<T>[]) => void;
|
|
4
|
-
Filter: Search.IFilter<T>[];
|
|
5
|
-
FieldName: string;
|
|
6
|
-
ApproxMatches?: boolean;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Component for rendering a text input filter.
|
|
10
|
-
* @param props - Props for configuring and managing the text filter.
|
|
11
|
-
* @returns JSX for rendering a text input filter with wildcard options.
|
|
12
|
-
*/
|
|
13
|
-
export declare function TextFilter<T>(props: IProps<T>): JSX.Element;
|
|
14
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextFilter = TextFilter;
|
|
4
|
-
// ******************************************************************************************************
|
|
5
|
-
// TextFilter.tsx - Gbtc
|
|
6
|
-
//
|
|
7
|
-
// Copyright © 2022, Grid Protection Alliance. All Rights Reserved.
|
|
8
|
-
//
|
|
9
|
-
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
10
|
-
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
11
|
-
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
12
|
-
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
13
|
-
//
|
|
14
|
-
// http://opensource.org/licenses/MIT
|
|
15
|
-
//
|
|
16
|
-
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
17
|
-
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
18
|
-
// License for the specific language governing permissions and limitations.
|
|
19
|
-
//
|
|
20
|
-
// Code Modification History:
|
|
21
|
-
// ----------------------------------------------------------------------------------------------------
|
|
22
|
-
// 03/02/2022 - C Lackner
|
|
23
|
-
// Generated original version of source code.
|
|
24
|
-
// ******************************************************************************************************
|
|
25
|
-
const React = require("react");
|
|
26
|
-
/**
|
|
27
|
-
* Component for rendering a text input filter.
|
|
28
|
-
* @param props - Props for configuring and managing the text filter.
|
|
29
|
-
* @returns JSX for rendering a text input filter with wildcard options.
|
|
30
|
-
*/
|
|
31
|
-
function TextFilter(props) {
|
|
32
|
-
const [txt, setTxt] = React.useState('');
|
|
33
|
-
// Handles changes in the Filter prop.
|
|
34
|
-
React.useEffect(() => {
|
|
35
|
-
var _a;
|
|
36
|
-
// Resets text input if there is no filter.
|
|
37
|
-
if (props.Filter.length === 0) {
|
|
38
|
-
setTxt('');
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (((_a = props.ApproxMatches) !== null && _a !== void 0 ? _a : true))
|
|
42
|
-
setTxt(props.Filter[0].SearchText.substring(1, props.Filter[0].SearchText.length - 1));
|
|
43
|
-
else
|
|
44
|
-
setTxt(props.Filter[0].SearchText);
|
|
45
|
-
}, [props.Filter]);
|
|
46
|
-
// Handles text input chanages.
|
|
47
|
-
React.useEffect(() => {
|
|
48
|
-
let handle = null;
|
|
49
|
-
// Clears filter if txt is empty AND filter is not empty.
|
|
50
|
-
if ((txt == null || txt.trim().length === 0) && props.Filter.length !== 0)
|
|
51
|
-
handle = setTimeout(() => props.SetFilter([]), 500);
|
|
52
|
-
// Applies filter based on specifications.
|
|
53
|
-
if (txt != null && txt.trim().length > 0 && (props.Filter.length === 0 || props.Filter[0].SearchText !== txt.trim()))
|
|
54
|
-
handle = setTimeout(() => props.SetFilter([{
|
|
55
|
-
FieldName: props.FieldName,
|
|
56
|
-
IsPivotColumn: false,
|
|
57
|
-
SearchText: (props.ApproxMatches === undefined || props.ApproxMatches ? '%' + txt.trim() + '%' : txt.trim()),
|
|
58
|
-
Operator: 'LIKE',
|
|
59
|
-
Type: 'string'
|
|
60
|
-
}]), 500);
|
|
61
|
-
// Cleans function to clear timeout.
|
|
62
|
-
return () => { if (handle !== null)
|
|
63
|
-
clearTimeout(handle); };
|
|
64
|
-
}, [txt]);
|
|
65
|
-
// renders text input filter and addl information
|
|
66
|
-
return React.createElement(React.Fragment, null,
|
|
67
|
-
React.createElement("tr", { onClick: (evt) => { evt.preventDefault(); } },
|
|
68
|
-
React.createElement("td", null,
|
|
69
|
-
React.createElement("input", { className: 'form-control', value: txt.replace('$_', '_'), placeholder: "Search", onChange: (evt) => {
|
|
70
|
-
const value = evt.target.value;
|
|
71
|
-
setTxt(value.replace('_', '$_'));
|
|
72
|
-
} }))),
|
|
73
|
-
React.createElement("tr", null,
|
|
74
|
-
React.createElement("td", null,
|
|
75
|
-
" ",
|
|
76
|
-
React.createElement("label", null, "Wildcard (*) can be used"),
|
|
77
|
-
" ")));
|
|
78
|
-
}
|
package/lib/SearchableTable.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TableProps } from './Table';
|
|
2
|
-
interface ISearchableTableProps<T> extends TableProps<T> {
|
|
3
|
-
/**
|
|
4
|
-
* Function used to filter data
|
|
5
|
-
* @param item: The T to be matched
|
|
6
|
-
* @param search: The string to search by
|
|
7
|
-
* @returns: true if the item should be shown in the Table
|
|
8
|
-
*/
|
|
9
|
-
matchSearch: (item: T, search: string) => boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A Table with an input Field to search on top
|
|
13
|
-
*/
|
|
14
|
-
export declare function SearchableTable<T>(props: ISearchableTableProps<T>): JSX.Element;
|
|
15
|
-
export {};
|
package/lib/SearchableTable.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// SearchableTable.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2021, 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
|
-
// 07/12/2021 - C. Lackner
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
//
|
|
23
|
-
// ******************************************************************************************************
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.SearchableTable = SearchableTable;
|
|
26
|
-
const React = require("react");
|
|
27
|
-
const Table_1 = require("./Table");
|
|
28
|
-
/**
|
|
29
|
-
* A Table with an input Field to search on top
|
|
30
|
-
*/
|
|
31
|
-
function SearchableTable(props) {
|
|
32
|
-
const [data, setData] = React.useState(props.data);
|
|
33
|
-
const [searchTextAS, setSearchTextAS] = React.useState('');
|
|
34
|
-
React.useEffect(() => {
|
|
35
|
-
setData(props.data.filter(s => props.matchSearch(s, searchTextAS)));
|
|
36
|
-
}, [props.data, searchTextAS]);
|
|
37
|
-
return React.createElement(React.Fragment, null,
|
|
38
|
-
React.createElement("input", { className: "form-control", placeholder: "Search filter for select box ...", value: searchTextAS, onChange: (e) => setSearchTextAS(e.target.value) }),
|
|
39
|
-
React.createElement(Table_1.default, Object.assign({}, props, { data: data })));
|
|
40
|
-
}
|
package/lib/SelectTable.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Column } from './Table';
|
|
3
|
-
export interface ISelectTableProps<T> {
|
|
4
|
-
cols: Column<T>[];
|
|
5
|
-
data: T[];
|
|
6
|
-
sortKey: string;
|
|
7
|
-
ascending: boolean;
|
|
8
|
-
tableClass?: string;
|
|
9
|
-
tableStyle?: React.CSSProperties;
|
|
10
|
-
theadStyle?: React.CSSProperties;
|
|
11
|
-
theadClass?: string;
|
|
12
|
-
tbodyStyle?: React.CSSProperties;
|
|
13
|
-
tbodyClass?: string;
|
|
14
|
-
rowStyle?: React.CSSProperties;
|
|
15
|
-
onSelection: (selected: T[]) => void;
|
|
16
|
-
KeyField: keyof T;
|
|
17
|
-
selectAllCounter?: number;
|
|
18
|
-
}
|
|
19
|
-
export declare function SelectTable<T>(props: ISelectTableProps<T>): JSX.Element;
|
package/lib/SelectTable.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// SelectTable.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2021, 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
|
-
// 01/22/2021 - C. Lackner
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
//
|
|
23
|
-
// ******************************************************************************************************
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.SelectTable = SelectTable;
|
|
26
|
-
const React = require("react");
|
|
27
|
-
const _ = require("lodash");
|
|
28
|
-
const Table_1 = require("./Table");
|
|
29
|
-
function SelectTable(props) {
|
|
30
|
-
const didMountRef = React.useRef(false);
|
|
31
|
-
const [data, setData] = React.useState(props.data);
|
|
32
|
-
const [selected, setSelected] = React.useState([]);
|
|
33
|
-
const [sortKey, setSortKey] = React.useState(props.sortKey);
|
|
34
|
-
const [ascending, setAscending] = React.useState(props.ascending);
|
|
35
|
-
React.useEffect(() => {
|
|
36
|
-
if (didMountRef.current)
|
|
37
|
-
selectAll();
|
|
38
|
-
else
|
|
39
|
-
didMountRef.current = true;
|
|
40
|
-
}, [props.selectAllCounter]);
|
|
41
|
-
React.useEffect(() => {
|
|
42
|
-
if (props.data.length !== data.length)
|
|
43
|
-
setData(props.data);
|
|
44
|
-
}, [props.data]);
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
setSelected((d) => d.filter(keyItem => data.findIndex(item => item[props.KeyField] === keyItem) > -1));
|
|
47
|
-
}, [data]);
|
|
48
|
-
React.useEffect(() => {
|
|
49
|
-
const sortColumn = props.cols.filter(col => col.key === sortKey)[0];
|
|
50
|
-
if (sortColumn === undefined || sortColumn.field === undefined)
|
|
51
|
-
return;
|
|
52
|
-
const sortField = sortColumn.field;
|
|
53
|
-
setData((lst) => (_.orderBy(lst, [sortField], [(ascending ? "asc" : "desc")])));
|
|
54
|
-
}, [ascending, sortKey]);
|
|
55
|
-
React.useEffect(() => {
|
|
56
|
-
props.onSelection(data.filter(item => selected.findIndex(key => key === item[props.KeyField]) > -1));
|
|
57
|
-
}, [selected]);
|
|
58
|
-
function handleClick(d) {
|
|
59
|
-
const sIndex = selected.findIndex(item => item === d.row[props.KeyField]);
|
|
60
|
-
if (sIndex === -1)
|
|
61
|
-
setSelected((od) => [...od, d.row[props.KeyField]]);
|
|
62
|
-
else
|
|
63
|
-
setSelected((od) => od.filter(item => item !== d.row[props.KeyField]));
|
|
64
|
-
}
|
|
65
|
-
function selectAll() {
|
|
66
|
-
setSelected((d) => { if (d.length === data.length)
|
|
67
|
-
return [];
|
|
68
|
-
else
|
|
69
|
-
return data.map(row => row[props.KeyField]); });
|
|
70
|
-
}
|
|
71
|
-
function handleSort(d) {
|
|
72
|
-
if (d.colKey === sortKey)
|
|
73
|
-
setAscending(!ascending);
|
|
74
|
-
else
|
|
75
|
-
setSortKey(d.colKey);
|
|
76
|
-
}
|
|
77
|
-
const tableProps = {
|
|
78
|
-
cols: [
|
|
79
|
-
{ key: 'gemstone-checkbox', field: props.KeyField, label: '', headerStyle: { width: '4em' }, rowStyle: { width: '4em' }, content: (item) => {
|
|
80
|
-
const index = selected.findIndex(i => i === item[props.KeyField]);
|
|
81
|
-
const iconClass = index > -1 ? 'fa-check-square-o' : 'fa-square-o';
|
|
82
|
-
return React.createElement("div", { style: { textAlign: 'center', verticalAlign: 'middle' } },
|
|
83
|
-
React.createElement("i", { className: `fa ${iconClass} fa-3x` }));
|
|
84
|
-
} },
|
|
85
|
-
...props.cols
|
|
86
|
-
],
|
|
87
|
-
data,
|
|
88
|
-
onClick: handleClick,
|
|
89
|
-
sortKey,
|
|
90
|
-
ascending,
|
|
91
|
-
onSort: handleSort,
|
|
92
|
-
tableClass: props.tableClass,
|
|
93
|
-
tableStyle: props.tableStyle,
|
|
94
|
-
theadStyle: props.theadStyle,
|
|
95
|
-
theadClass: props.theadClass,
|
|
96
|
-
tbodyStyle: props.tbodyStyle,
|
|
97
|
-
tbodyClass: props.tbodyClass,
|
|
98
|
-
selected: (d) => false,
|
|
99
|
-
rowStyle: props.rowStyle
|
|
100
|
-
};
|
|
101
|
-
return React.createElement(Table_1.default, Object.assign({}, tableProps));
|
|
102
|
-
}
|