@commercetools-uikit/data-table 12.2.1 → 12.2.5
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/README.md +141 -32
- package/dist/commercetools-uikit-data-table.cjs.d.ts +2 -0
- package/dist/commercetools-uikit-data-table.cjs.dev.js +489 -612
- package/dist/commercetools-uikit-data-table.cjs.prod.js +370 -297
- package/dist/commercetools-uikit-data-table.esm.js +455 -573
- package/dist/declarations/src/cell.d.ts +25 -0
- package/dist/declarations/src/cell.styles.d.ts +45 -0
- package/dist/declarations/src/column-resizer.d.ts +10 -0
- package/dist/declarations/src/column-resizing-context.d.ts +3 -0
- package/dist/declarations/src/data-row.d.ts +14 -0
- package/dist/declarations/src/data-table.d.ts +42 -0
- package/dist/declarations/src/data-table.styles.d.ts +38 -0
- package/dist/declarations/src/footer.d.ts +12 -0
- package/dist/declarations/src/header-cell.d.ts +24 -0
- package/dist/declarations/src/header-cell.styles.d.ts +26 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/use-manual-column-resizing-reducer.d.ts +20 -0
- package/dist/declarations/src/utils/convert-numeric-dimension-to-pixel-value.d.ts +2 -0
- package/dist/declarations/src/utils/is-fixed-width-value.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +19 -16
|
@@ -2,14 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
6
|
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
7
|
+
require('prop-types');
|
|
7
8
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
8
9
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
9
10
|
require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
10
11
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
12
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
13
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
14
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
15
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
16
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
17
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
18
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
19
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
20
|
+
var react$1 = require('react');
|
|
13
21
|
var isEqual = require('lodash/isEqual');
|
|
14
22
|
var utils = require('@commercetools-uikit/utils');
|
|
15
23
|
var hooks = require('@commercetools-uikit/hooks');
|
|
@@ -17,47 +25,36 @@ var _styled = require('@emotion/styled/base');
|
|
|
17
25
|
var react = require('@emotion/react');
|
|
18
26
|
var designSystem = require('@commercetools-uikit/design-system');
|
|
19
27
|
var AccessibleButton = require('@commercetools-uikit/accessible-button');
|
|
20
|
-
require('react-required-if');
|
|
21
28
|
var icons = require('@commercetools-uikit/icons');
|
|
29
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
22
30
|
var _Number$isNaN = require('@babel/runtime-corejs3/core-js-stable/number/is-nan');
|
|
23
31
|
var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
|
|
24
32
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
25
33
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
26
|
-
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
27
|
-
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
28
|
-
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
29
|
-
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
30
|
-
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
31
|
-
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
32
|
-
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
33
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
34
|
-
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
35
34
|
|
|
36
35
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
37
36
|
|
|
38
37
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
39
38
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
40
39
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
41
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
42
|
-
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
43
|
-
var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
|
|
44
|
-
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
45
|
-
var AccessibleButton__default = /*#__PURE__*/_interopDefault(AccessibleButton);
|
|
46
|
-
var _Number$isNaN__default = /*#__PURE__*/_interopDefault(_Number$isNaN);
|
|
47
|
-
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
48
|
-
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
49
40
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
50
41
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
51
42
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
52
43
|
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
44
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
53
45
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
54
46
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
55
47
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
56
|
-
var
|
|
48
|
+
var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
|
|
49
|
+
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
50
|
+
var AccessibleButton__default = /*#__PURE__*/_interopDefault(AccessibleButton);
|
|
51
|
+
var _Number$isNaN__default = /*#__PURE__*/_interopDefault(_Number$isNaN);
|
|
52
|
+
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
53
|
+
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
57
54
|
|
|
58
55
|
var getPaddingStyle = function getPaddingStyle(props) {
|
|
59
|
-
if (props.isCondensed) return /*#__PURE__*/react.css("padding:", designSystem.customProperties.spacingS, ";" + ("" ));
|
|
60
|
-
return /*#__PURE__*/react.css("padding:", designSystem.customProperties.spacingM, ";" + ("" ));
|
|
56
|
+
if (props.isCondensed) return /*#__PURE__*/react.css("padding:", designSystem.customProperties.spacingS, ";" + ("" ), "" );
|
|
57
|
+
return /*#__PURE__*/react.css("padding:", designSystem.customProperties.spacingM, ";" + ("" ), "" );
|
|
61
58
|
};
|
|
62
59
|
|
|
63
60
|
var _ref8 = {
|
|
@@ -150,13 +147,13 @@ var _ref3 = {
|
|
|
150
147
|
styles: "overflow:hidden"
|
|
151
148
|
} ;
|
|
152
149
|
|
|
153
|
-
var CellInner = _styled__default[
|
|
154
|
-
target: "
|
|
150
|
+
var CellInner = _styled__default["default"]("div", {
|
|
151
|
+
target: "e10u1n7e3"
|
|
155
152
|
} )("box-sizing:border-box;flex:1;", getPaddingStyle, " ", getCellInnerStyles, " ", function (props) {
|
|
156
153
|
return props.shouldClipContent ? _ref3 : '';
|
|
157
|
-
}, ";");
|
|
154
|
+
}, ";" + ("" ));
|
|
158
155
|
|
|
159
|
-
var _ref = {
|
|
156
|
+
var _ref$1 = {
|
|
160
157
|
name: "1a5erbp",
|
|
161
158
|
styles: "cursor:auto"
|
|
162
159
|
} ;
|
|
@@ -166,121 +163,131 @@ var _ref2 = {
|
|
|
166
163
|
styles: "overflow:hidden"
|
|
167
164
|
} ;
|
|
168
165
|
|
|
169
|
-
var BaseCell = _styled__default[
|
|
170
|
-
target: "
|
|
166
|
+
var BaseCell = _styled__default["default"]("td", {
|
|
167
|
+
target: "e10u1n7e2"
|
|
171
168
|
} )("position:relative;display:flex;background-color:", designSystem.customProperties.colorSurface, ";border-bottom:", function (props) {
|
|
172
169
|
return props.shouldRenderBottomBorder ? "1px solid ".concat(designSystem.customProperties.colorNeutral90, ";") : 'none';
|
|
173
170
|
}, ";", function (props) {
|
|
174
171
|
return props.shouldClipContent ? _ref2 : '';
|
|
175
172
|
}, " ", function (props) {
|
|
176
|
-
return props.shouldIgnoreRowClick ? _ref : '';
|
|
177
|
-
}, ";");
|
|
173
|
+
return props.shouldIgnoreRowClick ? _ref$1 : '';
|
|
174
|
+
}, ";" + ("" ));
|
|
178
175
|
|
|
179
|
-
_styled__default[
|
|
180
|
-
target: "
|
|
176
|
+
_styled__default["default"]("td", {
|
|
177
|
+
target: "e10u1n7e1"
|
|
181
178
|
} )("position:", function (props) {
|
|
182
179
|
return props.disableFooterStickiness ? 'relative' : 'sticky';
|
|
183
180
|
}, ";left:0;bottom:0;grid-column:1/", function (props) {
|
|
184
181
|
return props.numberOfColumns;
|
|
185
|
-
}, ";background-color:", designSystem.customProperties.colorSurface, ";border-bottom:1px solid ", designSystem.customProperties.colorNeutral90, ";border-top:1px solid ", designSystem.customProperties.colorNeutral90, ";margin-top:-1px;");
|
|
182
|
+
}, ";background-color:", designSystem.customProperties.colorSurface, ";border-bottom:1px solid ", designSystem.customProperties.colorNeutral90, ";border-top:1px solid ", designSystem.customProperties.colorNeutral90, ";margin-top:-1px;" + ("" ));
|
|
186
183
|
|
|
187
|
-
var RowExpandCollapseButton = /*#__PURE__*/_styled__default[
|
|
188
|
-
target: "
|
|
184
|
+
var RowExpandCollapseButton = /*#__PURE__*/_styled__default["default"](AccessibleButton__default["default"], {
|
|
185
|
+
target: "e10u1n7e0"
|
|
189
186
|
} )("cursor:", function (props) {
|
|
190
|
-
return props.isRowCollapsed ? /*#__PURE__*/react.css("" ) : /*#__PURE__*/react.css("" );
|
|
191
|
-
}, ";position:absolute;height:16px;width:16px;bottom:0;right:0;opacity:0;display:flex;justify-content:flex-end;align-items:flex-end;");
|
|
187
|
+
return props.isRowCollapsed ? /*#__PURE__*/react.css("" , "" ) : /*#__PURE__*/react.css("" , "" );
|
|
188
|
+
}, ";position:absolute;height:16px;width:16px;bottom:0;right:0;opacity:0;display:flex;justify-content:flex-end;align-items:flex-end;" + ("" ));
|
|
192
189
|
|
|
193
190
|
var convertNumericDimensionToPixelValue = function convertNumericDimensionToPixelValue(dimensionValue) {
|
|
194
191
|
return typeof dimensionValue === 'number' ? "".concat(dimensionValue, "px") : dimensionValue;
|
|
195
192
|
};
|
|
196
193
|
|
|
194
|
+
var convertNumericDimensionToPixelValue$1 = convertNumericDimensionToPixelValue;
|
|
195
|
+
|
|
197
196
|
var getClickableRowStyle = function getClickableRowStyle(props) {
|
|
198
197
|
if (props.isRowClickable) {
|
|
199
|
-
return /*#__PURE__*/react.css("cursor:pointer;&:hover td{background:", designSystem.customProperties.backgroundColorForInputWhenHovered, ";}" + ("" ));
|
|
198
|
+
return /*#__PURE__*/react.css("cursor:pointer;&:hover td{background:", designSystem.customProperties.backgroundColorForInputWhenHovered, ";}" + ("" ), "" );
|
|
200
199
|
}
|
|
201
200
|
|
|
202
201
|
return '';
|
|
203
202
|
};
|
|
204
203
|
|
|
205
|
-
var _ref
|
|
204
|
+
var _ref = {
|
|
206
205
|
name: "1jff5cf",
|
|
207
206
|
styles: "position:unset;overflow-x:unset;overflow-y:unset"
|
|
208
207
|
} ;
|
|
209
208
|
|
|
210
209
|
var getDisabledSelfContainmentStyles = function getDisabledSelfContainmentStyles(props) {
|
|
211
210
|
if (props.disableSelfContainment) {
|
|
212
|
-
return _ref
|
|
211
|
+
return _ref;
|
|
213
212
|
}
|
|
214
213
|
|
|
215
214
|
return '';
|
|
216
215
|
};
|
|
217
216
|
|
|
218
|
-
var TableContainer = _styled__default[
|
|
219
|
-
target: "
|
|
217
|
+
var TableContainer = _styled__default["default"]("div", {
|
|
218
|
+
target: "epk01s24"
|
|
220
219
|
} )("position:relative;z-index:0;overflow-x:auto;", function (props) {
|
|
221
|
-
return props.maxWidth && !props.disableSelfContainment ? "max-width: ".concat(convertNumericDimensionToPixelValue(props.maxWidth), ";") : '';
|
|
220
|
+
return props.maxWidth && !props.disableSelfContainment ? "max-width: ".concat(convertNumericDimensionToPixelValue$1(props.maxWidth), ";") : '';
|
|
222
221
|
}, " ", function (props) {
|
|
223
222
|
return props.isBeingResized && "\n * {\n user-select: none;\n }";
|
|
224
|
-
}, " ", getDisabledSelfContainmentStyles, ";");
|
|
223
|
+
}, " ", getDisabledSelfContainmentStyles, ";" + ("" ));
|
|
225
224
|
|
|
226
|
-
var TableGrid = _styled__default[
|
|
227
|
-
target: "
|
|
225
|
+
var TableGrid = _styled__default["default"]("table", {
|
|
226
|
+
target: "epk01s23"
|
|
228
227
|
} )("display:grid;grid-template-columns:", function (props) {
|
|
229
228
|
var _context;
|
|
230
229
|
|
|
231
|
-
return _mapInstanceProperty__default[
|
|
230
|
+
return props.columns && _mapInstanceProperty__default["default"](_context = props.columns).call(_context, function (column) {
|
|
232
231
|
return column.width || 'auto';
|
|
233
232
|
}).join(' ');
|
|
234
233
|
}, ";overflow-y:auto;", function (props) {
|
|
235
|
-
return props.maxHeight && !props.disableSelfContainment ? "max-height: ".concat(convertNumericDimensionToPixelValue(props.maxHeight), ";") : '';
|
|
234
|
+
return props.maxHeight && !props.disableSelfContainment ? "max-height: ".concat(convertNumericDimensionToPixelValue$1(props.maxHeight), ";") : '';
|
|
236
235
|
}, " ", function (props) {
|
|
237
236
|
return props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '';
|
|
238
|
-
}, " ", getDisabledSelfContainmentStyles, ";");
|
|
237
|
+
}, " ", getDisabledSelfContainmentStyles, ";" + ("" ));
|
|
239
238
|
|
|
240
|
-
var Header = _styled__default[
|
|
241
|
-
target: "
|
|
239
|
+
var Header = _styled__default["default"]("thead", {
|
|
240
|
+
target: "epk01s22"
|
|
242
241
|
} )({
|
|
243
242
|
name: "49aokf",
|
|
244
243
|
styles: "display:contents"
|
|
245
244
|
} );
|
|
246
245
|
|
|
247
|
-
var Body = _styled__default[
|
|
248
|
-
target: "
|
|
246
|
+
var Body = _styled__default["default"]("tbody", {
|
|
247
|
+
target: "epk01s21"
|
|
249
248
|
} )({
|
|
250
249
|
name: "49aokf",
|
|
251
250
|
styles: "display:contents"
|
|
252
251
|
} );
|
|
253
252
|
|
|
254
|
-
var Row = _styled__default[
|
|
255
|
-
target: "
|
|
256
|
-
} )("display:contents;", getClickableRowStyle, " :hover,:focus-within{", RowExpandCollapseButton, "{opacity:1;}}");
|
|
253
|
+
var Row = _styled__default["default"]("tr", {
|
|
254
|
+
target: "epk01s20"
|
|
255
|
+
} )("display:contents;", getClickableRowStyle, " :hover,:focus-within{", RowExpandCollapseButton, "{opacity:1;}}" + ("" ));
|
|
257
256
|
|
|
258
|
-
var
|
|
259
|
-
|
|
257
|
+
var defaultProps$4 = {
|
|
258
|
+
horizontalCellAlignment: 'left'
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
var Footer = _styled__default["default"]("div", {
|
|
262
|
+
target: "e2ce7vj0"
|
|
260
263
|
} )("box-sizing:border-box;display:block;", getPaddingStyle, " ", getHorizontalAlignmentStyle, " background-color:", designSystem.customProperties.colorSurface, ";border-top:1px solid ", designSystem.customProperties.colorNeutral90, ";border-bottom:1px solid ", designSystem.customProperties.colorNeutral90, ";", function (props) {
|
|
261
264
|
return props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '';
|
|
262
|
-
}, ";");
|
|
265
|
+
}, ";" + ("" ));
|
|
263
266
|
|
|
264
267
|
Footer.displayName = 'Footer';
|
|
265
|
-
Footer.
|
|
266
|
-
|
|
267
|
-
isCondensed: PropTypes__default['default'].bool,
|
|
268
|
-
horizontalCellAlignment: PropTypes__default['default'].oneOf(['left', 'center', 'right'])
|
|
269
|
-
};
|
|
270
|
-
Footer.defaultProps = {
|
|
271
|
-
horizontalCellAlignment: 'left'
|
|
272
|
-
};
|
|
268
|
+
Footer.defaultProps = defaultProps$4;
|
|
269
|
+
var Footer$1 = Footer;
|
|
273
270
|
|
|
274
271
|
var getButtonStyle = function getButtonStyle() {
|
|
275
|
-
return /*#__PURE__*/react.css("cursor:pointer;border:none;background:none;text-decoration:none;color:inherit;font:inherit;font-size:", designSystem.customProperties.fontSizeDefault, ";font-family:inherit;" + ("" ));
|
|
272
|
+
return /*#__PURE__*/react.css("cursor:pointer;border:none;background:none;text-decoration:none;color:inherit;font:inherit;font-size:", designSystem.customProperties.fontSizeDefault, ";font-family:inherit;" + ("" ), "" );
|
|
276
273
|
};
|
|
274
|
+
/* A sortable header has the two arrow svg icons
|
|
275
|
+
* GIVEN column is sortable and is not focused
|
|
276
|
+
* THEN AngleUpDown icon is shown (default behaviour)
|
|
277
|
+
* AND AngleUp or AngleDown icon is not shown
|
|
278
|
+
*
|
|
279
|
+
* GIVEN column is sortable and foucsed
|
|
280
|
+
* THEN AngleUpDown icon is hidden
|
|
281
|
+
* AND AngleUp or AngleDown icon is shown
|
|
282
|
+
*/
|
|
283
|
+
|
|
277
284
|
|
|
278
285
|
var getSortableHeaderStyles = function getSortableHeaderStyles(props) {
|
|
279
|
-
return /*#__PURE__*/react.css("width:100%;display:flex;align-items:center;svg[
|
|
286
|
+
return /*#__PURE__*/react.css("width:100%;display:flex;align-items:center;svg[data-icon-state='inactive'],svg[data-icon-state='active']{margin-left:", designSystem.customProperties.spacingS, ";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', ";}:hover,:focus{svg[data-icon-state='inactive']{display:none;}svg[data-icon-state='active']{display:inline-block;*{fill:", designSystem.customProperties.colorNeutral, ";}}}" + ("" ), "" );
|
|
280
287
|
};
|
|
281
288
|
|
|
282
|
-
var HeaderCellInner = _styled__default[
|
|
283
|
-
target: "
|
|
289
|
+
var HeaderCellInner = _styled__default["default"]("div", {
|
|
290
|
+
target: "e1ipt8n23"
|
|
284
291
|
} )("box-sizing:border-box;display:flex;justify-content:space-between;padding:0 ", function (props) {
|
|
285
292
|
return props.isCondensed ? designSystem.customProperties.spacingS : designSystem.customProperties.spacingM;
|
|
286
293
|
}, ";", getCellInnerStyles, " ", function (props) {
|
|
@@ -289,65 +296,75 @@ var HeaderCellInner = _styled__default['default']("div", {
|
|
|
289
296
|
return props.as === 'button' ? getButtonStyle() : '';
|
|
290
297
|
}, ";", function (props) {
|
|
291
298
|
return props.shouldWrap ? '' : 'white-space: nowrap';
|
|
292
|
-
}, ";");
|
|
299
|
+
}, ";" + ("" ));
|
|
293
300
|
|
|
294
|
-
var BaseHeaderCell = _styled__default[
|
|
295
|
-
target: "
|
|
301
|
+
var BaseHeaderCell = _styled__default["default"]("th", {
|
|
302
|
+
target: "e1ipt8n22"
|
|
296
303
|
} )("color:", designSystem.customProperties.colorSurface, ";background-color:", designSystem.customProperties.colorAccent, ";position:", function (props) {
|
|
297
304
|
return props.disableHeaderStickiness ? 'relative' : 'sticky';
|
|
298
305
|
}, ";top:0;z-index:1;padding:0;font-weight:normal;box-shadow:inset -1px 0 ", designSystem.customProperties.colorNeutral90, ";:hover,:active{z-index:2;}", HeaderCellInner, "{", function (props) {
|
|
299
306
|
return props.shouldClipContent ? 'overflow: hidden;' : '';
|
|
300
|
-
}, ";}");
|
|
307
|
+
}, ";}" + ("" ));
|
|
301
308
|
|
|
302
|
-
var HeaderLabelWrapper = _styled__default[
|
|
303
|
-
target: "
|
|
304
|
-
} )("min-height:1.4em;margin:", designSystem.customProperties.spacingS, " 0;flex:1;");
|
|
309
|
+
var HeaderLabelWrapper = _styled__default["default"]("div", {
|
|
310
|
+
target: "e1ipt8n21"
|
|
311
|
+
} )("min-height:1.4em;margin:", designSystem.customProperties.spacingS, " 0;flex:1;" + ("" ));
|
|
305
312
|
|
|
306
|
-
var HeaderIconWrapper = _styled__default[
|
|
307
|
-
target: "
|
|
308
|
-
} )("display:inline-flex;align-items:center;justify-content:center;margin-right:", designSystem.customProperties.spacingS, ";padding:", designSystem.customProperties.spacingXs, " 0;");
|
|
313
|
+
var HeaderIconWrapper = _styled__default["default"]("div", {
|
|
314
|
+
target: "e1ipt8n20"
|
|
315
|
+
} )("display:inline-flex;align-items:center;justify-content:center;margin-right:", designSystem.customProperties.spacingS, ";padding:", designSystem.customProperties.spacingXs, " 0;" + ("" ));
|
|
309
316
|
|
|
310
|
-
var ResizerIndicator = _styled__default[
|
|
311
|
-
target: "
|
|
317
|
+
var ResizerIndicator = _styled__default["default"]("div", {
|
|
318
|
+
target: "e1ccic7f1"
|
|
312
319
|
} )("height:100%;width:3px;background:", designSystem.customProperties.colorInfo, ";visibility:hidden;cursor:col-resize;", function (props // extra 1px of height to appear above the bottom horizontal row border
|
|
313
320
|
) {
|
|
314
321
|
return props.isOnDataCell ? 'visibility: visible; height: calc(100% + 1px);' : '';
|
|
315
|
-
}, ";");
|
|
322
|
+
}, ";" + ("" ));
|
|
316
323
|
|
|
317
|
-
var DraggableArea = _styled__default[
|
|
318
|
-
target: "
|
|
319
|
-
} )("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;}}");
|
|
324
|
+
var DraggableArea = _styled__default["default"]("div", {
|
|
325
|
+
target: "e1ccic7f0"
|
|
326
|
+
} )("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;}}" + ("" ));
|
|
320
327
|
|
|
321
328
|
var ColumnResizer = function ColumnResizer(props) {
|
|
322
|
-
return
|
|
329
|
+
return jsxRuntime.jsx(DraggableArea, {
|
|
323
330
|
role: "presentation",
|
|
324
|
-
onMouseDown: props.onMouseDown
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
331
|
+
onMouseDown: props.onMouseDown,
|
|
332
|
+
children: jsxRuntime.jsx(ResizerIndicator, {
|
|
333
|
+
isOnDataCell: props.isOnDataCell
|
|
334
|
+
})
|
|
335
|
+
});
|
|
328
336
|
};
|
|
329
337
|
|
|
330
|
-
ColumnResizer.displayName = 'ColumnResizer';
|
|
331
338
|
ColumnResizer.propTypes = {};
|
|
339
|
+
ColumnResizer.displayName = 'ColumnResizer';
|
|
340
|
+
var Resizer = ColumnResizer;
|
|
332
341
|
|
|
333
|
-
var ColumnResizingContext = /*#__PURE__*/
|
|
342
|
+
var ColumnResizingContext = /*#__PURE__*/react$1.createContext({});
|
|
334
343
|
|
|
335
344
|
var isFixedWidthValue = function isFixedWidthValue(value) {
|
|
336
|
-
return !_Number$isNaN__default[
|
|
345
|
+
return !_Number$isNaN__default["default"](_parseInt__default["default"](String(value), 10));
|
|
337
346
|
};
|
|
338
347
|
|
|
348
|
+
var isFixedWidthValue$1 = isFixedWidthValue;
|
|
349
|
+
|
|
350
|
+
function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
|
|
351
|
+
|
|
352
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$3(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _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; }
|
|
353
|
+
|
|
339
354
|
var HeaderCellWrapper = function HeaderCellWrapper(props) {
|
|
340
|
-
var _headerRef$
|
|
355
|
+
var _headerRef$current2;
|
|
341
356
|
|
|
342
|
-
var columnResizingReducer =
|
|
343
|
-
var headerRef =
|
|
357
|
+
var columnResizingReducer = react$1.useContext(ColumnResizingContext);
|
|
358
|
+
var headerRef = react$1.useRef(null);
|
|
344
359
|
|
|
345
360
|
var onStartResizing = function onStartResizing(event) {
|
|
346
361
|
columnResizingReducer.startResizing(headerRef, event);
|
|
347
362
|
};
|
|
348
363
|
|
|
349
364
|
var onDrag = function onDrag(event) {
|
|
350
|
-
|
|
365
|
+
var _headerRef$current;
|
|
366
|
+
|
|
367
|
+
return columnResizingReducer.onDragResizing(event, (_headerRef$current = headerRef.current) === null || _headerRef$current === void 0 ? void 0 : _headerRef$current.cellIndex);
|
|
351
368
|
};
|
|
352
369
|
|
|
353
370
|
var onDragEnd = function onDragEnd() {
|
|
@@ -361,7 +378,7 @@ var HeaderCellWrapper = function HeaderCellWrapper(props) {
|
|
|
361
378
|
window.removeEventListener('mouseup', onDragEnd);
|
|
362
379
|
};
|
|
363
380
|
|
|
364
|
-
if (columnResizingReducer.getIsColumnBeingResized((_headerRef$
|
|
381
|
+
if (columnResizingReducer.getIsColumnBeingResized((_headerRef$current2 = headerRef.current) === null || _headerRef$current2 === void 0 ? void 0 : _headerRef$current2.cellIndex)) {
|
|
365
382
|
window.addEventListener('mousemove', onDrag);
|
|
366
383
|
window.addEventListener('mouseup', onDragEnd);
|
|
367
384
|
}
|
|
@@ -372,20 +389,26 @@ var HeaderCellWrapper = function HeaderCellWrapper(props) {
|
|
|
372
389
|
*/
|
|
373
390
|
|
|
374
391
|
|
|
375
|
-
var shouldClipContent = isFixedWidthValue(props.columnWidth) || columnResizingReducer.getHasTableBeenResized() || columnResizingReducer.getIsAnyColumnBeingResized();
|
|
376
|
-
return
|
|
392
|
+
var shouldClipContent = props.columnWidth && isFixedWidthValue$1(props.columnWidth) || columnResizingReducer.getHasTableBeenResized() || columnResizingReducer.getIsAnyColumnBeingResized();
|
|
393
|
+
return jsxRuntime.jsxs(BaseHeaderCell, {
|
|
377
394
|
ref: headerRef,
|
|
378
395
|
"data-testid": "header-".concat(props.columnKey),
|
|
379
396
|
"data-id": props.columnKey,
|
|
380
397
|
shouldClipContent: shouldClipContent,
|
|
381
|
-
disableHeaderStickiness: props.disableHeaderStickiness
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
398
|
+
disableHeaderStickiness: props.disableHeaderStickiness,
|
|
399
|
+
children: [props.children, !props.disableResizing && jsxRuntime.jsx(Resizer, {
|
|
400
|
+
onMouseDown: onStartResizing
|
|
401
|
+
})]
|
|
402
|
+
});
|
|
385
403
|
};
|
|
386
404
|
|
|
387
405
|
HeaderCellWrapper.propTypes = {};
|
|
388
406
|
HeaderCellWrapper.displayName = 'HeaderCellWrapper';
|
|
407
|
+
var defaultProps$3 = {
|
|
408
|
+
sortDirection: 'desc',
|
|
409
|
+
disableHeaderStickiness: false,
|
|
410
|
+
horizontalCellAlignment: 'left'
|
|
411
|
+
};
|
|
389
412
|
|
|
390
413
|
var HeaderCell = function HeaderCell(props) {
|
|
391
414
|
var sortableHeaderProps = {};
|
|
@@ -399,96 +422,126 @@ var HeaderCell = function HeaderCell(props) {
|
|
|
399
422
|
as: 'button',
|
|
400
423
|
label: props.sortDirection,
|
|
401
424
|
onClick: function onClick() {
|
|
402
|
-
return props.onClick(props.columnKey, nextSortDirection);
|
|
425
|
+
return props.onClick && props.onClick(props.columnKey, nextSortDirection);
|
|
403
426
|
},
|
|
404
427
|
isActive: isActive,
|
|
405
428
|
isSortable: true
|
|
406
429
|
};
|
|
407
430
|
}
|
|
408
431
|
|
|
409
|
-
return
|
|
432
|
+
return jsxRuntime.jsx(HeaderCellWrapper, {
|
|
410
433
|
columnWidth: props.columnWidth,
|
|
411
434
|
columnKey: props.columnKey,
|
|
412
435
|
onColumnResized: props.onColumnResized,
|
|
413
436
|
disableResizing: props.disableResizing,
|
|
414
|
-
disableHeaderStickiness: props.disableHeaderStickiness
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
437
|
+
disableHeaderStickiness: props.disableHeaderStickiness,
|
|
438
|
+
children: jsxRuntime.jsxs(HeaderCellInner, _objectSpread$3(_objectSpread$3({
|
|
439
|
+
shouldWrap: props.shouldWrap,
|
|
440
|
+
isCondensed: props.isCondensed,
|
|
441
|
+
horizontalCellAlignment: props.horizontalCellAlignment
|
|
442
|
+
}, sortableHeaderProps), {}, {
|
|
443
|
+
children: [props.iconComponent && jsxRuntime.jsx(HeaderIconWrapper, {
|
|
444
|
+
children: props.iconComponent
|
|
445
|
+
}), jsxRuntime.jsx(HeaderLabelWrapper, {
|
|
446
|
+
children: props.children
|
|
447
|
+
}), props.isSortable && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
448
|
+
children: [jsxRuntime.jsx(icons.AngleUpDownIcon, {
|
|
449
|
+
size: "medium",
|
|
450
|
+
color: "surface",
|
|
451
|
+
"data-icon-state": "inactive"
|
|
452
|
+
}), jsxRuntime.jsx(SortingIcon, {
|
|
453
|
+
size: "medium",
|
|
454
|
+
color: "surface",
|
|
455
|
+
"data-icon-state": "active"
|
|
456
|
+
})]
|
|
457
|
+
})]
|
|
458
|
+
}))
|
|
459
|
+
});
|
|
428
460
|
};
|
|
429
461
|
|
|
430
|
-
HeaderCell.displayName = 'HeaderCell';
|
|
431
462
|
HeaderCell.propTypes = {};
|
|
432
|
-
HeaderCell.
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
463
|
+
HeaderCell.displayName = 'HeaderCell';
|
|
464
|
+
HeaderCell.defaultProps = defaultProps$3;
|
|
465
|
+
var HeaderCell$1 = HeaderCell;
|
|
466
|
+
|
|
467
|
+
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
|
|
468
|
+
|
|
469
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _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; }
|
|
470
|
+
var defaultProps$2 = {
|
|
471
|
+
isTruncated: false,
|
|
472
|
+
shouldRenderBottomBorder: true
|
|
436
473
|
};
|
|
437
474
|
|
|
438
475
|
var DataCell = function DataCell(props) {
|
|
476
|
+
if (props.shouldRenderCollapseButton) ;
|
|
477
|
+
|
|
439
478
|
var Icon = props.isRowCollapsed ? icons.RightTriangleFilledIcon : icons.RightTriangleLinearIcon;
|
|
440
|
-
return
|
|
479
|
+
return jsxRuntime.jsxs(BaseCell, {
|
|
441
480
|
onClick: props.onCellClick,
|
|
442
481
|
shouldIgnoreRowClick: props.shouldIgnoreRowClick,
|
|
443
482
|
shouldClipContent: props.isTruncated && !props.shouldRenderResizingIndicator,
|
|
444
|
-
shouldRenderBottomBorder: props.shouldRenderBottomBorder
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
event
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
483
|
+
shouldRenderBottomBorder: props.shouldRenderBottomBorder,
|
|
484
|
+
children: [jsxRuntime.jsx(CellInner, _objectSpread$2(_objectSpread$2({
|
|
485
|
+
isCondensed: props.isCondensed,
|
|
486
|
+
isTruncated: props.isTruncated,
|
|
487
|
+
verticalCellAlignment: props.verticalCellAlignment,
|
|
488
|
+
horizontalCellAlignment: props.horizontalCellAlignment
|
|
489
|
+
}, utils.filterDataAttributes(props)), {}, {
|
|
490
|
+
children: props.children
|
|
491
|
+
})), props.shouldRenderCollapseButton && jsxRuntime.jsx(RowExpandCollapseButton, {
|
|
492
|
+
label: "Expand/Collapse Row",
|
|
493
|
+
onClick: function onClick(event) {
|
|
494
|
+
if (props.handleRowCollapseClick) props.handleRowCollapseClick();
|
|
495
|
+
event.stopPropagation();
|
|
496
|
+
},
|
|
497
|
+
isRowCollapsed: props.isRowCollapsed,
|
|
498
|
+
children: jsxRuntime.jsx(Icon, {
|
|
499
|
+
size: "small"
|
|
500
|
+
})
|
|
501
|
+
}), props.shouldRenderResizingIndicator && jsxRuntime.jsx(Resizer, {
|
|
502
|
+
isOnDataCell: true
|
|
503
|
+
})]
|
|
504
|
+
});
|
|
462
505
|
};
|
|
463
506
|
|
|
464
|
-
DataCell.displayName = 'DataCell';
|
|
465
507
|
DataCell.propTypes = {};
|
|
466
|
-
DataCell.
|
|
467
|
-
|
|
468
|
-
|
|
508
|
+
DataCell.displayName = 'DataCell';
|
|
509
|
+
DataCell.defaultProps = defaultProps$2;
|
|
510
|
+
var DataCell$1 = DataCell;
|
|
511
|
+
|
|
512
|
+
var defaultProps$1 = {
|
|
513
|
+
isCondensed: false,
|
|
514
|
+
shouldClipContent: false,
|
|
515
|
+
verticalCellAlignment: 'top',
|
|
516
|
+
horizontalCellAlignment: 'left',
|
|
517
|
+
shouldRenderBottomBorder: true,
|
|
518
|
+
// @ts-ignore
|
|
519
|
+
itemRenderer: function itemRenderer(row, column) {
|
|
520
|
+
return row[column.key];
|
|
521
|
+
}
|
|
469
522
|
};
|
|
470
523
|
|
|
471
524
|
var DataRow = function DataRow(props) {
|
|
472
525
|
var _context, _context2;
|
|
473
526
|
|
|
474
|
-
var
|
|
475
|
-
getIsColumnBeingResized =
|
|
527
|
+
var _ref = react$1.useContext(ColumnResizingContext),
|
|
528
|
+
getIsColumnBeingResized = _ref.getIsColumnBeingResized;
|
|
476
529
|
|
|
477
|
-
var rowHasTruncatedColumn = _someInstanceProperty__default[
|
|
530
|
+
var rowHasTruncatedColumn = _someInstanceProperty__default["default"](_context = props.columns).call(_context, function (column) {
|
|
478
531
|
return column.isTruncated;
|
|
479
532
|
});
|
|
480
533
|
|
|
481
|
-
var
|
|
482
|
-
|
|
483
|
-
isRowCollapsed =
|
|
484
|
-
collapseRow =
|
|
534
|
+
var _useState = react$1.useState(rowHasTruncatedColumn),
|
|
535
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
536
|
+
isRowCollapsed = _useState2[0],
|
|
537
|
+
collapseRow = _useState2[1];
|
|
485
538
|
|
|
486
539
|
var handleRowCollapseClick = function handleRowCollapseClick() {
|
|
487
540
|
collapseRow(!isRowCollapsed);
|
|
488
541
|
}; // update the collapsed state if isTruncated options are changed for the whole row
|
|
489
542
|
|
|
490
543
|
|
|
491
|
-
|
|
544
|
+
react$1.useEffect(function () {
|
|
492
545
|
if (rowHasTruncatedColumn) {
|
|
493
546
|
collapseRow(true);
|
|
494
547
|
} else {
|
|
@@ -500,70 +553,67 @@ var DataRow = function DataRow(props) {
|
|
|
500
553
|
return rowHasTruncatedColumn && totalColumnsLength - 1 === currentColumnIndex;
|
|
501
554
|
};
|
|
502
555
|
|
|
503
|
-
return
|
|
504
|
-
isRowClickable: props.onRowClick
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
})
|
|
556
|
+
return jsxRuntime.jsx(Row, {
|
|
557
|
+
isRowClickable: props.onRowClick,
|
|
558
|
+
children: _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, function (column, columnIndex) {
|
|
559
|
+
var _context3, _context4;
|
|
560
|
+
|
|
561
|
+
return jsxRuntime.jsx(DataCell$1, {
|
|
562
|
+
"data-testid": _concatInstanceProperty__default["default"](_context4 = "cell-".concat(props.rowIndex, "-")).call(_context4, column.key),
|
|
563
|
+
isTruncated: column.isTruncated && isRowCollapsed,
|
|
564
|
+
isCondensed: props.isCondensed,
|
|
565
|
+
isRowCollapsed: isRowCollapsed,
|
|
566
|
+
verticalCellAlignment: props.verticalCellAlignment,
|
|
567
|
+
horizontalCellAlignment: column.align ? column.align : props.horizontalCellAlignment,
|
|
568
|
+
shouldIgnoreRowClick: column.shouldIgnoreRowClick,
|
|
569
|
+
handleRowCollapseClick: handleRowCollapseClick,
|
|
570
|
+
shouldRenderCollapseButton: shouldRenderCollapseButton(props.columns.length, columnIndex),
|
|
571
|
+
onCellClick: props.onRowClick && !column.shouldIgnoreRowClick ? function () {
|
|
572
|
+
var _props$onRowClick;
|
|
573
|
+
|
|
574
|
+
return (_props$onRowClick = props.onRowClick) === null || _props$onRowClick === void 0 ? void 0 : _props$onRowClick.call(props, props.row, props.rowIndex, column.key);
|
|
575
|
+
} : undefined,
|
|
576
|
+
shouldRenderBottomBorder: props.shouldRenderBottomBorder,
|
|
577
|
+
shouldRenderResizingIndicator: getIsColumnBeingResized(columnIndex),
|
|
578
|
+
children: column.renderItem ? column.renderItem(props.row, isRowCollapsed) : props.itemRenderer(props.row, column, isRowCollapsed)
|
|
579
|
+
}, _concatInstanceProperty__default["default"](_context3 = "".concat(props.row.id, "-")).call(_context3, column.key));
|
|
580
|
+
})
|
|
581
|
+
});
|
|
529
582
|
};
|
|
530
583
|
|
|
531
584
|
DataRow.propTypes = {};
|
|
532
|
-
DataRow.defaultProps =
|
|
533
|
-
isCondensed: false,
|
|
534
|
-
shouldClipContent: false,
|
|
535
|
-
verticalCellAlignment: 'top',
|
|
536
|
-
horizontalCellAlignment: 'left',
|
|
537
|
-
shouldRenderBottomBorder: true,
|
|
538
|
-
itemRenderer: function itemRenderer(row, column) {
|
|
539
|
-
return row[column.key];
|
|
540
|
-
}
|
|
541
|
-
};
|
|
585
|
+
DataRow.defaultProps = defaultProps$1;
|
|
542
586
|
DataRow.displayName = 'DataRow';
|
|
587
|
+
var DataRow$1 = DataRow;
|
|
543
588
|
|
|
544
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
589
|
+
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
|
|
545
590
|
|
|
546
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default[
|
|
591
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context4; _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; }
|
|
547
592
|
var MINIMUM_COLUMN_SIZE = 32; // calculates size on mouse-drag and enforces a minimum size
|
|
548
593
|
|
|
549
|
-
var calculateNewSize = function calculateNewSize(
|
|
594
|
+
var calculateNewSize = function calculateNewSize() {
|
|
595
|
+
var initialSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
596
|
+
var initialMousePosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
597
|
+
var newMousePosition = arguments.length > 2 ? arguments[2] : undefined;
|
|
550
598
|
var minSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MINIMUM_COLUMN_SIZE;
|
|
551
599
|
var newSize = initialSize - (initialMousePosition - newMousePosition);
|
|
552
600
|
return minSize > newSize ? minSize : newSize;
|
|
553
601
|
};
|
|
554
602
|
|
|
555
|
-
var setColumnWidth = function setColumnWidth(
|
|
603
|
+
var setColumnWidth = function setColumnWidth() {
|
|
604
|
+
var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
605
|
+
var position = arguments.length > 1 ? arguments[1] : undefined;
|
|
606
|
+
var value = arguments.length > 2 ? arguments[2] : undefined;
|
|
556
607
|
// columns => comes from state.sizes which reflects component's state
|
|
557
608
|
// any update to the columns results in updating the state
|
|
558
|
-
|
|
559
|
-
columns[position] = _objectSpread(_objectSpread({}, columns[position]), {}, {
|
|
609
|
+
columns[position] = _objectSpread$1(_objectSpread$1({}, columns[position]), {}, {
|
|
560
610
|
width: value
|
|
561
611
|
});
|
|
562
612
|
return columns;
|
|
563
613
|
};
|
|
564
614
|
|
|
565
615
|
var getGridTemplateColumnsStyle = function getGridTemplateColumnsStyle(columns) {
|
|
566
|
-
return "".concat(_mapInstanceProperty__default[
|
|
616
|
+
return "".concat(_mapInstanceProperty__default["default"](columns).call(columns, function (width) {
|
|
567
617
|
return "".concat(width || 0, "px");
|
|
568
618
|
}).join(' '));
|
|
569
619
|
};
|
|
@@ -583,25 +633,25 @@ function reducer(state, action) {
|
|
|
583
633
|
switch (action.type) {
|
|
584
634
|
case 'reset':
|
|
585
635
|
{
|
|
586
|
-
return _objectSpread({}, initialState(state.tableRef));
|
|
636
|
+
return _objectSpread$1({}, initialState(state.tableRef));
|
|
587
637
|
}
|
|
588
638
|
|
|
589
639
|
case 'registerColumnMeasurements':
|
|
590
640
|
{
|
|
591
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
641
|
+
return _objectSpread$1(_objectSpread$1({}, state), {}, {
|
|
592
642
|
sizes: action.payload.sizes
|
|
593
643
|
});
|
|
594
644
|
}
|
|
595
645
|
|
|
596
646
|
case 'startResizing':
|
|
597
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
647
|
+
return _objectSpread$1(_objectSpread$1({}, state), {}, {
|
|
598
648
|
initialColWidth: action.payload.initialColWidth,
|
|
599
649
|
initialMousePosition: action.payload.initialMousePosition,
|
|
600
650
|
columnBeingResized: action.payload.columnBeingResized
|
|
601
651
|
});
|
|
602
652
|
|
|
603
653
|
case 'finishResizing':
|
|
604
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
654
|
+
return _objectSpread$1(_objectSpread$1({}, state), {}, {
|
|
605
655
|
initialColWidth: undefined,
|
|
606
656
|
initialMousePosition: undefined,
|
|
607
657
|
columnBeingResized: undefined,
|
|
@@ -609,33 +659,35 @@ function reducer(state, action) {
|
|
|
609
659
|
});
|
|
610
660
|
|
|
611
661
|
default:
|
|
612
|
-
|
|
662
|
+
return state;
|
|
613
663
|
}
|
|
614
664
|
}
|
|
615
665
|
|
|
616
666
|
var useManualResizingReducer = function useManualResizingReducer(tableRef) {
|
|
617
|
-
var
|
|
618
|
-
|
|
619
|
-
manualResizingState =
|
|
620
|
-
dispatch =
|
|
667
|
+
var _useReducer = react$1.useReducer(reducer, initialState(tableRef)),
|
|
668
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
669
|
+
manualResizingState = _useReducer2[0],
|
|
670
|
+
dispatch = _useReducer2[1];
|
|
621
671
|
|
|
622
|
-
|
|
672
|
+
react$1.useDebugValue(manualResizingState);
|
|
623
673
|
return [manualResizingState, dispatch];
|
|
624
674
|
};
|
|
625
675
|
|
|
626
676
|
var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
677
|
+
var _state$tableRef;
|
|
678
|
+
|
|
627
679
|
var _useManualResizingRed = useManualResizingReducer(tableRef),
|
|
628
680
|
_useManualResizingRed2 = _slicedToArray(_useManualResizingRed, 2),
|
|
629
681
|
state = _useManualResizingRed2[0],
|
|
630
682
|
dispatch = _useManualResizingRed2[1]; // if the table element has been rendered and we haven't yet measured the columns
|
|
631
683
|
|
|
632
684
|
|
|
633
|
-
if (state.tableRef.current && !state.sizes) {
|
|
685
|
+
if ((_state$tableRef = state.tableRef) !== null && _state$tableRef !== void 0 && _state$tableRef.current && !state.sizes) {
|
|
634
686
|
var _context;
|
|
635
687
|
|
|
636
688
|
var renderedColumnMeasurements = [];
|
|
637
689
|
|
|
638
|
-
_forEachInstanceProperty__default[
|
|
690
|
+
_forEachInstanceProperty__default["default"](_context = state.tableRef.current.querySelectorAll('th')).call(_context, function (header) {
|
|
639
691
|
renderedColumnMeasurements.push({
|
|
640
692
|
key: header.getAttribute('data-id'),
|
|
641
693
|
width: header.getBoundingClientRect().width
|
|
@@ -662,15 +714,17 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
662
714
|
};
|
|
663
715
|
|
|
664
716
|
var onDragResizing = function onDragResizing(event, columnIndex) {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
717
|
+
// throttle and sync resizing update rate with screen refresh rate
|
|
718
|
+
requestAnimationFrame(function () {
|
|
719
|
+
var _state$tableRef2;
|
|
720
|
+
|
|
721
|
+
var width = calculateNewSize(state.initialColWidth, state.initialMousePosition, event.clientX);
|
|
722
|
+
var newColumnsSizes = setColumnWidth(state.sizes, columnIndex, width);
|
|
723
|
+
if (!((_state$tableRef2 = state.tableRef) !== null && _state$tableRef2 !== void 0 && _state$tableRef2.current)) return;
|
|
724
|
+
state.tableRef.current.style.gridTemplateColumns = getGridTemplateColumnsStyle(_mapInstanceProperty__default["default"](newColumnsSizes).call(newColumnsSizes, function (newColumnsSize) {
|
|
725
|
+
return newColumnsSize.width;
|
|
726
|
+
}));
|
|
727
|
+
});
|
|
674
728
|
};
|
|
675
729
|
|
|
676
730
|
var finishResizing = function finishResizing() {
|
|
@@ -699,12 +753,15 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
699
753
|
return -1;
|
|
700
754
|
}
|
|
701
755
|
|
|
702
|
-
return _reduceInstanceProperty__default[
|
|
756
|
+
return _reduceInstanceProperty__default["default"](_context2 = state.sizes).call(_context2, function (a, b) {
|
|
703
757
|
return a + b.width;
|
|
704
758
|
}, 0);
|
|
705
759
|
};
|
|
706
760
|
|
|
707
761
|
var reset = function reset() {
|
|
762
|
+
var _state$tableRef3;
|
|
763
|
+
|
|
764
|
+
if (!((_state$tableRef3 = state.tableRef) !== null && _state$tableRef3 !== void 0 && _state$tableRef3.current)) return;
|
|
708
765
|
state.tableRef.current.style.gridTemplateColumns = '';
|
|
709
766
|
return dispatch({
|
|
710
767
|
type: 'reset'
|
|
@@ -715,7 +772,7 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
715
772
|
return state.sizes;
|
|
716
773
|
};
|
|
717
774
|
|
|
718
|
-
|
|
775
|
+
react$1.useDebugValue(state);
|
|
719
776
|
return {
|
|
720
777
|
reset: reset,
|
|
721
778
|
getSizes: getSizes,
|
|
@@ -729,11 +786,17 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
729
786
|
};
|
|
730
787
|
};
|
|
731
788
|
|
|
789
|
+
var useManualColumnResizing$1 = useManualColumnResizing;
|
|
790
|
+
|
|
791
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
|
|
792
|
+
|
|
793
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source), true)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context5; _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(source))).call(_context5, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
794
|
+
|
|
732
795
|
var getColumnsLayoutInfo = function getColumnsLayoutInfo(columns) {
|
|
733
|
-
return _reduceInstanceProperty__default[
|
|
796
|
+
return _reduceInstanceProperty__default["default"](columns).call(columns, function (acc, currentValue) {
|
|
734
797
|
var _context;
|
|
735
798
|
|
|
736
|
-
return _concatInstanceProperty__default[
|
|
799
|
+
return _concatInstanceProperty__default["default"](_context = []).call(_context, _toConsumableArray(acc), [{
|
|
737
800
|
key: currentValue.key,
|
|
738
801
|
width: currentValue.width
|
|
739
802
|
}]);
|
|
@@ -746,10 +809,22 @@ var shouldRenderRowBottomBorder = function shouldRenderRowBottomBorder(rowIndex,
|
|
|
746
809
|
return false;
|
|
747
810
|
};
|
|
748
811
|
|
|
812
|
+
var defaultProps = {
|
|
813
|
+
isCondensed: false,
|
|
814
|
+
wrapHeaderLabels: true,
|
|
815
|
+
verticalCellAlignment: 'top',
|
|
816
|
+
horizontalCellAlignment: 'left',
|
|
817
|
+
disableSelfContainment: false,
|
|
818
|
+
// @ts-ignore
|
|
819
|
+
itemRenderer: function itemRenderer(row, column) {
|
|
820
|
+
return row[column.key];
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
|
|
749
824
|
var DataTable = function DataTable(props) {
|
|
750
825
|
var _context2, _context3;
|
|
751
|
-
var tableRef =
|
|
752
|
-
var columnResizingReducer = useManualColumnResizing(tableRef); // if the table columns have been measured
|
|
826
|
+
var tableRef = react$1.useRef();
|
|
827
|
+
var columnResizingReducer = useManualColumnResizing$1(tableRef); // if the table columns have been measured
|
|
753
828
|
// and if the list of columns, their width field, or the isCondensed prop has changed
|
|
754
829
|
// then we need to reset the resized column widths
|
|
755
830
|
|
|
@@ -762,90 +837,88 @@ var DataTable = function DataTable(props) {
|
|
|
762
837
|
columns: columnsInfo,
|
|
763
838
|
isCondensed: props.isCondensed
|
|
764
839
|
};
|
|
765
|
-
|
|
766
|
-
|
|
840
|
+
var hasLayoutChanged = !isEqual__default["default"](prevLayout, currentLayout);
|
|
841
|
+
react$1.useLayoutEffect(function () {
|
|
842
|
+
if (hasLayoutChanged) {
|
|
767
843
|
columnResizingReducer.reset();
|
|
768
844
|
}
|
|
769
|
-
}, [
|
|
845
|
+
}, [columnResizingReducer, hasLayoutChanged]);
|
|
770
846
|
var hasTableBeenResized = columnResizingReducer.getHasTableBeenResized();
|
|
771
|
-
var resizedTotalWidth = hasTableBeenResized ? columnResizingReducer.getTotalResizedTableWidth() + ( // if the table has a maxHeight, it might add a scrollbar which takes space inside the container
|
|
847
|
+
var resizedTotalWidth = hasTableBeenResized && tableRef.current ? columnResizingReducer.getTotalResizedTableWidth() + ( // if the table has a maxHeight, it might add a scrollbar which takes space inside the container
|
|
772
848
|
tableRef.current.offsetWidth - tableRef.current.clientWidth) : undefined;
|
|
773
|
-
return
|
|
849
|
+
return jsxRuntime.jsxs(TableContainer, {
|
|
774
850
|
maxWidth: props.maxWidth,
|
|
775
851
|
isBeingResized: columnResizingReducer.getIsAnyColumnBeingResized(),
|
|
776
|
-
disableSelfContainment: props.disableSelfContainment
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
852
|
+
disableSelfContainment: !!props.disableSelfContainment,
|
|
853
|
+
children: [jsxRuntime.jsx(TableGrid, _objectSpread(_objectSpread({
|
|
854
|
+
ref: tableRef
|
|
855
|
+
}, utils.filterDataAttributes(props)), {}, {
|
|
856
|
+
columns: props.columns,
|
|
857
|
+
maxHeight: props.maxHeight,
|
|
858
|
+
disableSelfContainment: !!props.disableSelfContainment,
|
|
859
|
+
resizedTotalWidth: resizedTotalWidth,
|
|
860
|
+
children: jsxRuntime.jsxs(ColumnResizingContext.Provider, {
|
|
861
|
+
value: columnResizingReducer,
|
|
862
|
+
children: [jsxRuntime.jsx(Header, {
|
|
863
|
+
children: jsxRuntime.jsx(Row, {
|
|
864
|
+
children: props.columns && _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, function (column) {
|
|
865
|
+
return jsxRuntime.jsx(HeaderCell$1, {
|
|
866
|
+
shouldWrap: props.wrapHeaderLabels,
|
|
867
|
+
isCondensed: props.isCondensed,
|
|
868
|
+
iconComponent: column.headerIcon,
|
|
869
|
+
onColumnResized: props.onColumnResized,
|
|
870
|
+
disableResizing: column.disableResizing,
|
|
871
|
+
horizontalCellAlignment: column.align ? column.align : props.horizontalCellAlignment,
|
|
872
|
+
disableHeaderStickiness: props.disableHeaderStickiness,
|
|
873
|
+
columnWidth: column.width
|
|
874
|
+
/* Sorting Props */
|
|
875
|
+
,
|
|
876
|
+
onClick: props.onSortChange && props.onSortChange,
|
|
877
|
+
sortedBy: props.sortedBy,
|
|
878
|
+
columnKey: column.key,
|
|
879
|
+
isSortable: column.isSortable,
|
|
880
|
+
sortDirection: props.sortDirection,
|
|
881
|
+
children: column.label
|
|
882
|
+
}, column.key);
|
|
883
|
+
})
|
|
884
|
+
})
|
|
885
|
+
}), jsxRuntime.jsx(Body, {
|
|
886
|
+
children: _mapInstanceProperty__default["default"](_context3 = props.rows).call(_context3, function (row, rowIndex) {
|
|
887
|
+
return react.createElement(DataRow$1, _objectSpread(_objectSpread({}, props), {}, {
|
|
888
|
+
row: row,
|
|
889
|
+
key: row.id,
|
|
890
|
+
rowIndex: rowIndex,
|
|
891
|
+
shouldClipContent: columnResizingReducer.getIsAnyColumnBeingResized() || hasTableBeenResized,
|
|
892
|
+
shouldRenderBottomBorder: shouldRenderRowBottomBorder(rowIndex, props.rows.length, props.footer)
|
|
893
|
+
}));
|
|
894
|
+
})
|
|
895
|
+
})]
|
|
896
|
+
})
|
|
897
|
+
})), props.footer && jsxRuntime.jsx(Footer$1, {
|
|
898
|
+
"data-testid": "footer",
|
|
790
899
|
isCondensed: props.isCondensed,
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
disableHeaderStickiness: props.disableHeaderStickiness,
|
|
797
|
-
columnWidth: column.width
|
|
798
|
-
/* Sorting Props */
|
|
799
|
-
,
|
|
800
|
-
onClick: props.onSortChange,
|
|
801
|
-
sortedBy: props.sortedBy,
|
|
802
|
-
columnKey: column.key,
|
|
803
|
-
isSortable: column.isSortable,
|
|
804
|
-
sortDirection: props.sortDirection
|
|
805
|
-
}, column.label);
|
|
806
|
-
}))), react.jsx(Body, null, _mapInstanceProperty__default['default'](_context3 = props.rows).call(_context3, function (row, rowIndex) {
|
|
807
|
-
return react.jsx(DataRow, _extends({}, props, {
|
|
808
|
-
row: row,
|
|
809
|
-
key: row.id,
|
|
810
|
-
rowIndex: rowIndex,
|
|
811
|
-
shouldClipContent: columnResizingReducer.getIsAnyColumnBeingResized() || hasTableBeenResized,
|
|
812
|
-
shouldRenderBottomBorder: shouldRenderRowBottomBorder(rowIndex, props.rows.length, props.footer)
|
|
813
|
-
}));
|
|
814
|
-
})))), props.footer && react.jsx(Footer, {
|
|
815
|
-
"data-testid": "footer",
|
|
816
|
-
isCondensed: props.isCondensed,
|
|
817
|
-
horizontalCellAlignment: props.horizontalCellAlignment,
|
|
818
|
-
resizedTotalWidth: resizedTotalWidth
|
|
819
|
-
}, props.footer));
|
|
900
|
+
horizontalCellAlignment: props.horizontalCellAlignment,
|
|
901
|
+
resizedTotalWidth: resizedTotalWidth,
|
|
902
|
+
children: props.footer
|
|
903
|
+
})]
|
|
904
|
+
});
|
|
820
905
|
};
|
|
821
906
|
|
|
822
907
|
DataTable.propTypes = {};
|
|
823
|
-
DataTable.defaultProps =
|
|
824
|
-
isCondensed: false,
|
|
825
|
-
wrapHeaderLabels: true,
|
|
826
|
-
verticalCellAlignment: 'top',
|
|
827
|
-
horizontalCellAlignment: 'left',
|
|
828
|
-
disableSelfContainment: false,
|
|
829
|
-
itemRenderer: function itemRenderer(row, column) {
|
|
830
|
-
return row[column.key];
|
|
831
|
-
}
|
|
832
|
-
};
|
|
908
|
+
DataTable.defaultProps = defaultProps;
|
|
833
909
|
DataTable.displayName = 'DataTable';
|
|
910
|
+
var DataTable$1 = DataTable;
|
|
834
911
|
|
|
835
|
-
// NOTE: This string will be replaced
|
|
836
|
-
var version =
|
|
912
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
913
|
+
var version = "12.2.5";
|
|
837
914
|
|
|
838
915
|
Object.defineProperty(exports, 'useRowSelection', {
|
|
839
916
|
enumerable: true,
|
|
840
|
-
get: function () {
|
|
841
|
-
return hooks.useRowSelection;
|
|
842
|
-
}
|
|
917
|
+
get: function () { return hooks.useRowSelection; }
|
|
843
918
|
});
|
|
844
919
|
Object.defineProperty(exports, 'useSorting', {
|
|
845
920
|
enumerable: true,
|
|
846
|
-
get: function () {
|
|
847
|
-
return hooks.useSorting;
|
|
848
|
-
}
|
|
921
|
+
get: function () { return hooks.useSorting; }
|
|
849
922
|
});
|
|
850
|
-
exports
|
|
923
|
+
exports["default"] = DataTable$1;
|
|
851
924
|
exports.version = version;
|