@gpa-gemstone/react-table 1.2.56 → 1.2.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/lib/AdjustableTable/Column.d.ts +6 -45
  2. package/lib/AdjustableTable/Column.js +32 -53
  3. package/lib/AdjustableTable/Table.d.ts +2 -116
  4. package/lib/AdjustableTable/Table.js +329 -347
  5. package/lib/AdjustableTable/Types.d.ts +148 -0
  6. package/lib/AdjustableTable/Types.js +24 -0
  7. package/lib/ConfigurableTable/ConfigurableColumn.d.ts +11 -0
  8. package/lib/ConfigurableTable/ConfigurableColumn.js +31 -0
  9. package/lib/ConfigurableTable/ConfigurableTable.d.ts +25 -0
  10. package/lib/ConfigurableTable/ConfigurableTable.js +189 -0
  11. package/lib/FilterableTable/BooleanFilter.d.ts +26 -0
  12. package/lib/FilterableTable/BooleanFilter.js +68 -0
  13. package/lib/FilterableTable/DateTimeFilters.d.ts +10 -0
  14. package/lib/FilterableTable/DateTimeFilters.js +321 -0
  15. package/lib/FilterableTable/EnumFilter.d.ts +37 -0
  16. package/lib/FilterableTable/EnumFilter.js +89 -0
  17. package/lib/FilterableTable/FilterableColumn.d.ts +20 -0
  18. package/lib/FilterableTable/FilterableColumn.js +34 -0
  19. package/lib/FilterableTable/FilterableTable.d.ts +12 -0
  20. package/lib/FilterableTable/FilterableTable.js +95 -0
  21. package/lib/FilterableTable/NumberFilter.d.ts +19 -0
  22. package/lib/FilterableTable/NumberFilter.js +160 -0
  23. package/lib/FilterableTable/TextFilter.d.ts +14 -0
  24. package/lib/FilterableTable/TextFilter.js +78 -0
  25. package/lib/Filters/BooleanFilter.d.ts +26 -0
  26. package/lib/Filters/BooleanFilter.js +68 -0
  27. package/lib/Filters/DateTimeFilters.d.ts +10 -0
  28. package/lib/Filters/DateTimeFilters.js +321 -0
  29. package/lib/Filters/EnumFilter.d.ts +37 -0
  30. package/lib/Filters/EnumFilter.js +89 -0
  31. package/lib/Filters/NumberFilter.d.ts +19 -0
  32. package/lib/Filters/NumberFilter.js +160 -0
  33. package/lib/Filters/TextFilter.d.ts +14 -0
  34. package/lib/Filters/TextFilter.js +78 -0
  35. package/lib/Table/Column.d.ts +19 -0
  36. package/lib/Table/Column.js +73 -0
  37. package/lib/Table/FilterableColumn.d.ts +20 -0
  38. package/lib/Table/FilterableColumn.js +74 -0
  39. package/lib/Table/Table.d.ts +3 -0
  40. package/lib/Table/Table.js +498 -0
  41. package/lib/Table/Types.d.ts +185 -0
  42. package/lib/Table/Types.js +24 -0
  43. package/lib/index.d.ts +7 -14
  44. package/lib/index.js +13 -19
  45. package/package.json +56 -52
  46. package/lib/AdjustableTable/AdjustableColumn.d.ts +0 -18
  47. package/lib/AdjustableTable/AdjustableColumn.js +0 -187
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = AdjustableTable;
3
+ exports.AdjustableTable = AdjustableTable;
4
4
  // ******************************************************************************************************
5
5
  // Table.tsx - Gbtc
6
6
  //
@@ -23,32 +23,192 @@ exports.default = AdjustableTable;
23
23
  // Generated original version of source code.
24
24
  // 05/31/2024 - C. Lackner
25
25
  // Refactored to fix sizing issues.
26
+ // 12/04/2024 - G. Santos
27
+ // Refactored to fix performance issues.
26
28
  //
27
29
  // ******************************************************************************************************
28
30
  const React = require("react");
29
31
  const _ = require("lodash");
30
32
  const Column_1 = require("./Column");
31
- const AdjustableColumn_1 = require("./AdjustableColumn");
32
33
  const defaultTableStyle = {
33
34
  padding: 0,
34
- width: '100%',
35
- height: '100%',
35
+ flex: 1,
36
36
  tableLayout: 'fixed',
37
37
  overflow: 'hidden',
38
38
  display: 'flex',
39
39
  flexDirection: 'column',
40
40
  marginBottom: 0,
41
+ width: '100%'
41
42
  };
