@commercetools-uikit/data-table 12.2.2 → 12.2.6
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 +441 -593
- package/dist/commercetools-uikit-data-table.cjs.prod.js +344 -293
- package/dist/commercetools-uikit-data-table.esm.js +406 -552
- 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 +10 -14
|
@@ -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,11 +147,11 @@ 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
156
|
var _ref$1 = {
|
|
160
157
|
name: "1a5erbp",
|
|
@@ -166,29 +163,29 @@ 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
173
|
return props.shouldIgnoreRowClick ? _ref$1 : '';
|
|
177
|
-
}, ";");
|
|
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;
|
|
@@ -198,7 +195,7 @@ var convertNumericDimensionToPixelValue$1 = convertNumericDimensionToPixelValue;
|
|
|
198
195
|
|
|
199
196
|
var getClickableRowStyle = function getClickableRowStyle(props) {
|
|
200
197
|
if (props.isRowClickable) {
|
|
201
|
-
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, ";}" + ("" ), "" );
|
|
202
199
|
}
|
|
203
200
|
|
|
204
201
|
return '';
|
|
@@ -217,65 +214,62 @@ var getDisabledSelfContainmentStyles = function getDisabledSelfContainmentStyles
|
|
|
217
214
|
return '';
|
|
218
215
|
};
|
|
219
216
|
|
|
220
|
-
var TableContainer = _styled__default[
|
|
221
|
-
target: "
|
|
217
|
+
var TableContainer = _styled__default["default"]("div", {
|
|
218
|
+
target: "epk01s24"
|
|
222
219
|
} )("position:relative;z-index:0;overflow-x:auto;", function (props) {
|
|
223
220
|
return props.maxWidth && !props.disableSelfContainment ? "max-width: ".concat(convertNumericDimensionToPixelValue$1(props.maxWidth), ";") : '';
|
|
224
221
|
}, " ", function (props) {
|
|
225
222
|
return props.isBeingResized && "\n * {\n user-select: none;\n }";
|
|
226
|
-
}, " ", getDisabledSelfContainmentStyles, ";");
|
|
223
|
+
}, " ", getDisabledSelfContainmentStyles, ";" + ("" ));
|
|
227
224
|
|
|
228
|
-
var TableGrid = _styled__default[
|
|
229
|
-
target: "
|
|
225
|
+
var TableGrid = _styled__default["default"]("table", {
|
|
226
|
+
target: "epk01s23"
|
|
230
227
|
} )("display:grid;grid-template-columns:", function (props) {
|
|
231
228
|
var _context;
|
|
232
229
|
|
|
233
|
-
return _mapInstanceProperty__default[
|
|
230
|
+
return props.columns && _mapInstanceProperty__default["default"](_context = props.columns).call(_context, function (column) {
|
|
234
231
|
return column.width || 'auto';
|
|
235
232
|
}).join(' ');
|
|
236
233
|
}, ";overflow-y:auto;", function (props) {
|
|
237
234
|
return props.maxHeight && !props.disableSelfContainment ? "max-height: ".concat(convertNumericDimensionToPixelValue$1(props.maxHeight), ";") : '';
|
|
238
235
|
}, " ", function (props) {
|
|
239
236
|
return props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '';
|
|
240
|
-
}, " ", getDisabledSelfContainmentStyles, ";");
|
|
237
|
+
}, " ", getDisabledSelfContainmentStyles, ";" + ("" ));
|
|
241
238
|
|
|
242
|
-
var Header = _styled__default[
|
|
243
|
-
target: "
|
|
239
|
+
var Header = _styled__default["default"]("thead", {
|
|
240
|
+
target: "epk01s22"
|
|
244
241
|
} )({
|
|
245
242
|
name: "49aokf",
|
|
246
243
|
styles: "display:contents"
|
|
247
244
|
} );
|
|
248
245
|
|
|
249
|
-
var Body = _styled__default[
|
|
250
|
-
target: "
|
|
246
|
+
var Body = _styled__default["default"]("tbody", {
|
|
247
|
+
target: "epk01s21"
|
|
251
248
|
} )({
|
|
252
249
|
name: "49aokf",
|
|
253
250
|
styles: "display:contents"
|
|
254
251
|
} );
|
|
255
252
|
|
|
256
|
-
var Row = _styled__default[
|
|
257
|
-
target: "
|
|
258
|
-
} )("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;}}" + ("" ));
|
|
259
256
|
|
|
260
|
-
var
|
|
261
|
-
|
|
257
|
+
var defaultProps$4 = {
|
|
258
|
+
horizontalCellAlignment: 'left'
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
var Footer = _styled__default["default"]("div", {
|
|
262
|
+
target: "e2ce7vj0"
|
|
262
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) {
|
|
263
264
|
return props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '';
|
|
264
|
-
}, ";");
|
|
265
|
+
}, ";" + ("" ));
|
|
265
266
|
|
|
266
267
|
Footer.displayName = 'Footer';
|
|
267
|
-
Footer.
|
|
268
|
-
children: PropTypes__default['default'].node.isRequired,
|
|
269
|
-
isCondensed: PropTypes__default['default'].bool,
|
|
270
|
-
horizontalCellAlignment: PropTypes__default['default'].oneOf(['left', 'center', 'right'])
|
|
271
|
-
};
|
|
272
|
-
Footer.defaultProps = {
|
|
273
|
-
horizontalCellAlignment: 'left'
|
|
274
|
-
};
|
|
268
|
+
Footer.defaultProps = defaultProps$4;
|
|
275
269
|
var Footer$1 = Footer;
|
|
276
270
|
|
|
277
271
|
var getButtonStyle = function getButtonStyle() {
|
|
278
|
-
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;" + ("" ), "" );
|
|
279
273
|
};
|
|
280
274
|
/* A sortable header has the two arrow svg icons
|
|
281
275
|
* GIVEN column is sortable and is not focused
|
|
@@ -289,11 +283,11 @@ var getButtonStyle = function getButtonStyle() {
|
|
|
289
283
|
|
|
290
284
|
|
|
291
285
|
var getSortableHeaderStyles = function getSortableHeaderStyles(props) {
|
|
292
|
-
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, ";}}}" + ("" ));
|
|
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, ";}}}" + ("" ), "" );
|
|
293
287
|
};
|
|
294
288
|
|
|
295
|
-
var HeaderCellInner = _styled__default[
|
|
296
|
-
target: "
|
|
289
|
+
var HeaderCellInner = _styled__default["default"]("div", {
|
|
290
|
+
target: "e1ipt8n23"
|
|
297
291
|
} )("box-sizing:border-box;display:flex;justify-content:space-between;padding:0 ", function (props) {
|
|
298
292
|
return props.isCondensed ? designSystem.customProperties.spacingS : designSystem.customProperties.spacingM;
|
|
299
293
|
}, ";", getCellInnerStyles, " ", function (props) {
|
|
@@ -302,68 +296,75 @@ var HeaderCellInner = _styled__default['default']("div", {
|
|
|
302
296
|
return props.as === 'button' ? getButtonStyle() : '';
|
|
303
297
|
}, ";", function (props) {
|
|
304
298
|
return props.shouldWrap ? '' : 'white-space: nowrap';
|
|
305
|
-
}, ";");
|
|
299
|
+
}, ";" + ("" ));
|
|
306
300
|
|
|
307
|
-
var BaseHeaderCell = _styled__default[
|
|
308
|
-
target: "
|
|
301
|
+
var BaseHeaderCell = _styled__default["default"]("th", {
|
|
302
|
+
target: "e1ipt8n22"
|
|
309
303
|
} )("color:", designSystem.customProperties.colorSurface, ";background-color:", designSystem.customProperties.colorAccent, ";position:", function (props) {
|
|
310
304
|
return props.disableHeaderStickiness ? 'relative' : 'sticky';
|
|
311
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) {
|
|
312
306
|
return props.shouldClipContent ? 'overflow: hidden;' : '';
|
|
313
|
-
}, ";}");
|
|
307
|
+
}, ";}" + ("" ));
|
|
314
308
|
|
|
315
|
-
var HeaderLabelWrapper = _styled__default[
|
|
316
|
-
target: "
|
|
317
|
-
} )("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;" + ("" ));
|
|
318
312
|
|
|
319
|
-
var HeaderIconWrapper = _styled__default[
|
|
320
|
-
target: "
|
|
321
|
-
} )("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;" + ("" ));
|
|
322
316
|
|
|
323
|
-
var ResizerIndicator = _styled__default[
|
|
324
|
-
target: "
|
|
317
|
+
var ResizerIndicator = _styled__default["default"]("div", {
|
|
318
|
+
target: "e1ccic7f1"
|
|
325
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
|
|
326
320
|
) {
|
|
327
321
|
return props.isOnDataCell ? 'visibility: visible; height: calc(100% + 1px);' : '';
|
|
328
|
-
}, ";");
|
|
322
|
+
}, ";" + ("" ));
|
|
329
323
|
|
|
330
|
-
var DraggableArea = _styled__default[
|
|
331
|
-
target: "
|
|
332
|
-
} )("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;}}" + ("" ));
|
|
333
327
|
|
|
334
328
|
var ColumnResizer = function ColumnResizer(props) {
|
|
335
|
-
return
|
|
329
|
+
return jsxRuntime.jsx(DraggableArea, {
|
|
336
330
|
role: "presentation",
|
|
337
|
-
onMouseDown: props.onMouseDown
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
331
|
+
onMouseDown: props.onMouseDown,
|
|
332
|
+
children: jsxRuntime.jsx(ResizerIndicator, {
|
|
333
|
+
isOnDataCell: props.isOnDataCell
|
|
334
|
+
})
|
|
335
|
+
});
|
|
341
336
|
};
|
|
342
337
|
|
|
343
|
-
ColumnResizer.displayName = 'ColumnResizer';
|
|
344
338
|
ColumnResizer.propTypes = {};
|
|
339
|
+
ColumnResizer.displayName = 'ColumnResizer';
|
|
345
340
|
var Resizer = ColumnResizer;
|
|
346
341
|
|
|
347
|
-
var ColumnResizingContext = /*#__PURE__*/
|
|
342
|
+
var ColumnResizingContext = /*#__PURE__*/react$1.createContext({});
|
|
348
343
|
|
|
349
344
|
var isFixedWidthValue = function isFixedWidthValue(value) {
|
|
350
|
-
return !_Number$isNaN__default[
|
|
345
|
+
return !_Number$isNaN__default["default"](_parseInt__default["default"](String(value), 10));
|
|
351
346
|
};
|
|
352
347
|
|
|
353
348
|
var isFixedWidthValue$1 = isFixedWidthValue;
|
|
354
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
|
+
|
|
355
354
|
var HeaderCellWrapper = function HeaderCellWrapper(props) {
|
|
356
|
-
var _headerRef$
|
|
355
|
+
var _headerRef$current2;
|
|
357
356
|
|
|
358
|
-
var columnResizingReducer =
|
|
359
|
-
var headerRef =
|
|
357
|
+
var columnResizingReducer = react$1.useContext(ColumnResizingContext);
|
|
358
|
+
var headerRef = react$1.useRef(null);
|
|
360
359
|
|
|
361
360
|
var onStartResizing = function onStartResizing(event) {
|
|
362
361
|
columnResizingReducer.startResizing(headerRef, event);
|
|
363
362
|
};
|
|
364
363
|
|
|
365
364
|
var onDrag = function onDrag(event) {
|
|
366
|
-
|
|
365
|
+
var _headerRef$current;
|
|
366
|
+
|
|
367
|
+
return columnResizingReducer.onDragResizing(event, (_headerRef$current = headerRef.current) === null || _headerRef$current === void 0 ? void 0 : _headerRef$current.cellIndex);
|
|
367
368
|
};
|
|
368
369
|
|
|
369
370
|
var onDragEnd = function onDragEnd() {
|
|
@@ -377,7 +378,7 @@ var HeaderCellWrapper = function HeaderCellWrapper(props) {
|
|
|
377
378
|
window.removeEventListener('mouseup', onDragEnd);
|
|
378
379
|
};
|
|
379
380
|
|
|
380
|
-
if (columnResizingReducer.getIsColumnBeingResized((_headerRef$
|
|
381
|
+
if (columnResizingReducer.getIsColumnBeingResized((_headerRef$current2 = headerRef.current) === null || _headerRef$current2 === void 0 ? void 0 : _headerRef$current2.cellIndex)) {
|
|
381
382
|
window.addEventListener('mousemove', onDrag);
|
|
382
383
|
window.addEventListener('mouseup', onDragEnd);
|
|
383
384
|
}
|
|
@@ -388,20 +389,25 @@ var HeaderCellWrapper = function HeaderCellWrapper(props) {
|
|
|
388
389
|
*/
|
|
389
390
|
|
|
390
391
|
|
|
391
|
-
var shouldClipContent = isFixedWidthValue$1(props.columnWidth) || columnResizingReducer.getHasTableBeenResized() || columnResizingReducer.getIsAnyColumnBeingResized();
|
|
392
|
-
return
|
|
392
|
+
var shouldClipContent = props.columnWidth && isFixedWidthValue$1(props.columnWidth) || columnResizingReducer.getHasTableBeenResized() || columnResizingReducer.getIsAnyColumnBeingResized();
|
|
393
|
+
return jsxRuntime.jsxs(BaseHeaderCell, {
|
|
393
394
|
ref: headerRef,
|
|
394
395
|
"data-testid": "header-".concat(props.columnKey),
|
|
395
396
|
"data-id": props.columnKey,
|
|
396
397
|
shouldClipContent: shouldClipContent,
|
|
397
|
-
disableHeaderStickiness: props.disableHeaderStickiness
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
398
|
+
disableHeaderStickiness: props.disableHeaderStickiness,
|
|
399
|
+
children: [props.children, !props.disableResizing && jsxRuntime.jsx(Resizer, {
|
|
400
|
+
onMouseDown: onStartResizing
|
|
401
|
+
})]
|
|
402
|
+
});
|
|
401
403
|
};
|
|
402
404
|
|
|
403
|
-
HeaderCellWrapper.propTypes = {};
|
|
404
405
|
HeaderCellWrapper.displayName = 'HeaderCellWrapper';
|
|
406
|
+
var defaultProps$3 = {
|
|
407
|
+
sortDirection: 'desc',
|
|
408
|
+
disableHeaderStickiness: false,
|
|
409
|
+
horizontalCellAlignment: 'left'
|
|
410
|
+
};
|
|
405
411
|
|
|
406
412
|
var HeaderCell = function HeaderCell(props) {
|
|
407
413
|
var sortableHeaderProps = {};
|
|
@@ -415,98 +421,126 @@ var HeaderCell = function HeaderCell(props) {
|
|
|
415
421
|
as: 'button',
|
|
416
422
|
label: props.sortDirection,
|
|
417
423
|
onClick: function onClick() {
|
|
418
|
-
return props.onClick(props.columnKey, nextSortDirection);
|
|
424
|
+
return props.onClick && props.onClick(props.columnKey, nextSortDirection);
|
|
419
425
|
},
|
|
420
426
|
isActive: isActive,
|
|
421
427
|
isSortable: true
|
|
422
428
|
};
|
|
423
429
|
}
|
|
424
430
|
|
|
425
|
-
return
|
|
431
|
+
return jsxRuntime.jsx(HeaderCellWrapper, {
|
|
426
432
|
columnWidth: props.columnWidth,
|
|
427
433
|
columnKey: props.columnKey,
|
|
428
434
|
onColumnResized: props.onColumnResized,
|
|
429
435
|
disableResizing: props.disableResizing,
|
|
430
|
-
disableHeaderStickiness: props.disableHeaderStickiness
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
436
|
+
disableHeaderStickiness: props.disableHeaderStickiness,
|
|
437
|
+
children: jsxRuntime.jsxs(HeaderCellInner, _objectSpread$3(_objectSpread$3({
|
|
438
|
+
shouldWrap: props.shouldWrap,
|
|
439
|
+
isCondensed: props.isCondensed,
|
|
440
|
+
horizontalCellAlignment: props.horizontalCellAlignment
|
|
441
|
+
}, sortableHeaderProps), {}, {
|
|
442
|
+
children: [props.iconComponent && jsxRuntime.jsx(HeaderIconWrapper, {
|
|
443
|
+
children: props.iconComponent
|
|
444
|
+
}), jsxRuntime.jsx(HeaderLabelWrapper, {
|
|
445
|
+
children: props.children
|
|
446
|
+
}), props.isSortable && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
447
|
+
children: [jsxRuntime.jsx(icons.AngleUpDownIcon, {
|
|
448
|
+
size: "medium",
|
|
449
|
+
color: "surface",
|
|
450
|
+
"data-icon-state": "inactive"
|
|
451
|
+
}), jsxRuntime.jsx(SortingIcon, {
|
|
452
|
+
size: "medium",
|
|
453
|
+
color: "surface",
|
|
454
|
+
"data-icon-state": "active"
|
|
455
|
+
})]
|
|
456
|
+
})]
|
|
457
|
+
}))
|
|
458
|
+
});
|
|
444
459
|
};
|
|
445
460
|
|
|
446
|
-
HeaderCell.displayName = 'HeaderCell';
|
|
447
461
|
HeaderCell.propTypes = {};
|
|
448
|
-
HeaderCell.
|
|
449
|
-
|
|
450
|
-
disableHeaderStickiness: false,
|
|
451
|
-
horizontalCellAlignment: 'left'
|
|
452
|
-
};
|
|
462
|
+
HeaderCell.displayName = 'HeaderCell';
|
|
463
|
+
HeaderCell.defaultProps = defaultProps$3;
|
|
453
464
|
var HeaderCell$1 = HeaderCell;
|
|
454
465
|
|
|
466
|
+
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; }
|
|
467
|
+
|
|
468
|
+
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; }
|
|
469
|
+
var defaultProps$2 = {
|
|
470
|
+
isTruncated: false,
|
|
471
|
+
shouldRenderBottomBorder: true
|
|
472
|
+
};
|
|
473
|
+
|
|
455
474
|
var DataCell = function DataCell(props) {
|
|
475
|
+
if (props.shouldRenderCollapseButton) ;
|
|
476
|
+
|
|
456
477
|
var Icon = props.isRowCollapsed ? icons.RightTriangleFilledIcon : icons.RightTriangleLinearIcon;
|
|
457
|
-
return
|
|
478
|
+
return jsxRuntime.jsxs(BaseCell, {
|
|
458
479
|
onClick: props.onCellClick,
|
|
459
480
|
shouldIgnoreRowClick: props.shouldIgnoreRowClick,
|
|
460
481
|
shouldClipContent: props.isTruncated && !props.shouldRenderResizingIndicator,
|
|
461
|
-
shouldRenderBottomBorder: props.shouldRenderBottomBorder
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
event
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
482
|
+
shouldRenderBottomBorder: props.shouldRenderBottomBorder,
|
|
483
|
+
children: [jsxRuntime.jsx(CellInner, _objectSpread$2(_objectSpread$2({
|
|
484
|
+
isCondensed: props.isCondensed,
|
|
485
|
+
isTruncated: props.isTruncated,
|
|
486
|
+
verticalCellAlignment: props.verticalCellAlignment,
|
|
487
|
+
horizontalCellAlignment: props.horizontalCellAlignment
|
|
488
|
+
}, utils.filterDataAttributes(props)), {}, {
|
|
489
|
+
children: props.children
|
|
490
|
+
})), props.shouldRenderCollapseButton && jsxRuntime.jsx(RowExpandCollapseButton, {
|
|
491
|
+
label: "Expand/Collapse Row",
|
|
492
|
+
onClick: function onClick(event) {
|
|
493
|
+
if (props.handleRowCollapseClick) props.handleRowCollapseClick();
|
|
494
|
+
event.stopPropagation();
|
|
495
|
+
},
|
|
496
|
+
isRowCollapsed: props.isRowCollapsed,
|
|
497
|
+
children: jsxRuntime.jsx(Icon, {
|
|
498
|
+
size: "small"
|
|
499
|
+
})
|
|
500
|
+
}), props.shouldRenderResizingIndicator && jsxRuntime.jsx(Resizer, {
|
|
501
|
+
isOnDataCell: true
|
|
502
|
+
})]
|
|
503
|
+
});
|
|
479
504
|
};
|
|
480
505
|
|
|
481
|
-
DataCell.displayName = 'DataCell';
|
|
482
506
|
DataCell.propTypes = {};
|
|
483
|
-
DataCell.
|
|
484
|
-
|
|
485
|
-
shouldRenderBottomBorder: true
|
|
486
|
-
};
|
|
507
|
+
DataCell.displayName = 'DataCell';
|
|
508
|
+
DataCell.defaultProps = defaultProps$2;
|
|
487
509
|
var DataCell$1 = DataCell;
|
|
488
510
|
|
|
511
|
+
var defaultProps$1 = {
|
|
512
|
+
isCondensed: false,
|
|
513
|
+
shouldClipContent: false,
|
|
514
|
+
verticalCellAlignment: 'top',
|
|
515
|
+
horizontalCellAlignment: 'left',
|
|
516
|
+
shouldRenderBottomBorder: true,
|
|
517
|
+
// @ts-ignore
|
|
518
|
+
itemRenderer: function itemRenderer(row, column) {
|
|
519
|
+
return row[column.key];
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
|
|
489
523
|
var DataRow = function DataRow(props) {
|
|
490
524
|
var _context, _context2;
|
|
491
525
|
|
|
492
|
-
var
|
|
493
|
-
getIsColumnBeingResized =
|
|
526
|
+
var _ref = react$1.useContext(ColumnResizingContext),
|
|
527
|
+
getIsColumnBeingResized = _ref.getIsColumnBeingResized;
|
|
494
528
|
|
|
495
|
-
var rowHasTruncatedColumn = _someInstanceProperty__default[
|
|
529
|
+
var rowHasTruncatedColumn = _someInstanceProperty__default["default"](_context = props.columns).call(_context, function (column) {
|
|
496
530
|
return column.isTruncated;
|
|
497
531
|
});
|
|
498
532
|
|
|
499
|
-
var
|
|
500
|
-
|
|
501
|
-
isRowCollapsed =
|
|
502
|
-
collapseRow =
|
|
533
|
+
var _useState = react$1.useState(rowHasTruncatedColumn),
|
|
534
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
535
|
+
isRowCollapsed = _useState2[0],
|
|
536
|
+
collapseRow = _useState2[1];
|
|
503
537
|
|
|
504
538
|
var handleRowCollapseClick = function handleRowCollapseClick() {
|
|
505
539
|
collapseRow(!isRowCollapsed);
|
|
506
540
|
}; // update the collapsed state if isTruncated options are changed for the whole row
|
|
507
541
|
|
|
508
542
|
|
|
509
|
-
|
|
543
|
+
react$1.useEffect(function () {
|
|
510
544
|
if (rowHasTruncatedColumn) {
|
|
511
545
|
collapseRow(true);
|
|
512
546
|
} else {
|
|
@@ -518,71 +552,67 @@ var DataRow = function DataRow(props) {
|
|
|
518
552
|
return rowHasTruncatedColumn && totalColumnsLength - 1 === currentColumnIndex;
|
|
519
553
|
};
|
|
520
554
|
|
|
521
|
-
return
|
|
522
|
-
isRowClickable: props.onRowClick
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
})
|
|
555
|
+
return jsxRuntime.jsx(Row, {
|
|
556
|
+
isRowClickable: props.onRowClick,
|
|
557
|
+
children: _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, function (column, columnIndex) {
|
|
558
|
+
var _context3, _context4;
|
|
559
|
+
|
|
560
|
+
return jsxRuntime.jsx(DataCell$1, {
|
|
561
|
+
"data-testid": _concatInstanceProperty__default["default"](_context4 = "cell-".concat(props.rowIndex, "-")).call(_context4, column.key),
|
|
562
|
+
isTruncated: column.isTruncated && isRowCollapsed,
|
|
563
|
+
isCondensed: props.isCondensed,
|
|
564
|
+
isRowCollapsed: isRowCollapsed,
|
|
565
|
+
verticalCellAlignment: props.verticalCellAlignment,
|
|
566
|
+
horizontalCellAlignment: column.align ? column.align : props.horizontalCellAlignment,
|
|
567
|
+
shouldIgnoreRowClick: column.shouldIgnoreRowClick,
|
|
568
|
+
handleRowCollapseClick: handleRowCollapseClick,
|
|
569
|
+
shouldRenderCollapseButton: shouldRenderCollapseButton(props.columns.length, columnIndex),
|
|
570
|
+
onCellClick: props.onRowClick && !column.shouldIgnoreRowClick ? function () {
|
|
571
|
+
var _props$onRowClick;
|
|
572
|
+
|
|
573
|
+
return (_props$onRowClick = props.onRowClick) === null || _props$onRowClick === void 0 ? void 0 : _props$onRowClick.call(props, props.row, props.rowIndex, column.key);
|
|
574
|
+
} : undefined,
|
|
575
|
+
shouldRenderBottomBorder: props.shouldRenderBottomBorder,
|
|
576
|
+
shouldRenderResizingIndicator: getIsColumnBeingResized(columnIndex),
|
|
577
|
+
children: column.renderItem ? column.renderItem(props.row, isRowCollapsed) : props.itemRenderer(props.row, column, isRowCollapsed)
|
|
578
|
+
}, _concatInstanceProperty__default["default"](_context3 = "".concat(props.row.id, "-")).call(_context3, column.key));
|
|
579
|
+
})
|
|
580
|
+
});
|
|
547
581
|
};
|
|
548
582
|
|
|
549
583
|
DataRow.propTypes = {};
|
|
550
|
-
DataRow.defaultProps =
|
|
551
|
-
isCondensed: false,
|
|
552
|
-
shouldClipContent: false,
|
|
553
|
-
verticalCellAlignment: 'top',
|
|
554
|
-
horizontalCellAlignment: 'left',
|
|
555
|
-
shouldRenderBottomBorder: true,
|
|
556
|
-
itemRenderer: function itemRenderer(row, column) {
|
|
557
|
-
return row[column.key];
|
|
558
|
-
}
|
|
559
|
-
};
|
|
584
|
+
DataRow.defaultProps = defaultProps$1;
|
|
560
585
|
DataRow.displayName = 'DataRow';
|
|
561
586
|
var DataRow$1 = DataRow;
|
|
562
587
|
|
|
563
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
588
|
+
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; }
|
|
564
589
|
|
|
565
|
-
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[
|
|
590
|
+
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; }
|
|
566
591
|
var MINIMUM_COLUMN_SIZE = 32; // calculates size on mouse-drag and enforces a minimum size
|
|
567
592
|
|
|
568
|
-
var calculateNewSize = function calculateNewSize(
|
|
593
|
+
var calculateNewSize = function calculateNewSize() {
|
|
594
|
+
var initialSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
595
|
+
var initialMousePosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
596
|
+
var newMousePosition = arguments.length > 2 ? arguments[2] : undefined;
|
|
569
597
|
var minSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MINIMUM_COLUMN_SIZE;
|
|
570
598
|
var newSize = initialSize - (initialMousePosition - newMousePosition);
|
|
571
599
|
return minSize > newSize ? minSize : newSize;
|
|
572
600
|
};
|
|
573
601
|
|
|
574
|
-
var setColumnWidth = function setColumnWidth(
|
|
602
|
+
var setColumnWidth = function setColumnWidth() {
|
|
603
|
+
var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
604
|
+
var position = arguments.length > 1 ? arguments[1] : undefined;
|
|
605
|
+
var value = arguments.length > 2 ? arguments[2] : undefined;
|
|
575
606
|
// columns => comes from state.sizes which reflects component's state
|
|
576
607
|
// any update to the columns results in updating the state
|
|
577
|
-
|
|
578
|
-
columns[position] = _objectSpread(_objectSpread({}, columns[position]), {}, {
|
|
608
|
+
columns[position] = _objectSpread$1(_objectSpread$1({}, columns[position]), {}, {
|
|
579
609
|
width: value
|
|
580
610
|
});
|
|
581
611
|
return columns;
|
|
582
612
|
};
|
|
583
613
|
|
|
584
614
|
var getGridTemplateColumnsStyle = function getGridTemplateColumnsStyle(columns) {
|
|
585
|
-
return "".concat(_mapInstanceProperty__default[
|
|
615
|
+
return "".concat(_mapInstanceProperty__default["default"](columns).call(columns, function (width) {
|
|
586
616
|
return "".concat(width || 0, "px");
|
|
587
617
|
}).join(' '));
|
|
588
618
|
};
|
|
@@ -602,25 +632,25 @@ function reducer(state, action) {
|
|
|
602
632
|
switch (action.type) {
|
|
603
633
|
case 'reset':
|
|
604
634
|
{
|
|
605
|
-
return _objectSpread({}, initialState(state.tableRef));
|
|
635
|
+
return _objectSpread$1({}, initialState(state.tableRef));
|
|
606
636
|
}
|
|
607
637
|
|
|
608
638
|
case 'registerColumnMeasurements':
|
|
609
639
|
{
|
|
610
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
640
|
+
return _objectSpread$1(_objectSpread$1({}, state), {}, {
|
|
611
641
|
sizes: action.payload.sizes
|
|
612
642
|
});
|
|
613
643
|
}
|
|
614
644
|
|
|
615
645
|
case 'startResizing':
|
|
616
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
646
|
+
return _objectSpread$1(_objectSpread$1({}, state), {}, {
|
|
617
647
|
initialColWidth: action.payload.initialColWidth,
|
|
618
648
|
initialMousePosition: action.payload.initialMousePosition,
|
|
619
649
|
columnBeingResized: action.payload.columnBeingResized
|
|
620
650
|
});
|
|
621
651
|
|
|
622
652
|
case 'finishResizing':
|
|
623
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
653
|
+
return _objectSpread$1(_objectSpread$1({}, state), {}, {
|
|
624
654
|
initialColWidth: undefined,
|
|
625
655
|
initialMousePosition: undefined,
|
|
626
656
|
columnBeingResized: undefined,
|
|
@@ -628,33 +658,35 @@ function reducer(state, action) {
|
|
|
628
658
|
});
|
|
629
659
|
|
|
630
660
|
default:
|
|
631
|
-
|
|
661
|
+
return state;
|
|
632
662
|
}
|
|
633
663
|
}
|
|
634
664
|
|
|
635
665
|
var useManualResizingReducer = function useManualResizingReducer(tableRef) {
|
|
636
|
-
var
|
|
637
|
-
|
|
638
|
-
manualResizingState =
|
|
639
|
-
dispatch =
|
|
666
|
+
var _useReducer = react$1.useReducer(reducer, initialState(tableRef)),
|
|
667
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
668
|
+
manualResizingState = _useReducer2[0],
|
|
669
|
+
dispatch = _useReducer2[1];
|
|
640
670
|
|
|
641
|
-
|
|
671
|
+
react$1.useDebugValue(manualResizingState);
|
|
642
672
|
return [manualResizingState, dispatch];
|
|
643
673
|
};
|
|
644
674
|
|
|
645
675
|
var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
676
|
+
var _state$tableRef;
|
|
677
|
+
|
|
646
678
|
var _useManualResizingRed = useManualResizingReducer(tableRef),
|
|
647
679
|
_useManualResizingRed2 = _slicedToArray(_useManualResizingRed, 2),
|
|
648
680
|
state = _useManualResizingRed2[0],
|
|
649
681
|
dispatch = _useManualResizingRed2[1]; // if the table element has been rendered and we haven't yet measured the columns
|
|
650
682
|
|
|
651
683
|
|
|
652
|
-
if (state.tableRef.current && !state.sizes) {
|
|
684
|
+
if ((_state$tableRef = state.tableRef) !== null && _state$tableRef !== void 0 && _state$tableRef.current && !state.sizes) {
|
|
653
685
|
var _context;
|
|
654
686
|
|
|
655
687
|
var renderedColumnMeasurements = [];
|
|
656
688
|
|
|
657
|
-
_forEachInstanceProperty__default[
|
|
689
|
+
_forEachInstanceProperty__default["default"](_context = state.tableRef.current.querySelectorAll('th')).call(_context, function (header) {
|
|
658
690
|
renderedColumnMeasurements.push({
|
|
659
691
|
key: header.getAttribute('data-id'),
|
|
660
692
|
width: header.getBoundingClientRect().width
|
|
@@ -681,15 +713,17 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
681
713
|
};
|
|
682
714
|
|
|
683
715
|
var onDragResizing = function onDragResizing(event, columnIndex) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
716
|
+
// throttle and sync resizing update rate with screen refresh rate
|
|
717
|
+
requestAnimationFrame(function () {
|
|
718
|
+
var _state$tableRef2;
|
|
719
|
+
|
|
720
|
+
var width = calculateNewSize(state.initialColWidth, state.initialMousePosition, event.clientX);
|
|
721
|
+
var newColumnsSizes = setColumnWidth(state.sizes, columnIndex, width);
|
|
722
|
+
if (!((_state$tableRef2 = state.tableRef) !== null && _state$tableRef2 !== void 0 && _state$tableRef2.current)) return;
|
|
723
|
+
state.tableRef.current.style.gridTemplateColumns = getGridTemplateColumnsStyle(_mapInstanceProperty__default["default"](newColumnsSizes).call(newColumnsSizes, function (newColumnsSize) {
|
|
724
|
+
return newColumnsSize.width.toString();
|
|
725
|
+
}));
|
|
726
|
+
});
|
|
693
727
|
};
|
|
694
728
|
|
|
695
729
|
var finishResizing = function finishResizing() {
|
|
@@ -718,12 +752,15 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
718
752
|
return -1;
|
|
719
753
|
}
|
|
720
754
|
|
|
721
|
-
return _reduceInstanceProperty__default[
|
|
755
|
+
return _reduceInstanceProperty__default["default"](_context2 = state.sizes).call(_context2, function (a, b) {
|
|
722
756
|
return a + b.width;
|
|
723
757
|
}, 0);
|
|
724
758
|
};
|
|
725
759
|
|
|
726
760
|
var reset = function reset() {
|
|
761
|
+
var _state$tableRef3;
|
|
762
|
+
|
|
763
|
+
if (!((_state$tableRef3 = state.tableRef) !== null && _state$tableRef3 !== void 0 && _state$tableRef3.current)) return;
|
|
727
764
|
state.tableRef.current.style.gridTemplateColumns = '';
|
|
728
765
|
return dispatch({
|
|
729
766
|
type: 'reset'
|
|
@@ -734,7 +771,7 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
734
771
|
return state.sizes;
|
|
735
772
|
};
|
|
736
773
|
|
|
737
|
-
|
|
774
|
+
react$1.useDebugValue(state);
|
|
738
775
|
return {
|
|
739
776
|
reset: reset,
|
|
740
777
|
getSizes: getSizes,
|
|
@@ -750,11 +787,15 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
|
|
|
750
787
|
|
|
751
788
|
var useManualColumnResizing$1 = useManualColumnResizing;
|
|
752
789
|
|
|
790
|
+
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; }
|
|
791
|
+
|
|
792
|
+
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; }
|
|
793
|
+
|
|
753
794
|
var getColumnsLayoutInfo = function getColumnsLayoutInfo(columns) {
|
|
754
|
-
return _reduceInstanceProperty__default[
|
|
795
|
+
return _reduceInstanceProperty__default["default"](columns).call(columns, function (acc, currentValue) {
|
|
755
796
|
var _context;
|
|
756
797
|
|
|
757
|
-
return _concatInstanceProperty__default[
|
|
798
|
+
return _concatInstanceProperty__default["default"](_context = []).call(_context, _toConsumableArray(acc), [{
|
|
758
799
|
key: currentValue.key,
|
|
759
800
|
width: currentValue.width
|
|
760
801
|
}]);
|
|
@@ -767,9 +808,21 @@ var shouldRenderRowBottomBorder = function shouldRenderRowBottomBorder(rowIndex,
|
|
|
767
808
|
return false;
|
|
768
809
|
};
|
|
769
810
|
|
|
811
|
+
var defaultProps = {
|
|
812
|
+
isCondensed: false,
|
|
813
|
+
wrapHeaderLabels: true,
|
|
814
|
+
verticalCellAlignment: 'top',
|
|
815
|
+
horizontalCellAlignment: 'left',
|
|
816
|
+
disableSelfContainment: false,
|
|
817
|
+
// @ts-ignore
|
|
818
|
+
itemRenderer: function itemRenderer(row, column) {
|
|
819
|
+
return row[column.key];
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
|
|
770
823
|
var DataTable = function DataTable(props) {
|
|
771
824
|
var _context2, _context3;
|
|
772
|
-
var tableRef =
|
|
825
|
+
var tableRef = react$1.useRef();
|
|
773
826
|
var columnResizingReducer = useManualColumnResizing$1(tableRef); // if the table columns have been measured
|
|
774
827
|
// and if the list of columns, their width field, or the isCondensed prop has changed
|
|
775
828
|
// then we need to reset the resized column widths
|
|
@@ -783,90 +836,88 @@ var DataTable = function DataTable(props) {
|
|
|
783
836
|
columns: columnsInfo,
|
|
784
837
|
isCondensed: props.isCondensed
|
|
785
838
|
};
|
|
786
|
-
|
|
787
|
-
|
|
839
|
+
var hasLayoutChanged = !isEqual__default["default"](prevLayout, currentLayout);
|
|
840
|
+
react$1.useLayoutEffect(function () {
|
|
841
|
+
if (hasLayoutChanged) {
|
|
788
842
|
columnResizingReducer.reset();
|
|
789
843
|
}
|
|
790
|
-
}, [
|
|
844
|
+
}, [columnResizingReducer, hasLayoutChanged]);
|
|
791
845
|
var hasTableBeenResized = columnResizingReducer.getHasTableBeenResized();
|
|
792
|
-
var resizedTotalWidth = hasTableBeenResized ? columnResizingReducer.getTotalResizedTableWidth() + (
|
|
793
|
-
|
|
846
|
+
var resizedTotalWidth = hasTableBeenResized && tableRef.current ? columnResizingReducer.getTotalResizedTableWidth() + ( // if the table has a maxHeight, it might add a scrollbar which takes space inside the container
|
|
847
|
+
tableRef.current.offsetWidth - tableRef.current.clientWidth) : undefined;
|
|
848
|
+
return jsxRuntime.jsxs(TableContainer, {
|
|
794
849
|
maxWidth: props.maxWidth,
|
|
795
850
|
isBeingResized: columnResizingReducer.getIsAnyColumnBeingResized(),
|
|
796
|
-
disableSelfContainment: props.disableSelfContainment
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
851
|
+
disableSelfContainment: !!props.disableSelfContainment,
|
|
852
|
+
children: [jsxRuntime.jsx(TableGrid, _objectSpread(_objectSpread({
|
|
853
|
+
ref: tableRef
|
|
854
|
+
}, utils.filterDataAttributes(props)), {}, {
|
|
855
|
+
columns: props.columns,
|
|
856
|
+
maxHeight: props.maxHeight,
|
|
857
|
+
disableSelfContainment: !!props.disableSelfContainment,
|
|
858
|
+
resizedTotalWidth: resizedTotalWidth,
|
|
859
|
+
children: jsxRuntime.jsxs(ColumnResizingContext.Provider, {
|
|
860
|
+
value: columnResizingReducer,
|
|
861
|
+
children: [jsxRuntime.jsx(Header, {
|
|
862
|
+
children: jsxRuntime.jsx(Row, {
|
|
863
|
+
children: props.columns && _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, function (column) {
|
|
864
|
+
return jsxRuntime.jsx(HeaderCell$1, {
|
|
865
|
+
shouldWrap: props.wrapHeaderLabels,
|
|
866
|
+
isCondensed: props.isCondensed,
|
|
867
|
+
iconComponent: column.headerIcon,
|
|
868
|
+
onColumnResized: props.onColumnResized,
|
|
869
|
+
disableResizing: column.disableResizing,
|
|
870
|
+
horizontalCellAlignment: column.align ? column.align : props.horizontalCellAlignment,
|
|
871
|
+
disableHeaderStickiness: props.disableHeaderStickiness,
|
|
872
|
+
columnWidth: column.width
|
|
873
|
+
/* Sorting Props */
|
|
874
|
+
,
|
|
875
|
+
onClick: props.onSortChange && props.onSortChange,
|
|
876
|
+
sortedBy: props.sortedBy,
|
|
877
|
+
columnKey: column.key,
|
|
878
|
+
isSortable: column.isSortable,
|
|
879
|
+
sortDirection: props.sortDirection,
|
|
880
|
+
children: column.label
|
|
881
|
+
}, column.key);
|
|
882
|
+
})
|
|
883
|
+
})
|
|
884
|
+
}), jsxRuntime.jsx(Body, {
|
|
885
|
+
children: _mapInstanceProperty__default["default"](_context3 = props.rows).call(_context3, function (row, rowIndex) {
|
|
886
|
+
return react.createElement(DataRow$1, _objectSpread(_objectSpread({}, props), {}, {
|
|
887
|
+
row: row,
|
|
888
|
+
key: row.id,
|
|
889
|
+
rowIndex: rowIndex,
|
|
890
|
+
shouldClipContent: columnResizingReducer.getIsAnyColumnBeingResized() || hasTableBeenResized,
|
|
891
|
+
shouldRenderBottomBorder: shouldRenderRowBottomBorder(rowIndex, props.rows.length, props.footer)
|
|
892
|
+
}));
|
|
893
|
+
})
|
|
894
|
+
})]
|
|
895
|
+
})
|
|
896
|
+
})), props.footer && jsxRuntime.jsx(Footer$1, {
|
|
897
|
+
"data-testid": "footer",
|
|
810
898
|
isCondensed: props.isCondensed,
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
disableHeaderStickiness: props.disableHeaderStickiness,
|
|
817
|
-
columnWidth: column.width
|
|
818
|
-
/* Sorting Props */
|
|
819
|
-
,
|
|
820
|
-
onClick: props.onSortChange,
|
|
821
|
-
sortedBy: props.sortedBy,
|
|
822
|
-
columnKey: column.key,
|
|
823
|
-
isSortable: column.isSortable,
|
|
824
|
-
sortDirection: props.sortDirection
|
|
825
|
-
}, column.label);
|
|
826
|
-
}))), react.jsx(Body, null, _mapInstanceProperty__default['default'](_context3 = props.rows).call(_context3, function (row, rowIndex) {
|
|
827
|
-
return react.jsx(DataRow$1, _extends({}, props, {
|
|
828
|
-
row: row,
|
|
829
|
-
key: row.id,
|
|
830
|
-
rowIndex: rowIndex,
|
|
831
|
-
shouldClipContent: columnResizingReducer.getIsAnyColumnBeingResized() || hasTableBeenResized,
|
|
832
|
-
shouldRenderBottomBorder: shouldRenderRowBottomBorder(rowIndex, props.rows.length, props.footer)
|
|
833
|
-
}));
|
|
834
|
-
})))), props.footer && react.jsx(Footer$1, {
|
|
835
|
-
"data-testid": "footer",
|
|
836
|
-
isCondensed: props.isCondensed,
|
|
837
|
-
horizontalCellAlignment: props.horizontalCellAlignment,
|
|
838
|
-
resizedTotalWidth: resizedTotalWidth
|
|
839
|
-
}, props.footer));
|
|
899
|
+
horizontalCellAlignment: props.horizontalCellAlignment,
|
|
900
|
+
resizedTotalWidth: resizedTotalWidth,
|
|
901
|
+
children: props.footer
|
|
902
|
+
})]
|
|
903
|
+
});
|
|
840
904
|
};
|
|
841
905
|
|
|
842
906
|
DataTable.propTypes = {};
|
|
843
|
-
DataTable.defaultProps =
|
|
844
|
-
isCondensed: false,
|
|
845
|
-
wrapHeaderLabels: true,
|
|
846
|
-
verticalCellAlignment: 'top',
|
|
847
|
-
horizontalCellAlignment: 'left',
|
|
848
|
-
disableSelfContainment: false,
|
|
849
|
-
itemRenderer: function itemRenderer(row, column) {
|
|
850
|
-
return row[column.key];
|
|
851
|
-
}
|
|
852
|
-
};
|
|
907
|
+
DataTable.defaultProps = defaultProps;
|
|
853
908
|
DataTable.displayName = 'DataTable';
|
|
854
909
|
var DataTable$1 = DataTable;
|
|
855
910
|
|
|
856
|
-
// NOTE: This string will be replaced
|
|
857
|
-
var version =
|
|
911
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
912
|
+
var version = "12.2.6";
|
|
858
913
|
|
|
859
914
|
Object.defineProperty(exports, 'useRowSelection', {
|
|
860
915
|
enumerable: true,
|
|
861
|
-
get: function () {
|
|
862
|
-
return hooks.useRowSelection;
|
|
863
|
-
}
|
|
916
|
+
get: function () { return hooks.useRowSelection; }
|
|
864
917
|
});
|
|
865
918
|
Object.defineProperty(exports, 'useSorting', {
|
|
866
919
|
enumerable: true,
|
|
867
|
-
get: function () {
|
|
868
|
-
return hooks.useSorting;
|
|
869
|
-
}
|
|
920
|
+
get: function () { return hooks.useSorting; }
|
|
870
921
|
});
|
|
871
|
-
exports[
|
|
922
|
+
exports["default"] = DataTable$1;
|
|
872
923
|
exports.version = version;
|