@gpa-gemstone/react-table 1.2.114 → 1.2.116

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.
@@ -131,7 +131,7 @@ function ConfigurableTable(props) {
131
131
  return isSortKey || isInLocal || isDefault;
132
132
  }
133
133
  return (React.createElement(React.Fragment, null,
134
- React.createElement(Table_1.Table, Object.assign({}, props, { LastColumn: React.createElement("div", { style: { marginLeft: -5, marginBottom: 12, cursor: 'pointer' }, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), id: guid + '-tooltip', onClick: () => setShowSettings(true) },
134
+ React.createElement(Table_1.Table, Object.assign({}, props, { LastColumn: React.createElement("div", { style: { marginBottom: 12, cursor: 'pointer' }, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), id: guid + '-tooltip', onClick: () => setShowSettings(true) },
135
135
  React.createElement(gpa_symbols_1.ReactIcons.Settings, null)), ReduceWidthCallback: handleReduceWidthCallback }), React.Children.map(props.children, (element) => {
136
136
  var _a, _b;
137
137
  if (!React.isValidElement(element))
@@ -189,16 +189,10 @@ function ColumnSelection(props) {
189
189
  return undefined;
190
190
  };
191
191
  return (React.createElement(React.Fragment, null,
192
- React.createElement("div", { className: "row" },
193
- React.createElement("div", { className: "col-4" }, props.columns.map((c, i) => i % 3 == 0 ? (React.createElement(react_forms_1.CheckBox, { Label: c.Label, Field: 'Enabled', Record: c, Setter: () => props.onChange(c.Key), key: c.Key, Disabled: c.Key === props.sortKey ||
192
+ React.createElement("div", { className: "row" }, props.columns.map((c) => React.createElement("div", { className: "col-4", key: c.Key },
193
+ React.createElement(react_forms_1.CheckBox, { Label: c.Label, Field: 'Enabled', Record: c, Setter: () => props.onChange(c.Key), Disabled: c.Key === props.sortKey ||
194
194
  (props.disableAdd && !c.Enabled) ||
195
- (isOnlyOneEnabled && c.Enabled), Help: helpMessage(c) })) : null)),
196
- React.createElement("div", { className: "col-4" }, props.columns.map((c, i) => i % 3 == 1 ? (React.createElement(react_forms_1.CheckBox, { Label: c.Label, Field: 'Enabled', Record: c, Setter: () => props.onChange(c.Key), key: c.Key, Disabled: c.Key === props.sortKey ||
197
- (props.disableAdd && !c.Enabled) ||
198
- (isOnlyOneEnabled && c.Enabled), Help: helpMessage(c) })) : null)),
199
- React.createElement("div", { className: "col-4" }, props.columns.map((c, i) => i % 3 == 2 ? (React.createElement(react_forms_1.CheckBox, { Label: c.Label, Field: 'Enabled', Record: c, Setter: () => props.onChange(c.Key), key: c.Key, Disabled: c.Key === props.sortKey ||
200
- (props.disableAdd && !c.Enabled) ||
201
- (isOnlyOneEnabled && c.Enabled), Help: helpMessage(c) })) : null))),
195
+ (isOnlyOneEnabled && c.Enabled), Help: helpMessage(c) })))),
202
196
  props.disableAdd ?
203
197
  React.createElement(react_interactive_1.Alert, { Class: 'alert-primary', Style: { marginBottom: 0, marginTop: '0.5em' } }, "Additional columns disabled due to table size.")
204
198
  : null));
@@ -0,0 +1,2 @@
1
+ import { Gemstone } from '@gpa-gemstone/application-typings';
2
+ export declare const GetConfigurableColumnsFromTypeEntries: <T>(recordFields: Gemstone.TSX.Interfaces.IRecordFields<T>, timeFormat: string, configurable?: boolean) => (JSX.Element | null)[];
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetConfigurableColumnsFromTypeEntries = void 0;
4
+ //******************************************************************************************************
5
+ // GetConfigurableColumnsFromTypeEntries.tsx - Gbtc
6
+ //
7
+ // Copyright (c) 2024, 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 may license 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
+ // 08/26/2024 - Preston Crawford
23
+ // Generated original version of source code.
24
+ //
25
+ //******************************************************************************************************
26
+ const React = require("react");
27
+ const _ = require("lodash");
28
+ const Column_1 = require("./Table/Column");
29
+ const moment = require("moment");
30
+ const gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
31
+ const ConfigurableColumn_1 = require("./ConfigurableTable/ConfigurableColumn");
32
+ const getTypedEntries = (obj) => {
33
+ return Object.entries(obj);
34
+ };
35
+ const GetConfigurableColumnsFromTypeEntries = (recordFields, timeFormat, configurable = true) => {
36
+ return _.sortBy(getTypedEntries(recordFields), ([key, value]) => { var _a; return (_a = value === null || value === void 0 ? void 0 : value.Label) !== null && _a !== void 0 ? _a : key; })
37
+ .map(([key, value]) => {
38
+ var _a, _b, _c;
39
+ if (value == null)
40
+ return null;
41
+ if (configurable)
42
+ return (React.createElement(ConfigurableColumn_1.default, { key: key, Key: key, Label: (_a = value.Label) !== null && _a !== void 0 ? _a : key, Default: value.IsDefaultColumn },
43
+ React.createElement(Column_1.Column, { Key: key, AllowSort: value.AllowSort, Field: key, Content: ({ item }) => getContent(item, key, value, timeFormat) }, ((_b = value.Label) !== null && _b !== void 0 ? _b : key))));
44
+ return (React.createElement(Column_1.Column, { Key: key, AllowSort: value.AllowSort, Field: key, Content: ({ item }) => getContent(item, key, value, timeFormat) }, ((_c = value.Label) !== null && _c !== void 0 ? _c : key)));
45
+ });
46
+ };
47
+ exports.GetConfigurableColumnsFromTypeEntries = GetConfigurableColumnsFromTypeEntries;
48
+ const getContent = (record, field, recordValue, timeFormat) => {
49
+ if (field === 'CreatedOn' || field == 'UpdatedOn')
50
+ return moment.utc(record[field]).format(timeFormat);
51
+ if (typeof record[field] === 'boolean')
52
+ return record[field] ? React.createElement(gpa_symbols_1.ReactIcons.CheckMark, { Color: 'green' }) : React.createElement(gpa_symbols_1.ReactIcons.CrossMark, { Color: 'red' });
53
+ if (recordValue.Content == null)
54
+ return record[field];
55
+ return recordValue.Content(record);
56
+ };
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+ import { Search } from '@gpa-gemstone/react-interactive';
3
+ export type width = {
4
+ width: number;
5
+ minWidth: number;
6
+ maxWidth?: number;
7
+ };
8
+ interface IProps<T> {
9
+ Class?: string;
10
+ Style?: React.CSSProperties;
11
+ SortKey: string;
12
+ Ascending: boolean;
13
+ OnSort: (data: {
14
+ colKey: string;
15
+ colField?: keyof T;
16
+ ascending: boolean;
17
+ }, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
18
+ ColWidths: React.MutableRefObject<Map<string, width>>;
19
+ TriggerRerender: () => void;
20
+ Trigger: number;
21
+ SetLastColumnWidth: (width: number) => void;
22
+ LastColumn?: string | React.ReactNode;
23
+ SetFilters?: (filters: Search.IFilter<T>[]) => void;
24
+ Filters?: Search.IFilter<T>[];
25
+ }
26
+ declare const Header: <T>(props: React.PropsWithChildren<IProps<T>>) => JSX.Element;
27
+ export default Header;
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // ******************************************************************************************************
4
+ // Header.tsx - Gbtc
5
+ //
6
+ // Copyright © 2023, Grid Protection Alliance. All Rights Reserved.
7
+ //
8
+ // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
9
+ // the NOTICE file distributed with this work for additional information regarding copyright ownership.
10
+ // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
11
+ // file except in compliance with the License. You may obtain a copy of the License at:
12
+ //
13
+ // http://opensource.org/licenses/MIT
14
+ //
15
+ // Unless agreed to in writing, the subject software distributed under the License is distributed on an
16
+ // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
17
+ // License for the specific language governing permissions and limitations.
18
+ //
19
+ // Code Modification History:
20
+ // ----------------------------------------------------------------------------------------------------
21
+ // 11/18/2023 - C. Lackner
22
+ // Generated original version of source code.
23
+ // 05/31/2024 - C. Lackner
24
+ // Refactored to fix sizing issues.
25
+ // 12/04/2024 - G. Santos
26
+ // Refactored to fix performance issues.
27
+ //
28
+ // ******************************************************************************************************
29
+ const React = require("react");
30
+ const Column_1 = require("./Column");
31
+ const helper_functions_1 = require("@gpa-gemstone/helper-functions");
32
+ const FilterableColumn_1 = require("./FilterableColumn");
33
+ const defaultHeadStyle = {
34
+ fontSize: 'auto',
35
+ tableLayout: 'fixed',
36
+ display: 'table',
37
+ width: '100%'
38
+ };
39
+ const defaultDataHeadStyle = {
40
+ display: 'inline-block',
41
+ position: 'relative',
42
+ borderTop: 'none',
43
+ width: 'auto'
44
+ };
45
+ const IsColumnProps = (props) => ((props === null || props === void 0 ? void 0 : props['Key']) != null);
46
+ const IsColumnAdjustable = (props) => {
47
+ const propValue = props === null || props === void 0 ? void 0 : props['Adjustable'];
48
+ if (propValue === false || propValue === true)
49
+ return propValue;
50
+ return false;
51
+ };
52
+ const Header = (props) => {
53
+ var _a;
54
+ const headStyle = React.useMemo(() => (Object.assign(Object.assign({}, defaultHeadStyle), props.Style)), [props.Style]);
55
+ const lastColRef = React.useRef(null);
56
+ const { width: lastColWidth } = (0, helper_functions_1.useGetContainerPosition)(lastColRef);
57
+ // Consts for adjustable columns
58
+ const [mouseDown, setMouseDown] = React.useState(0);
59
+ const [currentKeys, setCurrentKeys] = React.useState(undefined);
60
+ const [deltaW, setDeltaW] = React.useState(0);
61
+ const [tentativeLimits, setTentativeLimits] = React.useState({ min: -Infinity, max: Infinity });
62
+ // Consts for filterable columns
63
+ const [filters, setFilters] = React.useState(((_a = props.Filters) !== null && _a !== void 0 ? _a : []));
64
+ const [guid] = React.useState((0, helper_functions_1.CreateGuid)());
65
+ const getLeftKey = React.useCallback((key, colWidthsRef) => {
66
+ // Filtering down to shown adjustables only
67
+ var _a, _b;
68
+ const mapCallback = (element) => {
69
+ var _a;
70
+ if (!React.isValidElement(element))
71
+ return null;
72
+ const keyWidth = (_a = colWidthsRef.current.get(key)) === null || _a === void 0 ? void 0 : _a.width;
73
+ if (keyWidth == null || keyWidth <= 0)
74
+ return null;
75
+ if (IsColumnProps(element.props) && IsColumnAdjustable(element.props))
76
+ return element.props.Key;
77
+ return null;
78
+ };
79
+ const children = (_a = props.children) !== null && _a !== void 0 ? _a : [];
80
+ const keys = ((_b = React.Children.map(children, mapCallback)) !== null && _b !== void 0 ? _b : []).filter((item) => item !== null);
81
+ const index = keys.indexOf(key);
82
+ if (index <= 0)
83
+ return undefined;
84
+ return keys[index - 1];
85
+ }, [props.children]);
86
+ const calculateDeltaLimits = React.useCallback((mapKeys, colWidthsRef) => {
87
+ if (mapKeys === undefined)
88
+ return ({ min: -Infinity, max: Infinity });
89
+ const widthObjLeft = colWidthsRef.current.get(mapKeys[0]);
90
+ const widthObjRight = colWidthsRef.current.get(mapKeys[1]);
91
+ if (widthObjLeft == null || widthObjRight == null)
92
+ return ({ min: -Infinity, max: Infinity });
93
+ const limitByShrinkLeft = widthObjLeft.width - widthObjLeft.minWidth;
94
+ const limitByGrowthLeft = widthObjLeft.maxWidth == null ? Number.MAX_SAFE_INTEGER : (widthObjLeft.maxWidth - widthObjLeft.width);
95
+ const limitByShrinkRight = widthObjRight.width - widthObjRight.minWidth;
96
+ const limitByGrowthRight = widthObjRight.maxWidth == null ? Number.MAX_SAFE_INTEGER : (widthObjRight.maxWidth - widthObjRight.width);
97
+ // Recall that a left movement is a negative deltaW
98
+ const minDeltaW = -(limitByShrinkLeft < limitByGrowthRight ? limitByShrinkLeft : limitByGrowthRight);
99
+ const maxDeltaW = limitByShrinkRight < limitByGrowthLeft ? limitByShrinkRight : limitByGrowthLeft;
100
+ return ({ min: minDeltaW, max: maxDeltaW });
101
+ }, []);
102
+ const getDeltaSign = React.useCallback((index) => {
103
+ // Recall that a left movement is a negative deltaW
104
+ if (index === 0)
105
+ return 1;
106
+ else if (index === 1)
107
+ return -1;
108
+ else
109
+ return 0;
110
+ }, []);
111
+ const finishAdjustment = React.useCallback((adjustment, adjustKeys, colWidthsRef) => {
112
+ const deltaLimits = calculateDeltaLimits(adjustKeys, colWidthsRef);
113
+ let delta;
114
+ if (adjustment > deltaLimits.max)
115
+ delta = deltaLimits.max;
116
+ else if (adjustment < deltaLimits.min)
117
+ delta = deltaLimits.min;
118
+ else
119
+ delta = adjustment;
120
+ if (Math.abs(delta) > 5) {
121
+ const leftWidthObj = colWidthsRef.current.get(adjustKeys[0]);
122
+ const rightWidthObj = colWidthsRef.current.get(adjustKeys[1]);
123
+ if (leftWidthObj == null || rightWidthObj == null) {
124
+ console.error(`Unable to finalize adjustment on keys ${adjustKeys[0]}, ${adjustKeys[1]}`);
125
+ }
126
+ else {
127
+ leftWidthObj.width += (getDeltaSign(0) * delta);
128
+ rightWidthObj.width += (getDeltaSign(1) * delta);
129
+ }
130
+ }
131
+ setMouseDown(0);
132
+ setTentativeLimits({ min: -Infinity, max: Infinity });
133
+ setCurrentKeys(undefined);
134
+ setDeltaW(0);
135
+ }, [calculateDeltaLimits, getDeltaSign]);
136
+ const onMove = React.useCallback((e) => {
137
+ if (currentKeys === undefined)
138
+ return;
139
+ const w = e.screenX - mouseDown;
140
+ setDeltaW(w);
141
+ }, [mouseDown, currentKeys]);
142
+ const updateFilters = React.useCallback((flts, fld) => {
143
+ setFilters((fls) => {
144
+ const newFilters = fls.filter(item => item.FieldName !== fld).concat(flts);
145
+ if (props.SetFilters == null)
146
+ console.error("Attempted to set filters from column when no set filter arguement to table was provided. Data has not been filtered!");
147
+ else
148
+ props.SetFilters(newFilters);
149
+ return newFilters;
150
+ });
151
+ }, [props.SetFilters]);
152
+ React.useEffect(() => { var _a; return setFilters((_a = props.Filters) !== null && _a !== void 0 ? _a : []); }, [props.Filters]);
153
+ React.useEffect(() => props.SetLastColumnWidth(lastColWidth), [lastColWidth, props.SetLastColumnWidth]);
154
+ return (React.createElement("thead", { className: props.Class, style: headStyle, onMouseMove: (e) => {
155
+ onMove(e.nativeEvent);
156
+ e.stopPropagation();
157
+ }, onMouseUp: (e) => {
158
+ e.stopPropagation();
159
+ if (currentKeys == null)
160
+ return;
161
+ finishAdjustment(deltaW, currentKeys, props.ColWidths);
162
+ props.TriggerRerender();
163
+ }, onMouseLeave: (e) => {
164
+ e.stopPropagation();
165
+ if (currentKeys == null)
166
+ return;
167
+ finishAdjustment(deltaW, currentKeys, props.ColWidths);
168
+ props.TriggerRerender();
169
+ } },
170
+ React.createElement("tr", { style: { width: '100%', display: 'table' } },
171
+ React.Children.map(props.children, (element) => {
172
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
173
+ if (!React.isValidElement(element))
174
+ return null;
175
+ if (!IsColumnProps(element.props))
176
+ return null;
177
+ const colWidth = props.ColWidths.current.get(element.props.Key);
178
+ if (colWidth == null || colWidth.width === 0)
179
+ return null;
180
+ // Handling temporary width changes due to being in mid-adjustments
181
+ let currentWidth = colWidth.width;
182
+ const keyIndex = (_a = currentKeys === null || currentKeys === void 0 ? void 0 : currentKeys.indexOf(element.props.Key)) !== null && _a !== void 0 ? _a : -1;
183
+ if (keyIndex > -1) {
184
+ let delta;
185
+ if (deltaW > tentativeLimits.max)
186
+ delta = tentativeLimits.max;
187
+ else if (deltaW < tentativeLimits.min)
188
+ delta = tentativeLimits.min;
189
+ else
190
+ delta = deltaW;
191
+ currentWidth += (getDeltaSign(keyIndex) * delta);
192
+ }
193
+ let cursor = undefined;
194
+ if (((_c = (_b = element.props) === null || _b === void 0 ? void 0 : _b.HeaderStyle) === null || _c === void 0 ? void 0 : _c.cursor) != null)
195
+ cursor = element.props.HeaderStyle.cursor;
196
+ else if (((_e = (_d = element.props) === null || _d === void 0 ? void 0 : _d.AllowSort) !== null && _e !== void 0 ? _e : true))
197
+ cursor = 'pointer';
198
+ const style = Object.assign(Object.assign(Object.assign({}, defaultDataHeadStyle), (_f = element.props) === null || _f === void 0 ? void 0 : _f.HeaderStyle), { width: currentWidth, cursor: cursor });
199
+ let startAdjustment;
200
+ if (IsColumnAdjustable(element.props))
201
+ startAdjustment = (e) => {
202
+ const leftKey = getLeftKey(element.props.Key, props.ColWidths);
203
+ if (leftKey != null) {
204
+ const newCurrentKeys = [leftKey, element.props.Key];
205
+ setCurrentKeys(newCurrentKeys);
206
+ setMouseDown(e.screenX);
207
+ setTentativeLimits(calculateDeltaLimits(newCurrentKeys, props.ColWidths));
208
+ setDeltaW(0);
209
+ }
210
+ };
211
+ return (React.createElement(Column_1.ColumnHeaderWrapper, { onSort: (e) => {
212
+ var _a;
213
+ return props.OnSort({ colKey: element.props.Key, colField: (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field, ascending: props.Ascending }, e);
214
+ }, sorted: props.SortKey === element.props.Key && ((_h = (_g = element.props) === null || _g === void 0 ? void 0 : _g.AllowSort) !== null && _h !== void 0 ? _h : true), asc: props.Ascending, colKey: element.props.Key, key: element.props.Key, allowSort: (_j = element.props) === null || _j === void 0 ? void 0 : _j.AllowSort, startAdjustment: startAdjustment, style: style },
215
+ ' ',
216
+ (element.type === FilterableColumn_1.default) ?
217
+ React.createElement(FilterableColumn_1.FilterableColumnHeader, { Label: (_k = element.props) === null || _k === void 0 ? void 0 : _k.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: (_l = element.props) === null || _l === void 0 ? void 0 : _l.Field, Type: (_m = element.props) === null || _m === void 0 ? void 0 : _m.Type, Options: (_o = element.props) === null || _o === void 0 ? void 0 : _o.Enum, ExpandedLabel: (_p = element.props) === null || _p === void 0 ? void 0 : _p.ExpandedLabel, Guid: guid, Unit: (_q = element.props) === null || _q === void 0 ? void 0 : _q.Unit }) :
218
+ ((_r = element.props.children) !== null && _r !== void 0 ? _r : element.props.Key),
219
+ ' '));
220
+ }),
221
+ props.LastColumn !== undefined ?
222
+ React.createElement("th", { style: { width: lastColWidth, padding: 0, maxWidth: lastColWidth } },
223
+ React.createElement("div", { ref: lastColRef, style: { width: 'max-content' } }, props.LastColumn))
224
+ : null)));
225
+ };
226
+ exports.default = Header;
@@ -0,0 +1,35 @@
1
+ import * as React from 'react';
2
+ export type width = {
3
+ width: number;
4
+ minWidth: number;
5
+ maxWidth?: number;
6
+ };
7
+ interface IProps<T> {
8
+ Data: T[];
9
+ RowStyle?: React.CSSProperties;
10
+ BodyStyle?: React.CSSProperties;
11
+ BodyClass?: string;
12
+ OnClick?: (data: {
13
+ colKey?: string;
14
+ colField?: keyof T;
15
+ row: T;
16
+ data: T[keyof T] | null;
17
+ index: number;
18
+ }, e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
19
+ DragStart?: (data: {
20
+ colKey: string;
21
+ colField?: keyof T;
22
+ row: T;
23
+ data: T[keyof T] | null;
24
+ index: number;
25
+ }, e: React.DragEvent<Element>) => void;
26
+ Selected?: (data: T, index: number) => boolean;
27
+ KeySelector: (data: T, index?: number) => string | number;
28
+ BodyRef?: React.MutableRefObject<HTMLTableSectionElement | null>;
29
+ BodyScrolled: boolean;
30
+ ColWidths: React.MutableRefObject<Map<string, width>>;
31
+ Trigger: number;
32
+ }
33
+ declare const Rows: <T>(props: React.PropsWithChildren<IProps<T>>) => JSX.Element;
34
+ export declare const IsColumnProps: (props: unknown) => boolean;
35
+ export default Rows;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // Rows.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
+ // 11/18/2023 - C. Lackner
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.IsColumnProps = void 0;
30
+ const React = require("react");
31
+ const Column_1 = require("./Column");
32
+ const defaultDataCellStyle = {
33
+ overflowX: 'hidden',
34
+ display: 'inline-block',
35
+ width: 'auto'
36
+ };
37
+ const Rows = (props) => {
38
+ const bodyStyle = React.useMemo(() => (Object.assign(Object.assign({}, props.BodyStyle), { display: "block" })), [props.BodyStyle]);
39
+ const onClick = React.useCallback((e, item, index) => {
40
+ if (props.OnClick !== undefined)
41
+ props.OnClick({
42
+ colKey: undefined,
43
+ colField: undefined,
44
+ row: item,
45
+ data: null,
46
+ index: index,
47
+ }, e);
48
+ }, [props.OnClick]);
49
+ return (React.createElement("tbody", { style: bodyStyle, className: props.BodyClass, ref: props.BodyRef }, props.Data.map((d, i) => {
50
+ const style = props.RowStyle !== undefined ? Object.assign({}, props.RowStyle) : {};
51
+ if (style.cursor === undefined && (props.OnClick !== undefined || props.DragStart !== undefined))
52
+ style.cursor = 'pointer';
53
+ if (props.Selected !== undefined && props.Selected(d, i))
54
+ style.backgroundColor = 'var(--warning)';
55
+ const key = props.KeySelector(d, i);
56
+ return (React.createElement("tr", { key: key, style: style, onClick: (e) => onClick(e, d, i) }, React.Children.map(props.children, (element) => {
57
+ var _a, _b, _c, _d, _e, _f;
58
+ if (!React.isValidElement(element))
59
+ return null;
60
+ if (!(0, exports.IsColumnProps)(element.props))
61
+ return null;
62
+ const colWidth = props.ColWidths.current.get(element.props.Key);
63
+ if (colWidth == null || colWidth.width === 0)
64
+ return null;
65
+ let cursor = undefined;
66
+ if (((_b = (_a = element.props) === null || _a === void 0 ? void 0 : _a.RowStyle) === null || _b === void 0 ? void 0 : _b.cursor) != null)
67
+ cursor = element.props.RowStyle.cursor;
68
+ else if ((props === null || props === void 0 ? void 0 : props.OnClick) != null) {
69
+ cursor = 'pointer';
70
+ }
71
+ else if ((props === null || props === void 0 ? void 0 : props.DragStart) != null)
72
+ cursor = 'grab';
73
+ const style = Object.assign(Object.assign(Object.assign({}, defaultDataCellStyle), ((_c = element.props) === null || _c === void 0 ? void 0 : _c.RowStyle)), { width: colWidth.width, cursor: cursor });
74
+ return (React.createElement(Column_1.ColumnDataWrapper, { key: element.key, onClick: (e) => {
75
+ var _a, _b;
76
+ if (props.OnClick == null)
77
+ return;
78
+ return props.OnClick({
79
+ colKey: element.props.Key,
80
+ colField: (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field,
81
+ row: d,
82
+ data: d[(_b = element.props) === null || _b === void 0 ? void 0 : _b.Field],
83
+ index: i,
84
+ }, e);
85
+ }, dragStart: props.DragStart == null ? undefined :
86
+ (e) => {
87
+ var _a, _b;
88
+ if (props.DragStart == null)
89
+ return;
90
+ return props.DragStart({
91
+ colKey: element.props.Key,
92
+ colField: (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field,
93
+ row: d,
94
+ data: d[(_b = element.props) === null || _b === void 0 ? void 0 : _b.Field],
95
+ index: i,
96
+ }, e);
97
+ }, style: style }, ((_d = element.props) === null || _d === void 0 ? void 0 : _d.Content) != null
98
+ ? element.props.Content({
99
+ item: d,
100
+ key: element.props.Key,
101
+ field: (_e = element.props) === null || _e === void 0 ? void 0 : _e.Field,
102
+ style: style,
103
+ index: i,
104
+ })
105
+ : ((_f = element.props) === null || _f === void 0 ? void 0 : _f.Field) != null
106
+ ? d[element.props.Field]
107
+ : null));
108
+ })));
109
+ })));
110
+ };
111
+ const IsColumnProps = (props) => ((props === null || props === void 0 ? void 0 : props['Key']) != null);
112
+ exports.IsColumnProps = IsColumnProps;
113
+ exports.default = Rows;
@@ -28,10 +28,9 @@ exports.Table = Table;
28
28
  //
29
29
  // ******************************************************************************************************
30
30
  const React = require("react");
31
- const _ = require("lodash");
32
- const Column_1 = require("./Column");
33
31
  const helper_functions_1 = require("@gpa-gemstone/helper-functions");
34
- const FilterableColumn_1 = require("./FilterableColumn");
32
+ const Rows_1 = require("./Rows");
33
+ const Header_1 = require("./Header");
35
34
  const defaultTableStyle = {
36
35
  padding: 0,
37
36
  flex: 1,
@@ -58,29 +57,11 @@ const defaultRowStyle = {
58
57
  tableLayout: 'fixed',
59
58
  width: '100%'
60
59
  };
61
- const defaultDataHeadStyle = {
62
- display: 'inline-block',
63
- position: 'relative',
64
- borderTop: 'none',
65
- width: 'auto'
66
- };
67
- const defaultDataCellStyle = {
68
- overflowX: 'hidden',
69
- display: 'inline-block',
70
- width: 'auto'
71
- };
72
- const IsColumnProps = (props) => ((props === null || props === void 0 ? void 0 : props['Key']) != null);
73
- const IsColumnAdjustable = (props) => {
74
- const propValue = props === null || props === void 0 ? void 0 : props['Adjustable'];
75
- if (propValue === false || propValue === true)
76
- return propValue;
77
- return false;
78
- };
79
- const lastColumnWidth = 17;
80
60
  function Table(props) {
81
61
  const bodyRef = React.useRef(null);
82
62
  const colWidthsRef = React.useRef(new Map());
83
63
  const oldWidthRef = React.useRef(0);
64
+ const [lastColumnWidth, setLastColumnWidth] = React.useState(0);
84
65
  const [currentTableWidth, setCurrentTableWidth] = React.useState(0);
85
66
  const [scrolled, setScrolled] = React.useState(false);
86
67
  const [trigger, setTrigger] = React.useState(0);
@@ -117,7 +98,7 @@ function Table(props) {
117
98
  // Construct base map
118
99
  const newMap = new Map();
119
100
  React.Children.forEach(props.children, (element) => {
120
- if (React.isValidElement(element) && IsColumnProps(element.props)) {
101
+ if (React.isValidElement(element) && (0, Rows_1.IsColumnProps)(element.props)) {
121
102
  if (newMap.get(element.props.Key) != null)
122
103
  console.error("Multiple of the same key detected in table, this will cause issues.");
123
104
  newMap.set(element.props.Key, { minWidth: 10, maxWidth: undefined, width: 100 });
@@ -137,7 +118,7 @@ function Table(props) {
137
118
  const autoKeys = [];
138
119
  const measureKeys = [];
139
120
  React.Children.forEach(props.children, (element) => {
140
- if (React.isValidElement(element) && IsColumnProps(element.props)) {
121
+ if (React.isValidElement(element) && (0, Rows_1.IsColumnProps)(element.props)) {
141
122
  let widthValue = getWidthfromProps(element.props, type);
142
123
  if (type === 'width' && widthValue == null)
143
124
  widthValue = 'auto';
@@ -219,26 +200,26 @@ function Table(props) {
219
200
  oldWidthRef.current = currentTableWidth;
220
201
  setTrigger(c => c + 1);
221
202
  }, [props.children, currentTableWidth]);
222
- const setTableWidth = React.useCallback(_.debounce(() => {
223
- var _a, _b, _c, _d;
224
- if (bodyRef.current == null)
225
- return;
226
- // Note: certain body classes may break this check if they set overflow to scroll
227
- let newScroll = false;
228
- const dims = (_a = bodyRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(); //use getBoundClientRect() to get un rounded values
229
- if (((_b = props.TbodyStyle) === null || _b === void 0 ? void 0 : _b.overflowY) === 'scroll' || ((_c = props.TbodyStyle) === null || _c === void 0 ? void 0 : _c.overflow) === 'scroll')
230
- newScroll = true;
231
- else
232
- newScroll = (dims === null || dims === void 0 ? void 0 : dims.height) < bodyRef.current.scrollHeight;
233
- setScrolled(newScroll);
234
- // Pick whichever is larger so we dont double subtract
235
- const scrollbar = newScroll ? (0, helper_functions_1.GetScrollbarWidth)() : 0;
236
- const last = props.LastColumn !== undefined ? lastColumnWidth : 0;
237
- const spacer = Math.max(scrollbar, last);
238
- setCurrentTableWidth(((_d = dims.width) !== null && _d !== void 0 ? _d : 17) - spacer);
239
- }, 100), []);
240
203
  React.useEffect(() => {
241
204
  let resizeObserver;
205
+ const setTableWidth = () => {
206
+ var _a, _b, _c, _d;
207
+ if (bodyRef.current == null)
208
+ return;
209
+ // Note: certain body classes may break this check if they set overflow to scroll
210
+ let newScroll = false;
211
+ const dims = (_a = bodyRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(); //use getBoundClientRect() to get un rounded values
212
+ if (((_b = props.TbodyStyle) === null || _b === void 0 ? void 0 : _b.overflowY) === 'scroll' || ((_c = props.TbodyStyle) === null || _c === void 0 ? void 0 : _c.overflow) === 'scroll')
213
+ newScroll = true;
214
+ else
215
+ newScroll = (dims === null || dims === void 0 ? void 0 : dims.height) < bodyRef.current.scrollHeight;
216
+ setScrolled(newScroll);
217
+ // Pick whichever is larger so we dont double subtract
218
+ const scrollbar = newScroll ? (0, helper_functions_1.GetScrollbarWidth)() : 0;
219
+ const last = props.LastColumn !== undefined ? lastColumnWidth : 0;
220
+ const spacer = Math.max(scrollbar, last);
221
+ setCurrentTableWidth(((_d = dims.width) !== null && _d !== void 0 ? _d : 17) - spacer);
222
+ };
242
223
  const intervalHandle = setInterval(() => {
243
224
  if ((bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) == null)
244
225
  return;
@@ -253,258 +234,14 @@ function Table(props) {
253
234
  if (resizeObserver != null && resizeObserver.disconnect != null)
254
235
  resizeObserver.disconnect();
255
236
  };
256
- }, []);
237
+ }, [lastColumnWidth]);
257
238
  const handleSort = React.useCallback((data, event) => {
258
239
  if (data.colKey !== null)
259
240
  props.OnSort(data, event);
260
241
  }, [props.OnSort]);
261
242
  return (React.createElement("table", { className: props.TableClass !== undefined ? props.TableClass : 'table table-hover', style: tableStyle },
262
- React.createElement(Header, { Class: props.TheadClass, Style: headStyle, SortKey: props.SortKey, Ascending: props.Ascending, LastColumn: props.LastColumn, OnSort: handleSort, ColWidths: colWidthsRef, SetFilters: props.SetFilters, Filters: props.Filters, Trigger: trigger, TriggerRerender: () => setTrigger(c => c + 1) }, props.children),
263
- React.createElement(Rows, { DragStart: props.OnDragStart, Data: props.Data, RowStyle: rowStyle, BodyStyle: bodyStyle, BodyClass: props.TbodyClass, OnClick: props.OnClick, Selected: props.Selected, KeySelector: props.KeySelector, BodyRef: bodyRef, BodyScrolled: scrolled, ColWidths: colWidthsRef, Trigger: trigger }, props.children),
243
+ React.createElement(Header_1.default, { Class: props.TheadClass, Style: headStyle, SortKey: props.SortKey, Ascending: props.Ascending, LastColumn: props.LastColumn, OnSort: handleSort, ColWidths: colWidthsRef, SetFilters: props.SetFilters, Filters: props.Filters, Trigger: trigger, TriggerRerender: () => setTrigger(c => c + 1), SetLastColumnWidth: setLastColumnWidth }, props.children),
244
+ React.createElement(Rows_1.default, { DragStart: props.OnDragStart, Data: props.Data, RowStyle: rowStyle, BodyStyle: bodyStyle, BodyClass: props.TbodyClass, OnClick: props.OnClick, Selected: props.Selected, KeySelector: props.KeySelector, BodyRef: bodyRef, BodyScrolled: scrolled, ColWidths: colWidthsRef, Trigger: trigger }, props.children),
264
245
  props.LastRow !== undefined ? (React.createElement("tfoot", { style: props.TfootStyle, className: props.TfootClass },
265
246
  React.createElement("tr", { style: props.RowStyle !== undefined ? Object.assign({}, props.RowStyle) : {} }, props.LastRow))) : null));
266
247
  }
267
- function Rows(props) {
268
- const bodyStyle = React.useMemo(() => (Object.assign(Object.assign({}, props.BodyStyle), { display: "block" })), [props.BodyStyle]);
269
- const onClick = React.useCallback((e, item, index) => {
270
- if (props.OnClick !== undefined)
271
- props.OnClick({
272
- colKey: undefined,
273
- colField: undefined,
274
- row: item,
275
- data: null,
276
- index: index,
277
- }, e);
278
- }, [props.OnClick]);
279
- return (React.createElement("tbody", { style: bodyStyle, className: props.BodyClass, ref: props.BodyRef }, props.Data.map((d, i) => {
280
- const style = props.RowStyle !== undefined ? Object.assign({}, props.RowStyle) : {};
281
- if (style.cursor === undefined && (props.OnClick !== undefined || props.DragStart !== undefined))
282
- style.cursor = 'pointer';
283
- if (props.Selected !== undefined && props.Selected(d, i))
284
- style.backgroundColor = 'var(--warning)';
285
- const key = props.KeySelector(d, i);
286
- return (React.createElement("tr", { key: key, style: style, onClick: (e) => onClick(e, d, i) }, React.Children.map(props.children, (element) => {
287
- var _a, _b, _c, _d, _e, _f;
288
- if (!React.isValidElement(element))
289
- return null;
290
- if (!IsColumnProps(element.props))
291
- return null;
292
- const colWidth = props.ColWidths.current.get(element.props.Key);
293
- if (colWidth == null || colWidth.width === 0)
294
- return null;
295
- let cursor = undefined;
296
- if (((_b = (_a = element.props) === null || _a === void 0 ? void 0 : _a.RowStyle) === null || _b === void 0 ? void 0 : _b.cursor) != null)
297
- cursor = element.props.RowStyle.cursor;
298
- else if ((props === null || props === void 0 ? void 0 : props.OnClick) != null) {
299
- cursor = 'pointer';
300
- }
301
- else if ((props === null || props === void 0 ? void 0 : props.DragStart) != null)
302
- cursor = 'grab';
303
- const style = Object.assign(Object.assign(Object.assign({}, defaultDataCellStyle), ((_c = element.props) === null || _c === void 0 ? void 0 : _c.RowStyle)), { width: colWidth.width, cursor: cursor });
304
- return (React.createElement(Column_1.ColumnDataWrapper, { key: element.key, onClick: (e) => {
305
- var _a, _b;
306
- if (props.OnClick == null)
307
- return;
308
- return props.OnClick({
309
- colKey: element.props.Key,
310
- colField: (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field,
311
- row: d,
312
- data: d[(_b = element.props) === null || _b === void 0 ? void 0 : _b.Field],
313
- index: i,
314
- }, e);
315
- }, dragStart: props.DragStart == null ? undefined :
316
- (e) => {
317
- var _a, _b;
318
- if (props.DragStart == null)
319
- return;
320
- return props.DragStart({
321
- colKey: element.props.Key,
322
- colField: (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field,
323
- row: d,
324
- data: d[(_b = element.props) === null || _b === void 0 ? void 0 : _b.Field],
325
- index: i,
326
- }, e);
327
- }, style: style }, ((_d = element.props) === null || _d === void 0 ? void 0 : _d.Content) != null
328
- ? element.props.Content({
329
- item: d,
330
- key: element.props.Key,
331
- field: (_e = element.props) === null || _e === void 0 ? void 0 : _e.Field,
332
- style: style,
333
- index: i,
334
- })
335
- : ((_f = element.props) === null || _f === void 0 ? void 0 : _f.Field) != null
336
- ? d[element.props.Field]
337
- : null));
338
- })));
339
- })));
340
- }
341
- function Header(props) {
342
- var _a;
343
- const headStyle = React.useMemo(() => (Object.assign(Object.assign({}, defaultHeadStyle), props.Style)), [props.Style]);
344
- // Consts for adjustable columns
345
- const [mouseDown, setMouseDown] = React.useState(0);
346
- const [currentKeys, setCurrentKeys] = React.useState(undefined);
347
- const [deltaW, setDeltaW] = React.useState(0);
348
- const [tentativeLimits, setTentativeLimits] = React.useState({ min: -Infinity, max: Infinity });
349
- // Consts for filterable columns
350
- const [filters, setFilters] = React.useState(((_a = props.Filters) !== null && _a !== void 0 ? _a : []));
351
- const [guid] = React.useState((0, helper_functions_1.CreateGuid)());
352
- const getLeftKey = React.useCallback((key, colWidthsRef) => {
353
- // Filtering down to shown adjustables only
354
- var _a, _b;
355
- const mapCallback = (element) => {
356
- var _a;
357
- if (!React.isValidElement(element))
358
- return null;
359
- const keyWidth = (_a = colWidthsRef.current.get(key)) === null || _a === void 0 ? void 0 : _a.width;
360
- if (keyWidth == null || keyWidth <= 0)
361
- return null;
362
- if (IsColumnProps(element.props) && IsColumnAdjustable(element.props))
363
- return element.props.Key;
364
- return null;
365
- };
366
- const children = (_a = props.children) !== null && _a !== void 0 ? _a : [];
367
- const keys = ((_b = React.Children.map(children, mapCallback)) !== null && _b !== void 0 ? _b : []).filter((item) => item !== null);
368
- const index = keys.indexOf(key);
369
- if (index <= 0)
370
- return undefined;
371
- return keys[index - 1];
372
- }, [props.children]);
373
- const calculateDeltaLimits = React.useCallback((mapKeys, colWidthsRef) => {
374
- if (mapKeys === undefined)
375
- return ({ min: -Infinity, max: Infinity });
376
- const widthObjLeft = colWidthsRef.current.get(mapKeys[0]);
377
- const widthObjRight = colWidthsRef.current.get(mapKeys[1]);
378
- if (widthObjLeft == null || widthObjRight == null)
379
- return ({ min: -Infinity, max: Infinity });
380
- const limitByShrinkLeft = widthObjLeft.width - widthObjLeft.minWidth;
381
- const limitByGrowthLeft = widthObjLeft.maxWidth == null ? Number.MAX_SAFE_INTEGER : (widthObjLeft.maxWidth - widthObjLeft.width);
382
- const limitByShrinkRight = widthObjRight.width - widthObjRight.minWidth;
383
- const limitByGrowthRight = widthObjRight.maxWidth == null ? Number.MAX_SAFE_INTEGER : (widthObjRight.maxWidth - widthObjRight.width);
384
- // Recall that a left movement is a negative deltaW
385
- const minDeltaW = -(limitByShrinkLeft < limitByGrowthRight ? limitByShrinkLeft : limitByGrowthRight);
386
- const maxDeltaW = limitByShrinkRight < limitByGrowthLeft ? limitByShrinkRight : limitByGrowthLeft;
387
- return ({ min: minDeltaW, max: maxDeltaW });
388
- }, []);
389
- const getDeltaSign = React.useCallback((index) => {
390
- // Recall that a left movement is a negative deltaW
391
- if (index === 0)
392
- return 1;
393
- else if (index === 1)
394
- return -1;
395
- else
396
- return 0;
397
- }, []);
398
- const finishAdjustment = React.useCallback((adjustment, adjustKeys, colWidthsRef) => {
399
- const deltaLimits = calculateDeltaLimits(adjustKeys, colWidthsRef);
400
- let delta;
401
- if (adjustment > deltaLimits.max)
402
- delta = deltaLimits.max;
403
- else if (adjustment < deltaLimits.min)
404
- delta = deltaLimits.min;
405
- else
406
- delta = adjustment;
407
- if (Math.abs(delta) > 5) {
408
- const leftWidthObj = colWidthsRef.current.get(adjustKeys[0]);
409
- const rightWidthObj = colWidthsRef.current.get(adjustKeys[1]);
410
- if (leftWidthObj == null || rightWidthObj == null) {
411
- console.error(`Unable to finalize adjustment on keys ${adjustKeys[0]}, ${adjustKeys[1]}`);
412
- }
413
- else {
414
- leftWidthObj.width += (getDeltaSign(0) * delta);
415
- rightWidthObj.width += (getDeltaSign(1) * delta);
416
- }
417
- }
418
- setMouseDown(0);
419
- setTentativeLimits({ min: -Infinity, max: Infinity });
420
- setCurrentKeys(undefined);
421
- setDeltaW(0);
422
- }, [calculateDeltaLimits, getDeltaSign]);
423
- const onMove = React.useCallback((e) => {
424
- if (currentKeys === undefined)
425
- return;
426
- const w = e.screenX - mouseDown;
427
- setDeltaW(w);
428
- }, [mouseDown, currentKeys]);
429
- const updateFilters = React.useCallback((flts, fld) => {
430
- setFilters((fls) => {
431
- const newFilters = fls.filter(item => item.FieldName !== fld).concat(flts);
432
- if (props.SetFilters == null)
433
- console.error("Attempted to set filters from column when no set filter arguement to table was provided. Data has not been filtered!");
434
- else
435
- props.SetFilters(newFilters);
436
- return newFilters;
437
- });
438
- }, [props.SetFilters]);
439
- React.useEffect(() => { var _a; return setFilters((_a = props.Filters) !== null && _a !== void 0 ? _a : []); }, [props.Filters]);
440
- return (React.createElement("thead", { className: props.Class, style: headStyle, onMouseMove: (e) => {
441
- onMove(e.nativeEvent);
442
- e.stopPropagation();
443
- }, onMouseUp: (e) => {
444
- e.stopPropagation();
445
- if (currentKeys == null)
446
- return;
447
- finishAdjustment(deltaW, currentKeys, props.ColWidths);
448
- props.TriggerRerender();
449
- }, onMouseLeave: (e) => {
450
- e.stopPropagation();
451
- if (currentKeys == null)
452
- return;
453
- finishAdjustment(deltaW, currentKeys, props.ColWidths);
454
- props.TriggerRerender();
455
- } },
456
- React.createElement("tr", { style: { width: '100%', display: 'table' } },
457
- React.Children.map(props.children, (element) => {
458
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
459
- if (!React.isValidElement(element))
460
- return null;
461
- if (!IsColumnProps(element.props))
462
- return null;
463
- const colWidth = props.ColWidths.current.get(element.props.Key);
464
- if (colWidth == null || colWidth.width === 0)
465
- return null;
466
- // Handling temporary width changes due to being in mid-adjustments
467
- let currentWidth = colWidth.width;
468
- const keyIndex = (_a = currentKeys === null || currentKeys === void 0 ? void 0 : currentKeys.indexOf(element.props.Key)) !== null && _a !== void 0 ? _a : -1;
469
- if (keyIndex > -1) {
470
- let delta;
471
- if (deltaW > tentativeLimits.max)
472
- delta = tentativeLimits.max;
473
- else if (deltaW < tentativeLimits.min)
474
- delta = tentativeLimits.min;
475
- else
476
- delta = deltaW;
477
- currentWidth += (getDeltaSign(keyIndex) * delta);
478
- }
479
- let cursor = undefined;
480
- if (((_c = (_b = element.props) === null || _b === void 0 ? void 0 : _b.HeaderStyle) === null || _c === void 0 ? void 0 : _c.cursor) != null)
481
- cursor = element.props.HeaderStyle.cursor;
482
- else if (((_e = (_d = element.props) === null || _d === void 0 ? void 0 : _d.AllowSort) !== null && _e !== void 0 ? _e : true))
483
- cursor = 'pointer';
484
- const style = Object.assign(Object.assign(Object.assign({}, defaultDataHeadStyle), (_f = element.props) === null || _f === void 0 ? void 0 : _f.HeaderStyle), { width: currentWidth, cursor: cursor });
485
- let startAdjustment;
486
- if (IsColumnAdjustable(element.props))
487
- startAdjustment = (e) => {
488
- const leftKey = getLeftKey(element.props.Key, props.ColWidths);
489
- if (leftKey != null) {
490
- const newCurrentKeys = [leftKey, element.props.Key];
491
- setCurrentKeys(newCurrentKeys);
492
- setMouseDown(e.screenX);
493
- setTentativeLimits(calculateDeltaLimits(newCurrentKeys, props.ColWidths));
494
- setDeltaW(0);
495
- }
496
- };
497
- return (React.createElement(Column_1.ColumnHeaderWrapper, { onSort: (e) => {
498
- var _a;
499
- return props.OnSort({ colKey: element.props.Key, colField: (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field, ascending: props.Ascending }, e);
500
- }, sorted: props.SortKey === element.props.Key && ((_h = (_g = element.props) === null || _g === void 0 ? void 0 : _g.AllowSort) !== null && _h !== void 0 ? _h : true), asc: props.Ascending, colKey: element.props.Key, key: element.props.Key, allowSort: (_j = element.props) === null || _j === void 0 ? void 0 : _j.AllowSort, startAdjustment: startAdjustment, style: style },
501
- ' ',
502
- (element.type === FilterableColumn_1.default) ?
503
- React.createElement(FilterableColumn_1.FilterableColumnHeader, { Label: (_k = element.props) === null || _k === void 0 ? void 0 : _k.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: (_l = element.props) === null || _l === void 0 ? void 0 : _l.Field, Type: (_m = element.props) === null || _m === void 0 ? void 0 : _m.Type, Options: (_o = element.props) === null || _o === void 0 ? void 0 : _o.Enum, ExpandedLabel: (_p = element.props) === null || _p === void 0 ? void 0 : _p.ExpandedLabel, Guid: guid, Unit: (_q = element.props) === null || _q === void 0 ? void 0 : _q.Unit }) :
504
- ((_r = element.props.children) !== null && _r !== void 0 ? _r : element.props.Key),
505
- ' '));
506
- }),
507
- props.LastColumn !== undefined ?
508
- React.createElement("th", { style: { width: lastColumnWidth, padding: 0, maxWidth: lastColumnWidth } }, props.LastColumn)
509
- : null)));
510
- }
package/lib/index.d.ts CHANGED
@@ -5,4 +5,5 @@ import { Column } from './Table/Column';
5
5
  import FilterableColumn from './Table/FilterableColumn';
6
6
  import ConfigurableTable from './ConfigurableTable/ConfigurableTable';
7
7
  import ConfigurableColumn from './ConfigurableTable/ConfigurableColumn';
8
- export { ReactTableProps, Table, Column, FilterableColumn, ConfigurableTable, ConfigurableColumn, Paging };
8
+ import { GetConfigurableColumnsFromTypeEntries } from './GetConfigurableColumnsFromTypeEntries';
9
+ export { ReactTableProps, Table, Column, FilterableColumn, ConfigurableTable, ConfigurableColumn, Paging, GetConfigurableColumnsFromTypeEntries };
package/lib/index.js CHANGED
@@ -24,7 +24,7 @@
24
24
  //
25
25
  // ******************************************************************************************************
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.Paging = exports.ConfigurableColumn = exports.ConfigurableTable = exports.FilterableColumn = exports.Column = exports.Table = exports.ReactTableProps = void 0;
27
+ exports.GetConfigurableColumnsFromTypeEntries = exports.Paging = exports.ConfigurableColumn = exports.ConfigurableTable = exports.FilterableColumn = exports.Column = exports.Table = exports.ReactTableProps = void 0;
28
28
  const Paging_1 = require("./Paging");
29
29
  exports.Paging = Paging_1.default;
30
30
  const ReactTableProps = require("./Table/Types");
@@ -39,3 +39,5 @@ const ConfigurableTable_1 = require("./ConfigurableTable/ConfigurableTable");
39
39
  exports.ConfigurableTable = ConfigurableTable_1.default;
40
40
  const ConfigurableColumn_1 = require("./ConfigurableTable/ConfigurableColumn");
41
41
  exports.ConfigurableColumn = ConfigurableColumn_1.default;
42
+ const GetConfigurableColumnsFromTypeEntries_1 = require("./GetConfigurableColumnsFromTypeEntries");
43
+ Object.defineProperty(exports, "GetConfigurableColumnsFromTypeEntries", { enumerable: true, get: function () { return GetConfigurableColumnsFromTypeEntries_1.GetConfigurableColumnsFromTypeEntries; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpa-gemstone/react-table",
3
- "version": "1.2.114",
3
+ "version": "1.2.116",
4
4
  "description": "Table for GPA web applications",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -45,9 +45,9 @@
45
45
  "typescript": "5.5.3"
46
46
  },
47
47
  "dependencies": {
48
- "@gpa-gemstone/gpa-symbols": "0.0.62",
49
- "@gpa-gemstone/helper-functions": "0.0.60",
50
- "@gpa-gemstone/react-interactive": "1.0.190",
48
+ "@gpa-gemstone/gpa-symbols": "0.0.64",
49
+ "@gpa-gemstone/helper-functions": "0.0.61",
50
+ "@gpa-gemstone/react-interactive": "1.0.192",
51
51
  "lodash": "^4.17.21",
52
52
  "react-portal": "4.2.2"
53
53
  },