43
+ const defaultHeadStyle = {
44
+ fontSize: 'auto',
45
+ tableLayout: 'fixed',
46
+ display: 'table',
47
+ width: '100%'
48
+ };
49
+ const defaultBodyStyle = {
50
+ flex: 1,
51
+ display: 'block',
52
+ overflow: 'auto'
53
+ };
54
+ const defaultRowStyle = {
55
+ display: 'table',
56
+ tableLayout: 'fixed',
57
+ width: '100%'
58
+ };
59
+ const defaultDataHeadStyle = {
60
+ display: 'inline-block',
61
+ position: 'relative',
62
+ borderTop: 'none',
63
+ width: 'auto'
64
+ };
65
+ const defaultDataCellStyle = {
66
+ overflowX: 'hidden',
67
+ display: 'inline-block',
68
+ width: 'auto'
69
+ };
70
+ const IsColumnProps = (props) => ((props === null || props === void 0 ? void 0 : props['Key']) != null);
42
71
  function AdjustableTable(props) {
43
- var _a;
44
72
  const bodyRef = React.useRef(null);
45
- const throtleRef = React.useRef(null);
46
- const colCountRef = React.useRef(null);
47
- const autoWidth = React.useRef(new Map());
48
- const [autoWidthVersion, setAutoWidthVersion] = React.useState(0);
73
+ const colWidthsRef = React.useRef(new Map());
74
+ const oldWidthRef = React.useRef(0);
49
75
  const [currentTableWidth, setCurrentTableWidth] = React.useState(0);
50
76
  const [scrolled, setScrolled] = React.useState(false);
51
- const [extraWidthPerRow, setExtraWidthPerRow] = React.useState(0);
77
+ const [trigger, setTrigger] = React.useState(0);
78
+ // Style consts
79
+ const tableStyle = React.useMemo(() => (Object.assign(Object.assign({}, defaultTableStyle), props.TableStyle)), [props.TableStyle]);
80
+ const headStyle = React.useMemo(() => (Object.assign(Object.assign({}, defaultHeadStyle), props.TheadStyle)), [props.TheadStyle]);
81
+ const bodyStyle = React.useMemo(() => (Object.assign(Object.assign({}, defaultBodyStyle), props.TbodyStyle)), [props.TbodyStyle]);
82
+ const rowStyle = React.useMemo(() => (Object.assign(Object.assign({}, defaultRowStyle), props.RowStyle)), [props.RowStyle]);
83
+ // Send warning if styles are overridden
84
+ React.useEffect(() => {
85
+ if (props.TableStyle !== undefined)
86
+ console.warn('TableStyle properties may be overridden if needed. consider using the defaults');
87
+ if (props.TheadStyle !== undefined)
88
+ console.warn('TheadStyle properties may be overridden if needed. consider using the defaults');
89
+ if (props.TbodyStyle !== undefined)
90
+ console.warn('TBodyStyle properties may be overridden if needed. consider using the defaults');
91
+ if (props.RowStyle !== undefined)
92
+ console.warn('RowStyle properties may be overridden if needed. consider using the defaults');
93
+ }, []);
94
+ // Measure widths and hide columns
95
+ React.useLayoutEffect(() => {
96
+ if (currentTableWidth <= 0)
97
+ return;
98
+ // Helper functions for the calculations
99
+ const getWidthfromProps = (p, type) => {
100
+ var _a, _b;
101
+ // This priotizes rowstyling for width over header, since it was decided that they need to be the same
102
+ if (((_a = p === null || p === void 0 ? void 0 : p.RowStyle) === null || _a === void 0 ? void 0 : _a[type]) !== undefined)
103
+ return p.RowStyle[type];
104
+ if (((_b = p === null || p === void 0 ? void 0 : p.HeaderStyle) === null || _b === void 0 ? void 0 : _b[type]) !== undefined)
105
+ return p.HeaderStyle[type];
106
+ return undefined;
107
+ };
108
+ // Construct base map
109
+ const newMap = new Map();
110
+ React.Children.forEach(props.children, (element) => {
111
+ if (React.isValidElement(element) && IsColumnProps(element.props)) {
112
+ if (newMap.get(element.props.Key) != null)
113
+ console.error("Multiple of the same key detected in table, this will cause issues.");
114
+ newMap.set(element.props.Key, { minWidth: 100, maxWidth: 1000, width: 100 });
115
+ }
116
+ });
117
+ // If width is the same and keys are identical, we can skip the operation
118
+ if (currentTableWidth === oldWidthRef.current &&
119
+ (newMap.size === colWidthsRef.current.size &&
120
+ ![...newMap.keys()].some(key => !colWidthsRef.current.has(key))))
121
+ return;
122
+ // Find and set widths for map
123
+ ['minWidth', 'width', 'maxWidth'].forEach(type => {
124
+ const widthsContainer = document.createElement("div");
125
+ widthsContainer.style.height = '0px';
126
+ widthsContainer.style.width = `${currentTableWidth}px`;
127
+ // Append columns as divs for measurement
128
+ const autoKeys = [];
129
+ const measureKeys = [];
130
+ React.Children.forEach(props.children, (element) => {
131
+ if (React.isValidElement(element) && IsColumnProps(element.props)) {
132
+ let widthValue = getWidthfromProps(element.props, type);
133
+ if (type === 'width' && widthValue == null)
134
+ widthValue = 'auto';
135
+ if (widthValue != null) {
136
+ if (widthValue === 'auto')
137
+ autoKeys.push(element.props.Key);
138
+ else {
139
+ const widthElement = document.createElement("div");
140
+ widthElement.id = element.props.Key + "_measurement";
141
+ widthElement.style.height = '0px';
142
+ if ((widthValue === null || widthValue === void 0 ? void 0 : widthValue.length) != null)
143
+ widthElement.style.width = widthValue;
144
+ else
145
+ widthElement.style.width = `${widthValue}px`;
146
+ widthsContainer.appendChild(widthElement);
147
+ measureKeys.push(element.props.Key);
148
+ }
149
+ }
150
+ }
151
+ });
152
+ document.body.appendChild(widthsContainer);
153
+ // Handle Measurements
154
+ let autoSpace = currentTableWidth;
155
+ measureKeys.forEach(key => {
156
+ const element = document.getElementById(key + "_measurement");
157
+ if (element != null) {
158
+ const widthObj = newMap.get(key);
159
+ if (widthObj != null) {
160
+ autoSpace -= element.clientWidth;
161
+ widthObj[type] = element.clientWidth;
162
+ }
163
+ else
164
+ console.error("Could not find width object for Key: " + key);
165
+ }
166
+ else
167
+ console.error("Could not find measurement div with Key: " + key);
168
+ });
169
+ document.body.removeChild(widthsContainer);
170
+ // Handle Autos (width type only)
171
+ if (type === 'width' && autoKeys.length > 0) {
172
+ const spacePerElement = Math.floor(autoSpace / autoKeys.length);
173
+ autoKeys.forEach(key => {
174
+ const widthObj = newMap.get(key);
175
+ if (widthObj != null)
176
+ widthObj[type] = spacePerElement;
177
+ else
178
+ console.error("Could not find width object for Key: " + key);
179
+ });
180
+ }
181
+ let remainingSpace = currentTableWidth;
182
+ [...newMap.keys()].forEach(key => {
183
+ const widthObj = newMap.get(key);
184
+ if (widthObj != null) {
185
+ if (widthObj.minWidth <= remainingSpace) {
186
+ // This follows behavior consistent with MDN documentation on how these width types should behave
187
+ if (widthObj.minWidth > widthObj.width)
188
+ widthObj.width = widthObj.minWidth;
189
+ if (widthObj.minWidth > widthObj.maxWidth)
190
+ widthObj.maxWidth = widthObj.minWidth;
191
+ if (widthObj.width > widthObj.maxWidth)
192
+ widthObj.width = widthObj.maxWidth;
193
+ // Constrain Width to remainingSpace
194
+ if (widthObj.width > remainingSpace)
195
+ widthObj.width = remainingSpace;
196
+ remainingSpace -= widthObj.width;
197
+ }
198
+ else {
199
+ widthObj.minWidth = 0;
200
+ widthObj.width = 0;
201
+ widthObj.maxWidth = 0;
202
+ }
203
+ }
204
+ else
205
+ console.error("Could not find width object for Key: " + key);
206
+ });
207
+ });
208
+ colWidthsRef.current = newMap;
209
+ oldWidthRef.current = currentTableWidth;
210
+ setTrigger(c => c + 1);
211
+ }, [props.children, currentTableWidth]);
52
212
  const setTableWidth = React.useCallback(_.debounce(() => {
53
213
  var _a, _b, _c, _d;
54
214
  if (bodyRef.current == null)
@@ -79,205 +239,18 @@ function AdjustableTable(props) {
79
239
  resizeObserver.disconnect();
80
240
  };
81
241
  }, []);
82
- React.useEffect(() => {
83
- autoWidth.current = new Map();
84
- setAutoWidthVersion(0);
85
- }, [currentTableWidth]);
86
- React.useEffect(() => {
87
- var _a;
88
- let totalMaxWidth = 0;
89
- autoWidth.current.forEach((v) => {
90
- totalMaxWidth += v.maxColWidth;
91
- });
92
- if (totalMaxWidth > currentTableWidth && currentTableWidth > 0) {
93
- const hideKeys = [];
94
- const showKeys = [];
95
- let t = 0;
96
- let colW = 0;
97
- autoWidth.current.forEach((v, k) => {
98
- t = t + v.maxColWidth;
99
- if (t < currentTableWidth) {
100
- showKeys.push(k);
101
- colW += v.maxColWidth;
102
- }
103
- else
104
- hideKeys.push(k);
105
- });
106
- const numEnabledColumns = showKeys.length;
107
- if (Array.from(autoWidth.current.values()).filter(autoWidth => !autoWidth.enabled).length == hideKeys.length) {
108
- return;
109
- }
110
- if (colCountRef.current !== null)
111
- clearTimeout(colCountRef.current);
112
- colCountRef.current = setTimeout(() => {
113
- var _a;
114
- hideKeys.forEach((k) => (autoWidth.current.get(k).enabled = false));
115
- showKeys.forEach((k) => (autoWidth.current.get(k).enabled = true));
116
- const numOfColsWithAutoCSS = Array.from(autoWidth.current.values()).filter(autoWidth => autoWidth.isAuto && autoWidth.enabled).length;
117
- const numOfColsWithUndefinedCSS = Array.from(autoWidth.current.values()).filter(autoWidth => autoWidth.isUndefined && autoWidth.enabled).length;
118
- let colsToDivideBy = numEnabledColumns; // Split the extra across all cols
119
- if (numOfColsWithAutoCSS > 0) { // Split only on the css auto-cols and no css undefined cols
120
- colsToDivideBy = numOfColsWithAutoCSS;
121
- }
122
- if (numOfColsWithUndefinedCSS > 0 && numOfColsWithAutoCSS == 0) { // Split only on the css undefined if there are no auto-cols
123
- colsToDivideBy = numOfColsWithUndefinedCSS;
124
- }
125
- const extraSpace = (currentTableWidth - colW) / colsToDivideBy;
126
- setExtraWidthPerRow(Math.floor(extraSpace));
127
- (_a = props.ReduceWidthCallback) === null || _a === void 0 ? void 0 : _a.call(props, hideKeys);
128
- setAutoWidthVersion((v) => v + 1);
129
- }, 500);
130
- }
131
- else if (currentTableWidth > 0) {
132
- const numEnabledColumns = Array.from(autoWidth.current.values()).filter(autoWidth => autoWidth.enabled).length;
133
- const numOfColsWithAutoCSS = Array.from(autoWidth.current.values()).filter(autoWidth => autoWidth.isAuto && autoWidth.enabled).length;
134
- const colsToDivideBy = (numOfColsWithAutoCSS > 0) ? numOfColsWithAutoCSS : numEnabledColumns;
135
- const extraSpace = (currentTableWidth - totalMaxWidth - numEnabledColumns) / colsToDivideBy;
136
- setExtraWidthPerRow(extraSpace);
137
- (_a = props.ReduceWidthCallback) === null || _a === void 0 ? void 0 : _a.call(props, []);
138
- }
139
- }, [autoWidthVersion]);
140
- React.useEffect(() => {
141
- // if there are keys in the map not present in children, map is old
142
- const children = React.Children.toArray(props.children);
143
- const childKeys = [];
144
- const mapKeys = autoWidth.current.keys();
145
- children.forEach(child => {
146
- if (!React.isValidElement(child))
147
- return;
148
- if (child.type === Column_1.default ||
149
- child.type === AdjustableColumn_1.default)
150
- childKeys.push(child.props.Key);
151
- });
152
- for (const key of mapKeys) {
153
- if (childKeys.includes(key)) {
154
- continue;
155
- }
156
- else {
157
- autoWidth.current.clear();
158
- setAutoWidthVersion(0);
159
- break;
160
- }
161
- }
162
- }, [props.children]);
163
242
  const handleSort = React.useCallback((data, event) => {
164
243
  if (data.colKey !== null)
165
244
  props.OnSort(data, event);
166
245
  }, [props.OnSort]);
167
- const setWidth = React.useCallback((colKey, key, width, isAuto, isUndefined) => {
168
- var _a, _b, _c, _d, _e, _f;
169
- const flooredWidth = Math.floor(width);
170
- if (!autoWidth.current.has(colKey)) { // does the column exist
171
- autoWidth.current.set(colKey, {
172
- maxColWidth: flooredWidth,
173
- width: new Map([[key, flooredWidth]]),
174
- enabled: true,
175
- adjustement: 0,
176
- isAuto: isAuto,
177
- isUndefined: isUndefined
178
- });
179
- }
180
- else if (!((_b = (_a = autoWidth.current.get(colKey)) === null || _a === void 0 ? void 0 : _a.width.has(key)) !== null && _b !== void 0 ? _b : false)) { // it exists but the key does not
181
- (_c = autoWidth.current.get(colKey)) === null || _c === void 0 ? void 0 : _c.width.set(key, flooredWidth); // add the width for this key
182
- autoWidth.current.get(colKey).isAuto = isAuto;
183
- if (flooredWidth > ((_e = (_d = autoWidth.current.get(colKey)) === null || _d === void 0 ? void 0 : _d.maxColWidth) !== null && _e !== void 0 ? _e : 9e10)) // if width is > to max col
184
- autoWidth.current.get(colKey).maxColWidth = flooredWidth; // set max to width
185
- }
186
- else if (autoWidth.current.get(colKey).width.get(key) == flooredWidth) { // width == newW
187
- autoWidth.current.get(colKey).isAuto = isAuto;
188
- return;
189
- }
190
- else {
191
- autoWidth.current.get(colKey).width.set(key, flooredWidth); // otherwise, it exists, just set the width
192
- autoWidth.current.get(colKey).isAuto = isAuto;
193
- if (flooredWidth == ((_f = autoWidth.current.get(colKey)) === null || _f === void 0 ? void 0 : _f.maxColWidth)) // check against max
194
- autoWidth.current.get(colKey).maxColWidth = Math.max(...autoWidth.current.get(colKey).width.values());
195
- }
196
- //cancel ref
197
- //Add a Timer - runs within 10 ms from when the Timer started to avoid React thinking this is an indinfinte loop....
198
- if (throtleRef.current !== null)
199
- clearTimeout(throtleRef.current);
200
- throtleRef.current = setTimeout(() => {
201
- setAutoWidthVersion((v) => v + 1);
202
- }, 10);
203
- }, []);
204
- const setAdjustment = React.useCallback((colKey, w) => {
205
- if (!autoWidth.current.has(colKey) || autoWidth.current.get(colKey) == undefined) { // doesnt exist/is undefined
206
- autoWidth.current.set(colKey, {
207
- maxColWidth: 0,
208
- width: new Map(),
209
- enabled: true,
210
- adjustement: w,
211
- isAuto: false,
212
- isUndefined: false
213
- });
214
- }
215
- else {
216
- const x = autoWidth.current.get(colKey);
217
- if ((x === null || x === void 0 ? void 0 : x.adjustement) != undefined)
218
- x.adjustement += w;
219
- }
220
- //cancel ref
221
- //Add a Timer - runs within 10 ms from when the Timer started to avoid React thinking this is an indinfinte loop....
222
- if (throtleRef.current !== null)
223
- clearTimeout(throtleRef.current);
224
- throtleRef.current = setTimeout(() => {
225
- setAutoWidthVersion((v) => v + 1);
226
- }, 10);
227
- }, []);
228
- const setMinWidth = React.useCallback((colKey, w) => {
229
- var _a;
230
- if (!autoWidth.current.has(colKey))
231
- autoWidth.current.set(colKey, {
232
- maxColWidth: 0,
233
- width: new Map(),
234
- enabled: true,
235
- adjustement: 0,
236
- minWidth: w,
237
- isAuto: false,
238
- isUndefined: false
239
- });
240
- else if (((_a = autoWidth.current.get(colKey)) === null || _a === void 0 ? void 0 : _a.minWidth) == w)
241
- return;
242
- autoWidth.current.get(colKey).minWidth = w;
243
- //cancel ref
244
- //Add a Timer - runs within 10 ms from when the Timer started to avoid React thinking this is an indinfinte loop....
245
- if (throtleRef.current !== null)
246
- clearTimeout(throtleRef.current);
247
- throtleRef.current = setTimeout(() => {
248
- setAutoWidthVersion((v) => v + 1);
249
- }, 10);
250
- }, []);
251
- const setMaxWidth = React.useCallback((colKey, w) => {
252
- var _a;
253
- if (!autoWidth.current.has(colKey))
254
- autoWidth.current.set(colKey, {
255
- maxColWidth: 0,
256
- width: new Map(),
257
- enabled: true,
258
- adjustement: 0,
259
- maxWidth: w,
260
- isAuto: false,
261
- isUndefined: false
262
- });
263
- else if (((_a = autoWidth.current.get(colKey)) === null || _a === void 0 ? void 0 : _a.maxWidth) == w)
264
- return;
265
- autoWidth.current.get(colKey).maxWidth = w;
266
- //cancel ref
267
- //Add a Timer - runs within 10 ms from when the Timer started to avoid React thinking this is an indinfinte loop....
268
- if (throtleRef.current !== null)
269
- clearTimeout(throtleRef.current);
270
- throtleRef.current = setTimeout(() => {
271
- setAutoWidthVersion((v) => v + 1);
272
- }, 10);
273
- }, []);
274
- return (React.createElement("table", { className: props.TableClass !== undefined ? props.TableClass : 'table table-hover', style: (_a = props.TableStyle) !== null && _a !== void 0 ? _a : defaultTableStyle },
275
- React.createElement(Header, { Class: props.TheadClass, Style: props.TheadStyle, SortKey: props.SortKey, Ascending: props.Ascending, OnSort: handleSort, SetWidth: (k, w, a, u) => setWidth(k, -1, w, a, u), SetMaxWidth: setMaxWidth, SetMinWidth: setMinWidth, AutoWidth: autoWidth, AutoWidthVersion: autoWidthVersion, LastColumn: props.LastColumn, SetAdjustment: setAdjustment, ExtraWidth: extraWidthPerRow }, props.children),
276
- React.createElement(Rows, { DragStart: props.OnDragStart, Data: props.Data, RowStyle: props.RowStyle, BodyStyle: props.TbodyStyle, BodyClass: props.TbodyClass, OnClick: props.OnClick, Selected: props.Selected, KeySelector: props.KeySelector, AutoWidth: autoWidth, AutoWidthVersion: autoWidthVersion, SetWidth: setWidth, ExtraWidth: extraWidthPerRow, BodyRef: bodyRef, BodyScrolled: scrolled }, props.children),
246
+ return (React.createElement("table", { className: props.TableClass !== undefined ? props.TableClass : 'table table-hover', style: tableStyle },
247
+ React.createElement(Header, { Class: props.TheadClass, Style: headStyle, SortKey: props.SortKey, Ascending: props.Ascending, LastColumn: props.LastColumn, OnSort: handleSort, ColWidths: colWidthsRef, Trigger: trigger, TriggerRerender: () => setTrigger(c => c + 1) }, props.children),
248
+ 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),
277
249
  props.LastRow !== undefined ? (React.createElement("tfoot", { style: props.TfootStyle, className: props.TfootClass },
278
250
  React.createElement("tr", { style: props.RowStyle !== undefined ? Object.assign({}, props.RowStyle) : {} }, props.LastRow))) : null));
279
251
  }
280
252
  function Rows(props) {
253
+ const bodyStyle = React.useMemo(() => (Object.assign(Object.assign({}, props.BodyStyle), { paddingRight: (props.BodyScrolled ? 0 : 17), display: "block" })), [props.BodyStyle, props.BodyScrolled]);
281
254
  const onClick = React.useCallback((e, item, index) => {
282
255
  if (props.OnClick !== undefined)
283
256
  props.OnClick({
@@ -288,7 +261,6 @@ function Rows(props) {
288
261
  index: index,
289
262
  }, e);
290
263
  }, [props.OnClick]);
291
- const bodyStyle = React.useMemo(() => (Object.assign(Object.assign({}, props.BodyStyle), { paddingRight: (props.BodyScrolled ? 0 : 17), display: "block" })), [props.BodyStyle, props.BodyScrolled]);
292
264
  return (React.createElement("tbody", { style: bodyStyle, className: props.BodyClass, ref: props.BodyRef }, props.Data.map((d, i) => {
293
265
  const style = props.RowStyle !== undefined ? Object.assign({}, props.RowStyle) : {};
294
266
  if (style.cursor === undefined && (props.OnClick !== undefined || props.DragStart !== undefined))
@@ -297,192 +269,202 @@ function Rows(props) {
297
269
  style.backgroundColor = 'yellow';
298
270
  const key = props.KeySelector(d, i);
299
271
  return (React.createElement("tr", { key: key, style: style, onClick: (e) => onClick(e, d, i) }, React.Children.map(props.children, (element) => {
300
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
272
+ var _a, _b, _c, _d, _e, _f;
301
273
  if (!React.isValidElement(element))
302
274
  return null;
303
- if (element.type === Column_1.default)
304
- if ((_b = (_a = props.AutoWidth.current.get(element.props.Key)) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : true)
305
- return (React.createElement(Column_1.ColumnDataWrapper, { key: element.key, extraWidth: props.ExtraWidth, onClick: (props.OnClick !== undefined && props.OnClick !== null) ? (e) => props.OnClick({
306
- colKey: element.props.Key,
307
- colField: element.props.Field,
308
- row: d,
309
- data: d[element.props.Field],
310
- index: i,
311
- }, e) : undefined, dragStart: (props.DragStart !== undefined && props.DragStart !== null) ? (e) => props.DragStart({
312
- colKey: element.props.Key,
313
- colField: element.props.Field,
314
- row: d,
315
- data: d[element.props.Field],
316
- index: i,
317
- }, e) : undefined, setWidth: (w, a, u) => props.SetWidth(element.props.Key, key, w, a, u), style: element.props.RowStyle, width: ((_d = (_c = props.AutoWidth.current.get(element.props.Key)) === null || _c === void 0 ? void 0 : _c.width.has(key)) !== null && _d !== void 0 ? _d : false)
318
- ? (_e = props.AutoWidth.current.get(element.props.Key)) === null || _e === void 0 ? void 0 : _e.maxColWidth // if not auto <-
319
- : undefined // otherwise get the extrawidth
320
- , enabled: (_g = (_f = props.AutoWidth.current.get(element.props.Key)) === null || _f === void 0 ? void 0 : _f.enabled) !== null && _g !== void 0 ? _g : true }, element.props.Content !== undefined
321
- ? element.props.Content({
322
- item: d,
323
- key: element.props.Key,
324
- field: element.props.Field,
325
- style: style,
326
- index: i,
327
- })
328
- : element.props.Field !== undefined
329
- ? d[element.props.Field]
330
- : null));
331
- if (element.type === AdjustableColumn_1.default)
332
- if ((_j = (_h = props.AutoWidth.current.get(element.props.Key)) === null || _h === void 0 ? void 0 : _h.enabled) !== null && _j !== void 0 ? _j : true)
333
- return (React.createElement(AdjustableColumn_1.AdjustableColumnDataWrapper, { adjustment: (_k = props.AutoWidth.current.get(element.props.Key)) === null || _k === void 0 ? void 0 : _k.adjustement, key: element.key, onClick: (props.OnClick !== undefined && props.OnClick !== null) ? (e) => props.OnClick({
334
- colKey: element.props.Key,
335
- colField: element.props.Field,
336
- row: d,
337
- data: d[element.props.Field],
338
- index: i,
339
- }, e) : undefined, dragStart: (props.DragStart !== undefined && props.DragStart !== null) ? (e) => props.DragStart({
340
- colKey: element.props.Key,
341
- colField: element.props.Field,
342
- row: d,
343
- data: d[element.props.Field],
344
- index: i,
345
- }, e) : undefined, setWidth: (w, a, u) => props.SetWidth(element.props.Key, key, w, a, u), style: element.props.RowStyle, width: ((_m = (_l = props.AutoWidth.current.get(element.props.Key)) === null || _l === void 0 ? void 0 : _l.width.has(key)) !== null && _m !== void 0 ? _m : false)
346
- ? (_o = props.AutoWidth.current.get(element.props.Key)) === null || _o === void 0 ? void 0 : _o.maxColWidth
347
- : undefined, enabled: (_q = (_p = props.AutoWidth.current.get(element.props.Key)) === null || _p === void 0 ? void 0 : _p.enabled) !== null && _q !== void 0 ? _q : true, extraWidth: props.ExtraWidth },
348
- ' ',
349
- element.props.Content !== undefined
350
- ? element.props.Content({
351
- item: d,
352
- key: element.props.Key,
353
- field: element.props.Field,
354
- style: style,
355
- index: i,
356
- })
357
- : element.props.Field !== undefined
358
- ? d[element.props.Field]
359
- : null));
360
- return null;
275
+ if (!IsColumnProps(element.props))
276
+ return null;
277
+ const colWidth = props.ColWidths.current.get(element.props.Key);
278
+ if (colWidth == null || colWidth.width === 0)
279
+ return null;
280
+ let cursor = undefined;
281
+ if (((_b = (_a = element.props) === null || _a === void 0 ? void 0 : _a.RowStyle) === null || _b === void 0 ? void 0 : _b.cursor) != null)
282
+ cursor = element.props.RowStyle.cursor;
283
+ else if ((props === null || props === void 0 ? void 0 : props.OnClick) != null)
284
+ cursor = 'pointer';
285
+ else if ((props === null || props === void 0 ? void 0 : props.DragStart) != null)
286
+ cursor = 'grab';
287
+ 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 });
288
+ return (React.createElement(Column_1.ColumnDataWrapper, { key: element.key, onClick: (props.OnClick != null) ? (e) => {
289
+ var _a, _b;
290
+ return props.OnClick({
291
+ colKey: element.props.Key,
292
+ colField: (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field,
293
+ row: d,
294
+ data: d[(_b = element.props) === null || _b === void 0 ? void 0 : _b.Field],
295
+ index: i,
296
+ }, e);
297
+ } : undefined, dragStart: (props.DragStart != null) ? (e) => {
298
+ var _a, _b;
299
+ return props.DragStart({
300
+ colKey: element.props.Key,
301
+ colField: (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field,
302
+ row: d,
303
+ data: d[(_b = element.props) === null || _b === void 0 ? void 0 : _b.Field],
304
+ index: i,
305
+ }, e);
306
+ } : undefined, style: style }, ((_d = element.props) === null || _d === void 0 ? void 0 : _d.Content) != null
307
+ ? element.props.Content({
308
+ item: d,
309
+ key: element.props.Key,
310
+ field: (_e = element.props) === null || _e === void 0 ? void 0 : _e.Field,
311
+ style: style,
312
+ index: i,
313
+ })
314
+ : ((_f = element.props) === null || _f === void 0 ? void 0 : _f.Field) != null
315
+ ? d[element.props.Field]
316
+ : null));
361
317
  })));
362
318
  })));
363
319
  }
364
320
  function Header(props) {
365
- const trRef = React.useRef(null);
321
+ const headStyle = React.useMemo(() => (Object.assign(Object.assign({}, defaultHeadStyle), props.Style)), [props.Style]);
322
+ // Consts for adjustable columns
366
323
  const [mouseDown, setMouseDown] = React.useState(0);
367
324
  const [currentKeys, setCurrentKeys] = React.useState(undefined);
368
325
  const [deltaW, setDeltaW] = React.useState(0);
369
326
  const [tentativeLimits, setTentativeLimits] = React.useState({ min: -Infinity, max: Infinity });
370
- const calculateDeltaLimits = React.useCallback((mapKeys, autoWidthRef) => {
371
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
372
- if (mapKeys === undefined)
373
- return ({ min: -Infinity, max: Infinity });
374
- const maxLeftAdjustment = ((_b = (_a = autoWidthRef.current.get(mapKeys[0])) === null || _a === void 0 ? void 0 : _a.maxColWidth) !== null && _b !== void 0 ? _b : 0) +
375
- ((_d = (_c = autoWidthRef.current.get(mapKeys[0])) === null || _c === void 0 ? void 0 : _c.adjustement) !== null && _d !== void 0 ? _d : 0);
376
- const minWidthLeftAdjusted = ((_f = (_e = autoWidthRef.current.get(mapKeys[0])) === null || _e === void 0 ? void 0 : _e.minWidth) !== null && _f !== void 0 ? _f : 100) - maxLeftAdjustment;
377
- const maxWidthLeftAdjusted = ((_h = (_g = autoWidthRef.current.get(mapKeys[0])) === null || _g === void 0 ? void 0 : _g.maxWidth) !== null && _h !== void 0 ? _h : 9e10) - maxLeftAdjustment;
378
- const maxRightAdjustment = ((_k = (_j = autoWidthRef.current.get(mapKeys[1])) === null || _j === void 0 ? void 0 : _j.maxColWidth) !== null && _k !== void 0 ? _k : 0) +
379
- ((_m = (_l = autoWidthRef.current.get(mapKeys[1])) === null || _l === void 0 ? void 0 : _l.adjustement) !== null && _m !== void 0 ? _m : 0);
380
- const minWidthRightAdjusted = ((_p = (_o = autoWidthRef.current.get(mapKeys[1])) === null || _o === void 0 ? void 0 : _o.minWidth) !== null && _p !== void 0 ? _p : 100) - maxRightAdjustment;
381
- const maxWidthRightAdjusted = ((_r = (_q = autoWidthRef.current.get(mapKeys[1])) === null || _q === void 0 ? void 0 : _q.maxWidth) !== null && _r !== void 0 ? _r : 9e10) - maxRightAdjustment;
382
- // Recall that a right movement is the result of a negative value on deltaW
383
- const minDeltaW = Math.abs(minWidthLeftAdjusted) < Math.abs(maxWidthRightAdjusted) ? minWidthLeftAdjusted : -maxWidthRightAdjusted;
384
- const maxDeltaW = Math.abs(minWidthRightAdjusted) < Math.abs(maxWidthLeftAdjusted) ? -minWidthRightAdjusted : maxWidthLeftAdjusted;
385
- return ({ min: minDeltaW, max: maxDeltaW });
386
- }, []);
387
- const calculateAdjustment = (key) => {
388
- var _a, _b;
389
- let adj = 0;
390
- let delta;
391
- if (deltaW > tentativeLimits.max)
392
- delta = tentativeLimits.max;
393
- else if (deltaW < tentativeLimits.min)
394
- delta = tentativeLimits.min;
395
- else
396
- delta = deltaW;
397
- if (currentKeys !== undefined && currentKeys[0] == key)
398
- adj = delta;
399
- else if (currentKeys !== undefined && currentKeys[1] == key)
400
- adj = -delta;
401
- return ((_b = (_a = props.AutoWidth.current.get(key)) === null || _a === void 0 ? void 0 : _a.adjustement) !== null && _b !== void 0 ? _b : 0) + adj;
402
- };
403
- const finishAdjustment = () => {
404
- if (currentKeys === undefined)
405
- return;
406
- if (Math.abs(deltaW) > 5) {
407
- const deltaLimits = calculateDeltaLimits(currentKeys, props.AutoWidth);
408
- let delta;
409
- if (deltaW > deltaLimits.max)
410
- delta = deltaLimits.max;
411
- else if (deltaW < deltaLimits.min)
412
- delta = deltaLimits.min;
413
- else
414
- delta = deltaW;
415
- props.SetAdjustment(currentKeys[0], delta);
416
- props.SetAdjustment(currentKeys[1], -delta);
417
- }
418
- setMouseDown(0);
419
- setTentativeLimits({ min: -Infinity, max: Infinity });
420
- setCurrentKeys(undefined);
421
- setDeltaW(0);
422
- };
423
- const getLeftKey = React.useCallback((key) => {
327
+ const getLeftKey = React.useCallback((key, colWidthsRef) => {
424
328
  var _a;
329
+ // Filtering down to shown adjustables only
425
330
  const keys = React.Children.map((_a = props.children) !== null && _a !== void 0 ? _a : [], (element) => {
426
331
  var _a;
427
332
  if (!React.isValidElement(element)) {
428
333
  return null;
429
334
  }
430
- if ((_a = !(props.AutoWidth.current.get(element.props.Key).enabled)) !== null && _a !== void 0 ? _a : true) {
335
+ const keyWidth = (_a = colWidthsRef.current.get(key)) === null || _a === void 0 ? void 0 : _a.width;
336
+ if (keyWidth == null || keyWidth <= 0) {
431
337
  return null;
432
338
  }
433
- if (element.type === AdjustableColumn_1.default) {
339
+ if (element.type === Column_1.AdjustableColumn) {
434
340
  return element.props.Key;
435
341
  }
436
342
  return null;
437
343
  }).filter((item) => item !== null);
438
344
  const index = keys.indexOf(key);
439
- if (index < 1)
345
+ if (index <= 0)
440
346
  return undefined;
441
347
  return keys[index - 1];
442
348
  }, [props.children]);
349
+ const calculateDeltaLimits = React.useCallback((mapKeys, colWidthsRef) => {
350
+ if (mapKeys === undefined)
351
+ return ({ min: -Infinity, max: Infinity });
352
+ const widthObjLeft = colWidthsRef.current.get(mapKeys[0]);
353
+ const widthObjRight = colWidthsRef.current.get(mapKeys[1]);
354
+ if (widthObjLeft == null || widthObjRight == null)
355
+ return ({ min: -Infinity, max: Infinity });
356
+ const limitByShrinkLeft = widthObjLeft.width - widthObjLeft.minWidth;
357
+ const limitByGrowthLeft = widthObjLeft.maxWidth - widthObjLeft.width;
358
+ const limitByShrinkRight = widthObjRight.width - widthObjRight.minWidth;
359
+ const limitByGrowthRight = widthObjRight.maxWidth - widthObjRight.width;
360
+ // Recall that a left movement is a negative deltaW
361
+ const minDeltaW = -(limitByShrinkLeft < limitByGrowthRight ? limitByShrinkLeft : limitByGrowthRight);
362
+ const maxDeltaW = limitByShrinkRight < limitByGrowthLeft ? limitByShrinkRight : limitByGrowthLeft;
363
+ return ({ min: minDeltaW, max: maxDeltaW });
364
+ }, []);
365
+ const getDeltaSign = React.useCallback((index) => {
366
+ // Recall that a left movement is a negative deltaW
367
+ if (index === 0)
368
+ return 1;
369
+ else if (index === 1)
370
+ return -1;
371
+ else
372
+ return 0;
373
+ }, []);
374
+ const finishAdjustment = React.useCallback((adjustment, adjustKeys, colWidthsRef) => {
375
+ const deltaLimits = calculateDeltaLimits(adjustKeys, colWidthsRef);
376
+ let delta;
377
+ if (adjustment > deltaLimits.max)
378
+ delta = deltaLimits.max;
379
+ else if (adjustment < deltaLimits.min)
380
+ delta = deltaLimits.min;
381
+ else
382
+ delta = adjustment;
383
+ if (Math.abs(delta) > 5) {
384
+ const leftWidthObj = colWidthsRef.current.get(adjustKeys[0]);
385
+ const rightWidthObj = colWidthsRef.current.get(adjustKeys[1]);
386
+ if (leftWidthObj == null || rightWidthObj == null) {
387
+ console.error(`Unable to finalize adjustment on keys ${adjustKeys[0]}, ${adjustKeys[1]}`);
388
+ }
389
+ else {
390
+ leftWidthObj.width += (getDeltaSign(0) * delta);
391
+ rightWidthObj.width += (getDeltaSign(1) * delta);
392
+ }
393
+ }
394
+ setMouseDown(0);
395
+ setTentativeLimits({ min: -Infinity, max: Infinity });
396
+ setCurrentKeys(undefined);
397
+ setDeltaW(0);
398
+ }, [calculateDeltaLimits, getDeltaSign]);
443
399
  const onMove = React.useCallback((e) => {
444
400
  if (currentKeys === undefined)
445
401
  return;
446
402
  const w = e.screenX - mouseDown;
447
403
  setDeltaW(w);
448
404
  }, [mouseDown, currentKeys]);
449
- return (React.createElement("thead", { className: props.Class, style: props.Style, onMouseMove: (e) => {
405
+ return (React.createElement("thead", { className: props.Class, style: headStyle, onMouseMove: (e) => {
450
406
  onMove(e.nativeEvent);
451
407
  e.stopPropagation();
452
408
  }, onMouseUp: (e) => {
453
- finishAdjustment();
454
409
  e.stopPropagation();
410
+ if (currentKeys == null)
411
+ return;
412
+ finishAdjustment(deltaW, currentKeys, props.ColWidths);
413
+ props.TriggerRerender();
455
414
  }, onMouseLeave: (e) => {
456
- finishAdjustment();
457
415
  e.stopPropagation();
416
+ if (currentKeys == null)
417
+ return;
418
+ finishAdjustment(deltaW, currentKeys, props.ColWidths);
419
+ props.TriggerRerender();
458
420
  } },
459
- React.createElement("tr", { ref: trRef },
421
+ React.createElement("tr", { style: { width: '100%', display: 'table' } },
460
422
  React.Children.map(props.children, (element) => {
461
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
423
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
462
424
  if (!React.isValidElement(element))
463
425
  return null;
464
- if (element.type === Column_1.default)
465
- if ((_b = (_a = props.AutoWidth.current.get(element.props.Key)) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : true)
466
- return (React.createElement(Column_1.ColumnHeaderWrapper, { enabled: (_d = (_c = props.AutoWidth.current.get(element.props.Key)) === null || _c === void 0 ? void 0 : _c.enabled) !== null && _d !== void 0 ? _d : true, setWidth: (w, a, u) => props.SetWidth(element.props.Key, w, a, u), onSort: (e) => props.OnSort({ colKey: element.props.Key, colField: element.props.Field, ascending: props.Ascending }, e), sorted: props.SortKey === element.props.Key && ((_e = element.props.AllowSort) !== null && _e !== void 0 ? _e : true), asc: props.Ascending, colKey: element.props.Key, key: element.props.Key, allowSort: element.props.AllowSort, width: ((_g = (_f = props.AutoWidth.current.get(element.props.Key)) === null || _f === void 0 ? void 0 : _f.width.has(-1)) !== null && _g !== void 0 ? _g : false)
467
- ? (_h = props.AutoWidth.current.get(element.props.Key)) === null || _h === void 0 ? void 0 : _h.maxColWidth
468
- : undefined, style: (_j = element.props.HeaderStyle) !== null && _j !== void 0 ? _j : element.props.RowStyle, extraWidth: props.ExtraWidth },
469
- ' ', (_k = element.props.children) !== null && _k !== void 0 ? _k : element.props.Key,
470
- ' '));
471
- if (element.type === AdjustableColumn_1.default)
472
- if ((_m = (_l = props.AutoWidth.current.get(element.props.Key)) === null || _l === void 0 ? void 0 : _l.enabled) !== null && _m !== void 0 ? _m : true)
473
- return (React.createElement(AdjustableColumn_1.AdjustableColumnHeaderWrapper, { enabled: (_p = (_o = props.AutoWidth.current.get(element.props.Key)) === null || _o === void 0 ? void 0 : _o.enabled) !== null && _p !== void 0 ? _p : true, setWidth: (w, a, u) => props.SetWidth(element.props.Key, w, a, u), setMinWidth: (w) => props.SetMinWidth(element.props.Key, Math.round(w)), minWidth: (_q = props.AutoWidth.current.get(element.props.Key)) === null || _q === void 0 ? void 0 : _q.minWidth, setMaxWidth: (w) => props.SetMaxWidth(element.props.Key, Math.round(w)), maxWidth: (_r = props.AutoWidth.current.get(element.props.Key)) === null || _r === void 0 ? void 0 : _r.maxWidth, extraWidth: props.ExtraWidth, onSort: (e) => props.OnSort({ colKey: element.props.Key, colField: element.props.Field, ascending: props.Ascending }, e), sorted: props.SortKey === element.props.Key && ((_s = element.props.AllowSort) !== null && _s !== void 0 ? _s : true), key: element.props.Key, colKey: element.props.Key, asc: props.Ascending, allowSort: element.props.AllowSort, width: ((_u = (_t = props.AutoWidth.current.get(element.props.Key)) === null || _t === void 0 ? void 0 : _t.width.has(-1)) !== null && _u !== void 0 ? _u : false)
474
- ? (_v = props.AutoWidth.current.get(element.props.Key)) === null || _v === void 0 ? void 0 : _v.maxColWidth
475
- : undefined, startAdjustment: (e) => {
476
- let newCurrentKeys;
477
- if (getLeftKey(element.props.Key) !== undefined)
478
- newCurrentKeys = [getLeftKey(element.props.Key), element.props.Key];
479
- setCurrentKeys(newCurrentKeys);
480
- setMouseDown(e.screenX);
481
- setTentativeLimits(calculateDeltaLimits(newCurrentKeys, props.AutoWidth));
482
- setDeltaW(0);
483
- }, adjustment: calculateAdjustment(element.props.Key), style: (_w = element.props.HeaderStyle) !== null && _w !== void 0 ? _w : element.props.RowStyle },
484
- ' ', (_x = element.props.children) !== null && _x !== void 0 ? _x : element.props.Key));
485
- return null;
426
+ if (!IsColumnProps(element.props))
427
+ return null;
428
+ const colWidth = props.ColWidths.current.get(element.props.Key);
429
+ if (colWidth == null || colWidth.width === 0)
430
+ return null;
431
+ // Handling temporary width changes due to being in mid-adjustments
432
+ let currentWidth = colWidth.width;
433
+ const keyIndex = (_a = currentKeys === null || currentKeys === void 0 ? void 0 : currentKeys.indexOf(element.props.Key)) !== null && _a !== void 0 ? _a : -1;
434
+ if (keyIndex > -1) {
435
+ let delta;
436
+ if (deltaW > tentativeLimits.max)
437
+ delta = tentativeLimits.max;
438
+ else if (deltaW < tentativeLimits.min)
439
+ delta = tentativeLimits.min;
440
+ else
441
+ delta = deltaW;
442
+ currentWidth += (getDeltaSign(keyIndex) * delta);
443
+ }
444
+ let cursor = undefined;
445
+ if (((_c = (_b = element.props) === null || _b === void 0 ? void 0 : _b.HeaderStyle) === null || _c === void 0 ? void 0 : _c.cursor) != null)
446
+ cursor = element.props.HeaderStyle.cursor;
447
+ else if (((_e = (_d = element.props) === null || _d === void 0 ? void 0 : _d.AllowSort) !== null && _e !== void 0 ? _e : true))
448
+ cursor = 'pointer';
449
+ const style = Object.assign(Object.assign(Object.assign({}, defaultDataHeadStyle), (_f = element.props) === null || _f === void 0 ? void 0 : _f.HeaderStyle), { width: currentWidth, cursor: cursor });
450
+ let startAdjustment;
451
+ if (element.type === Column_1.AdjustableColumn)
452
+ startAdjustment = (e) => {
453
+ const leftKey = getLeftKey(element.props.Key, props.ColWidths);
454
+ if (leftKey != null) {
455
+ const newCurrentKeys = [leftKey, element.props.Key];
456
+ setCurrentKeys(newCurrentKeys);
457
+ setMouseDown(e.screenX);
458
+ setTentativeLimits(calculateDeltaLimits(newCurrentKeys, props.ColWidths));
459
+ setDeltaW(0);
460
+ }
461
+ };
462
+ return (React.createElement(Column_1.ColumnHeaderWrapper, { onSort: (e) => {
463
+ var _a;
464
+ return props.OnSort({ colKey: element.props.Key, colField: (_a = element.props) === null || _a === void 0 ? void 0 : _a.Field, ascending: props.Ascending }, e);
465
+ }, 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 },
466
+ ' ', (_k = element.props.children) !== null && _k !== void 0 ? _k : element.props.Key,
467
+ ' '));
486
468
  }),
487
- React.createElement("th", { style: { width: 17, padding: 0 } }, props.LastColumn))));
469
+ React.createElement("th", { style: { width: 17, padding: 0, maxWidth: 17 } }, props.LastColumn))));
488
470
  }