@gpa-gemstone/react-table 1.2.51 → 1.2.53
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/AdjustableTable/AdjustableColumn.d.ts +14 -16
- package/lib/AdjustableTable/AdjustableColumn.js +140 -52
- package/lib/AdjustableTable/Column.d.ts +23 -31
- package/lib/AdjustableTable/Column.js +52 -78
- package/lib/AdjustableTable/Table.d.ts +116 -0
- package/lib/AdjustableTable/Table.js +490 -0
- package/lib/DynamicTable.js +9 -10
- package/lib/Paging.js +16 -16
- package/lib/SearchableTable.js +8 -19
- package/lib/SelectTable.js +37 -56
- package/lib/Table.js +17 -28
- package/lib/index.d.ts +3 -3
- package/lib/index.js +11 -11
- package/package.json +3 -3
- package/lib/AdjustableTable/AdjustableTable.d.ts +0 -102
- package/lib/AdjustableTable/AdjustableTable.js +0 -273
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { IColumnProps } from './Column';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
8
12
|
}
|
|
9
|
-
export
|
|
10
|
-
interface
|
|
11
|
-
|
|
12
|
-
width?: number;
|
|
13
|
-
onSort: (key: string, event: any, field?: keyof T) => void;
|
|
14
|
-
sorted: boolean;
|
|
15
|
-
asc: boolean;
|
|
16
|
-
startAdjustment: (e: any) => void;
|
|
17
|
-
fixedLayout: boolean;
|
|
13
|
+
export declare function AdjustableColumnHeaderWrapper(props: React.PropsWithChildren<IAdjustableHeaderWrapperProps>): JSX.Element | null;
|
|
14
|
+
interface IAdjustableDataWrapperProps extends IDataWrapperProps {
|
|
15
|
+
adjustment?: number;
|
|
18
16
|
}
|
|
19
|
-
export declare function
|
|
17
|
+
export declare function AdjustableColumnDataWrapper(props: React.PropsWithChildren<IAdjustableDataWrapperProps>): JSX.Element | null;
|
|
20
18
|
export {};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = AdjustableColumn;
|
|
4
|
+
exports.AdjustableColumnHeaderWrapper = AdjustableColumnHeaderWrapper;
|
|
5
|
+
exports.AdjustableColumnDataWrapper = AdjustableColumnDataWrapper;
|
|
2
6
|
// ******************************************************************************************************
|
|
3
7
|
// AdjustableColumn.tsx - Gbtc
|
|
4
8
|
//
|
|
@@ -19,68 +23,114 @@
|
|
|
19
23
|
// ----------------------------------------------------------------------------------------------------
|
|
20
24
|
// 11/19/2023 - C. Lackner
|
|
21
25
|
// Generated original version of source code.
|
|
26
|
+
// 05/31/2024 - C. Lackner
|
|
27
|
+
// Refactored to fix sizing issues.
|
|
22
28
|
//
|
|
23
29
|
// ******************************************************************************************************
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
s = arguments[i];
|
|
28
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29
|
-
t[p] = s[p];
|
|
30
|
-
}
|
|
31
|
-
return t;
|
|
32
|
-
};
|
|
33
|
-
return __assign.apply(this, arguments);
|
|
34
|
-
};
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.default = AdjustableCol;
|
|
37
|
-
exports.AdjColumnHeaderWrapper = AdjColumnHeaderWrapper;
|
|
38
|
-
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
39
|
-
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
40
|
-
var React = require("react");
|
|
41
|
-
function AdjustableCol(props) {
|
|
30
|
+
const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
31
|
+
const React = require("react");
|
|
32
|
+
function AdjustableColumn(props) {
|
|
42
33
|
return React.createElement(React.Fragment, null, props.children);
|
|
43
34
|
}
|
|
44
|
-
function
|
|
45
|
-
var _a, _b;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
55
|
}
|
|
56
|
-
if (
|
|
57
|
-
style.
|
|
56
|
+
if (mode === 'minWidth') {
|
|
57
|
+
style.width = style.minWidth;
|
|
58
58
|
}
|
|
59
|
-
if (
|
|
60
|
-
style.
|
|
59
|
+
if (mode === 'maxWidth') {
|
|
60
|
+
style.width = style.maxWidth;
|
|
61
61
|
}
|
|
62
|
-
if (style.
|
|
63
|
-
style.
|
|
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
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var
|
|
70
|
-
if (
|
|
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
71
|
return;
|
|
72
|
-
|
|
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
|
+
}
|
|
73
114
|
});
|
|
74
|
-
|
|
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) => {
|
|
75
124
|
var _a;
|
|
76
|
-
if ((_a = props.
|
|
77
|
-
props.onSort(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var onClickBorder = React.useCallback(function (e) {
|
|
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) => {
|
|
81
129
|
props.startAdjustment(e);
|
|
82
130
|
}, [props.startAdjustment]);
|
|
83
|
-
|
|
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(); } },
|
|
84
134
|
React.createElement("div", { style: {
|
|
85
135
|
width: 5,
|
|
86
136
|
height: '100%',
|
|
@@ -91,9 +141,47 @@ function AdjColumnHeaderWrapper(props) {
|
|
|
91
141
|
background: '#e9ecef',
|
|
92
142
|
cursor: 'col-resize'
|
|
93
143
|
}, onMouseEnter: onHover, onMouseLeave: onLeave, onMouseDown: onClickBorder }),
|
|
94
|
-
props.sorted
|
|
95
|
-
props.sorted && !props.asc ? React.createElement("div", { style: { position: 'absolute', width: 25 } }, gpa_symbols_1.SVGIcons.ArrowDropUp) : null,
|
|
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,
|
|
96
145
|
React.createElement("div", { style: {
|
|
97
146
|
marginLeft: (props.sorted ? 25 : 0),
|
|
98
|
-
} }, (
|
|
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";
|
|
99
187
|
}
|
|
@@ -12,16 +12,16 @@ export interface IColumnProps<T> {
|
|
|
12
12
|
* Optional - the Field to be used
|
|
13
13
|
*/
|
|
14
14
|
Field?: keyof T;
|
|
15
|
-
/**
|
|
16
|
-
* The Default style for the td element
|
|
17
|
-
*/
|
|
18
|
-
RowStyle?: React.CSSProperties;
|
|
19
15
|
/**
|
|
20
16
|
* The Default style for the th element
|
|
21
17
|
*/
|
|
22
18
|
HeaderStyle?: React.CSSProperties;
|
|
23
19
|
/**
|
|
24
|
-
*
|
|
20
|
+
* The Default style for the td element
|
|
21
|
+
*/
|
|
22
|
+
RowStyle?: React.CSSProperties;
|
|
23
|
+
/**
|
|
24
|
+
* Determines the Content to be displayed
|
|
25
25
|
* @param d the data to be turned into content
|
|
26
26
|
* @returns the content displayed
|
|
27
27
|
*/
|
|
@@ -34,34 +34,26 @@ export interface IColumnProps<T> {
|
|
|
34
34
|
}) => React.ReactNode;
|
|
35
35
|
}
|
|
36
36
|
export default function Column<T>(props: React.PropsWithChildren<IColumnProps<T>>): JSX.Element;
|
|
37
|
-
interface IHeaderWrapperProps
|
|
38
|
-
setWidth: (w: number) => void;
|
|
39
|
-
|
|
40
|
-
onSort: (key: string, event: any, field?: keyof T) => void;
|
|
37
|
+
export interface IHeaderWrapperProps {
|
|
38
|
+
setWidth: (w: number, a: boolean, u: boolean) => void;
|
|
39
|
+
onSort: React.MouseEventHandler<HTMLTableCellElement>;
|
|
41
40
|
sorted: boolean;
|
|
42
41
|
asc: boolean;
|
|
43
|
-
|
|
42
|
+
style: React.CSSProperties;
|
|
43
|
+
allowSort?: boolean;
|
|
44
|
+
colKey: string;
|
|
45
|
+
width?: number;
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
extraWidth: number;
|
|
44
48
|
}
|
|
45
|
-
export declare function ColumnHeaderWrapper
|
|
46
|
-
interface IDataWrapperProps
|
|
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;
|
|
47
52
|
width?: number;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
row: T;
|
|
54
|
-
data: T[keyof T] | null;
|
|
55
|
-
index: number;
|
|
56
|
-
}, e: any) => void;
|
|
57
|
-
onClick?: (data: {
|
|
58
|
-
colKey: string;
|
|
59
|
-
colField?: keyof T;
|
|
60
|
-
row: T;
|
|
61
|
-
data: T[keyof T] | null;
|
|
62
|
-
index: number;
|
|
63
|
-
}, e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
64
|
-
fixedLayout: boolean;
|
|
53
|
+
enabled: boolean;
|
|
54
|
+
dragStart?: (e: React.DragEvent) => void;
|
|
55
|
+
onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
56
|
+
style: React.CSSProperties;
|
|
57
|
+
extraWidth: number;
|
|
65
58
|
}
|
|
66
|
-
export declare function ColumnDataWrapper
|
|
67
|
-
export {};
|
|
59
|
+
export declare function ColumnDataWrapper(props: React.PropsWithChildren<IDataWrapperProps>): JSX.Element | null;
|
|
@@ -19,106 +19,80 @@
|
|
|
19
19
|
// ----------------------------------------------------------------------------------------------------
|
|
20
20
|
// 08/02/2018 - Billy Ernest
|
|
21
21
|
// Generated original version of source code.
|
|
22
|
+
// 05/31/2024 - C. Lackner
|
|
23
|
+
// Refactored to fix sizing issues.
|
|
22
24
|
//
|
|
23
25
|
// ******************************************************************************************************
|
|
24
|
-
var __assign = (this && this.__assign) || function () {
|
|
25
|
-
__assign = Object.assign || function(t) {
|
|
26
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27
|
-
s = arguments[i];
|
|
28
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29
|
-
t[p] = s[p];
|
|
30
|
-
}
|
|
31
|
-
return t;
|
|
32
|
-
};
|
|
33
|
-
return __assign.apply(this, arguments);
|
|
34
|
-
};
|
|
35
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
27
|
exports.default = Column;
|
|
37
28
|
exports.ColumnHeaderWrapper = ColumnHeaderWrapper;
|
|
38
29
|
exports.ColumnDataWrapper = ColumnDataWrapper;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var React = require("react");
|
|
30
|
+
const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
31
|
+
const React = require("react");
|
|
42
32
|
function Column(props) {
|
|
43
33
|
return React.createElement(React.Fragment, null, props.children);
|
|
44
34
|
}
|
|
45
35
|
function ColumnHeaderWrapper(props) {
|
|
46
|
-
var _a, _b;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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;
|
|
55
47
|
}
|
|
56
|
-
if (style.cursor === undefined && ((
|
|
48
|
+
if (style.cursor === undefined && ((_e = props.allowSort) !== null && _e !== void 0 ? _e : true)) {
|
|
57
49
|
style.cursor = 'pointer';
|
|
58
50
|
}
|
|
59
|
-
|
|
60
|
-
style.position = 'relative';
|
|
61
|
-
}
|
|
62
|
-
if (style.borderTop === undefined) {
|
|
63
|
-
style.borderTop = 'none';
|
|
64
|
-
}
|
|
65
|
-
React.useLayoutEffect(function () {
|
|
51
|
+
React.useLayoutEffect(() => {
|
|
66
52
|
var _a;
|
|
67
|
-
if (thref.current == null
|
|
53
|
+
if (thref.current == null)
|
|
68
54
|
return;
|
|
69
|
-
|
|
70
|
-
if (w === undefined)
|
|
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)))
|
|
71
57
|
return;
|
|
72
|
-
props.setWidth(w);
|
|
58
|
+
props.setWidth(w, isAuto, isUndefined);
|
|
73
59
|
});
|
|
74
|
-
|
|
60
|
+
const onClick = React.useCallback((e) => {
|
|
75
61
|
var _a;
|
|
76
|
-
if ((_a = props.
|
|
77
|
-
props.onSort(
|
|
78
|
-
}, [props.onSort, props.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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,
|
|
82
69
|
React.createElement("div", { style: {
|
|
83
70
|
marginLeft: (props.sorted ? 25 : 0),
|
|
84
|
-
} }, (
|
|
71
|
+
} }, (_f = props.children) !== null && _f !== void 0 ? _f : props.colKey));
|
|
85
72
|
}
|
|
86
73
|
function ColumnDataWrapper(props) {
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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;
|
|
94
83
|
}
|
|
95
84
|
if (props.dragStart !== undefined)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
colField: props.Field,
|
|
110
|
-
row: props.item,
|
|
111
|
-
data: getFieldValue(),
|
|
112
|
-
index: props.index
|
|
113
|
-
}, e);
|
|
114
|
-
}, [props.Key, props.Field, props.item, props.index, props.onClick]);
|
|
115
|
-
return (React.createElement("td", { style: css, onClick: onClick, draggable: props.dragStart !== undefined, onDragStart: function (e) {
|
|
116
|
-
props.dragStart({
|
|
117
|
-
colKey: props.Key,
|
|
118
|
-
colField: props.Field,
|
|
119
|
-
row: props.item,
|
|
120
|
-
data: getFieldValue(),
|
|
121
|
-
index: props.index
|
|
122
|
-
}, e);
|
|
123
|
-
} }, getFieldContent()));
|
|
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));
|
|
124
98
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface TableProps<T> {
|
|
3
|
+
/**
|
|
4
|
+
* List of T objects used to generate rows
|
|
5
|
+
*/
|
|
6
|
+
Data: T[];
|
|
7
|
+
/**
|
|
8
|
+
* Callback when the user clicks on a data entry
|
|
9
|
+
* @param data contains the data including the columnKey
|
|
10
|
+
* @param event the onClick Event to allow propagation as needed
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
OnClick?: (data: {
|
|
14
|
+
colKey?: string;
|
|
15
|
+
colField?: keyof T;
|
|
16
|
+
row: T;
|
|
17
|
+
data: T[keyof T] | null;
|
|
18
|
+
index: number;
|
|
19
|
+
}, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Key of the collumn to sort by
|
|
22
|
+
*/
|
|
23
|
+
SortKey: string;
|
|
24
|
+
/**
|
|
25
|
+
* Boolen to indicate whether the sort is ascending or descending
|
|
26
|
+
*/
|
|
27
|
+
Ascending: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Callback when the data should be sorted
|
|
30
|
+
* @param data the information of the collumn including the Key of the collumn
|
|
31
|
+
* @param event The onCLick event to allow Propagation as needed
|
|
32
|
+
*/
|
|
33
|
+
OnSort(data: {
|
|
34
|
+
colKey: string;
|
|
35
|
+
colField?: keyof T;
|
|
36
|
+
ascending: boolean;
|
|
37
|
+
}, event: React.MouseEvent<HTMLElement, MouseEvent>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Class of the table component
|
|
40
|
+
*/
|
|
41
|
+
TableClass?: string;
|
|
42
|
+
/**
|
|
43
|
+
* style of the table component
|
|
44
|
+
*/
|
|
45
|
+
TableStyle?: React.CSSProperties;
|
|
46
|
+
/**
|
|
47
|
+
* style of the thead component
|
|
48
|
+
*/
|
|
49
|
+
TheadStyle?: React.CSSProperties;
|
|
50
|
+
/**
|
|
51
|
+
* Class of the thead component
|
|
52
|
+
*/
|
|
53
|
+
TheadClass?: string;
|
|
54
|
+
/**
|
|
55
|
+
* style of the tbody component
|
|
56
|
+
*/
|
|
57
|
+
TbodyStyle?: React.CSSProperties;
|
|
58
|
+
/**
|
|
59
|
+
* Class of the tbody component
|
|
60
|
+
*/
|
|
61
|
+
TbodyClass?: string;
|
|
62
|
+
/**
|
|
63
|
+
* style of the tfoot component
|
|
64
|
+
*/
|
|
65
|
+
TfootStyle?: React.CSSProperties;
|
|
66
|
+
/**
|
|
67
|
+
* Class of the tfoot component
|
|
68
|
+
*/
|
|
69
|
+
TfootClass?: string;
|
|
70
|
+
/**
|
|
71
|
+
* determines if a row should be styled as selected
|
|
72
|
+
* @param data the item to be checked
|
|
73
|
+
* @returns true if the row should be styled as selected
|
|
74
|
+
*/
|
|
75
|
+
Selected?: (data: T, index: number) => boolean;
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param data the information of the row including the item of the row
|
|
79
|
+
* @param e the event triggering this
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
OnDragStart?: (data: {
|
|
83
|
+
colKey?: string;
|
|
84
|
+
colField?: keyof T;
|
|
85
|
+
row: T;
|
|
86
|
+
data: T[keyof T] | null;
|
|
87
|
+
index: number;
|
|
88
|
+
}, e: React.DragEvent<Element>) => void;
|
|
89
|
+
/**
|
|
90
|
+
* The default style for the tr element
|
|
91
|
+
*/
|
|
92
|
+
RowStyle?: React.CSSProperties;
|
|
93
|
+
/**
|
|
94
|
+
* a Function that retrieves a unique key used for React key properties
|
|
95
|
+
* @param data the item to be turned into a key
|
|
96
|
+
* @returns a unique Key
|
|
97
|
+
*/
|
|
98
|
+
KeySelector: (data: T, index?: number) => string | number;
|
|
99
|
+
/**
|
|
100
|
+
* Optional Element to display in the last row of the Table
|
|
101
|
+
* use this for displaying warnings when the Table content gets cut off.
|
|
102
|
+
* Data appears in the tfoot element
|
|
103
|
+
*/
|
|
104
|
+
LastRow?: string | React.ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* Optional Element to display on upper Right corner
|
|
107
|
+
*/
|
|
108
|
+
LastColumn?: string | React.ReactNode;
|
|
109
|
+
/**
|
|
110
|
+
* Optional Callback that gets called when there is not enough space to display columns
|
|
111
|
+
* @param disabled takes in string of disabled keys
|
|
112
|
+
*/
|
|
113
|
+
ReduceWidthCallback?: (disabled: string[]) => void;
|
|
114
|
+
}
|
|
115
|
+
export default function AdjustableTable<T>(props: React.PropsWithChildren<TableProps<T>>): JSX.Element;
|
|
116
|
+
export {};
|