@gpa-gemstone/react-table 1.2.56 → 1.2.58

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 (47) hide show
  1. package/lib/AdjustableTable/Column.d.ts +6 -45
  2. package/lib/AdjustableTable/Column.js +32 -53
  3. package/lib/AdjustableTable/Table.d.ts +2 -116
  4. package/lib/AdjustableTable/Table.js +329 -347
  5. package/lib/AdjustableTable/Types.d.ts +148 -0
  6. package/lib/AdjustableTable/Types.js +24 -0
  7. package/lib/ConfigurableTable/ConfigurableColumn.d.ts +11 -0
  8. package/lib/ConfigurableTable/ConfigurableColumn.js +31 -0
  9. package/lib/ConfigurableTable/ConfigurableTable.d.ts +25 -0
  10. package/lib/ConfigurableTable/ConfigurableTable.js +189 -0
  11. package/lib/FilterableTable/BooleanFilter.d.ts +26 -0
  12. package/lib/FilterableTable/BooleanFilter.js +68 -0
  13. package/lib/FilterableTable/DateTimeFilters.d.ts +10 -0
  14. package/lib/FilterableTable/DateTimeFilters.js +321 -0
  15. package/lib/FilterableTable/EnumFilter.d.ts +37 -0
  16. package/lib/FilterableTable/EnumFilter.js +89 -0
  17. package/lib/FilterableTable/FilterableColumn.d.ts +20 -0
  18. package/lib/FilterableTable/FilterableColumn.js +34 -0
  19. package/lib/FilterableTable/FilterableTable.d.ts +12 -0
  20. package/lib/FilterableTable/FilterableTable.js +95 -0
  21. package/lib/FilterableTable/NumberFilter.d.ts +19 -0
  22. package/lib/FilterableTable/NumberFilter.js +160 -0
  23. package/lib/FilterableTable/TextFilter.d.ts +14 -0
  24. package/lib/FilterableTable/TextFilter.js +78 -0
  25. package/lib/Filters/BooleanFilter.d.ts +26 -0
  26. package/lib/Filters/BooleanFilter.js +68 -0
  27. package/lib/Filters/DateTimeFilters.d.ts +10 -0
  28. package/lib/Filters/DateTimeFilters.js +321 -0
  29. package/lib/Filters/EnumFilter.d.ts +37 -0
  30. package/lib/Filters/EnumFilter.js +89 -0
  31. package/lib/Filters/NumberFilter.d.ts +19 -0
  32. package/lib/Filters/NumberFilter.js +160 -0
  33. package/lib/Filters/TextFilter.d.ts +14 -0
  34. package/lib/Filters/TextFilter.js +78 -0
  35. package/lib/Table/Column.d.ts +19 -0
  36. package/lib/Table/Column.js +73 -0
  37. package/lib/Table/FilterableColumn.d.ts +20 -0
  38. package/lib/Table/FilterableColumn.js +74 -0
  39. package/lib/Table/Table.d.ts +3 -0
  40. package/lib/Table/Table.js +498 -0
  41. package/lib/Table/Types.d.ts +185 -0
  42. package/lib/Table/Types.js +24 -0
  43. package/lib/index.d.ts +7 -14
  44. package/lib/index.js +13 -19
  45. package/package.json +56 -52
  46. package/lib/AdjustableTable/AdjustableColumn.d.ts +0 -18
  47. package/lib/AdjustableTable/AdjustableColumn.js +0 -187
