@innovaccer/design-system 2.30.1 → 2.31.0
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/CHANGELOG.md +43 -0
- package/css/dist/index.css +60 -9
- package/css/dist/index.css.map +1 -1
- package/css/src/components/grid.css +24 -4
- package/css/src/components/listbox.css +18 -5
- package/css/src/components/table.css +14 -0
- package/dist/.lib/tsconfig.type.tsbuildinfo +26 -11
- package/dist/core/components/organisms/grid/Grid.d.ts +1 -1
- package/dist/core/components/organisms/grid/utility.d.ts +1 -1
- package/dist/core/components/organisms/table/Header.d.ts +7 -1
- package/dist/core/components/organisms/table/Table.d.ts +7 -0
- package/dist/core/components/organisms/table/utils.d.ts +3 -0
- package/dist/index.esm.js +373 -75
- package/dist/index.js +346 -60
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.br +0 -0
- package/dist/index.umd.js.gz +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* Generated on:
|
|
3
|
+
* Generated on: 1713188219586
|
|
4
4
|
* Package: @innovaccer/design-system
|
|
5
|
-
* Version: v2.
|
|
5
|
+
* Version: v2.31.0
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Docs: https://innovaccer.github.io/design-system
|
|
8
8
|
*/
|
|
@@ -6910,6 +6910,7 @@
|
|
|
6910
6910
|
switch (eventType) {
|
|
6911
6911
|
case 'edit':
|
|
6912
6912
|
setEditing(true);
|
|
6913
|
+
setShowComponent(true);
|
|
6913
6914
|
break;
|
|
6914
6915
|
|
|
6915
6916
|
case 'hover':
|
|
@@ -6929,6 +6930,7 @@
|
|
|
6929
6930
|
|
|
6930
6931
|
var onClose = function onClose(selected) {
|
|
6931
6932
|
setEditing(false);
|
|
6933
|
+
setShowComponent(false);
|
|
6932
6934
|
if (onDropdownClose) onDropdownClose(selected);
|
|
6933
6935
|
};
|
|
6934
6936
|
|
|
@@ -9488,7 +9490,7 @@
|
|
|
9488
9490
|
var element = elementRef ? elementRef : childrenRef;
|
|
9489
9491
|
setIsTruncated(detectTruncation(element));
|
|
9490
9492
|
}, [childrenRef, elementRef]);
|
|
9491
|
-
var
|
|
9493
|
+
var renderChildren = elementRef || ! /*#__PURE__*/React__namespace.isValidElement(children) ? children : /*#__PURE__*/React__namespace.cloneElement(children, {
|
|
9492
9494
|
ref: childrenRef
|
|
9493
9495
|
});
|
|
9494
9496
|
|
|
@@ -9505,7 +9507,7 @@
|
|
|
9505
9507
|
|
|
9506
9508
|
if (showOnTruncation) {
|
|
9507
9509
|
return isTruncated ? /*#__PURE__*/React__namespace.createElement(Popover, __assign({
|
|
9508
|
-
trigger:
|
|
9510
|
+
trigger: renderChildren,
|
|
9509
9511
|
on: 'hover',
|
|
9510
9512
|
offset: 'medium'
|
|
9511
9513
|
}, rest, {
|
|
@@ -9514,7 +9516,7 @@
|
|
|
9514
9516
|
close: "Tooltip-animation-close-" + positionValue[props.position]
|
|
9515
9517
|
},
|
|
9516
9518
|
className: "Tooltip-container"
|
|
9517
|
-
}), tooltipWrapper) :
|
|
9519
|
+
}), tooltipWrapper) : renderChildren;
|
|
9518
9520
|
}
|
|
9519
9521
|
|
|
9520
9522
|
return /*#__PURE__*/React__namespace.createElement(Popover, __assign({
|
|
@@ -13861,7 +13863,14 @@
|
|
|
13861
13863
|
var getTotalPages = function getTotalPages(totalRecords, pageSize) {
|
|
13862
13864
|
return Math.ceil(totalRecords / pageSize);
|
|
13863
13865
|
};
|
|
13864
|
-
var getSelectAll = function getSelectAll(tableData, selectDisabledRow) {
|
|
13866
|
+
var getSelectAll = function getSelectAll(tableData, selectDisabledRow, clearSelection) {
|
|
13867
|
+
if (clearSelection) {
|
|
13868
|
+
return {
|
|
13869
|
+
indeterminate: false,
|
|
13870
|
+
checked: false
|
|
13871
|
+
};
|
|
13872
|
+
}
|
|
13873
|
+
|
|
13865
13874
|
var data = tableData.filter(function (d) {
|
|
13866
13875
|
return d.disabled && selectDisabledRow || !d.disabled;
|
|
13867
13876
|
});
|
|
@@ -14693,7 +14702,7 @@
|
|
|
14693
14702
|
var onSelectAll = _this.props.onSelectAll;
|
|
14694
14703
|
|
|
14695
14704
|
if (onSelectAll) {
|
|
14696
|
-
onSelectAll(event.target.checked);
|
|
14705
|
+
onSelectAll(event.target.checked, undefined, true);
|
|
14697
14706
|
}
|
|
14698
14707
|
};
|
|
14699
14708
|
|
|
@@ -15187,6 +15196,8 @@
|
|
|
15187
15196
|
};
|
|
15188
15197
|
|
|
15189
15198
|
var Header = function Header(props) {
|
|
15199
|
+
var _a;
|
|
15200
|
+
|
|
15190
15201
|
var loading = props.loading,
|
|
15191
15202
|
error = props.error,
|
|
15192
15203
|
data = props.data,
|
|
@@ -15200,11 +15211,11 @@
|
|
|
15200
15211
|
withCheckbox = props.withCheckbox,
|
|
15201
15212
|
children = props.children,
|
|
15202
15213
|
updateSchema = props.updateSchema,
|
|
15203
|
-
|
|
15204
|
-
filterList =
|
|
15214
|
+
_b = props.filterList,
|
|
15215
|
+
filterList = _b === void 0 ? {} : _b,
|
|
15205
15216
|
updateFilterList = props.updateFilterList,
|
|
15206
|
-
|
|
15207
|
-
totalRecords =
|
|
15217
|
+
_c = props.totalRecords,
|
|
15218
|
+
totalRecords = _c === void 0 ? 0 : _c,
|
|
15208
15219
|
onSelectAll = props.onSelectAll,
|
|
15209
15220
|
searchPlaceholder = props.searchPlaceholder,
|
|
15210
15221
|
selectAll = props.selectAll,
|
|
@@ -15214,16 +15225,73 @@
|
|
|
15214
15225
|
dynamicColumn = props.dynamicColumn,
|
|
15215
15226
|
allowSelectAll = props.allowSelectAll,
|
|
15216
15227
|
showFilters = props.showFilters,
|
|
15217
|
-
customSelectionLabel = props.customSelectionLabel
|
|
15228
|
+
customSelectionLabel = props.customSelectionLabel,
|
|
15229
|
+
selectedRowsRef = props.selectedRowsRef,
|
|
15230
|
+
selectedAllRef = props.selectedAllRef,
|
|
15231
|
+
onClearSelection = props.onClearSelection,
|
|
15232
|
+
onSelectAllRows = props.onSelectAllRows,
|
|
15233
|
+
selectionActionRenderer = props.selectionActionRenderer,
|
|
15234
|
+
uniqueColumnName = props.uniqueColumnName;
|
|
15218
15235
|
|
|
15219
|
-
var
|
|
15220
|
-
selectAllRecords =
|
|
15221
|
-
setSelectAllRecords =
|
|
15236
|
+
var _d = React__namespace.useState(false),
|
|
15237
|
+
selectAllRecords = _d[0],
|
|
15238
|
+
setSelectAllRecords = _d[1];
|
|
15239
|
+
|
|
15240
|
+
var _e = React__namespace.useState(true),
|
|
15241
|
+
flag = _e[0],
|
|
15242
|
+
setFlag = _e[1];
|
|
15243
|
+
|
|
15244
|
+
var customLabel = customSelectionLabel ? customSelectionLabel : 'item';
|
|
15245
|
+
var selectedCount = data.filter(function (d) {
|
|
15246
|
+
return d._selected;
|
|
15247
|
+
}).length;
|
|
15248
|
+
var startIndex = (page - 1) * pageSize + 1;
|
|
15249
|
+
var endIndex = Math.min(page * pageSize, totalRecords);
|
|
15250
|
+
var selectedRowsCount = (selectedAllRef === null || selectedAllRef === void 0 ? void 0 : selectedAllRef.current) === true ? totalRecords : ((_a = selectedRowsRef === null || selectedRowsRef === void 0 ? void 0 : selectedRowsRef.current) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
15251
|
+
var showSelectedRowLabel = withCheckbox && (selectedCount || selectedRowsCount > 0);
|
|
15252
|
+
|
|
15253
|
+
var _f = React__namespace.useState(true),
|
|
15254
|
+
showSelectedLabel = _f[0],
|
|
15255
|
+
setShowSelectedLabel = _f[1];
|
|
15256
|
+
|
|
15257
|
+
var _g = React__namespace.useState(false),
|
|
15258
|
+
animateSelectedLabel = _g[0],
|
|
15259
|
+
setAnimateSelectedLabel = _g[1];
|
|
15260
|
+
|
|
15261
|
+
var _h = React__namespace.useState(false),
|
|
15262
|
+
animateUnSelectedLabel = _h[0],
|
|
15263
|
+
setAnimateUnSelectedLabel = _h[1];
|
|
15264
|
+
|
|
15265
|
+
React__namespace.useEffect(function () {
|
|
15266
|
+
if (showSelectedRowLabel) {
|
|
15267
|
+
setAnimateUnSelectedLabel(true);
|
|
15268
|
+
setAnimateSelectedLabel(false);
|
|
15269
|
+
} else {
|
|
15270
|
+
setAnimateUnSelectedLabel(false);
|
|
15271
|
+
setAnimateSelectedLabel(true);
|
|
15272
|
+
}
|
|
15273
|
+
}, [showSelectedRowLabel]);
|
|
15222
15274
|
|
|
15223
|
-
var
|
|
15224
|
-
|
|
15225
|
-
|
|
15275
|
+
var onUnSelectAnimationEnd = function onUnSelectAnimationEnd() {
|
|
15276
|
+
showSelectedRowLabel ? setShowSelectedLabel(true) : setShowSelectedLabel(false);
|
|
15277
|
+
setAnimateSelectedLabel(true);
|
|
15278
|
+
setAnimateUnSelectedLabel(false);
|
|
15279
|
+
};
|
|
15226
15280
|
|
|
15281
|
+
var onSelectAnimationEnd = function onSelectAnimationEnd() {
|
|
15282
|
+
showSelectedRowLabel ? setShowSelectedLabel(true) : setShowSelectedLabel(false);
|
|
15283
|
+
setAnimateSelectedLabel(false);
|
|
15284
|
+
setAnimateUnSelectedLabel(true);
|
|
15285
|
+
};
|
|
15286
|
+
|
|
15287
|
+
var unselectedRowLabelClass = classNames__default["default"]({
|
|
15288
|
+
'Table-Header-Label--hide': animateUnSelectedLabel && showSelectedRowLabel,
|
|
15289
|
+
'Table-Header-Label--show': animateUnSelectedLabel && !showSelectedRowLabel
|
|
15290
|
+
});
|
|
15291
|
+
var selectedRowLabelClass = classNames__default["default"]({
|
|
15292
|
+
'Table-Header-Label--hide': animateSelectedLabel && !showSelectedRowLabel,
|
|
15293
|
+
'Table-Header-Label--show': animateSelectedLabel && showSelectedRowLabel
|
|
15294
|
+
});
|
|
15227
15295
|
React__namespace.useEffect(function () {
|
|
15228
15296
|
setFlag(!flag);
|
|
15229
15297
|
}, [schema]);
|
|
@@ -15276,13 +15344,26 @@
|
|
|
15276
15344
|
if (updateSchema) updateSchema(newSchema);
|
|
15277
15345
|
};
|
|
15278
15346
|
|
|
15279
|
-
var
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
|
|
15347
|
+
var getUnSelectedRowLabel = function getUnSelectedRowLabel() {
|
|
15348
|
+
if (error) {
|
|
15349
|
+
return "Showing 0 " + customLabel + "s";
|
|
15350
|
+
} else if (withPagination) {
|
|
15351
|
+
return "Showing " + startIndex + "-" + endIndex + " of " + totalRecords + " " + customLabel + getPluralSuffix(totalRecords);
|
|
15352
|
+
}
|
|
15353
|
+
|
|
15354
|
+
return "Showing " + totalRecords + " " + customLabel + getPluralSuffix(totalRecords);
|
|
15355
|
+
};
|
|
15356
|
+
|
|
15357
|
+
var getSelectedRowLabel = function getSelectedRowLabel() {
|
|
15358
|
+
if (selectedRowsCount > 0 && uniqueColumnName && withCheckbox) {
|
|
15359
|
+
return "Selected " + selectedRowsCount + " " + customLabel + getPluralSuffix(selectedRowsCount);
|
|
15360
|
+
} else if (selectedCount && !uniqueColumnName && withCheckbox) {
|
|
15361
|
+
return "Selected " + selectedCount + " " + customLabel + getPluralSuffix(selectedCount);
|
|
15362
|
+
}
|
|
15363
|
+
|
|
15364
|
+
return;
|
|
15365
|
+
};
|
|
15366
|
+
|
|
15286
15367
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
15287
15368
|
className: "Header"
|
|
15288
15369
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -15346,21 +15427,33 @@
|
|
|
15346
15427
|
}, /*#__PURE__*/React__namespace.createElement(PlaceholderParagraph, {
|
|
15347
15428
|
length: 'small',
|
|
15348
15429
|
size: 's'
|
|
15349
|
-
})) : /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null,
|
|
15350
|
-
className:
|
|
15351
|
-
|
|
15430
|
+
})) : /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, showSelectedLabel ? /*#__PURE__*/React__namespace.createElement("span", {
|
|
15431
|
+
className: selectedRowLabelClass,
|
|
15432
|
+
onAnimationEnd: onSelectAnimationEnd
|
|
15433
|
+
}, /*#__PURE__*/React__namespace.createElement(Label, null, getSelectedRowLabel())) : /*#__PURE__*/React__namespace.createElement("span", {
|
|
15434
|
+
className: unselectedRowLabelClass,
|
|
15435
|
+
onAnimationEnd: onUnSelectAnimationEnd
|
|
15436
|
+
}, /*#__PURE__*/React__namespace.createElement(Label, null, getUnSelectedRowLabel())), selectedRowsCount > 0 && allowSelectAll && showSelectedLabel && /*#__PURE__*/React__namespace.createElement("div", {
|
|
15437
|
+
className: selectedRowLabelClass
|
|
15438
|
+
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
15439
|
+
className: "ml-4 d-flex"
|
|
15440
|
+
}, /*#__PURE__*/React__namespace.createElement(Button, {
|
|
15352
15441
|
"data-test": "DesignSystem-Table-Header--selectAllItemsButton",
|
|
15353
15442
|
size: "tiny",
|
|
15354
|
-
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
}, "Select all " + totalRecords + " " + customLabel + "s") : /*#__PURE__*/React__namespace.createElement(Button, {
|
|
15443
|
+
disabled: selectedRowsCount === totalRecords,
|
|
15444
|
+
onClick: onSelectAllRows
|
|
15445
|
+
}, "Select " + totalRecords + " " + customLabel + "s"), /*#__PURE__*/React__namespace.createElement(Button, {
|
|
15358
15446
|
"data-test": "DesignSystem-Table-Header--clearSelectionItemsButton",
|
|
15359
15447
|
size: "tiny",
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
|
|
15363
|
-
|
|
15448
|
+
className: "ml-4",
|
|
15449
|
+
onClick: onClearSelection
|
|
15450
|
+
}, "Clear Selection"), selectionActionRenderer && /*#__PURE__*/React__namespace.createElement(Divider, {
|
|
15451
|
+
vertical: true,
|
|
15452
|
+
className: "mx-4 Table-Header--Divider"
|
|
15453
|
+
}))), selectionActionRenderer && selectedRowsCount > 0 && showSelectedLabel && /*#__PURE__*/React__namespace.createElement("div", {
|
|
15454
|
+
"data-test": "DesignSystem-Table-Header--ActionRenderer",
|
|
15455
|
+
className: selectedRowLabelClass
|
|
15456
|
+
}, selectionActionRenderer(selectedRowsRef === null || selectedRowsRef === void 0 ? void 0 : selectedRowsRef.current, selectedAllRef === null || selectedAllRef === void 0 ? void 0 : selectedAllRef.current)))), dynamicColumn && /*#__PURE__*/React__namespace.createElement("div", {
|
|
15364
15457
|
className: "Header-hideColumns"
|
|
15365
15458
|
}, /*#__PURE__*/React__namespace.createElement(DraggableDropdown, {
|
|
15366
15459
|
options: columnOptions,
|
|
@@ -15375,6 +15468,46 @@
|
|
|
15375
15468
|
showFilters: true
|
|
15376
15469
|
};
|
|
15377
15470
|
|
|
15471
|
+
var isElementPresent = function isElementPresent(list, uniqueColumnName, value) {
|
|
15472
|
+
var arr = list === null || list === void 0 ? void 0 : list.filter(function (item) {
|
|
15473
|
+
return item[uniqueColumnName] === value;
|
|
15474
|
+
});
|
|
15475
|
+
return arr.length > 0;
|
|
15476
|
+
};
|
|
15477
|
+
|
|
15478
|
+
var getUpdatedData = function getUpdatedData(data, uniqueColumnName, selectedList, isCancelSelection, isSelectAll) {
|
|
15479
|
+
var updatedData = data.map(function (item) {
|
|
15480
|
+
if (isSelectAll || item._selected && !isCancelSelection || item[uniqueColumnName] && selectedList && isElementPresent(selectedList, uniqueColumnName, item[uniqueColumnName]) && !isCancelSelection) {
|
|
15481
|
+
item._selected = true;
|
|
15482
|
+
} else if (isCancelSelection) {
|
|
15483
|
+
item._selected = false;
|
|
15484
|
+
} else {
|
|
15485
|
+
item._selected = false;
|
|
15486
|
+
}
|
|
15487
|
+
|
|
15488
|
+
return item;
|
|
15489
|
+
});
|
|
15490
|
+
return updatedData;
|
|
15491
|
+
};
|
|
15492
|
+
|
|
15493
|
+
var uniqueByKey = function uniqueByKey(arr, key) {
|
|
15494
|
+
var list = new Set();
|
|
15495
|
+
return arr.filter(function (obj) {
|
|
15496
|
+
var value = obj[key];
|
|
15497
|
+
|
|
15498
|
+
if (list.has(value)) {
|
|
15499
|
+
return false;
|
|
15500
|
+
} else {
|
|
15501
|
+
list.add(value);
|
|
15502
|
+
return true;
|
|
15503
|
+
}
|
|
15504
|
+
});
|
|
15505
|
+
};
|
|
15506
|
+
|
|
15507
|
+
var removeDuplicate = function removeDuplicate(data, uniqueColumnName) {
|
|
15508
|
+
return uniqueByKey(data, uniqueColumnName);
|
|
15509
|
+
};
|
|
15510
|
+
|
|
15378
15511
|
var defaultErrorTemplate = function defaultErrorTemplate(props) {
|
|
15379
15512
|
var _a = props.errorType,
|
|
15380
15513
|
errorType = _a === void 0 ? 'DEFAULT' : _a;
|
|
@@ -15418,6 +15551,10 @@
|
|
|
15418
15551
|
function Table(props) {
|
|
15419
15552
|
var _this = _super.call(this, props) || this;
|
|
15420
15553
|
|
|
15554
|
+
_this.selectedRowsRef = /*#__PURE__*/React__namespace.createRef();
|
|
15555
|
+
_this.clearSelectionRef = /*#__PURE__*/React__namespace.createRef();
|
|
15556
|
+
_this.selectAllRef = /*#__PURE__*/React__namespace.createRef();
|
|
15557
|
+
|
|
15421
15558
|
_this.updateData = function (searchUpdate) {
|
|
15422
15559
|
if (_this.state.async) {
|
|
15423
15560
|
_this.setState({
|
|
@@ -15438,13 +15575,15 @@
|
|
|
15438
15575
|
pageSize = _a.pageSize,
|
|
15439
15576
|
withPagination = _a.withPagination,
|
|
15440
15577
|
dataProp = _a.data,
|
|
15441
|
-
onSearch = _a.onSearch
|
|
15442
|
-
|
|
15443
|
-
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15578
|
+
onSearch = _a.onSearch,
|
|
15579
|
+
_b = _a.uniqueColumnName,
|
|
15580
|
+
uniqueColumnName = _b === void 0 ? 'id' : _b;
|
|
15581
|
+
var _c = _this.state,
|
|
15582
|
+
async = _c.async,
|
|
15583
|
+
page = _c.page,
|
|
15584
|
+
sortingList = _c.sortingList,
|
|
15585
|
+
filterList = _c.filterList,
|
|
15586
|
+
searchTerm = _c.searchTerm;
|
|
15448
15587
|
|
|
15449
15588
|
_this.onSelect(-1, false);
|
|
15450
15589
|
|
|
@@ -15466,13 +15605,25 @@
|
|
|
15466
15605
|
fetchData(opts).then(function (res) {
|
|
15467
15606
|
if (!res.searchTerm || res.searchTerm && res.searchTerm === _this.state.searchTerm) {
|
|
15468
15607
|
var data = res.data;
|
|
15608
|
+
var dataReplica = JSON.parse(JSON.stringify(data));
|
|
15469
15609
|
var schema = _this.state.schema.length ? _this.state.schema : res.schema;
|
|
15610
|
+
var preSelectedRows = data.filter(function (item) {
|
|
15611
|
+
return item._selected;
|
|
15612
|
+
});
|
|
15613
|
+
|
|
15614
|
+
if (_this.clearSelectionRef.current) {
|
|
15615
|
+
_this.selectedRowsRef.current = [];
|
|
15616
|
+
} else {
|
|
15617
|
+
_this.selectedRowsRef.current = _this.selectedRowsRef.current ? removeDuplicate(__spreadArrays(_this.selectedRowsRef.current, preSelectedRows), uniqueColumnName) : removeDuplicate(__spreadArrays(preSelectedRows), uniqueColumnName);
|
|
15618
|
+
}
|
|
15619
|
+
|
|
15620
|
+
var selectedData = getUpdatedData(dataReplica, uniqueColumnName, _this.selectedRowsRef.current, _this.clearSelectionRef.current, _this.selectAllRef.current);
|
|
15470
15621
|
|
|
15471
15622
|
_this.setState({
|
|
15472
|
-
data:
|
|
15623
|
+
data: selectedData,
|
|
15473
15624
|
displayData: data,
|
|
15474
15625
|
schema: schema,
|
|
15475
|
-
selectAll: getSelectAll(
|
|
15626
|
+
selectAll: getSelectAll(selectedData, _this.props.selectDisabledRow, _this.clearSelectionRef.current),
|
|
15476
15627
|
totalRecords: res.count,
|
|
15477
15628
|
loading: false,
|
|
15478
15629
|
error: !data.length,
|
|
@@ -15500,23 +15651,73 @@
|
|
|
15500
15651
|
}
|
|
15501
15652
|
|
|
15502
15653
|
var renderedSchema = _this.state.schema.length ? _this.state.schema : schema;
|
|
15654
|
+
var preSelectedRows = renderedData.filter(function (item) {
|
|
15655
|
+
return item._selected;
|
|
15656
|
+
});
|
|
15657
|
+
|
|
15658
|
+
if (_this.clearSelectionRef.current) {
|
|
15659
|
+
_this.selectedRowsRef.current = [];
|
|
15660
|
+
} else {
|
|
15661
|
+
_this.selectedRowsRef.current = _this.selectedRowsRef.current ? removeDuplicate(__spreadArrays(_this.selectedRowsRef.current, preSelectedRows), uniqueColumnName) : removeDuplicate(__spreadArrays(preSelectedRows), uniqueColumnName);
|
|
15662
|
+
}
|
|
15663
|
+
|
|
15664
|
+
var selectedData = getUpdatedData(renderedData, uniqueColumnName, _this.selectedRowsRef.current, _this.clearSelectionRef.current, _this.selectAllRef.current);
|
|
15503
15665
|
|
|
15504
15666
|
_this.setState({
|
|
15505
15667
|
totalRecords: totalRecords,
|
|
15506
15668
|
error: !renderedData.length,
|
|
15507
15669
|
errorType: 'NO_RECORDS_FOUND',
|
|
15508
|
-
selectAll: getSelectAll(renderedData, _this.props.selectDisabledRow),
|
|
15670
|
+
selectAll: getSelectAll(renderedData, _this.props.selectDisabledRow, _this.clearSelectionRef.current),
|
|
15509
15671
|
schema: renderedSchema,
|
|
15510
15672
|
displayData: sortedData,
|
|
15511
|
-
data:
|
|
15673
|
+
data: selectedData
|
|
15512
15674
|
});
|
|
15513
15675
|
}
|
|
15514
15676
|
};
|
|
15515
15677
|
|
|
15516
15678
|
_this.onSelect = function (rowIndexes, selected) {
|
|
15517
15679
|
var data = _this.state.data;
|
|
15518
|
-
var
|
|
15680
|
+
var _a = _this.props,
|
|
15681
|
+
onSelect = _a.onSelect,
|
|
15682
|
+
_b = _a.uniqueColumnName,
|
|
15683
|
+
uniqueColumnName = _b === void 0 ? 'id' : _b;
|
|
15684
|
+
|
|
15685
|
+
if (_this.selectAllRef.current && rowIndexes !== -1 && !selected) {
|
|
15686
|
+
_this.selectAllRef.current = false;
|
|
15687
|
+
_this.selectedRowsRef.current = [];
|
|
15688
|
+
var indexes_1 = Array.from({
|
|
15689
|
+
length: data.length
|
|
15690
|
+
}, function (_, i) {
|
|
15691
|
+
return i;
|
|
15692
|
+
});
|
|
15693
|
+
var newData_1 = updateBatchData(data, indexes_1, {
|
|
15694
|
+
_selected: false
|
|
15695
|
+
}, _this.props.selectDisabledRow);
|
|
15696
|
+
|
|
15697
|
+
_this.setState({
|
|
15698
|
+
data: newData_1,
|
|
15699
|
+
selectAll: {
|
|
15700
|
+
checked: false,
|
|
15701
|
+
indeterminate: false
|
|
15702
|
+
}
|
|
15703
|
+
});
|
|
15704
|
+
|
|
15705
|
+
if (onSelect) {
|
|
15706
|
+
if (_this.props.uniqueColumnName) {
|
|
15707
|
+
onSelect(indexes_1, selected, _this.selectedRowsRef.current, _this.selectAllRef.current);
|
|
15708
|
+
} else {
|
|
15709
|
+
onSelect(indexes_1, selected, rowIndexes === -1 ? [] : newData_1.filter(function (d) {
|
|
15710
|
+
return d._selected;
|
|
15711
|
+
}));
|
|
15712
|
+
}
|
|
15713
|
+
}
|
|
15714
|
+
|
|
15715
|
+
return;
|
|
15716
|
+
}
|
|
15717
|
+
|
|
15519
15718
|
var indexes = [rowIndexes];
|
|
15719
|
+
var rowData = data[rowIndexes];
|
|
15720
|
+
var selectedItemList = rowIndexes === -1 ? [] : [rowData];
|
|
15520
15721
|
var newData = data;
|
|
15521
15722
|
|
|
15522
15723
|
if (rowIndexes >= 0) {
|
|
@@ -15524,21 +15725,46 @@
|
|
|
15524
15725
|
_selected: selected
|
|
15525
15726
|
}, _this.props.selectDisabledRow);
|
|
15526
15727
|
|
|
15728
|
+
_this.resetClearSelection();
|
|
15729
|
+
|
|
15527
15730
|
_this.setState({
|
|
15528
15731
|
data: newData,
|
|
15529
|
-
selectAll: getSelectAll(newData, _this.props.selectDisabledRow)
|
|
15732
|
+
selectAll: getSelectAll(newData, _this.props.selectDisabledRow, _this.clearSelectionRef.current)
|
|
15530
15733
|
});
|
|
15734
|
+
|
|
15735
|
+
if (_this.selectedRowsRef.current && selected) {
|
|
15736
|
+
selectedItemList = __spreadArrays([__assign(__assign({}, rowData), {
|
|
15737
|
+
_selected: selected
|
|
15738
|
+
})], _this.selectedRowsRef.current);
|
|
15739
|
+
}
|
|
15740
|
+
|
|
15741
|
+
if (!selected) {
|
|
15742
|
+
selectedItemList = _this.selectedRowsRef.current.filter(function (item) {
|
|
15743
|
+
return item[uniqueColumnName] !== rowData[uniqueColumnName];
|
|
15744
|
+
});
|
|
15745
|
+
}
|
|
15746
|
+
|
|
15747
|
+
_this.selectedRowsRef.current = removeDuplicate(selectedItemList, uniqueColumnName);
|
|
15748
|
+
} else if (rowIndexes === -1 && _this.selectedRowsRef.current) {
|
|
15749
|
+
selectedItemList = _this.selectedRowsRef.current;
|
|
15531
15750
|
}
|
|
15532
15751
|
|
|
15533
15752
|
if (onSelect) {
|
|
15534
|
-
|
|
15535
|
-
|
|
15536
|
-
}
|
|
15753
|
+
if (_this.props.uniqueColumnName) {
|
|
15754
|
+
onSelect(indexes, selected, rowIndexes === -1 && (selectedItemList === null || selectedItemList === void 0 ? void 0 : selectedItemList.length) === 0 ? [] : _this.selectedRowsRef.current, _this.selectAllRef.current);
|
|
15755
|
+
} else {
|
|
15756
|
+
onSelect(indexes, selected, rowIndexes === -1 ? [] : newData.filter(function (d) {
|
|
15757
|
+
return d._selected;
|
|
15758
|
+
}));
|
|
15759
|
+
}
|
|
15537
15760
|
}
|
|
15538
15761
|
};
|
|
15539
15762
|
|
|
15540
|
-
_this.onSelectAll = function (selected, selectAll) {
|
|
15541
|
-
var
|
|
15763
|
+
_this.onSelectAll = function (selected, selectAll, headerCheckbox) {
|
|
15764
|
+
var _a = _this.props,
|
|
15765
|
+
onSelect = _a.onSelect,
|
|
15766
|
+
_b = _a.uniqueColumnName,
|
|
15767
|
+
uniqueColumnName = _b === void 0 ? 'id' : _b;
|
|
15542
15768
|
var data = _this.state.data;
|
|
15543
15769
|
var indexes = Array.from({
|
|
15544
15770
|
length: data.length
|
|
@@ -15554,11 +15780,43 @@
|
|
|
15554
15780
|
selectedIndex.push(key);
|
|
15555
15781
|
}
|
|
15556
15782
|
});
|
|
15783
|
+
var selectedData = [];
|
|
15557
15784
|
|
|
15558
|
-
if (
|
|
15559
|
-
|
|
15785
|
+
if (selected) {
|
|
15786
|
+
_this.resetClearSelection();
|
|
15787
|
+
|
|
15788
|
+
selectedData = selectAll === undefined ? __spreadArrays(_this.selectedRowsRef.current || [], newData.filter(function (d) {
|
|
15560
15789
|
return d._selected;
|
|
15561
|
-
})
|
|
15790
|
+
})) : _this.selectedRowsRef.current;
|
|
15791
|
+
} else if (!selected && headerCheckbox) {
|
|
15792
|
+
_this.selectAllRef.current = false;
|
|
15793
|
+
_this.selectedRowsRef.current = __spreadArrays(_this.selectedRowsRef.current || [], newData);
|
|
15794
|
+
_this.selectedRowsRef.current = _this.selectedRowsRef.current.filter(function (item1) {
|
|
15795
|
+
return !newData.some(function (item2) {
|
|
15796
|
+
return item1[uniqueColumnName] === item2[uniqueColumnName];
|
|
15797
|
+
});
|
|
15798
|
+
});
|
|
15799
|
+
} else {
|
|
15800
|
+
_this.selectedRowsRef.current = [];
|
|
15801
|
+
_this.selectAllRef.current = false;
|
|
15802
|
+
}
|
|
15803
|
+
|
|
15804
|
+
if (!(headerCheckbox && !selected)) {
|
|
15805
|
+
_this.selectedRowsRef.current = removeDuplicate(selectedData, uniqueColumnName);
|
|
15806
|
+
}
|
|
15807
|
+
|
|
15808
|
+
if (onSelect) {
|
|
15809
|
+
if (_this.props.uniqueColumnName) {
|
|
15810
|
+
if (headerCheckbox && !selected) {
|
|
15811
|
+
onSelect(selectedIndex, selected, removeDuplicate(_this.selectedRowsRef.current, uniqueColumnName), _this.selectAllRef.current);
|
|
15812
|
+
} else {
|
|
15813
|
+
onSelect(selectedIndex, selected, removeDuplicate(selectedData, uniqueColumnName), _this.selectAllRef.current);
|
|
15814
|
+
}
|
|
15815
|
+
} else {
|
|
15816
|
+
onSelect(selectedIndex, selected, newData.filter(function (d) {
|
|
15817
|
+
return d._selected;
|
|
15818
|
+
}), selectAll);
|
|
15819
|
+
}
|
|
15562
15820
|
}
|
|
15563
15821
|
|
|
15564
15822
|
_this.setState({
|
|
@@ -15602,6 +15860,28 @@
|
|
|
15602
15860
|
});
|
|
15603
15861
|
};
|
|
15604
15862
|
|
|
15863
|
+
_this.onClearSelection = function () {
|
|
15864
|
+
_this.selectedRowsRef.current = [];
|
|
15865
|
+
_this.clearSelectionRef.current = true;
|
|
15866
|
+
_this.selectAllRef.current = false;
|
|
15867
|
+
|
|
15868
|
+
_this.onSelectAll(false);
|
|
15869
|
+
|
|
15870
|
+
_this.setState({
|
|
15871
|
+
selectAll: getSelectAll([], _this.props.selectDisabledRow, _this.clearSelectionRef.current)
|
|
15872
|
+
});
|
|
15873
|
+
};
|
|
15874
|
+
|
|
15875
|
+
_this.resetClearSelection = function () {
|
|
15876
|
+
_this.clearSelectionRef.current = false;
|
|
15877
|
+
};
|
|
15878
|
+
|
|
15879
|
+
_this.onSelectAllRows = function () {
|
|
15880
|
+
_this.selectAllRef.current = _this.props.uniqueColumnName ? true : false;
|
|
15881
|
+
|
|
15882
|
+
_this.onSelectAll(true, true);
|
|
15883
|
+
};
|
|
15884
|
+
|
|
15605
15885
|
var async = ('fetchData' in _this.props);
|
|
15606
15886
|
var data = props.data || [];
|
|
15607
15887
|
var schema = props.schema || [];
|
|
@@ -15707,7 +15987,8 @@
|
|
|
15707
15987
|
loaderSchema = _a.loaderSchema,
|
|
15708
15988
|
errorTemplate = _a.errorTemplate,
|
|
15709
15989
|
className = _a.className,
|
|
15710
|
-
filterPosition = _a.filterPosition
|
|
15990
|
+
filterPosition = _a.filterPosition,
|
|
15991
|
+
uniqueColumnName = _a.uniqueColumnName;
|
|
15711
15992
|
var baseProps = extractBaseProps(this.props);
|
|
15712
15993
|
|
|
15713
15994
|
var _b = headerOptions,
|
|
@@ -15732,7 +16013,12 @@
|
|
|
15732
16013
|
withCheckbox: withCheckbox,
|
|
15733
16014
|
withPagination: withPagination,
|
|
15734
16015
|
pageSize: pageSize,
|
|
15735
|
-
showFilters: filterPosition === 'HEADER'
|
|
16016
|
+
showFilters: filterPosition === 'HEADER',
|
|
16017
|
+
selectedRowsRef: this.selectedRowsRef,
|
|
16018
|
+
onClearSelection: this.onClearSelection,
|
|
16019
|
+
onSelectAllRows: this.onSelectAllRows,
|
|
16020
|
+
selectedAllRef: this.selectAllRef,
|
|
16021
|
+
uniqueColumnName: uniqueColumnName
|
|
15736
16022
|
}, headerAttr), headerChildren)), /*#__PURE__*/React__namespace.createElement("div", {
|
|
15737
16023
|
className: "Table-grid"
|
|
15738
16024
|
}, /*#__PURE__*/React__namespace.createElement(Grid, __assign({}, this.state, {
|
|
@@ -20413,7 +20699,7 @@
|
|
|
20413
20699
|
position: 'bottom-start'
|
|
20414
20700
|
};
|
|
20415
20701
|
|
|
20416
|
-
var version = "2.
|
|
20702
|
+
var version = "2.31.0";
|
|
20417
20703
|
|
|
20418
20704
|
exports.ActionCard = ActionCard;
|
|
20419
20705
|
exports.Avatar = Avatar;
|