@commercetools-uikit/data-table 15.15.0 → 15.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commercetools-uikit-data-table.cjs.d.ts +1 -0
- package/dist/commercetools-uikit-data-table.cjs.d.ts.map +1 -0
- package/dist/commercetools-uikit-data-table.cjs.dev.js +190 -277
- package/dist/commercetools-uikit-data-table.cjs.prod.js +190 -277
- package/dist/commercetools-uikit-data-table.esm.js +189 -276
- package/package.json +7 -7
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
-
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
7
6
|
require('prop-types');
|
|
8
7
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
9
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
10
8
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
11
9
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
12
10
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
@@ -30,11 +28,11 @@ var _Number$isNaN = require('@babel/runtime-corejs3/core-js-stable/number/is-nan
|
|
|
30
28
|
var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
|
|
31
29
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
32
30
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
31
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
33
32
|
|
|
34
33
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
35
34
|
|
|
36
35
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
37
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
38
36
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
39
37
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
40
38
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
@@ -50,8 +48,9 @@ var AccessibleButton__default = /*#__PURE__*/_interopDefault(AccessibleButton);
|
|
|
50
48
|
var _Number$isNaN__default = /*#__PURE__*/_interopDefault(_Number$isNaN);
|
|
51
49
|
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
52
50
|
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
51
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
const getPaddingStyle = props => {
|
|
55
54
|
if (props.isCondensed) return /*#__PURE__*/react.css("padding:", designSystem.designTokens.paddingForTableCellAsCondensed, ";" + ("" ), "" );
|
|
56
55
|
return /*#__PURE__*/react.css("padding:", designSystem.designTokens.paddingForTableCell, ";" + ("" ), "" );
|
|
57
56
|
};
|
|
@@ -71,7 +70,7 @@ var _ref10 = {
|
|
|
71
70
|
styles: "text-align:center;justify-self:center"
|
|
72
71
|
} ;
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
const getHorizontalAlignmentStyle = props => {
|
|
75
74
|
if (props.horizontalCellAlignment === 'center') {
|
|
76
75
|
return _ref10;
|
|
77
76
|
}
|
|
@@ -98,7 +97,7 @@ var _ref7 = {
|
|
|
98
97
|
styles: "align-self:center"
|
|
99
98
|
} ;
|
|
100
99
|
|
|
101
|
-
|
|
100
|
+
const getVerticalAlignmentStyle = props => {
|
|
102
101
|
if (props.verticalCellAlignment === 'center') {
|
|
103
102
|
return _ref7;
|
|
104
103
|
}
|
|
@@ -115,7 +114,7 @@ var _ref4 = {
|
|
|
115
114
|
styles: "overflow:hidden;white-space:nowrap;text-overflow:ellipsis"
|
|
116
115
|
} ;
|
|
117
116
|
|
|
118
|
-
|
|
117
|
+
const getTruncatedStyle = props => {
|
|
119
118
|
if (props.isTruncated) {
|
|
120
119
|
return _ref4;
|
|
121
120
|
}
|
|
@@ -126,12 +125,12 @@ var getTruncatedStyle = function getTruncatedStyle(props) {
|
|
|
126
125
|
so we have to set them manually. */
|
|
127
126
|
|
|
128
127
|
|
|
129
|
-
|
|
128
|
+
const outlineStyles = {
|
|
130
129
|
name: "1oudntj",
|
|
131
130
|
styles: "outline-offset:-3px;:not(:focus):focus-within{outline-style:auto;outline-color:Highlight;outline-color:activeborder;outline-color:-moz-mac-focusring;outline-color:-webkit-focus-ring-color;}"
|
|
132
131
|
} ;
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
const getCellInnerStyles = props => {
|
|
135
134
|
return [getVerticalAlignmentStyle(props), getHorizontalAlignmentStyle(props), getTruncatedStyle(props), outlineStyles];
|
|
136
135
|
};
|
|
137
136
|
/**
|
|
@@ -146,11 +145,9 @@ var _ref3 = {
|
|
|
146
145
|
styles: "overflow:hidden"
|
|
147
146
|
} ;
|
|
148
147
|
|
|
149
|
-
|
|
148
|
+
const CellInner = /*#__PURE__*/_styled__default["default"]("div", {
|
|
150
149
|
target: "e10u1n7e3"
|
|
151
|
-
} )("box-sizing:border-box;flex:1;", getPaddingStyle, " ", getCellInnerStyles, " ",
|
|
152
|
-
return props.shouldClipContent ? _ref3 : '';
|
|
153
|
-
}, ";" + ("" ));
|
|
150
|
+
} )("box-sizing:border-box;flex:1;", getPaddingStyle, " ", getCellInnerStyles, " ", props => props.shouldClipContent ? _ref3 : '', ";" + ("" ));
|
|
154
151
|
|
|
155
152
|
var _ref$1 = {
|
|
156
153
|
name: "1a5erbp",
|
|
@@ -162,37 +159,23 @@ var _ref2 = {
|
|
|
162
159
|
styles: "overflow:hidden"
|
|
163
160
|
} ;
|
|
164
161
|
|
|
165
|
-
|
|
162
|
+
const BaseCell = /*#__PURE__*/_styled__default["default"]("td", {
|
|
166
163
|
target: "e10u1n7e2"
|
|
167
|
-
} )("position:relative;display:flex;background-color:", designSystem.designTokens.colorSurface, ";border-bottom:",
|
|
168
|
-
return props.shouldRenderBottomBorder ? "1px solid ".concat(designSystem.designTokens.colorNeutral90, ";") : 'none';
|
|
169
|
-
}, ";font-size:", designSystem.designTokens.fontSizeForTable, ";", function (props) {
|
|
170
|
-
return props.shouldClipContent ? _ref2 : '';
|
|
171
|
-
}, " ", function (props) {
|
|
172
|
-
return props.shouldIgnoreRowClick ? _ref$1 : '';
|
|
173
|
-
}, ";" + ("" ));
|
|
164
|
+
} )("position:relative;display:flex;background-color:", designSystem.designTokens.colorSurface, ";border-bottom:", props => props.shouldRenderBottomBorder ? "1px solid ".concat(designSystem.designTokens.colorNeutral90, ";") : 'none', ";font-size:", designSystem.designTokens.fontSizeForTable, ";", props => props.shouldClipContent ? _ref2 : '', " ", props => props.shouldIgnoreRowClick ? _ref$1 : '', ";" + ("" ));
|
|
174
165
|
|
|
175
166
|
/*#__PURE__*/_styled__default["default"]("td", {
|
|
176
167
|
target: "e10u1n7e1"
|
|
177
|
-
} )("position:",
|
|
178
|
-
return props.disableFooterStickiness ? 'relative' : 'sticky';
|
|
179
|
-
}, ";left:0;bottom:0;grid-column:1/", function (props) {
|
|
180
|
-
return props.numberOfColumns;
|
|
181
|
-
}, ";background-color:", designSystem.designTokens.colorSurface, ";border-bottom:1px solid ", designSystem.designTokens.colorNeutral90, ";border-top:1px solid ", designSystem.designTokens.colorNeutral90, ";margin-top:-1px;" + ("" ));
|
|
168
|
+
} )("position:", props => props.disableFooterStickiness ? 'relative' : 'sticky', ";left:0;bottom:0;grid-column:1/", props => props.numberOfColumns, ";background-color:", designSystem.designTokens.colorSurface, ";border-bottom:1px solid ", designSystem.designTokens.colorNeutral90, ";border-top:1px solid ", designSystem.designTokens.colorNeutral90, ";margin-top:-1px;" + ("" ));
|
|
182
169
|
|
|
183
|
-
|
|
170
|
+
const RowExpandCollapseButton = /*#__PURE__*/_styled__default["default"](AccessibleButton__default["default"], {
|
|
184
171
|
target: "e10u1n7e0"
|
|
185
|
-
} )("cursor:",
|
|
186
|
-
return props.isRowCollapsed ? /*#__PURE__*/react.css("" , "" ) : /*#__PURE__*/react.css("" , "" );
|
|
187
|
-
}, ";position:absolute;height:16px;width:16px;bottom:0;right:0;opacity:0;display:flex;justify-content:flex-end;align-items:flex-end;" + ("" ));
|
|
172
|
+
} )("cursor:", props => props.isRowCollapsed ? /*#__PURE__*/react.css("" , "" ) : /*#__PURE__*/react.css("" , "" ), ";position:absolute;height:16px;width:16px;bottom:0;right:0;opacity:0;display:flex;justify-content:flex-end;align-items:flex-end;" + ("" ));
|
|
188
173
|
|
|
189
|
-
|
|
190
|
-
return typeof dimensionValue === 'number' ? "".concat(dimensionValue, "px") : dimensionValue;
|
|
191
|
-
};
|
|
174
|
+
const convertNumericDimensionToPixelValue = dimensionValue => typeof dimensionValue === 'number' ? "".concat(dimensionValue, "px") : dimensionValue;
|
|
192
175
|
|
|
193
176
|
var convertNumericDimensionToPixelValue$1 = convertNumericDimensionToPixelValue;
|
|
194
177
|
|
|
195
|
-
|
|
178
|
+
const getClickableRowStyle = props => {
|
|
196
179
|
if (props.isRowClickable) {
|
|
197
180
|
return /*#__PURE__*/react.css("cursor:pointer;&:hover td{background:", designSystem.designTokens.backgroundColorForTableCellWhenHovered, ";}" + ("" ), "" );
|
|
198
181
|
}
|
|
@@ -205,7 +188,7 @@ var _ref = {
|
|
|
205
188
|
styles: "position:unset;overflow-x:unset;overflow-y:unset"
|
|
206
189
|
} ;
|
|
207
190
|
|
|
208
|
-
|
|
191
|
+
const getDisabledSelfContainmentStyles = props => {
|
|
209
192
|
if (props.disableSelfContainment) {
|
|
210
193
|
return _ref;
|
|
211
194
|
}
|
|
@@ -213,63 +196,49 @@ var getDisabledSelfContainmentStyles = function getDisabledSelfContainmentStyles
|
|
|
213
196
|
return '';
|
|
214
197
|
};
|
|
215
198
|
|
|
216
|
-
|
|
199
|
+
const TableContainer = /*#__PURE__*/_styled__default["default"]("div", {
|
|
217
200
|
target: "epk01s24"
|
|
218
|
-
} )("position:relative;z-index:0;overflow-x:auto;",
|
|
219
|
-
return props.maxWidth && !props.disableSelfContainment ? "max-width: ".concat(convertNumericDimensionToPixelValue$1(props.maxWidth), ";") : '';
|
|
220
|
-
}, " ", function (props) {
|
|
221
|
-
return props.isBeingResized && "\n * {\n user-select: none;\n }";
|
|
222
|
-
}, " ", getDisabledSelfContainmentStyles, ";" + ("" ));
|
|
201
|
+
} )("position:relative;z-index:0;overflow-x:auto;", props => props.maxWidth && !props.disableSelfContainment ? "max-width: ".concat(convertNumericDimensionToPixelValue$1(props.maxWidth), ";") : '', " ", props => props.isBeingResized && "\n * {\n user-select: none;\n }", " ", getDisabledSelfContainmentStyles, ";" + ("" ));
|
|
223
202
|
|
|
224
|
-
|
|
203
|
+
const TableGrid = /*#__PURE__*/_styled__default["default"]("table", {
|
|
225
204
|
target: "epk01s23"
|
|
226
|
-
} )("display:grid;grid-template-columns:",
|
|
205
|
+
} )("display:grid;grid-template-columns:", props => {
|
|
227
206
|
var _context;
|
|
228
207
|
|
|
229
|
-
return props.columns && _mapInstanceProperty__default["default"](_context = props.columns).call(_context,
|
|
230
|
-
|
|
231
|
-
}).join(' ');
|
|
232
|
-
}, ";overflow-y:auto;", function (props) {
|
|
233
|
-
return props.maxHeight && !props.disableSelfContainment ? "max-height: ".concat(convertNumericDimensionToPixelValue$1(props.maxHeight), ";") : '';
|
|
234
|
-
}, " ", function (props) {
|
|
235
|
-
return props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '';
|
|
236
|
-
}, " ", getDisabledSelfContainmentStyles, ";" + ("" ));
|
|
208
|
+
return props.columns && _mapInstanceProperty__default["default"](_context = props.columns).call(_context, column => column.width || 'auto').join(' ');
|
|
209
|
+
}, ";overflow-y:auto;", props => props.maxHeight && !props.disableSelfContainment ? "max-height: ".concat(convertNumericDimensionToPixelValue$1(props.maxHeight), ";") : '', " ", props => props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '', " ", getDisabledSelfContainmentStyles, ";" + ("" ));
|
|
237
210
|
|
|
238
|
-
|
|
211
|
+
const TableHeader = /*#__PURE__*/_styled__default["default"]("thead", {
|
|
239
212
|
target: "epk01s22"
|
|
240
213
|
} )({
|
|
241
214
|
name: "49aokf",
|
|
242
215
|
styles: "display:contents"
|
|
243
216
|
} );
|
|
244
217
|
|
|
245
|
-
|
|
218
|
+
const TableBody = /*#__PURE__*/_styled__default["default"]("tbody", {
|
|
246
219
|
target: "epk01s21"
|
|
247
220
|
} )({
|
|
248
221
|
name: "49aokf",
|
|
249
222
|
styles: "display:contents"
|
|
250
223
|
} );
|
|
251
224
|
|
|
252
|
-
|
|
225
|
+
const TableRow = /*#__PURE__*/_styled__default["default"]("tr", {
|
|
253
226
|
target: "epk01s20"
|
|
254
227
|
} )("display:contents;", getClickableRowStyle, " :hover,:focus-within{", RowExpandCollapseButton, "{opacity:1;}}" + ("" ));
|
|
255
228
|
|
|
256
|
-
|
|
229
|
+
const defaultProps$4 = {
|
|
257
230
|
horizontalCellAlignment: 'left'
|
|
258
231
|
};
|
|
259
232
|
|
|
260
|
-
|
|
233
|
+
const Footer = /*#__PURE__*/_styled__default["default"]("div", {
|
|
261
234
|
target: "e2ce7vj0"
|
|
262
|
-
} )("box-sizing:border-box;display:block;", getPaddingStyle, " ", getHorizontalAlignmentStyle, " background-color:", designSystem.designTokens.colorSurface, ";border-top:1px solid ", designSystem.designTokens.colorNeutral90, ";border-bottom:1px solid ", designSystem.designTokens.colorNeutral90, ";",
|
|
263
|
-
return props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '';
|
|
264
|
-
}, ";" + ("" ));
|
|
235
|
+
} )("box-sizing:border-box;display:block;", getPaddingStyle, " ", getHorizontalAlignmentStyle, " background-color:", designSystem.designTokens.colorSurface, ";border-top:1px solid ", designSystem.designTokens.colorNeutral90, ";border-bottom:1px solid ", designSystem.designTokens.colorNeutral90, ";", props => props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '', ";" + ("" ));
|
|
265
236
|
|
|
266
237
|
Footer.displayName = 'Footer';
|
|
267
238
|
Footer.defaultProps = defaultProps$4;
|
|
268
239
|
var Footer$1 = Footer;
|
|
269
240
|
|
|
270
|
-
|
|
271
|
-
return /*#__PURE__*/react.css("cursor:pointer;border:none;background:none;text-decoration:none;color:inherit;font:inherit;font-size:", designSystem.designTokens.fontSizeForTable, ";font-family:inherit;" + ("" ), "" );
|
|
272
|
-
};
|
|
241
|
+
const getButtonStyle = () => /*#__PURE__*/react.css("cursor:pointer;border:none;background:none;text-decoration:none;color:inherit;font:inherit;font-size:", designSystem.designTokens.fontSizeForTable, ";font-family:inherit;" + ("" ), "" );
|
|
273
242
|
/* A sortable header has the two arrow svg icons
|
|
274
243
|
* GIVEN column is sortable and is not focused
|
|
275
244
|
* THEN AngleUpDown icon is shown (default behaviour)
|
|
@@ -281,60 +250,40 @@ var getButtonStyle = function getButtonStyle() {
|
|
|
281
250
|
*/
|
|
282
251
|
|
|
283
252
|
|
|
284
|
-
|
|
285
|
-
return /*#__PURE__*/react.css("width:100%;display:flex;align-items:center;svg[data-icon-state='inactive'],svg[data-icon-state='active']{margin-left:", designSystem.designTokens.spacing20, ";flex-shrink:0;}svg[data-icon-state='inactive']{display:", props.isActive ? 'none' : 'inline-block', ";}svg[data-icon-state='active']{display:", props.isActive ? 'inline-block' : 'none', ";}>svg *{fill:", designSystem.designTokens.fontColorForTableHeader, "!important;}:hover,:focus{svg[data-icon-state='inactive']{display:none;}svg[data-icon-state='active']{display:inline-block;}}" + ("" ), "" );
|
|
286
|
-
};
|
|
253
|
+
const getSortableHeaderStyles = props => /*#__PURE__*/react.css("width:100%;display:flex;align-items:center;svg[data-icon-state='inactive'],svg[data-icon-state='active']{margin-left:", designSystem.designTokens.spacing20, ";flex-shrink:0;}svg[data-icon-state='inactive']{display:", props.isActive ? 'none' : 'inline-block', ";}svg[data-icon-state='active']{display:", props.isActive ? 'inline-block' : 'none', ";}>svg *{fill:", designSystem.designTokens.fontColorForTableHeader, "!important;}:hover,:focus{svg[data-icon-state='inactive']{display:none;}svg[data-icon-state='active']{display:inline-block;}}" + ("" ), "" );
|
|
287
254
|
|
|
288
|
-
|
|
255
|
+
const HeaderCellInner = /*#__PURE__*/_styled__default["default"]("div", {
|
|
289
256
|
target: "e1ipt8n23"
|
|
290
|
-
} )("box-sizing:border-box;display:flex;justify-content:space-between;padding:0 ",
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
return props.isSortable ? getSortableHeaderStyles(props) : '';
|
|
294
|
-
}, ";", function (props) {
|
|
295
|
-
return props.as === 'button' ? getButtonStyle() : '';
|
|
296
|
-
}, ";", function (props) {
|
|
297
|
-
return props.shouldWrap ? '' : 'white-space: nowrap';
|
|
298
|
-
}, ";" + ("" ));
|
|
299
|
-
|
|
300
|
-
var BaseHeaderCell = /*#__PURE__*/_styled__default["default"]("th", {
|
|
257
|
+
} )("box-sizing:border-box;display:flex;justify-content:space-between;padding:0 ", props => props.isCondensed ? designSystem.designTokens.paddingForTableHeaderAsCondensed : designSystem.designTokens.paddingForTableHeader, ";", getCellInnerStyles, " ", props => props.isSortable ? getSortableHeaderStyles(props) : '', ";", props => props.as === 'button' ? getButtonStyle() : '', ";", props => props.shouldWrap ? '' : 'white-space: nowrap', ";" + ("" ));
|
|
258
|
+
|
|
259
|
+
const BaseHeaderCell = /*#__PURE__*/_styled__default["default"]("th", {
|
|
301
260
|
target: "e1ipt8n22"
|
|
302
|
-
} )("color:", designSystem.designTokens.fontColorForTableHeader, ";background-color:", designSystem.designTokens.backgroundColorForTableHeader, ";position:",
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return !props.isNewTheme && ":before {\n content: '';\n position: absolute;\n z-index: -1;\n width: 100%;\n height: 1px;\n bottom: 0;\n left: 0;\n background-color: ".concat(designSystem.designTokens.borderColorForTableHeaderAsBottom, ";\n };");
|
|
306
|
-
}, " ", HeaderCellInner, "{", function (props) {
|
|
307
|
-
return props.shouldClipContent ? 'overflow: hidden;' : '';
|
|
308
|
-
}, ";}" + ("" ));
|
|
309
|
-
|
|
310
|
-
var HeaderLabelWrapper = /*#__PURE__*/_styled__default["default"]("div", {
|
|
261
|
+
} )("color:", designSystem.designTokens.fontColorForTableHeader, ";background-color:", designSystem.designTokens.backgroundColorForTableHeader, ";position:", props => props.disableHeaderStickiness ? 'relative' : 'sticky', ";top:0;z-index:1;line-height:", designSystem.designTokens.lineHeightForTableHeader, ";padding:0;font-weight:", designSystem.designTokens.fontWeightForTableHeader, ";font-size:", designSystem.designTokens.fontSizeForTable, ";box-shadow:inset -1px 0 ", designSystem.designTokens.borderColorForTableHeader, ";:hover,:active{z-index:2;}", props => !props.isNewTheme && ":before {\n content: '';\n position: absolute;\n z-index: -1;\n width: 100%;\n height: 1px;\n bottom: 0;\n left: 0;\n background-color: ".concat(designSystem.designTokens.borderColorForTableHeaderAsBottom, ";\n };"), " ", HeaderCellInner, "{", props => props.shouldClipContent ? 'overflow: hidden;' : '', ";}" + ("" ));
|
|
262
|
+
|
|
263
|
+
const HeaderLabelWrapper = /*#__PURE__*/_styled__default["default"]("div", {
|
|
311
264
|
target: "e1ipt8n21"
|
|
312
265
|
} )("min-height:1.4em;margin:", designSystem.designTokens.marginForTableHeader, " 0;flex:1;" + ("" ));
|
|
313
266
|
|
|
314
|
-
|
|
267
|
+
const HeaderIconWrapper = /*#__PURE__*/_styled__default["default"]("div", {
|
|
315
268
|
target: "e1ipt8n20"
|
|
316
269
|
} )("display:inline-flex;align-items:center;justify-content:center;margin-left:", designSystem.designTokens.spacing20, ";vertical-align:middle;" + ("" ));
|
|
317
270
|
|
|
318
|
-
|
|
271
|
+
const ResizerIndicator = /*#__PURE__*/_styled__default["default"]("div", {
|
|
319
272
|
target: "e1ccic7f1"
|
|
320
|
-
} )("height:100%;width:3px;background:", designSystem.designTokens.colorInfo, ";visibility:hidden;cursor:col-resize;",
|
|
321
|
-
)
|
|
322
|
-
return props.isOnDataCell ? 'visibility: visible; height: calc(100% + 1px);' : '';
|
|
323
|
-
}, ";" + ("" ));
|
|
273
|
+
} )("height:100%;width:3px;background:", designSystem.designTokens.colorInfo, ";visibility:hidden;cursor:col-resize;", (props // extra 1px of height to appear above the bottom horizontal row border
|
|
274
|
+
) => props.isOnDataCell ? 'visibility: visible; height: calc(100% + 1px);' : '', ";" + ("" ));
|
|
324
275
|
|
|
325
|
-
|
|
276
|
+
const DraggableArea = /*#__PURE__*/_styled__default["default"]("div", {
|
|
326
277
|
target: "e1ccic7f0"
|
|
327
278
|
} )("display:flex;justify-content:flex-end;height:100%;position:absolute;top:0;right:0;width:6px;cursor:col-resize;user-select:none;&:hover ", ResizerIndicator, "{height:100%;visibility:visible;}&:active{width:20px;right:-10px;", ResizerIndicator, "{margin-right:10px;visibility:visible;}}" + ("" ));
|
|
328
279
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
});
|
|
337
|
-
};
|
|
280
|
+
const ColumnResizer = props => jsxRuntime.jsx(DraggableArea, {
|
|
281
|
+
role: "presentation",
|
|
282
|
+
onMouseDown: props.onMouseDown,
|
|
283
|
+
children: jsxRuntime.jsx(ResizerIndicator, {
|
|
284
|
+
isOnDataCell: props.isOnDataCell
|
|
285
|
+
})
|
|
286
|
+
});
|
|
338
287
|
|
|
339
288
|
ColumnResizer.propTypes = {};
|
|
340
289
|
ColumnResizer.displayName = 'ColumnResizer';
|
|
@@ -342,7 +291,7 @@ var Resizer = ColumnResizer;
|
|
|
342
291
|
|
|
343
292
|
var ColumnResizingContext = /*#__PURE__*/react$1.createContext({});
|
|
344
293
|
|
|
345
|
-
|
|
294
|
+
const isFixedWidthValue = value => {
|
|
346
295
|
return !_Number$isNaN__default["default"](_parseInt__default["default"](String(value), 10));
|
|
347
296
|
};
|
|
348
297
|
|
|
@@ -352,27 +301,27 @@ function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default["d
|
|
|
352
301
|
|
|
353
302
|
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$3(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
354
303
|
|
|
355
|
-
|
|
304
|
+
const HeaderCellWrapper = props => {
|
|
356
305
|
var _headerRef$current2;
|
|
357
306
|
|
|
358
|
-
|
|
359
|
-
|
|
307
|
+
const _useTheme = designSystem.useTheme(),
|
|
308
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
360
309
|
|
|
361
|
-
|
|
362
|
-
|
|
310
|
+
const columnResizingReducer = react$1.useContext(ColumnResizingContext);
|
|
311
|
+
const headerRef = react$1.useRef(null);
|
|
363
312
|
|
|
364
|
-
|
|
313
|
+
const onStartResizing = event => {
|
|
365
314
|
columnResizingReducer.startResizing(headerRef, event);
|
|
366
315
|
};
|
|
367
316
|
|
|
368
|
-
|
|
317
|
+
const onDrag = event => {
|
|
369
318
|
var _headerRef$current;
|
|
370
319
|
|
|
371
320
|
return columnResizingReducer.onDragResizing(event, (_headerRef$current = headerRef.current) === null || _headerRef$current === void 0 ? void 0 : _headerRef$current.cellIndex);
|
|
372
321
|
};
|
|
373
322
|
|
|
374
|
-
|
|
375
|
-
|
|
323
|
+
const onDragEnd = () => {
|
|
324
|
+
const finalSizes = columnResizingReducer.finishResizing();
|
|
376
325
|
|
|
377
326
|
if (props.onColumnResized) {
|
|
378
327
|
props.onColumnResized(finalSizes);
|
|
@@ -393,7 +342,7 @@ var HeaderCellWrapper = function HeaderCellWrapper(props) {
|
|
|
393
342
|
*/
|
|
394
343
|
|
|
395
344
|
|
|
396
|
-
|
|
345
|
+
const shouldClipContent = props.columnWidth && isFixedWidthValue$1(props.columnWidth) || columnResizingReducer.getHasTableBeenResized() || columnResizingReducer.getIsAnyColumnBeingResized();
|
|
397
346
|
return jsxRuntime.jsxs(BaseHeaderCell, {
|
|
398
347
|
ref: headerRef,
|
|
399
348
|
"data-testid": "header-".concat(props.columnKey),
|
|
@@ -408,27 +357,25 @@ var HeaderCellWrapper = function HeaderCellWrapper(props) {
|
|
|
408
357
|
};
|
|
409
358
|
|
|
410
359
|
HeaderCellWrapper.displayName = 'HeaderCellWrapper';
|
|
411
|
-
|
|
360
|
+
const defaultProps$3 = {
|
|
412
361
|
sortDirection: 'desc',
|
|
413
362
|
disableHeaderStickiness: false,
|
|
414
363
|
horizontalCellAlignment: 'left'
|
|
415
364
|
};
|
|
416
365
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
366
|
+
const HeaderCell = props => {
|
|
367
|
+
let sortableHeaderProps = {};
|
|
368
|
+
let SortingIcon;
|
|
420
369
|
|
|
421
370
|
if (props.isSortable) {
|
|
422
|
-
|
|
423
|
-
|
|
371
|
+
const isActive = props.sortedBy === props.columnKey;
|
|
372
|
+
const nextSortDirection = !isActive || props.sortDirection === 'desc' ? 'asc' : 'desc';
|
|
424
373
|
SortingIcon = props.sortDirection === 'desc' ? icons.AngleDownIcon : icons.AngleUpIcon;
|
|
425
374
|
sortableHeaderProps = {
|
|
426
375
|
as: 'button',
|
|
427
376
|
label: props.sortDirection,
|
|
428
|
-
onClick:
|
|
429
|
-
|
|
430
|
-
},
|
|
431
|
-
isActive: isActive,
|
|
377
|
+
onClick: () => props.onClick && props.onClick(props.columnKey, nextSortDirection),
|
|
378
|
+
isActive,
|
|
432
379
|
isSortable: true
|
|
433
380
|
};
|
|
434
381
|
}
|
|
@@ -471,15 +418,15 @@ var HeaderCell$1 = HeaderCell;
|
|
|
471
418
|
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
472
419
|
|
|
473
420
|
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
474
|
-
|
|
421
|
+
const defaultProps$2 = {
|
|
475
422
|
isTruncated: false,
|
|
476
423
|
shouldRenderBottomBorder: true
|
|
477
424
|
};
|
|
478
425
|
|
|
479
|
-
|
|
426
|
+
const DataCell = props => {
|
|
480
427
|
if (props.shouldRenderCollapseButton) ;
|
|
481
428
|
|
|
482
|
-
|
|
429
|
+
const Icon = props.isRowCollapsed ? icons.RightTriangleFilledIcon : icons.RightTriangleLinearIcon;
|
|
483
430
|
return jsxRuntime.jsxs(BaseCell, {
|
|
484
431
|
onClick: props.onCellClick,
|
|
485
432
|
shouldIgnoreRowClick: props.shouldIgnoreRowClick,
|
|
@@ -494,7 +441,7 @@ var DataCell = function DataCell(props) {
|
|
|
494
441
|
children: props.children
|
|
495
442
|
})), props.shouldRenderCollapseButton && jsxRuntime.jsx(RowExpandCollapseButton, {
|
|
496
443
|
label: "Expand/Collapse Row",
|
|
497
|
-
onClick:
|
|
444
|
+
onClick: event => {
|
|
498
445
|
if (props.handleRowCollapseClick) props.handleRowCollapseClick();
|
|
499
446
|
event.stopPropagation();
|
|
500
447
|
},
|
|
@@ -513,12 +460,12 @@ DataCell.displayName = 'DataCell';
|
|
|
513
460
|
DataCell.defaultProps = defaultProps$2;
|
|
514
461
|
var DataCell$1 = DataCell;
|
|
515
462
|
|
|
516
|
-
|
|
463
|
+
const defaultItemRenderer = (row, column) => {
|
|
517
464
|
// @ts-ignore
|
|
518
465
|
return row[column.key];
|
|
519
466
|
};
|
|
520
467
|
|
|
521
|
-
|
|
468
|
+
const defaultProps$1 = {
|
|
522
469
|
isCondensed: false,
|
|
523
470
|
shouldClipContent: false,
|
|
524
471
|
verticalCellAlignment: 'top',
|
|
@@ -527,27 +474,25 @@ var defaultProps$1 = {
|
|
|
527
474
|
itemRenderer: defaultItemRenderer
|
|
528
475
|
};
|
|
529
476
|
|
|
530
|
-
|
|
477
|
+
const DataRow = props => {
|
|
531
478
|
var _context, _context2;
|
|
532
479
|
|
|
533
|
-
|
|
534
|
-
|
|
480
|
+
const _ref = react$1.useContext(ColumnResizingContext),
|
|
481
|
+
getIsColumnBeingResized = _ref.getIsColumnBeingResized;
|
|
535
482
|
|
|
536
|
-
|
|
537
|
-
return column.isTruncated;
|
|
538
|
-
});
|
|
483
|
+
const rowHasTruncatedColumn = _someInstanceProperty__default["default"](_context = props.columns).call(_context, column => column.isTruncated);
|
|
539
484
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
485
|
+
const _useState = react$1.useState(rowHasTruncatedColumn),
|
|
486
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
487
|
+
isRowCollapsed = _useState2[0],
|
|
488
|
+
collapseRow = _useState2[1];
|
|
544
489
|
|
|
545
|
-
|
|
490
|
+
const handleRowCollapseClick = () => {
|
|
546
491
|
collapseRow(!isRowCollapsed);
|
|
547
492
|
}; // update the collapsed state if isTruncated options are changed for the whole row
|
|
548
493
|
|
|
549
494
|
|
|
550
|
-
react$1.useEffect(
|
|
495
|
+
react$1.useEffect(() => {
|
|
551
496
|
if (rowHasTruncatedColumn) {
|
|
552
497
|
collapseRow(true);
|
|
553
498
|
} else {
|
|
@@ -555,13 +500,11 @@ var DataRow = function DataRow(props) {
|
|
|
555
500
|
}
|
|
556
501
|
}, [rowHasTruncatedColumn]);
|
|
557
502
|
|
|
558
|
-
|
|
559
|
-
return rowHasTruncatedColumn && totalColumnsLength - 1 === currentColumnIndex;
|
|
560
|
-
};
|
|
503
|
+
const shouldRenderCollapseButton = (totalColumnsLength, currentColumnIndex) => rowHasTruncatedColumn && totalColumnsLength - 1 === currentColumnIndex;
|
|
561
504
|
|
|
562
505
|
return jsxRuntime.jsx(TableRow, {
|
|
563
506
|
isRowClickable: Boolean(props.onRowClick),
|
|
564
|
-
children: _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2,
|
|
507
|
+
children: _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, (column, columnIndex) => {
|
|
565
508
|
var _context3, _context4;
|
|
566
509
|
|
|
567
510
|
return jsxRuntime.jsx(DataCell$1, {
|
|
@@ -574,7 +517,7 @@ var DataRow = function DataRow(props) {
|
|
|
574
517
|
shouldIgnoreRowClick: column.shouldIgnoreRowClick,
|
|
575
518
|
handleRowCollapseClick: handleRowCollapseClick,
|
|
576
519
|
shouldRenderCollapseButton: shouldRenderCollapseButton(props.columns.length, columnIndex),
|
|
577
|
-
onCellClick: props.onRowClick && !column.shouldIgnoreRowClick ?
|
|
520
|
+
onCellClick: props.onRowClick && !column.shouldIgnoreRowClick ? () => {
|
|
578
521
|
var _props$onRowClick;
|
|
579
522
|
|
|
580
523
|
return (_props$onRowClick = props.onRowClick) === null || _props$onRowClick === void 0 ? void 0 : _props$onRowClick.call(props, props.row, props.rowIndex, column.key);
|
|
@@ -595,21 +538,21 @@ var DataRow$1 = DataRow;
|
|
|
595
538
|
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
596
539
|
|
|
597
540
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$1(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
541
|
+
const MINIMUM_COLUMN_SIZE = 32; // calculates size on mouse-drag and enforces a minimum size
|
|
542
|
+
|
|
543
|
+
const calculateNewSize = function () {
|
|
544
|
+
let initialSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
545
|
+
let initialMousePosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
546
|
+
let newMousePosition = arguments.length > 2 ? arguments[2] : undefined;
|
|
547
|
+
let minSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MINIMUM_COLUMN_SIZE;
|
|
548
|
+
const newSize = initialSize - (initialMousePosition - newMousePosition);
|
|
606
549
|
return minSize > newSize ? minSize : newSize;
|
|
607
550
|
};
|
|
608
551
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
552
|
+
const setColumnWidth = function () {
|
|
553
|
+
let columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
554
|
+
let position = arguments.length > 1 ? arguments[1] : undefined;
|
|
555
|
+
let value = arguments.length > 2 ? arguments[2] : undefined;
|
|
613
556
|
// columns => comes from state.sizes which reflects component's state
|
|
614
557
|
// any update to the columns results in updating the state
|
|
615
558
|
columns[position] = _objectSpread$1(_objectSpread$1({}, columns[position]), {}, {
|
|
@@ -618,22 +561,16 @@ var setColumnWidth = function setColumnWidth() {
|
|
|
618
561
|
return columns;
|
|
619
562
|
};
|
|
620
563
|
|
|
621
|
-
|
|
622
|
-
return "".concat(_mapInstanceProperty__default["default"](columns).call(columns, function (width) {
|
|
623
|
-
return "".concat(width || 0, "px");
|
|
624
|
-
}).join(' '));
|
|
625
|
-
};
|
|
564
|
+
const getGridTemplateColumnsStyle = columns => "".concat(_mapInstanceProperty__default["default"](columns).call(columns, width => "".concat(width || 0, "px")).join(' '));
|
|
626
565
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
};
|
|
636
|
-
};
|
|
566
|
+
const initialState = tableRef => ({
|
|
567
|
+
initialColWidth: undefined,
|
|
568
|
+
initialMousePosition: undefined,
|
|
569
|
+
columnBeingResized: undefined,
|
|
570
|
+
hasBeenResized: false,
|
|
571
|
+
sizes: undefined,
|
|
572
|
+
tableRef
|
|
573
|
+
});
|
|
637
574
|
|
|
638
575
|
function reducer(state, action) {
|
|
639
576
|
switch (action.type) {
|
|
@@ -669,31 +606,31 @@ function reducer(state, action) {
|
|
|
669
606
|
}
|
|
670
607
|
}
|
|
671
608
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
609
|
+
const useManualResizingReducer = tableRef => {
|
|
610
|
+
const _useReducer = react$1.useReducer(reducer, initialState(tableRef)),
|
|
611
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
612
|
+
manualResizingState = _useReducer2[0],
|
|
613
|
+
dispatch = _useReducer2[1];
|
|
677
614
|
|
|
678
615
|
react$1.useDebugValue(manualResizingState);
|
|
679
616
|
return [manualResizingState, dispatch];
|
|
680
617
|
};
|
|
681
618
|
|
|
682
|
-
|
|
619
|
+
const useManualColumnResizing = tableRef => {
|
|
683
620
|
var _state$tableRef;
|
|
684
621
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
622
|
+
const _useManualResizingRed = useManualResizingReducer(tableRef),
|
|
623
|
+
_useManualResizingRed2 = _slicedToArray(_useManualResizingRed, 2),
|
|
624
|
+
state = _useManualResizingRed2[0],
|
|
625
|
+
dispatch = _useManualResizingRed2[1]; // if the table element has been rendered and we haven't yet measured the columns
|
|
689
626
|
|
|
690
627
|
|
|
691
628
|
if ((_state$tableRef = state.tableRef) !== null && _state$tableRef !== void 0 && _state$tableRef.current && !state.sizes) {
|
|
692
629
|
var _context;
|
|
693
630
|
|
|
694
|
-
|
|
631
|
+
const renderedColumnMeasurements = [];
|
|
695
632
|
|
|
696
|
-
_forEachInstanceProperty__default["default"](_context = state.tableRef.current.querySelectorAll('th')).call(_context,
|
|
633
|
+
_forEachInstanceProperty__default["default"](_context = state.tableRef.current.querySelectorAll('th')).call(_context, header => {
|
|
697
634
|
renderedColumnMeasurements.push({
|
|
698
635
|
key: header.getAttribute('data-id'),
|
|
699
636
|
width: header.getBoundingClientRect().width
|
|
@@ -708,7 +645,7 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
708
645
|
});
|
|
709
646
|
}
|
|
710
647
|
|
|
711
|
-
|
|
648
|
+
const startResizing = (headerRef, mouseEvent) => {
|
|
712
649
|
dispatch({
|
|
713
650
|
type: 'startResizing',
|
|
714
651
|
payload: {
|
|
@@ -719,52 +656,42 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
719
656
|
});
|
|
720
657
|
};
|
|
721
658
|
|
|
722
|
-
|
|
659
|
+
const onDragResizing = (event, columnIndex) => {
|
|
723
660
|
// throttle and sync resizing update rate with screen refresh rate
|
|
724
|
-
requestAnimationFrame(
|
|
661
|
+
requestAnimationFrame(() => {
|
|
725
662
|
var _state$tableRef2;
|
|
726
663
|
|
|
727
|
-
|
|
728
|
-
|
|
664
|
+
const width = calculateNewSize(state.initialColWidth, state.initialMousePosition, event.clientX);
|
|
665
|
+
const newColumnsSizes = setColumnWidth(state.sizes, columnIndex, width);
|
|
729
666
|
if (!((_state$tableRef2 = state.tableRef) !== null && _state$tableRef2 !== void 0 && _state$tableRef2.current)) return;
|
|
730
|
-
state.tableRef.current.style.gridTemplateColumns = getGridTemplateColumnsStyle(_mapInstanceProperty__default["default"](newColumnsSizes).call(newColumnsSizes,
|
|
731
|
-
return newColumnsSize.width.toString();
|
|
732
|
-
}));
|
|
667
|
+
state.tableRef.current.style.gridTemplateColumns = getGridTemplateColumnsStyle(_mapInstanceProperty__default["default"](newColumnsSizes).call(newColumnsSizes, newColumnsSize => newColumnsSize.width.toString()));
|
|
733
668
|
});
|
|
734
669
|
};
|
|
735
670
|
|
|
736
|
-
|
|
671
|
+
const finishResizing = () => {
|
|
737
672
|
dispatch({
|
|
738
673
|
type: 'finishResizing'
|
|
739
674
|
});
|
|
740
675
|
return state.sizes;
|
|
741
676
|
};
|
|
742
677
|
|
|
743
|
-
|
|
744
|
-
return state.columnBeingResized !== undefined ? state.columnBeingResized === columnIndex : false;
|
|
745
|
-
};
|
|
678
|
+
const getIsColumnBeingResized = columnIndex => state.columnBeingResized !== undefined ? state.columnBeingResized === columnIndex : false;
|
|
746
679
|
|
|
747
|
-
|
|
748
|
-
return state.columnBeingResized !== undefined;
|
|
749
|
-
};
|
|
680
|
+
const getIsAnyColumnBeingResized = () => state.columnBeingResized !== undefined;
|
|
750
681
|
|
|
751
|
-
|
|
752
|
-
return state.hasBeenResized;
|
|
753
|
-
};
|
|
682
|
+
const getHasTableBeenResized = () => state.hasBeenResized;
|
|
754
683
|
|
|
755
|
-
|
|
684
|
+
const getTotalResizedTableWidth = () => {
|
|
756
685
|
var _context2;
|
|
757
686
|
|
|
758
687
|
if (!state.hasBeenResized || !state.sizes) {
|
|
759
688
|
return -1;
|
|
760
689
|
}
|
|
761
690
|
|
|
762
|
-
return _reduceInstanceProperty__default["default"](_context2 = state.sizes).call(_context2,
|
|
763
|
-
return a + b.width;
|
|
764
|
-
}, 0);
|
|
691
|
+
return _reduceInstanceProperty__default["default"](_context2 = state.sizes).call(_context2, (a, b) => a + b.width, 0);
|
|
765
692
|
};
|
|
766
693
|
|
|
767
|
-
|
|
694
|
+
const reset = () => {
|
|
768
695
|
var _state$tableRef3;
|
|
769
696
|
|
|
770
697
|
if (!((_state$tableRef3 = state.tableRef) !== null && _state$tableRef3 !== void 0 && _state$tableRef3.current)) return;
|
|
@@ -774,21 +701,19 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
774
701
|
});
|
|
775
702
|
};
|
|
776
703
|
|
|
777
|
-
|
|
778
|
-
return state.sizes;
|
|
779
|
-
};
|
|
704
|
+
const getSizes = () => state.sizes;
|
|
780
705
|
|
|
781
706
|
react$1.useDebugValue(state);
|
|
782
707
|
return {
|
|
783
|
-
reset
|
|
784
|
-
getSizes
|
|
785
|
-
startResizing
|
|
786
|
-
onDragResizing
|
|
787
|
-
finishResizing
|
|
788
|
-
getHasTableBeenResized
|
|
789
|
-
getIsColumnBeingResized
|
|
790
|
-
getIsAnyColumnBeingResized
|
|
791
|
-
getTotalResizedTableWidth
|
|
708
|
+
reset,
|
|
709
|
+
getSizes,
|
|
710
|
+
startResizing,
|
|
711
|
+
onDragResizing,
|
|
712
|
+
finishResizing,
|
|
713
|
+
getHasTableBeenResized,
|
|
714
|
+
getIsColumnBeingResized,
|
|
715
|
+
getIsAnyColumnBeingResized,
|
|
716
|
+
getTotalResizedTableWidth
|
|
792
717
|
};
|
|
793
718
|
};
|
|
794
719
|
|
|
@@ -796,26 +721,20 @@ var useManualColumnResizing$1 = useManualColumnResizing;
|
|
|
796
721
|
|
|
797
722
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
798
723
|
|
|
799
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
800
|
-
|
|
801
|
-
var getColumnsLayoutInfo = function getColumnsLayoutInfo(columns) {
|
|
802
|
-
return _reduceInstanceProperty__default["default"](columns).call(columns, function (acc, currentValue) {
|
|
803
|
-
var _context;
|
|
724
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
804
725
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}, []);
|
|
810
|
-
};
|
|
726
|
+
const getColumnsLayoutInfo = columns => _reduceInstanceProperty__default["default"](columns).call(columns, (acc, currentValue) => [...acc, {
|
|
727
|
+
key: currentValue.key,
|
|
728
|
+
width: currentValue.width
|
|
729
|
+
}], []);
|
|
811
730
|
|
|
812
|
-
|
|
731
|
+
const shouldRenderRowBottomBorder = (rowIndex, rowCount, footer) => {
|
|
813
732
|
if (!footer) return true;
|
|
814
733
|
if (rowIndex + 1 < rowCount) return true;
|
|
815
734
|
return false;
|
|
816
735
|
};
|
|
817
736
|
|
|
818
|
-
|
|
737
|
+
const defaultProps = {
|
|
819
738
|
columns: [],
|
|
820
739
|
isCondensed: false,
|
|
821
740
|
wrapHeaderLabels: true,
|
|
@@ -823,35 +742,33 @@ var defaultProps = {
|
|
|
823
742
|
horizontalCellAlignment: 'left',
|
|
824
743
|
disableSelfContainment: false,
|
|
825
744
|
// @ts-ignore
|
|
826
|
-
itemRenderer:
|
|
827
|
-
return row[column.key];
|
|
828
|
-
}
|
|
745
|
+
itemRenderer: (row, column) => row[column.key]
|
|
829
746
|
};
|
|
830
747
|
|
|
831
|
-
|
|
832
|
-
var
|
|
833
|
-
|
|
834
|
-
|
|
748
|
+
const DataTable = props => {
|
|
749
|
+
var _context, _context2;
|
|
750
|
+
const tableRef = react$1.useRef();
|
|
751
|
+
const columnResizingReducer = useManualColumnResizing$1(tableRef); // if the table columns have been measured
|
|
835
752
|
// and if the list of columns, their width field, or the isCondensed prop has changed
|
|
836
753
|
// then we need to reset the resized column widths
|
|
837
754
|
|
|
838
|
-
|
|
839
|
-
|
|
755
|
+
const columnsInfo = getColumnsLayoutInfo(props.columns);
|
|
756
|
+
const prevLayout = hooks.usePrevious({
|
|
840
757
|
columns: columnsInfo,
|
|
841
758
|
isCondensed: props.isCondensed
|
|
842
759
|
});
|
|
843
|
-
|
|
760
|
+
const currentLayout = {
|
|
844
761
|
columns: columnsInfo,
|
|
845
762
|
isCondensed: props.isCondensed
|
|
846
763
|
};
|
|
847
|
-
|
|
848
|
-
react$1.useLayoutEffect(
|
|
764
|
+
const hasLayoutChanged = !isEqual__default["default"](prevLayout, currentLayout);
|
|
765
|
+
react$1.useLayoutEffect(() => {
|
|
849
766
|
if (hasLayoutChanged) {
|
|
850
767
|
columnResizingReducer.reset();
|
|
851
768
|
}
|
|
852
769
|
}, [columnResizingReducer, hasLayoutChanged]);
|
|
853
|
-
|
|
854
|
-
|
|
770
|
+
const hasTableBeenResized = columnResizingReducer.getHasTableBeenResized();
|
|
771
|
+
const resizedTotalWidth = hasTableBeenResized && tableRef.current ? columnResizingReducer.getTotalResizedTableWidth() + ( // if the table has a maxHeight, it might add a scrollbar which takes space inside the container
|
|
855
772
|
tableRef.current.offsetWidth - tableRef.current.clientWidth) : undefined;
|
|
856
773
|
return jsxRuntime.jsxs(TableContainer, {
|
|
857
774
|
maxWidth: props.maxWidth,
|
|
@@ -869,37 +786,33 @@ var DataTable = function DataTable(props) {
|
|
|
869
786
|
children: [jsxRuntime.jsx(TableHeader, {
|
|
870
787
|
children: jsxRuntime.jsx(TableRow, {
|
|
871
788
|
isRowClickable: false,
|
|
872
|
-
children: _mapInstanceProperty__default["default"](
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
}, column.key);
|
|
891
|
-
})
|
|
789
|
+
children: _mapInstanceProperty__default["default"](_context = props.columns).call(_context, column => jsxRuntime.jsx(HeaderCell$1, {
|
|
790
|
+
shouldWrap: props.wrapHeaderLabels,
|
|
791
|
+
isCondensed: props.isCondensed,
|
|
792
|
+
iconComponent: column.headerIcon,
|
|
793
|
+
onColumnResized: props.onColumnResized,
|
|
794
|
+
disableResizing: column.disableResizing,
|
|
795
|
+
horizontalCellAlignment: column.align ? column.align : props.horizontalCellAlignment,
|
|
796
|
+
disableHeaderStickiness: props.disableHeaderStickiness,
|
|
797
|
+
columnWidth: column.width
|
|
798
|
+
/* Sorting Props */
|
|
799
|
+
,
|
|
800
|
+
onClick: props.onSortChange && props.onSortChange,
|
|
801
|
+
sortedBy: props.sortedBy,
|
|
802
|
+
columnKey: column.key,
|
|
803
|
+
isSortable: column.isSortable,
|
|
804
|
+
sortDirection: props.sortDirection,
|
|
805
|
+
children: column.label
|
|
806
|
+
}, column.key))
|
|
892
807
|
})
|
|
893
808
|
}), jsxRuntime.jsx(TableBody, {
|
|
894
|
-
children: _mapInstanceProperty__default["default"](
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
}));
|
|
902
|
-
})
|
|
809
|
+
children: _mapInstanceProperty__default["default"](_context2 = props.rows).call(_context2, (row, rowIndex) => react.createElement(DataRow$1, _objectSpread(_objectSpread({}, props), {}, {
|
|
810
|
+
row: row,
|
|
811
|
+
key: row.id,
|
|
812
|
+
rowIndex: rowIndex,
|
|
813
|
+
shouldClipContent: columnResizingReducer.getIsAnyColumnBeingResized() || hasTableBeenResized,
|
|
814
|
+
shouldRenderBottomBorder: shouldRenderRowBottomBorder(rowIndex, props.rows.length, props.footer)
|
|
815
|
+
})))
|
|
903
816
|
})]
|
|
904
817
|
})
|
|
905
818
|
})), props.footer && jsxRuntime.jsx(Footer$1, {
|
|
@@ -918,7 +831,7 @@ DataTable.displayName = 'DataTable';
|
|
|
918
831
|
var DataTable$1 = DataTable;
|
|
919
832
|
|
|
920
833
|
// NOTE: This string will be replaced on build time with the package version.
|
|
921
|
-
var version = "15.15.
|
|
834
|
+
var version = "15.15.1";
|
|
922
835
|
|
|
923
836
|
Object.defineProperty(exports, 'useRowSelection', {
|
|
924
837
|
enumerable: true,
|