@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.
- package/lib/ConfigurableTable/ConfigurableColumn.d.ts +11 -0
- package/lib/{SearchableTable.js → ConfigurableTable/ConfigurableColumn.js} +7 -16
- package/lib/ConfigurableTable/ConfigurableTable.d.ts +25 -0
- package/lib/ConfigurableTable/ConfigurableTable.js +189 -0
- package/lib/Filters/BooleanFilter.d.ts +26 -0
- package/lib/Filters/BooleanFilter.js +68 -0
- package/lib/Filters/DateTimeFilters.d.ts +10 -0
- package/lib/Filters/DateTimeFilters.js +321 -0
- package/lib/Filters/EnumFilter.d.ts +37 -0
- package/lib/Filters/EnumFilter.js +89 -0
- package/lib/Filters/NumberFilter.d.ts +19 -0
- package/lib/Filters/NumberFilter.js +160 -0
- package/lib/Filters/TextFilter.d.ts +14 -0
- package/lib/Filters/TextFilter.js +78 -0
- package/lib/Table/Column.d.ts +19 -0
- package/lib/Table/Column.js +73 -0
- package/lib/Table/FilterableColumn.d.ts +20 -0
- package/lib/Table/FilterableColumn.js +74 -0
- package/lib/Table/Table.d.ts +3 -0
- package/lib/Table/Table.js +498 -0
- package/lib/{AdjustableTable/Table.d.ts → Table/Types.d.ts} +72 -4
- package/lib/{DynamicTable.js → Table/Types.js} +3 -23
- package/lib/index.d.ts +7 -14
- package/lib/index.js +13 -19
- package/package.json +8 -4
- package/lib/AdjustableTable/AdjustableColumn.d.ts +0 -18
- package/lib/AdjustableTable/AdjustableColumn.js +0 -187
- package/lib/AdjustableTable/Column.d.ts +0 -59
- package/lib/AdjustableTable/Column.js +0 -98
- package/lib/AdjustableTable/Table.js +0 -488
- package/lib/DynamicTable.d.ts +0 -37
- package/lib/SearchableTable.d.ts +0 -15
- 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/index.js
CHANGED
|
@@ -24,24 +24,18 @@
|
|
|
24
24
|
//
|
|
25
25
|
// ******************************************************************************************************
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.Paging = exports.
|
|
28
|
-
const Table_1 = require("./Table");
|
|
29
|
-
Object.defineProperty(exports, "Rows", { enumerable: true, get: function () { return Table_1.Rows; } });
|
|
30
|
-
const SelectTable_1 = require("./SelectTable");
|
|
31
|
-
Object.defineProperty(exports, "SelectTable", { enumerable: true, get: function () { return SelectTable_1.SelectTable; } });
|
|
32
|
-
const SearchableTable_1 = require("./SearchableTable");
|
|
33
|
-
Object.defineProperty(exports, "SearchableTable", { enumerable: true, get: function () { return SearchableTable_1.SearchableTable; } });
|
|
34
|
-
const DynamicTable_1 = require("./DynamicTable");
|
|
35
|
-
Object.defineProperty(exports, "DynamicTable", { enumerable: true, get: function () { return DynamicTable_1.DynamicTable; } });
|
|
27
|
+
exports.Paging = exports.ConfigurableColumn = exports.ConfigurableTable = exports.FilterableColumn = exports.Column = exports.Table = exports.ReactTableProps = void 0;
|
|
36
28
|
const Paging_1 = require("./Paging");
|
|
37
29
|
exports.Paging = Paging_1.default;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
exports.
|
|
30
|
+
const ReactTableProps = require("./Table/Types");
|
|
31
|
+
exports.ReactTableProps = ReactTableProps;
|
|
32
|
+
const Table_1 = require("./Table/Table");
|
|
33
|
+
Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return Table_1.Table; } });
|
|
34
|
+
const Column_1 = require("./Table/Column");
|
|
35
|
+
Object.defineProperty(exports, "Column", { enumerable: true, get: function () { return Column_1.Column; } });
|
|
36
|
+
const FilterableColumn_1 = require("./Table/FilterableColumn");
|
|
37
|
+
exports.FilterableColumn = FilterableColumn_1.default;
|
|
38
|
+
const ConfigurableTable_1 = require("./ConfigurableTable/ConfigurableTable");
|
|
39
|
+
exports.ConfigurableTable = ConfigurableTable_1.default;
|
|
40
|
+
const ConfigurableColumn_1 = require("./ConfigurableTable/ConfigurableColumn");
|
|
41
|
+
exports.ConfigurableColumn = ConfigurableColumn_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.59",
|
|
4
4
|
"description": "Table for GPA web applications",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@types/jest": "^27.0.0",
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
|
37
37
|
"@typescript-eslint/parser": "^5.60.0",
|
|
38
|
+
"@types/react-portal": "4.0.4",
|
|
38
39
|
"eslint": "^8.43.0",
|
|
39
40
|
"jest": "^29.0.0",
|
|
40
41
|
"prettier": "^2.3.2",
|
|
@@ -42,12 +43,15 @@
|
|
|
42
43
|
"typescript": "5.5.3"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@gpa-gemstone/gpa-symbols": "0.0.
|
|
46
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
46
|
+
"@gpa-gemstone/gpa-symbols": "0.0.46",
|
|
47
|
+
"@gpa-gemstone/helper-functions": "0.0.37",
|
|
48
|
+
"@gpa-gemstone/react-interactive": "1.0.138",
|
|
47
49
|
"@types/lodash": "^4.14.171",
|
|
48
50
|
"@types/react": "^17.0.14",
|
|
49
51
|
"lodash": "^4.17.21",
|
|
50
|
-
"react": "^18.2.0"
|
|
52
|
+
"react": "^18.2.0",
|
|
53
|
+
"react-dom": "18.2.0",
|
|
54
|
+
"react-portal": "4.2.2"
|
|
51
55
|
},
|
|
52
56
|
"publishConfig": {"access": "public"}
|
|
53
57
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { IColumnProps, IDataWrapperProps, IHeaderWrapperProps } from './Column';
|
|
3
|
-
export default function AdjustableColumn<T>(props: React.PropsWithChildren<IColumnProps<T>>): JSX.Element;
|
|
4
|
-
interface IAdjustableHeaderWrapperProps extends IHeaderWrapperProps {
|
|
5
|
-
adjustment: number;
|
|
6
|
-
startAdjustment: React.MouseEventHandler<HTMLDivElement>;
|
|
7
|
-
setMinWidth: (w: number) => void;
|
|
8
|
-
minWidth?: number;
|
|
9
|
-
setMaxWidth: (w: number) => void;
|
|
10
|
-
maxWidth?: number;
|
|
11
|
-
extraWidth: number;
|
|
12
|
-
}
|
|
13
|
-
export declare function AdjustableColumnHeaderWrapper(props: React.PropsWithChildren<IAdjustableHeaderWrapperProps>): JSX.Element | null;
|
|
14
|
-
interface IAdjustableDataWrapperProps extends IDataWrapperProps {
|
|
15
|
-
adjustment?: number;
|
|
16
|
-
}
|
|
17
|
-
export declare function AdjustableColumnDataWrapper(props: React.PropsWithChildren<IAdjustableDataWrapperProps>): JSX.Element | null;
|
|
18
|
-
export {};
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = AdjustableColumn;
|
|
4
|
-
exports.AdjustableColumnHeaderWrapper = AdjustableColumnHeaderWrapper;
|
|
5
|
-
exports.AdjustableColumnDataWrapper = AdjustableColumnDataWrapper;
|
|
6
|
-
// ******************************************************************************************************
|
|
7
|
-
// AdjustableColumn.tsx - Gbtc
|
|
8
|
-
//
|
|
9
|
-
// Copyright © 2023, Grid Protection Alliance. All Rights Reserved.
|
|
10
|
-
//
|
|
11
|
-
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
12
|
-
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
13
|
-
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
14
|
-
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
15
|
-
//
|
|
16
|
-
// http://opensource.org/licenses/MIT
|
|
17
|
-
//
|
|
18
|
-
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
19
|
-
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
20
|
-
// License for the specific language governing permissions and limitations.
|
|
21
|
-
//
|
|
22
|
-
// Code Modification History:
|
|
23
|
-
// ----------------------------------------------------------------------------------------------------
|
|
24
|
-
// 11/19/2023 - C. Lackner
|
|
25
|
-
// Generated original version of source code.
|
|
26
|
-
// 05/31/2024 - C. Lackner
|
|
27
|
-
// Refactored to fix sizing issues.
|
|
28
|
-
//
|
|
29
|
-
// ******************************************************************************************************
|
|
30
|
-
const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
31
|
-
const React = require("react");
|
|
32
|
-
function AdjustableColumn(props) {
|
|
33
|
-
return React.createElement(React.Fragment, null, props.children);
|
|
34
|
-
}
|
|
35
|
-
function AdjustableColumnHeaderWrapper(props) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
37
|
-
const thref = React.useRef(null);
|
|
38
|
-
const [mode, setMode] = React.useState('minWidth');
|
|
39
|
-
//const [width, setWidth] = React.useState<number>();
|
|
40
|
-
const [minWidth, setMinWidth] = React.useState();
|
|
41
|
-
const [maxWidth, setMaxWidth] = React.useState();
|
|
42
|
-
const [showBorder, setShowBorder] = React.useState(false);
|
|
43
|
-
const onHover = React.useCallback(() => { setShowBorder(true); }, []);
|
|
44
|
-
const onLeave = React.useCallback(() => { setShowBorder(false); }, []);
|
|
45
|
-
const style = (props.style !== undefined) ? Object.assign({}, props.style) : {};
|
|
46
|
-
style.overflowX = (_a = style.overflowX) !== null && _a !== void 0 ? _a : 'hidden';
|
|
47
|
-
style.display = (_b = style.display) !== null && _b !== void 0 ? _b : 'inline-block';
|
|
48
|
-
style.position = (_c = style.position) !== null && _c !== void 0 ? _c : 'relative';
|
|
49
|
-
style.borderTop = (_d = style.borderTop) !== null && _d !== void 0 ? _d : 'none';
|
|
50
|
-
style.minWidth = (_e = style.minWidth) !== null && _e !== void 0 ? _e : 100;
|
|
51
|
-
const isAuto = style.width == 'auto';
|
|
52
|
-
const isUndefined = style.width === undefined;
|
|
53
|
-
if ((style.width == undefined || style.width == 'auto') && props.width !== undefined && mode === 'width') {
|
|
54
|
-
style.width = (props.width) + props.extraWidth;
|
|
55
|
-
}
|
|
56
|
-
if (mode === 'minWidth') {
|
|
57
|
-
style.width = style.minWidth;
|
|
58
|
-
}
|
|
59
|
-
if (mode === 'maxWidth') {
|
|
60
|
-
style.width = style.maxWidth;
|
|
61
|
-
}
|
|
62
|
-
if (mode === 'width' && props.adjustment !== undefined && props.adjustment !== 0 && style.width !== undefined) {
|
|
63
|
-
style.width = `calc(${formatwidth(style.width).toString()} ${props.adjustment < 0 ? '-' : '+'} ${Math.abs(props.adjustment).toString()}px)`;
|
|
64
|
-
}
|
|
65
|
-
if (style.cursor === undefined && ((_f = props.allowSort) !== null && _f !== void 0 ? _f : true)) {
|
|
66
|
-
style.cursor = 'pointer';
|
|
67
|
-
}
|
|
68
|
-
React.useLayoutEffect(() => {
|
|
69
|
-
var _a, _b, _c;
|
|
70
|
-
if (thref.current == null)
|
|
71
|
-
return;
|
|
72
|
-
if (mode == 'minWidth') {
|
|
73
|
-
const w = (_a = thref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
|
|
74
|
-
if (w === undefined)
|
|
75
|
-
return;
|
|
76
|
-
if (w !== minWidth) {
|
|
77
|
-
setMinWidth(w);
|
|
78
|
-
}
|
|
79
|
-
if (maxWidth === undefined && style.maxWidth !== undefined) {
|
|
80
|
-
setMode('maxWidth');
|
|
81
|
-
}
|
|
82
|
-
else if (props.width === undefined) {
|
|
83
|
-
setMode('width');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (mode == 'maxWidth') {
|
|
87
|
-
const w = (_b = thref.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width;
|
|
88
|
-
if (w === undefined)
|
|
89
|
-
return;
|
|
90
|
-
if (w !== maxWidth) {
|
|
91
|
-
setMaxWidth(w);
|
|
92
|
-
}
|
|
93
|
-
if (props.width === undefined) {
|
|
94
|
-
setMode('width');
|
|
95
|
-
}
|
|
96
|
-
else if (props.minWidth === undefined && style.minWidth !== undefined) {
|
|
97
|
-
setMode('minWidth');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (mode == 'width') {
|
|
101
|
-
const w = (_c = thref.current) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().width;
|
|
102
|
-
if (w === undefined)
|
|
103
|
-
return;
|
|
104
|
-
if (props.width === undefined || (w !== (props.width + props.extraWidth))) {
|
|
105
|
-
props.setWidth(w, isAuto, isUndefined);
|
|
106
|
-
}
|
|
107
|
-
if (maxWidth === undefined && style.maxWidth !== undefined) {
|
|
108
|
-
setMode('maxWidth');
|
|
109
|
-
}
|
|
110
|
-
else if (minWidth === undefined && style.minWidth !== undefined) {
|
|
111
|
-
setMode('minWidth');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
React.useEffect(() => {
|
|
116
|
-
if (minWidth !== props.minWidth)
|
|
117
|
-
props.setMinWidth(minWidth);
|
|
118
|
-
}, [minWidth]);
|
|
119
|
-
React.useEffect(() => {
|
|
120
|
-
if (maxWidth !== props.maxWidth)
|
|
121
|
-
props.setMaxWidth(maxWidth);
|
|
122
|
-
}, [maxWidth]);
|
|
123
|
-
const onClick = React.useCallback((e) => {
|
|
124
|
-
var _a;
|
|
125
|
-
if ((_a = props.allowSort) !== null && _a !== void 0 ? _a : true)
|
|
126
|
-
props.onSort(e);
|
|
127
|
-
}, [props.onSort, props.allowSort]);
|
|
128
|
-
const onClickBorder = React.useCallback((e) => {
|
|
129
|
-
props.startAdjustment(e);
|
|
130
|
-
}, [props.startAdjustment]);
|
|
131
|
-
if (props.width != undefined && !props.enabled)
|
|
132
|
-
return null;
|
|
133
|
-
return React.createElement("th", { ref: thref, style: style, onClick: onClick, onDrag: (e) => { e.stopPropagation(); } },
|
|
134
|
-
React.createElement("div", { style: {
|
|
135
|
-
width: 5,
|
|
136
|
-
height: '100%',
|
|
137
|
-
position: 'absolute',
|
|
138
|
-
top: 0,
|
|
139
|
-
left: 0,
|
|
140
|
-
opacity: showBorder ? 1 : 0,
|
|
141
|
-
background: '#e9ecef',
|
|
142
|
-
cursor: 'col-resize'
|
|
143
|
-
}, onMouseEnter: onHover, onMouseLeave: onLeave, onMouseDown: onClickBorder }),
|
|
144
|
-
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,
|
|
145
|
-
React.createElement("div", { style: {
|
|
146
|
-
marginLeft: (props.sorted ? 25 : 0),
|
|
147
|
-
} }, (_g = props.children) !== null && _g !== void 0 ? _g : props.colKey));
|
|
148
|
-
}
|
|
149
|
-
function AdjustableColumnDataWrapper(props) {
|
|
150
|
-
var _a, _b;
|
|
151
|
-
const tdref = React.useRef(null);
|
|
152
|
-
const style = (props.style !== undefined) ? Object.assign({}, props.style) : {};
|
|
153
|
-
style.overflowX = (_a = style.overflowX) !== null && _a !== void 0 ? _a : 'hidden';
|
|
154
|
-
style.display = (_b = style.display) !== null && _b !== void 0 ? _b : 'inline-block';
|
|
155
|
-
const isAuto = style.width == 'auto';
|
|
156
|
-
const isUndefined = style.width === undefined;
|
|
157
|
-
if ((style.width == undefined || style.width == 'auto') && props.width !== undefined) {
|
|
158
|
-
style.width = (props.width) + props.extraWidth;
|
|
159
|
-
}
|
|
160
|
-
if (props.dragStart !== undefined)
|
|
161
|
-
style.cursor = "grab";
|
|
162
|
-
React.useLayoutEffect(() => {
|
|
163
|
-
var _a;
|
|
164
|
-
if (tdref.current == null)
|
|
165
|
-
return;
|
|
166
|
-
const w = (_a = tdref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
|
|
167
|
-
if (style.width === undefined && props.width === undefined) {
|
|
168
|
-
props.setWidth(w, isAuto, isUndefined);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
if (props.adjustment !== undefined && props.adjustment !== 0)
|
|
172
|
-
return;
|
|
173
|
-
if (w === undefined || (props.width !== undefined && w == (props.width + props.extraWidth)))
|
|
174
|
-
return;
|
|
175
|
-
props.setWidth(w, isAuto, isUndefined);
|
|
176
|
-
});
|
|
177
|
-
if (props.adjustment !== undefined && props.adjustment !== 0 && style.width !== undefined)
|
|
178
|
-
style.width = `calc(${formatwidth(style.width)} ${props.adjustment < 0 ? '-' : '+'} ${Math.abs(props.adjustment).toString()}px)`;
|
|
179
|
-
if (props.width != undefined && !props.enabled)
|
|
180
|
-
return null;
|
|
181
|
-
return (React.createElement("td", { ref: tdref, style: style, onClick: props.onClick, draggable: props.dragStart !== undefined, onDragStart: props.dragStart }, props.children));
|
|
182
|
-
}
|
|
183
|
-
function formatwidth(style) {
|
|
184
|
-
if (style.toString().endsWith('%') || style.toString().endsWith('px'))
|
|
185
|
-
return style;
|
|
186
|
-
return style.toString() + "px";
|
|
187
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export interface IColumnProps<T> {
|
|
3
|
-
/**
|
|
4
|
-
* a unique Key for this Collumn
|
|
5
|
-
*/
|
|
6
|
-
Key: string;
|
|
7
|
-
/**
|
|
8
|
-
* Flag indicating whether sorting by this Collumn is allowed
|
|
9
|
-
*/
|
|
10
|
-
AllowSort?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Optional - the Field to be used
|
|
13
|
-
*/
|
|
14
|
-
Field?: keyof T;
|
|
15
|
-
/**
|
|
16
|
-
* The Default style for the th element
|
|
17
|
-
*/
|
|
18
|
-
HeaderStyle?: React.CSSProperties;
|
|
19
|
-
/**
|
|
20
|
-
* The Default style for the td element
|
|
21
|
-
*/
|
|
22
|
-
RowStyle?: React.CSSProperties;
|
|
23
|
-
/**
|
|
24
|
-
* Determines the Content to be displayed
|
|
25
|
-
* @param d the data to be turned into content
|
|
26
|
-
* @returns the content displayed
|
|
27
|
-
*/
|
|
28
|
-
Content?: (d: {
|
|
29
|
-
item: T;
|
|
30
|
-
key: string;
|
|
31
|
-
field: keyof T | undefined;
|
|
32
|
-
index: number;
|
|
33
|
-
style?: React.CSSProperties;
|
|
34
|
-
}) => React.ReactNode;
|
|
35
|
-
}
|
|
36
|
-
export default function Column<T>(props: React.PropsWithChildren<IColumnProps<T>>): JSX.Element;
|
|
37
|
-
export interface IHeaderWrapperProps {
|
|
38
|
-
setWidth: (w: number, a: boolean, u: boolean) => void;
|
|
39
|
-
onSort: React.MouseEventHandler<HTMLTableCellElement>;
|
|
40
|
-
sorted: boolean;
|
|
41
|
-
asc: boolean;
|
|
42
|
-
style: React.CSSProperties;
|
|
43
|
-
allowSort?: boolean;
|
|
44
|
-
colKey: string;
|
|
45
|
-
width?: number;
|
|
46
|
-
enabled: boolean;
|
|
47
|
-
extraWidth: number;
|
|
48
|
-
}
|
|
49
|
-
export declare function ColumnHeaderWrapper(props: React.PropsWithChildren<IHeaderWrapperProps>): JSX.Element | null;
|
|
50
|
-
export interface IDataWrapperProps {
|
|
51
|
-
setWidth: (w: number, a: boolean, u: boolean) => void;
|
|
52
|
-
width?: number;
|
|
53
|
-
enabled: boolean;
|
|
54
|
-
dragStart?: (e: React.DragEvent) => void;
|
|
55
|
-
onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
56
|
-
style: React.CSSProperties;
|
|
57
|
-
extraWidth: number;
|
|
58
|
-
}
|
|
59
|
-
export declare function ColumnDataWrapper(props: React.PropsWithChildren<IDataWrapperProps>): JSX.Element | null;
|
|
@@ -1,98 +0,0 @@
|
|
|
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
|
-
//
|
|
25
|
-
// ******************************************************************************************************
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.default = Column;
|
|
28
|
-
exports.ColumnHeaderWrapper = ColumnHeaderWrapper;
|
|
29
|
-
exports.ColumnDataWrapper = ColumnDataWrapper;
|
|
30
|
-
const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
31
|
-
const React = require("react");
|
|
32
|
-
function Column(props) {
|
|
33
|
-
return React.createElement(React.Fragment, null, props.children);
|
|
34
|
-
}
|
|
35
|
-
function ColumnHeaderWrapper(props) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f;
|
|
37
|
-
const thref = React.useRef(null);
|
|
38
|
-
const style = (props.style !== undefined) ? Object.assign({}, props.style) : {};
|
|
39
|
-
style.overflowX = (_a = style.overflowX) !== null && _a !== void 0 ? _a : 'hidden';
|
|
40
|
-
style.display = (_b = style.display) !== null && _b !== void 0 ? _b : 'inline-block';
|
|
41
|
-
style.position = (_c = style.position) !== null && _c !== void 0 ? _c : 'relative';
|
|
42
|
-
style.borderTop = (_d = style.borderTop) !== null && _d !== void 0 ? _d : 'none';
|
|
43
|
-
const isAuto = style.width == 'auto';
|
|
44
|
-
const isUndefined = style.width === undefined;
|
|
45
|
-
if ((style.width == undefined || style.width == 'auto') && props.width !== undefined) {
|
|
46
|
-
style.width = (props.width) + props.extraWidth;
|
|
47
|
-
}
|
|
48
|
-
if (style.cursor === undefined && ((_e = props.allowSort) !== null && _e !== void 0 ? _e : true)) {
|
|
49
|
-
style.cursor = 'pointer';
|
|
50
|
-
}
|
|
51
|
-
React.useLayoutEffect(() => {
|
|
52
|
-
var _a;
|
|
53
|
-
if (thref.current == null)
|
|
54
|
-
return;
|
|
55
|
-
const w = (_a = thref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
|
|
56
|
-
if (props.width !== undefined && (w === undefined || w == (props.width + props.extraWidth)))
|
|
57
|
-
return;
|
|
58
|
-
props.setWidth(w, isAuto, isUndefined);
|
|
59
|
-
});
|
|
60
|
-
const onClick = React.useCallback((e) => {
|
|
61
|
-
var _a;
|
|
62
|
-
if ((_a = props.allowSort) !== null && _a !== void 0 ? _a : true)
|
|
63
|
-
props.onSort(e);
|
|
64
|
-
}, [props.onSort, props.allowSort]);
|
|
65
|
-
if (props.width != undefined && !props.enabled)
|
|
66
|
-
return null;
|
|
67
|
-
return React.createElement("th", { ref: thref, style: style, onClick: onClick, onDrag: (e) => { e.stopPropagation(); } },
|
|
68
|
-
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,
|
|
69
|
-
React.createElement("div", { style: {
|
|
70
|
-
marginLeft: (props.sorted ? 25 : 0),
|
|
71
|
-
} }, (_f = props.children) !== null && _f !== void 0 ? _f : props.colKey));
|
|
72
|
-
}
|
|
73
|
-
function ColumnDataWrapper(props) {
|
|
74
|
-
var _a, _b;
|
|
75
|
-
const tdref = React.useRef(null);
|
|
76
|
-
const style = (props.style !== undefined) ? Object.assign({}, props.style) : {};
|
|
77
|
-
style.overflowX = (_a = style.overflowX) !== null && _a !== void 0 ? _a : 'hidden';
|
|
78
|
-
style.display = (_b = style.display) !== null && _b !== void 0 ? _b : 'inline-block';
|
|
79
|
-
const isAuto = style.width == 'auto';
|
|
80
|
-
const isUndefined = style.width === undefined;
|
|
81
|
-
if ((style.width == undefined || style.width == 'auto') && props.width !== undefined) {
|
|
82
|
-
style.width = (props.width) + props.extraWidth;
|
|
83
|
-
}
|
|
84
|
-
if (props.dragStart !== undefined)
|
|
85
|
-
style.cursor = "grab";
|
|
86
|
-
React.useLayoutEffect(() => {
|
|
87
|
-
var _a;
|
|
88
|
-
if (tdref.current == null)
|
|
89
|
-
return;
|
|
90
|
-
const w = (_a = tdref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
|
|
91
|
-
if (props.width !== undefined && (w === undefined || w == (props.width + props.extraWidth)))
|
|
92
|
-
return;
|
|
93
|
-
props.setWidth(w, isAuto, isUndefined);
|
|
94
|
-
});
|
|
95
|
-
if (props.width != undefined && !props.enabled)
|
|
96
|
-
return null;
|
|
97
|
-
return (React.createElement("td", { ref: tdref, style: style, onClick: props.onClick, draggable: props.dragStart !== undefined, onDragStart: props.dragStart }, props.children));
|
|
98
|
-
}
|