@@ -0,0 +1,78 @@
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
+ }
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import * as ReactTableProps from './Types';
3
+ export declare function Column<T>(props: React.PropsWithChildren<ReactTableProps.IColumn<T>>): JSX.Element;
4
+ export interface IHeaderWrapperProps {
5
+ onSort: React.MouseEventHandler<HTMLTableCellElement>;
6
+ startAdjustment?: React.MouseEventHandler<HTMLDivElement>;
7
+ sorted: boolean;
8
+ asc: boolean;
9
+ style: React.CSSProperties;
10
+ allowSort?: boolean;
11
+ colKey: string;
12
+ }
13
+ export declare function ColumnHeaderWrapper(props: React.PropsWithChildren<IHeaderWrapperProps>): JSX.Element;
14
+ export interface IDataWrapperProps {
15
+ dragStart?: (e: React.DragEvent) => void;
16
+ onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
17
+ style: React.CSSProperties;
18
+ }
19
+ export declare function ColumnDataWrapper(props: React.PropsWithChildren<IDataWrapperProps>): JSX.Element;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // Column.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
+ // 05/31/2024 - C. Lackner
23
+ // Refactored to fix sizing issues.
24
+ // 12/04/2024 - G. Santos
25
+ // Refactored to fix performance issues.
26
+ //
27
+ // ******************************************************************************************************
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Column = Column;
30
+ exports.ColumnHeaderWrapper = ColumnHeaderWrapper;
31
+ exports.ColumnDataWrapper = ColumnDataWrapper;
32
+ const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
33
+ const React = require("react");
34
+ function Column(props) {
35
+ return React.createElement(React.Fragment, null, props.children);
36
+ }
37
+ function ColumnHeaderWrapper(props) {
38
+ var _a;
39
+ const [showBorder, setShowBorder] = React.useState(false);
40
+ const onHover = React.useCallback(() => { setShowBorder(true); }, []);
41
+ const onLeave = React.useCallback(() => { setShowBorder(false); }, []);
42
+ const onClickBorder = React.useCallback((e) => {
43
+ if (props.startAdjustment != null)
44
+ props.startAdjustment(e);
45
+ }, [props.startAdjustment]);
46
+ const onClick = React.useCallback((e) => {
47
+ var _a;
48
+ if ((_a = props.allowSort) !== null && _a !== void 0 ? _a : true)
49
+ props.onSort(e);
50
+ }, [props.onSort, props.allowSort]);
51
+ const preventPropagation = React.useCallback((e) => {
52
+ e.stopPropagation();
53
+ }, []);
54
+ return React.createElement("th", { style: props.style, onClick: onClick, onDrag: (e) => { e.stopPropagation(); }, id: props.colKey },
55
+ props.startAdjustment == null ? React.createElement(React.Fragment, null) :
56
+ React.createElement("div", { style: {
57
+ width: 5,
58
+ height: '100%',
59
+ position: 'absolute',
60
+ top: 0,
61
+ left: 0,
62
+ opacity: showBorder ? 1 : 0,
63
+ background: '#e9ecef',
64
+ cursor: 'col-resize',
65
+ }, onMouseEnter: onHover, onMouseLeave: onLeave, onMouseDown: onClickBorder, onClick: preventPropagation }),
66
+ props.sorted ? React.createElement("div", { style: { position: 'absolute', width: 25 } }, props.asc ? React.createElement(gpa_symbols_1.ReactIcons.ArrowDropUp, null) : React.createElement(gpa_symbols_1.ReactIcons.ArrowDropDown, null)) : null,
67
+ React.createElement("div", { style: {
68
+ marginLeft: (props.sorted ? 25 : 0),
69
+ } }, (_a = props.children) !== null && _a !== void 0 ? _a : props.colKey));
70
+ }
71
+ function ColumnDataWrapper(props) {
72
+ return (React.createElement("td", { style: props.style, onClick: props.onClick, draggable: props.dragStart !== undefined, onDragStart: props.dragStart }, props.children));
73
+ }
@@ -0,0 +1,20 @@
1
+ import * as ReactTableProps from './Types';
2
+ import * as React from 'react';
3
+ import { Search } from '@gpa-gemstone/react-interactive';
4
+ import { IUnit } from '../Filters/NumberFilter';
5
+ /**
6
+ * Wrapper to make any column configurable
7
+ */
8
+ export default function FilterableColumn<T>(props: React.PropsWithChildren<ReactTableProps.IFilterableCollumn<T>>): JSX.Element;
9
+ export interface IHeaderProps<T> {
10
+ Label: string | React.ReactNode;
11
+ Type?: Search.FieldType;
12
+ Unit?: IUnit[];
13
+ Filter: Search.IFilter<T>[];
14
+ SetFilter: (flt: Search.IFilter<T>[]) => void;
15
+ Field: string | number | symbol | undefined;
16
+ Options?: ReactTableProps.IOptions[];
17
+ ExpandedLabel?: string;
18
+ Guid: string;
19
+ }
20
+ export declare function FilterableColumnHeader<T>(props: IHeaderProps<T>): JSX.Element;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // FilterableColumn.tsx - Gbtc
4
+ //
5
+ // Copyright © 2023, 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
+ // 12/05/2024 - G. Santos
21
+ // Generated original version of source code.
22
+ // ******************************************************************************************************
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.default = FilterableColumn;
25
+ exports.FilterableColumnHeader = FilterableColumnHeader;
26
+ const React = require("react");
27
+ const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
28
+ const BooleanFilter_1 = require("../Filters/BooleanFilter");
29
+ const TextFilter_1 = require("../Filters/TextFilter");
30
+ const EnumFilter_1 = require("../Filters/EnumFilter");
31
+ const NumberFilter_1 = require("../Filters/NumberFilter");
32
+ const DateTimeFilters_1 = require("../Filters/DateTimeFilters");
33
+ /**
34
+ * Wrapper to make any column configurable
35
+ */
36
+ function FilterableColumn(props) {
37
+ return React.createElement(React.Fragment, null, props.children);
38
+ }
39
+ // Table column header details
40
+ function FilterableColumnHeader(props) {
41
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
42
+ const [show, setShow] = React.useState(false);
43
+ return React.createElement(React.Fragment, null,
44
+ React.createElement("div", { onMouseEnter: () => setShow(true), onMouseLeave: () => setShow(false) },
45
+ React.createElement("div", { style: { marginRight: 25 } }, props.Label),
46
+ props.Type !== undefined ? React.createElement(React.Fragment, null,
47
+ 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),
48
+ React.createElement("div", { style: {
49
+ maxHeight: window.innerHeight * 0.50,
50
+ overflowY: 'auto',
51
+ padding: '10 5',
52
+ display: show ? 'block' : 'none',
53
+ position: 'absolute',
54
+ backgroundColor: '#fff',
55
+ boxShadow: '0px 8px 16px 0px rgba(0,0,0,0.2)',
56
+ zIndex: 401,
57
+ minWidth: 'calc(100% - 50px)',
58
+ marginLeft: -25
59
+ }, "data-tableid": props.Guid, onClick: (evt) => { evt.preventDefault(); evt.stopPropagation(); } },
60
+ React.createElement("table", { style: { margin: 0 } },
61
+ React.createElement("tbody", null,
62
+ ((props.ExpandedLabel !== null) && (props.ExpandedLabel !== "") && (props.ExpandedLabel !== undefined)) ?
63
+ React.createElement("tr", null,
64
+ React.createElement("th", { colSpan: props.Type === 'boolean' ? 2 : 1 },
65
+ React.createElement("label", null, props.ExpandedLabel)))
66
+ : null,
67
+ 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,
68
+ 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,
69
+ 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,
70
+ 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,
71
+ 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,
72
+ 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,
73
+ 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));
74
+ }
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import * as ReactTableProps from './Types';
3
+ export declare function Table<T>(props: React.PropsWithChildren<ReactTableProps.ITable<T>>): JSX.Element;