@innovaccer/design-system 2.30.1 → 2.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -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 +377 -75
- package/dist/index.js +344 -54
- 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.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* Generated on:
|
|
3
|
+
* Generated on: 1713523162579
|
|
4
4
|
* Package: @innovaccer/design-system
|
|
5
|
-
* Version: v2.
|
|
5
|
+
* Version: v2.31.1
|
|
6
6
|
* License: MIT
|
|
7
7
|
* Docs: https://innovaccer.github.io/design-system
|
|
8
8
|
*/
|
|
@@ -7536,6 +7536,7 @@ var EditableDropdown = function EditableDropdown(props) {
|
|
|
7536
7536
|
switch (eventType) {
|
|
7537
7537
|
case 'edit':
|
|
7538
7538
|
setEditing(true);
|
|
7539
|
+
setShowComponent(true);
|
|
7539
7540
|
break;
|
|
7540
7541
|
|
|
7541
7542
|
case 'hover':
|
|
@@ -7555,6 +7556,7 @@ var EditableDropdown = function EditableDropdown(props) {
|
|
|
7555
7556
|
|
|
7556
7557
|
var onClose = function onClose(selected) {
|
|
7557
7558
|
setEditing(false);
|
|
7559
|
+
setShowComponent(false);
|
|
7558
7560
|
if (onDropdownClose) onDropdownClose(selected);
|
|
7559
7561
|
};
|
|
7560
7562
|
|
|
@@ -14850,7 +14852,7 @@ var Tooltip = function Tooltip(props) {
|
|
|
14850
14852
|
var element = elementRef ? elementRef : childrenRef;
|
|
14851
14853
|
setIsTruncated(detectTruncation(element));
|
|
14852
14854
|
}, [childrenRef, elementRef]);
|
|
14853
|
-
var
|
|
14855
|
+
var renderChildren = elementRef || ! /*#__PURE__*/React.isValidElement(children) ? children : /*#__PURE__*/React.cloneElement(children, {
|
|
14854
14856
|
ref: childrenRef
|
|
14855
14857
|
});
|
|
14856
14858
|
|
|
@@ -14868,7 +14870,7 @@ var Tooltip = function Tooltip(props) {
|
|
|
14868
14870
|
|
|
14869
14871
|
if (showOnTruncation) {
|
|
14870
14872
|
return isTruncated ? /*#__PURE__*/React.createElement(Popover, _extends$2({
|
|
14871
|
-
trigger:
|
|
14873
|
+
trigger: renderChildren,
|
|
14872
14874
|
on: 'hover',
|
|
14873
14875
|
offset: 'medium'
|
|
14874
14876
|
}, rest, {
|
|
@@ -14877,7 +14879,7 @@ var Tooltip = function Tooltip(props) {
|
|
|
14877
14879
|
close: "Tooltip-animation-close-".concat(positionValue[props.position])
|
|
14878
14880
|
},
|
|
14879
14881
|
className: "Tooltip-container"
|
|
14880
|
-
}), tooltipWrapper) :
|
|
14882
|
+
}), tooltipWrapper) : renderChildren;
|
|
14881
14883
|
}
|
|
14882
14884
|
|
|
14883
14885
|
return /*#__PURE__*/React.createElement(Popover, _extends$2({
|
|
@@ -19443,7 +19445,14 @@ var moveToIndex = function moveToIndex(arr, from, to) {
|
|
|
19443
19445
|
var getTotalPages = function getTotalPages(totalRecords, pageSize) {
|
|
19444
19446
|
return Math.ceil(totalRecords / pageSize);
|
|
19445
19447
|
};
|
|
19446
|
-
var getSelectAll = function getSelectAll(tableData, selectDisabledRow) {
|
|
19448
|
+
var getSelectAll = function getSelectAll(tableData, selectDisabledRow, clearSelection) {
|
|
19449
|
+
if (clearSelection) {
|
|
19450
|
+
return {
|
|
19451
|
+
indeterminate: false,
|
|
19452
|
+
checked: false
|
|
19453
|
+
};
|
|
19454
|
+
}
|
|
19455
|
+
|
|
19447
19456
|
var data = tableData.filter(function (d) {
|
|
19448
19457
|
return d.disabled && selectDisabledRow || !d.disabled;
|
|
19449
19458
|
});
|
|
@@ -20323,7 +20332,7 @@ var Grid = /*#__PURE__*/function (_React$Component) {
|
|
|
20323
20332
|
var onSelectAll = _this.props.onSelectAll;
|
|
20324
20333
|
|
|
20325
20334
|
if (onSelectAll) {
|
|
20326
|
-
onSelectAll(event.target.checked);
|
|
20335
|
+
onSelectAll(event.target.checked, undefined, true);
|
|
20327
20336
|
}
|
|
20328
20337
|
});
|
|
20329
20338
|
|
|
@@ -20828,6 +20837,8 @@ var DraggableDropdown = function DraggableDropdown(props) {
|
|
|
20828
20837
|
};
|
|
20829
20838
|
|
|
20830
20839
|
var Header = function Header(props) {
|
|
20840
|
+
var _selectedRowsRef$curr;
|
|
20841
|
+
|
|
20831
20842
|
var loading = props.loading,
|
|
20832
20843
|
error = props.error,
|
|
20833
20844
|
data = props.data,
|
|
@@ -20855,7 +20866,13 @@ var Header = function Header(props) {
|
|
|
20855
20866
|
dynamicColumn = props.dynamicColumn,
|
|
20856
20867
|
allowSelectAll = props.allowSelectAll,
|
|
20857
20868
|
showFilters = props.showFilters,
|
|
20858
|
-
customSelectionLabel = props.customSelectionLabel
|
|
20869
|
+
customSelectionLabel = props.customSelectionLabel,
|
|
20870
|
+
selectedRowsRef = props.selectedRowsRef,
|
|
20871
|
+
selectedAllRef = props.selectedAllRef,
|
|
20872
|
+
onClearSelection = props.onClearSelection,
|
|
20873
|
+
onSelectAllRows = props.onSelectAllRows,
|
|
20874
|
+
selectionActionRenderer = props.selectionActionRenderer,
|
|
20875
|
+
uniqueColumnName = props.uniqueColumnName;
|
|
20859
20876
|
|
|
20860
20877
|
var _React$useState = React.useState(false),
|
|
20861
20878
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -20867,6 +20884,60 @@ var Header = function Header(props) {
|
|
|
20867
20884
|
flag = _React$useState4[0],
|
|
20868
20885
|
setFlag = _React$useState4[1];
|
|
20869
20886
|
|
|
20887
|
+
var customLabel = customSelectionLabel ? customSelectionLabel : 'item';
|
|
20888
|
+
var selectedCount = data.filter(function (d) {
|
|
20889
|
+
return d._selected;
|
|
20890
|
+
}).length;
|
|
20891
|
+
var startIndex = (page - 1) * pageSize + 1;
|
|
20892
|
+
var endIndex = Math.min(page * pageSize, totalRecords);
|
|
20893
|
+
var selectedRowsCount = (selectedAllRef === null || selectedAllRef === void 0 ? void 0 : selectedAllRef.current) === true ? totalRecords : (selectedRowsRef === null || selectedRowsRef === void 0 ? void 0 : (_selectedRowsRef$curr = selectedRowsRef.current) === null || _selectedRowsRef$curr === void 0 ? void 0 : _selectedRowsRef$curr.length) || 0;
|
|
20894
|
+
var showSelectedRowLabel = withCheckbox && (selectedCount || selectedRowsCount > 0);
|
|
20895
|
+
|
|
20896
|
+
var _React$useState5 = React.useState(true),
|
|
20897
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
20898
|
+
showSelectedLabel = _React$useState6[0],
|
|
20899
|
+
setShowSelectedLabel = _React$useState6[1];
|
|
20900
|
+
|
|
20901
|
+
var _React$useState7 = React.useState(false),
|
|
20902
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
20903
|
+
animateSelectedLabel = _React$useState8[0],
|
|
20904
|
+
setAnimateSelectedLabel = _React$useState8[1];
|
|
20905
|
+
|
|
20906
|
+
var _React$useState9 = React.useState(false),
|
|
20907
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
20908
|
+
animateUnSelectedLabel = _React$useState10[0],
|
|
20909
|
+
setAnimateUnSelectedLabel = _React$useState10[1];
|
|
20910
|
+
|
|
20911
|
+
React.useEffect(function () {
|
|
20912
|
+
if (showSelectedRowLabel) {
|
|
20913
|
+
setAnimateUnSelectedLabel(true);
|
|
20914
|
+
setAnimateSelectedLabel(false);
|
|
20915
|
+
} else {
|
|
20916
|
+
setAnimateUnSelectedLabel(false);
|
|
20917
|
+
setAnimateSelectedLabel(true);
|
|
20918
|
+
}
|
|
20919
|
+
}, [showSelectedRowLabel]);
|
|
20920
|
+
|
|
20921
|
+
var onUnSelectAnimationEnd = function onUnSelectAnimationEnd() {
|
|
20922
|
+
showSelectedRowLabel ? setShowSelectedLabel(true) : setShowSelectedLabel(false);
|
|
20923
|
+
setAnimateSelectedLabel(true);
|
|
20924
|
+
setAnimateUnSelectedLabel(false);
|
|
20925
|
+
};
|
|
20926
|
+
|
|
20927
|
+
var onSelectAnimationEnd = function onSelectAnimationEnd() {
|
|
20928
|
+
showSelectedRowLabel ? setShowSelectedLabel(true) : setShowSelectedLabel(false);
|
|
20929
|
+
setAnimateSelectedLabel(false);
|
|
20930
|
+
setAnimateUnSelectedLabel(true);
|
|
20931
|
+
};
|
|
20932
|
+
|
|
20933
|
+
var unselectedRowLabelClass = classnames({
|
|
20934
|
+
'Table-Header-Label--hide': animateUnSelectedLabel && showSelectedRowLabel,
|
|
20935
|
+
'Table-Header-Label--show': animateUnSelectedLabel && !showSelectedRowLabel
|
|
20936
|
+
});
|
|
20937
|
+
var selectedRowLabelClass = classnames({
|
|
20938
|
+
'Table-Header-Label--hide': animateSelectedLabel && !showSelectedRowLabel,
|
|
20939
|
+
'Table-Header-Label--show': animateSelectedLabel && showSelectedRowLabel
|
|
20940
|
+
});
|
|
20870
20941
|
React.useEffect(function () {
|
|
20871
20942
|
setFlag(!flag);
|
|
20872
20943
|
}, [schema]);
|
|
@@ -20921,13 +20992,28 @@ var Header = function Header(props) {
|
|
|
20921
20992
|
if (updateSchema) updateSchema(newSchema);
|
|
20922
20993
|
};
|
|
20923
20994
|
|
|
20924
|
-
var
|
|
20925
|
-
|
|
20926
|
-
|
|
20927
|
-
|
|
20928
|
-
|
|
20929
|
-
|
|
20930
|
-
|
|
20995
|
+
var getUnSelectedRowLabel = function getUnSelectedRowLabel() {
|
|
20996
|
+
if (error) {
|
|
20997
|
+
return "Showing 0 ".concat(customLabel, "s");
|
|
20998
|
+
} else if (withPagination) {
|
|
20999
|
+
return "Showing ".concat(startIndex, "-").concat(endIndex, " of ").concat(totalRecords, " ").concat(customLabel).concat(getPluralSuffix(totalRecords));
|
|
21000
|
+
}
|
|
21001
|
+
|
|
21002
|
+
return "Showing ".concat(totalRecords, " ").concat(customLabel).concat(getPluralSuffix(totalRecords));
|
|
21003
|
+
};
|
|
21004
|
+
|
|
21005
|
+
var getSelectedRowLabel = function getSelectedRowLabel() {
|
|
21006
|
+
if (selectedRowsCount > 0 && uniqueColumnName && withCheckbox) {
|
|
21007
|
+
return "Selected ".concat(selectedRowsCount, " ").concat(customLabel).concat(getPluralSuffix(selectedRowsCount));
|
|
21008
|
+
} else if (selectedCount && !uniqueColumnName && withCheckbox) {
|
|
21009
|
+
return "Selected ".concat(selectedCount, " ").concat(customLabel).concat(getPluralSuffix(selectedCount));
|
|
21010
|
+
} else if (withPagination) {
|
|
21011
|
+
return "Showing ".concat(startIndex, "-").concat(endIndex, " of ").concat(totalRecords, " ").concat(customLabel).concat(getPluralSuffix(totalRecords));
|
|
21012
|
+
}
|
|
21013
|
+
|
|
21014
|
+
return "Showing ".concat(totalRecords, " ").concat(customLabel).concat(getPluralSuffix(totalRecords));
|
|
21015
|
+
};
|
|
21016
|
+
|
|
20931
21017
|
return /*#__PURE__*/React.createElement("div", {
|
|
20932
21018
|
className: "Header"
|
|
20933
21019
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -20991,21 +21077,33 @@ var Header = function Header(props) {
|
|
|
20991
21077
|
}, /*#__PURE__*/React.createElement(PlaceholderParagraph, {
|
|
20992
21078
|
length: 'small',
|
|
20993
21079
|
size: 's'
|
|
20994
|
-
})) : /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
20995
|
-
className:
|
|
20996
|
-
|
|
21080
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, showSelectedLabel ? /*#__PURE__*/React.createElement("span", {
|
|
21081
|
+
className: selectedRowLabelClass,
|
|
21082
|
+
onAnimationEnd: onSelectAnimationEnd
|
|
21083
|
+
}, /*#__PURE__*/React.createElement(Label, null, getSelectedRowLabel())) : /*#__PURE__*/React.createElement("span", {
|
|
21084
|
+
className: unselectedRowLabelClass,
|
|
21085
|
+
onAnimationEnd: onUnSelectAnimationEnd
|
|
21086
|
+
}, /*#__PURE__*/React.createElement(Label, null, getUnSelectedRowLabel())), selectedRowsCount > 0 && allowSelectAll && showSelectedLabel && /*#__PURE__*/React.createElement("div", {
|
|
21087
|
+
className: selectedRowLabelClass
|
|
21088
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
21089
|
+
className: "ml-4 d-flex"
|
|
21090
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
20997
21091
|
"data-test": "DesignSystem-Table-Header--selectAllItemsButton",
|
|
20998
21092
|
size: "tiny",
|
|
20999
|
-
|
|
21000
|
-
|
|
21001
|
-
|
|
21002
|
-
}, "Select all ".concat(totalRecords, " ").concat(customLabel, "s")) : /*#__PURE__*/React.createElement(Button, {
|
|
21093
|
+
disabled: selectedRowsCount === totalRecords,
|
|
21094
|
+
onClick: onSelectAllRows
|
|
21095
|
+
}, "Select ".concat(totalRecords, " ").concat(customLabel, "s")), /*#__PURE__*/React.createElement(Button, {
|
|
21003
21096
|
"data-test": "DesignSystem-Table-Header--clearSelectionItemsButton",
|
|
21004
21097
|
size: "tiny",
|
|
21005
|
-
|
|
21006
|
-
|
|
21007
|
-
|
|
21008
|
-
|
|
21098
|
+
className: "ml-4",
|
|
21099
|
+
onClick: onClearSelection
|
|
21100
|
+
}, "Clear Selection"), selectionActionRenderer && /*#__PURE__*/React.createElement(Divider, {
|
|
21101
|
+
vertical: true,
|
|
21102
|
+
className: "mx-4 Table-Header--Divider"
|
|
21103
|
+
}))), selectionActionRenderer && selectedRowsCount > 0 && showSelectedLabel && /*#__PURE__*/React.createElement("div", {
|
|
21104
|
+
"data-test": "DesignSystem-Table-Header--ActionRenderer",
|
|
21105
|
+
className: selectedRowLabelClass
|
|
21106
|
+
}, selectionActionRenderer(selectedRowsRef === null || selectedRowsRef === void 0 ? void 0 : selectedRowsRef.current, selectedAllRef === null || selectedAllRef === void 0 ? void 0 : selectedAllRef.current)))), dynamicColumn && /*#__PURE__*/React.createElement("div", {
|
|
21009
21107
|
className: "Header-hideColumns"
|
|
21010
21108
|
}, /*#__PURE__*/React.createElement(DraggableDropdown, {
|
|
21011
21109
|
options: columnOptions,
|
|
@@ -21020,6 +21118,50 @@ Header.defaultProps = {
|
|
|
21020
21118
|
showFilters: true
|
|
21021
21119
|
};
|
|
21022
21120
|
|
|
21121
|
+
var isElementPresent = function isElementPresent(list, uniqueColumnName, value) {
|
|
21122
|
+
var arr = list === null || list === void 0 ? void 0 : list.filter(function (item) {
|
|
21123
|
+
return item[uniqueColumnName] === value;
|
|
21124
|
+
});
|
|
21125
|
+
return arr.length > 0;
|
|
21126
|
+
};
|
|
21127
|
+
|
|
21128
|
+
var getUpdatedData = function getUpdatedData(data, selectedList, uniqueColumnName, isCancelSelection, isSelectAll) {
|
|
21129
|
+
var updatedData = data.map(function (item) {
|
|
21130
|
+
if (isSelectAll || item._selected && !isCancelSelection || uniqueColumnName && item[uniqueColumnName] && selectedList && isElementPresent(selectedList, uniqueColumnName, item[uniqueColumnName]) && !isCancelSelection) {
|
|
21131
|
+
item._selected = true;
|
|
21132
|
+
} else if (isCancelSelection) {
|
|
21133
|
+
item._selected = false;
|
|
21134
|
+
} else {
|
|
21135
|
+
item._selected = false;
|
|
21136
|
+
}
|
|
21137
|
+
|
|
21138
|
+
return item;
|
|
21139
|
+
});
|
|
21140
|
+
return updatedData;
|
|
21141
|
+
};
|
|
21142
|
+
|
|
21143
|
+
var uniqueByKey = function uniqueByKey(arr, key) {
|
|
21144
|
+
var list = new Set();
|
|
21145
|
+
return arr.filter(function (obj) {
|
|
21146
|
+
var value = obj[key];
|
|
21147
|
+
|
|
21148
|
+
if (list.has(value)) {
|
|
21149
|
+
return false;
|
|
21150
|
+
} else {
|
|
21151
|
+
list.add(value);
|
|
21152
|
+
return true;
|
|
21153
|
+
}
|
|
21154
|
+
});
|
|
21155
|
+
};
|
|
21156
|
+
|
|
21157
|
+
var removeDuplicate = function removeDuplicate(data, uniqueColumnName) {
|
|
21158
|
+
if (uniqueColumnName) {
|
|
21159
|
+
return uniqueByKey(data, uniqueColumnName);
|
|
21160
|
+
}
|
|
21161
|
+
|
|
21162
|
+
return data;
|
|
21163
|
+
};
|
|
21164
|
+
|
|
21023
21165
|
var _excluded$l = ["children"];
|
|
21024
21166
|
|
|
21025
21167
|
var defaultErrorTemplate = function defaultErrorTemplate(props) {
|
|
@@ -21099,6 +21241,12 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21099
21241
|
|
|
21100
21242
|
_defineProperty$1(_assertThisInitialized$1(_this), "debounceUpdate", void 0);
|
|
21101
21243
|
|
|
21244
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "selectedRowsRef", /*#__PURE__*/React.createRef());
|
|
21245
|
+
|
|
21246
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "clearSelectionRef", /*#__PURE__*/React.createRef());
|
|
21247
|
+
|
|
21248
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "selectAllRef", /*#__PURE__*/React.createRef());
|
|
21249
|
+
|
|
21102
21250
|
_defineProperty$1(_assertThisInitialized$1(_this), "updateData", function (searchUpdate) {
|
|
21103
21251
|
if (_this.state.async) {
|
|
21104
21252
|
_this.setState({
|
|
@@ -21119,7 +21267,8 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21119
21267
|
pageSize = _this$props.pageSize,
|
|
21120
21268
|
withPagination = _this$props.withPagination,
|
|
21121
21269
|
dataProp = _this$props.data,
|
|
21122
|
-
onSearch = _this$props.onSearch
|
|
21270
|
+
onSearch = _this$props.onSearch,
|
|
21271
|
+
uniqueColumnName = _this$props.uniqueColumnName;
|
|
21123
21272
|
var _this$state = _this.state,
|
|
21124
21273
|
async = _this$state.async,
|
|
21125
21274
|
page = _this$state.page,
|
|
@@ -21147,13 +21296,26 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21147
21296
|
fetchData(opts).then(function (res) {
|
|
21148
21297
|
if (!res.searchTerm || res.searchTerm && res.searchTerm === _this.state.searchTerm) {
|
|
21149
21298
|
var _data2 = res.data;
|
|
21299
|
+
var dataReplica = JSON.parse(JSON.stringify(_data2));
|
|
21150
21300
|
var schema = _this.state.schema.length ? _this.state.schema : res.schema;
|
|
21151
21301
|
|
|
21302
|
+
var preSelectedRows = _data2.filter(function (item) {
|
|
21303
|
+
return item._selected;
|
|
21304
|
+
});
|
|
21305
|
+
|
|
21306
|
+
if (_this.clearSelectionRef.current) {
|
|
21307
|
+
_this.selectedRowsRef.current = [];
|
|
21308
|
+
} else {
|
|
21309
|
+
_this.selectedRowsRef.current = _this.selectedRowsRef.current ? removeDuplicate([].concat(_toConsumableArray(_this.selectedRowsRef.current), _toConsumableArray(preSelectedRows)), uniqueColumnName) : removeDuplicate(_toConsumableArray(preSelectedRows), uniqueColumnName);
|
|
21310
|
+
}
|
|
21311
|
+
|
|
21312
|
+
var selectedData = getUpdatedData(dataReplica, _this.selectedRowsRef.current, uniqueColumnName, _this.clearSelectionRef.current, _this.selectAllRef.current);
|
|
21313
|
+
|
|
21152
21314
|
_this.setState({
|
|
21153
|
-
data:
|
|
21315
|
+
data: selectedData,
|
|
21154
21316
|
displayData: _data2,
|
|
21155
21317
|
schema: schema,
|
|
21156
|
-
selectAll: getSelectAll(
|
|
21318
|
+
selectAll: getSelectAll(selectedData, _this.props.selectDisabledRow, _this.clearSelectionRef.current),
|
|
21157
21319
|
totalRecords: res.count,
|
|
21158
21320
|
loading: false,
|
|
21159
21321
|
error: !_data2.length,
|
|
@@ -21181,23 +21343,76 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21181
21343
|
}
|
|
21182
21344
|
|
|
21183
21345
|
var renderedSchema = _this.state.schema.length ? _this.state.schema : schema;
|
|
21346
|
+
var preSelectedRows = renderedData.filter(function (item) {
|
|
21347
|
+
return item._selected;
|
|
21348
|
+
});
|
|
21349
|
+
var renderedDataReplica = JSON.parse(JSON.stringify(renderedData));
|
|
21350
|
+
|
|
21351
|
+
if (_this.clearSelectionRef.current) {
|
|
21352
|
+
_this.selectedRowsRef.current = [];
|
|
21353
|
+
} else {
|
|
21354
|
+
_this.selectedRowsRef.current = _this.selectedRowsRef.current ? removeDuplicate([].concat(_toConsumableArray(_this.selectedRowsRef.current), _toConsumableArray(preSelectedRows)), uniqueColumnName) : removeDuplicate(_toConsumableArray(preSelectedRows), uniqueColumnName);
|
|
21355
|
+
}
|
|
21356
|
+
|
|
21357
|
+
var selectedData = getUpdatedData(renderedDataReplica, _this.selectedRowsRef.current, uniqueColumnName, _this.clearSelectionRef.current, _this.selectAllRef.current);
|
|
21184
21358
|
|
|
21185
21359
|
_this.setState({
|
|
21186
21360
|
totalRecords: totalRecords,
|
|
21187
21361
|
error: !renderedData.length,
|
|
21188
21362
|
errorType: 'NO_RECORDS_FOUND',
|
|
21189
|
-
selectAll: getSelectAll(renderedData, _this.props.selectDisabledRow),
|
|
21363
|
+
selectAll: getSelectAll(renderedData, _this.props.selectDisabledRow, _this.clearSelectionRef.current),
|
|
21190
21364
|
schema: renderedSchema,
|
|
21191
21365
|
displayData: sortedData,
|
|
21192
|
-
data:
|
|
21366
|
+
data: selectedData
|
|
21193
21367
|
});
|
|
21194
21368
|
}
|
|
21195
21369
|
});
|
|
21196
21370
|
|
|
21197
21371
|
_defineProperty$1(_assertThisInitialized$1(_this), "onSelect", function (rowIndexes, selected) {
|
|
21198
21372
|
var data = _this.state.data;
|
|
21199
|
-
var
|
|
21373
|
+
var _this$props2 = _this.props,
|
|
21374
|
+
onSelect = _this$props2.onSelect,
|
|
21375
|
+
uniqueColumnName = _this$props2.uniqueColumnName;
|
|
21376
|
+
|
|
21377
|
+
if (_this.selectAllRef.current && rowIndexes !== -1 && !selected) {
|
|
21378
|
+
_this.selectAllRef.current = false;
|
|
21379
|
+
_this.selectedRowsRef.current = [];
|
|
21380
|
+
|
|
21381
|
+
var _indexes = Array.from({
|
|
21382
|
+
length: data.length
|
|
21383
|
+
}, function (_, i) {
|
|
21384
|
+
return i;
|
|
21385
|
+
});
|
|
21386
|
+
|
|
21387
|
+
var _newData = updateBatchData(data, _indexes, {
|
|
21388
|
+
_selected: false
|
|
21389
|
+
}, _this.props.selectDisabledRow);
|
|
21390
|
+
|
|
21391
|
+
_this.setState({
|
|
21392
|
+
data: _newData,
|
|
21393
|
+
selectAll: {
|
|
21394
|
+
checked: false,
|
|
21395
|
+
indeterminate: false
|
|
21396
|
+
}
|
|
21397
|
+
});
|
|
21398
|
+
|
|
21399
|
+
if (onSelect) {
|
|
21400
|
+
if (_this.props.uniqueColumnName) {
|
|
21401
|
+
onSelect(_indexes, selected, _this.selectedRowsRef.current, _this.selectAllRef.current);
|
|
21402
|
+
} else {
|
|
21403
|
+
// To avoid breaking the current selection flow
|
|
21404
|
+
onSelect(_indexes, selected, rowIndexes === -1 ? [] : _newData.filter(function (d) {
|
|
21405
|
+
return d._selected;
|
|
21406
|
+
}));
|
|
21407
|
+
}
|
|
21408
|
+
}
|
|
21409
|
+
|
|
21410
|
+
return;
|
|
21411
|
+
}
|
|
21412
|
+
|
|
21200
21413
|
var indexes = [rowIndexes];
|
|
21414
|
+
var rowData = data[rowIndexes];
|
|
21415
|
+
var selectedItemList = rowIndexes === -1 ? [] : [rowData];
|
|
21201
21416
|
var newData = data;
|
|
21202
21417
|
|
|
21203
21418
|
if (rowIndexes >= 0) {
|
|
@@ -21205,21 +21420,48 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21205
21420
|
_selected: selected
|
|
21206
21421
|
}, _this.props.selectDisabledRow);
|
|
21207
21422
|
|
|
21423
|
+
_this.resetClearSelection();
|
|
21424
|
+
|
|
21208
21425
|
_this.setState({
|
|
21209
21426
|
data: newData,
|
|
21210
|
-
selectAll: getSelectAll(newData, _this.props.selectDisabledRow)
|
|
21427
|
+
selectAll: getSelectAll(newData, _this.props.selectDisabledRow, _this.clearSelectionRef.current)
|
|
21211
21428
|
});
|
|
21429
|
+
|
|
21430
|
+
if (_this.selectedRowsRef.current && selected) {
|
|
21431
|
+
selectedItemList = [_objectSpread2(_objectSpread2({}, rowData), {}, {
|
|
21432
|
+
_selected: selected
|
|
21433
|
+
})].concat(_toConsumableArray(_this.selectedRowsRef.current));
|
|
21434
|
+
}
|
|
21435
|
+
|
|
21436
|
+
if (!selected && uniqueColumnName) {
|
|
21437
|
+
selectedItemList = _this.selectedRowsRef.current.filter(function (item) {
|
|
21438
|
+
return item[uniqueColumnName] !== rowData[uniqueColumnName];
|
|
21439
|
+
});
|
|
21440
|
+
}
|
|
21441
|
+
|
|
21442
|
+
_this.selectedRowsRef.current = removeDuplicate(selectedItemList, uniqueColumnName);
|
|
21443
|
+
} else if (rowIndexes === -1 && _this.selectedRowsRef.current) {
|
|
21444
|
+
selectedItemList = _this.selectedRowsRef.current;
|
|
21212
21445
|
}
|
|
21213
21446
|
|
|
21214
21447
|
if (onSelect) {
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
|
|
21448
|
+
if (_this.props.uniqueColumnName) {
|
|
21449
|
+
var _selectedItemList;
|
|
21450
|
+
|
|
21451
|
+
onSelect(indexes, selected, rowIndexes === -1 && ((_selectedItemList = selectedItemList) === null || _selectedItemList === void 0 ? void 0 : _selectedItemList.length) === 0 ? [] : _this.selectedRowsRef.current, _this.selectAllRef.current);
|
|
21452
|
+
} else {
|
|
21453
|
+
// To avoid breaking the current selection flow
|
|
21454
|
+
onSelect(indexes, selected, rowIndexes === -1 ? [] : newData.filter(function (d) {
|
|
21455
|
+
return d._selected;
|
|
21456
|
+
}));
|
|
21457
|
+
}
|
|
21218
21458
|
}
|
|
21219
21459
|
});
|
|
21220
21460
|
|
|
21221
|
-
_defineProperty$1(_assertThisInitialized$1(_this), "onSelectAll", function (selected, selectAll) {
|
|
21222
|
-
var
|
|
21461
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "onSelectAll", function (selected, selectAll, headerCheckbox) {
|
|
21462
|
+
var _this$props3 = _this.props,
|
|
21463
|
+
onSelect = _this$props3.onSelect,
|
|
21464
|
+
uniqueColumnName = _this$props3.uniqueColumnName;
|
|
21223
21465
|
var data = _this.state.data;
|
|
21224
21466
|
var indexes = Array.from({
|
|
21225
21467
|
length: data.length
|
|
@@ -21235,11 +21477,43 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21235
21477
|
selectedIndex.push(key);
|
|
21236
21478
|
}
|
|
21237
21479
|
});
|
|
21480
|
+
var selectedData = [];
|
|
21238
21481
|
|
|
21239
|
-
if (
|
|
21240
|
-
|
|
21482
|
+
if (selected) {
|
|
21483
|
+
_this.resetClearSelection();
|
|
21484
|
+
|
|
21485
|
+
selectedData = selectAll === undefined ? [].concat(_toConsumableArray(_this.selectedRowsRef.current || []), _toConsumableArray(newData.filter(function (d) {
|
|
21241
21486
|
return d._selected;
|
|
21242
|
-
})
|
|
21487
|
+
}))) : _this.selectedRowsRef.current;
|
|
21488
|
+
} else if (!selected && headerCheckbox && uniqueColumnName) {
|
|
21489
|
+
_this.selectAllRef.current = false;
|
|
21490
|
+
_this.selectedRowsRef.current = [].concat(_toConsumableArray(_this.selectedRowsRef.current || []), _toConsumableArray(newData));
|
|
21491
|
+
_this.selectedRowsRef.current = _this.selectedRowsRef.current.filter(function (item1) {
|
|
21492
|
+
return !newData.some(function (item2) {
|
|
21493
|
+
return item1[uniqueColumnName] === item2[uniqueColumnName];
|
|
21494
|
+
});
|
|
21495
|
+
});
|
|
21496
|
+
} else {
|
|
21497
|
+
_this.selectedRowsRef.current = [];
|
|
21498
|
+
_this.selectAllRef.current = false;
|
|
21499
|
+
}
|
|
21500
|
+
|
|
21501
|
+
if (!(headerCheckbox && !selected)) {
|
|
21502
|
+
_this.selectedRowsRef.current = removeDuplicate(selectedData, uniqueColumnName);
|
|
21503
|
+
}
|
|
21504
|
+
|
|
21505
|
+
if (onSelect) {
|
|
21506
|
+
if (_this.props.uniqueColumnName) {
|
|
21507
|
+
if (headerCheckbox && !selected) {
|
|
21508
|
+
onSelect(selectedIndex, selected, removeDuplicate(_this.selectedRowsRef.current, uniqueColumnName), _this.selectAllRef.current);
|
|
21509
|
+
} else {
|
|
21510
|
+
onSelect(selectedIndex, selected, removeDuplicate(selectedData, uniqueColumnName), _this.selectAllRef.current);
|
|
21511
|
+
}
|
|
21512
|
+
} else {
|
|
21513
|
+
onSelect(selectedIndex, selected, newData.filter(function (d) {
|
|
21514
|
+
return d._selected;
|
|
21515
|
+
}), selectAll);
|
|
21516
|
+
}
|
|
21243
21517
|
}
|
|
21244
21518
|
|
|
21245
21519
|
_this.setState({
|
|
@@ -21283,6 +21557,28 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21283
21557
|
});
|
|
21284
21558
|
});
|
|
21285
21559
|
|
|
21560
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "onClearSelection", function () {
|
|
21561
|
+
_this.selectedRowsRef.current = [];
|
|
21562
|
+
_this.clearSelectionRef.current = true;
|
|
21563
|
+
_this.selectAllRef.current = false;
|
|
21564
|
+
|
|
21565
|
+
_this.onSelectAll(false);
|
|
21566
|
+
|
|
21567
|
+
_this.setState({
|
|
21568
|
+
selectAll: getSelectAll([], _this.props.selectDisabledRow, _this.clearSelectionRef.current)
|
|
21569
|
+
});
|
|
21570
|
+
});
|
|
21571
|
+
|
|
21572
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "resetClearSelection", function () {
|
|
21573
|
+
_this.clearSelectionRef.current = false;
|
|
21574
|
+
});
|
|
21575
|
+
|
|
21576
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "onSelectAllRows", function () {
|
|
21577
|
+
_this.selectAllRef.current = _this.props.uniqueColumnName ? true : false;
|
|
21578
|
+
|
|
21579
|
+
_this.onSelectAll(true, true);
|
|
21580
|
+
});
|
|
21581
|
+
|
|
21286
21582
|
var _async = ('fetchData' in _this.props);
|
|
21287
21583
|
|
|
21288
21584
|
var _data = props.data || [];
|
|
@@ -21320,11 +21616,11 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21320
21616
|
|
|
21321
21617
|
if (!this.state.async) {
|
|
21322
21618
|
if (prevProps.error !== this.props.error) {
|
|
21323
|
-
var _this$
|
|
21324
|
-
_this$
|
|
21325
|
-
_data3 = _this$
|
|
21326
|
-
_this$
|
|
21327
|
-
schema = _this$
|
|
21619
|
+
var _this$props4 = this.props,
|
|
21620
|
+
_this$props4$data = _this$props4.data,
|
|
21621
|
+
_data3 = _this$props4$data === void 0 ? [] : _this$props4$data,
|
|
21622
|
+
_this$props4$schema = _this$props4.schema,
|
|
21623
|
+
schema = _this$props4$schema === void 0 ? [] : _this$props4$schema;
|
|
21328
21624
|
|
|
21329
21625
|
this.setState({
|
|
21330
21626
|
data: _data3,
|
|
@@ -21339,11 +21635,11 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21339
21635
|
}
|
|
21340
21636
|
|
|
21341
21637
|
if (prevProps.loading !== this.props.loading) {
|
|
21342
|
-
var _this$
|
|
21343
|
-
_this$
|
|
21344
|
-
_data4 = _this$
|
|
21345
|
-
_this$
|
|
21346
|
-
_schema2 = _this$
|
|
21638
|
+
var _this$props5 = this.props,
|
|
21639
|
+
_this$props5$data = _this$props5.data,
|
|
21640
|
+
_data4 = _this$props5$data === void 0 ? [] : _this$props5$data,
|
|
21641
|
+
_this$props5$schema = _this$props5.schema,
|
|
21642
|
+
_schema2 = _this$props5$schema === void 0 ? [] : _this$props5$schema;
|
|
21347
21643
|
|
|
21348
21644
|
this.setState({
|
|
21349
21645
|
data: _data4,
|
|
@@ -21385,28 +21681,29 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21385
21681
|
}, {
|
|
21386
21682
|
key: "render",
|
|
21387
21683
|
value: function render() {
|
|
21388
|
-
var _this$
|
|
21389
|
-
showHead = _this$
|
|
21390
|
-
type = _this$
|
|
21391
|
-
size = _this$
|
|
21392
|
-
headCellTooltip = _this$
|
|
21393
|
-
separator = _this$
|
|
21394
|
-
draggable = _this$
|
|
21395
|
-
nestedRows = _this$
|
|
21396
|
-
nestedRowRenderer = _this$
|
|
21397
|
-
withHeader = _this$
|
|
21398
|
-
headerOptions = _this$
|
|
21399
|
-
withCheckbox = _this$
|
|
21400
|
-
showMenu = _this$
|
|
21401
|
-
withPagination = _this$
|
|
21402
|
-
paginationType = _this$
|
|
21403
|
-
pageSize = _this$
|
|
21404
|
-
pageJumpDebounceDuration = _this$
|
|
21405
|
-
onRowClick = _this$
|
|
21406
|
-
loaderSchema = _this$
|
|
21407
|
-
errorTemplate = _this$
|
|
21408
|
-
className = _this$
|
|
21409
|
-
filterPosition = _this$
|
|
21684
|
+
var _this$props6 = this.props,
|
|
21685
|
+
showHead = _this$props6.showHead,
|
|
21686
|
+
type = _this$props6.type,
|
|
21687
|
+
size = _this$props6.size,
|
|
21688
|
+
headCellTooltip = _this$props6.headCellTooltip,
|
|
21689
|
+
separator = _this$props6.separator,
|
|
21690
|
+
draggable = _this$props6.draggable,
|
|
21691
|
+
nestedRows = _this$props6.nestedRows,
|
|
21692
|
+
nestedRowRenderer = _this$props6.nestedRowRenderer,
|
|
21693
|
+
withHeader = _this$props6.withHeader,
|
|
21694
|
+
headerOptions = _this$props6.headerOptions,
|
|
21695
|
+
withCheckbox = _this$props6.withCheckbox,
|
|
21696
|
+
showMenu = _this$props6.showMenu,
|
|
21697
|
+
withPagination = _this$props6.withPagination,
|
|
21698
|
+
paginationType = _this$props6.paginationType,
|
|
21699
|
+
pageSize = _this$props6.pageSize,
|
|
21700
|
+
pageJumpDebounceDuration = _this$props6.pageJumpDebounceDuration,
|
|
21701
|
+
onRowClick = _this$props6.onRowClick,
|
|
21702
|
+
loaderSchema = _this$props6.loaderSchema,
|
|
21703
|
+
errorTemplate = _this$props6.errorTemplate,
|
|
21704
|
+
className = _this$props6.className,
|
|
21705
|
+
filterPosition = _this$props6.filterPosition,
|
|
21706
|
+
uniqueColumnName = _this$props6.uniqueColumnName;
|
|
21410
21707
|
var baseProps = extractBaseProps(this.props);
|
|
21411
21708
|
|
|
21412
21709
|
var _ref = headerOptions,
|
|
@@ -21433,7 +21730,12 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21433
21730
|
withCheckbox: withCheckbox,
|
|
21434
21731
|
withPagination: withPagination,
|
|
21435
21732
|
pageSize: pageSize,
|
|
21436
|
-
showFilters: filterPosition === 'HEADER'
|
|
21733
|
+
showFilters: filterPosition === 'HEADER',
|
|
21734
|
+
selectedRowsRef: this.selectedRowsRef,
|
|
21735
|
+
onClearSelection: this.onClearSelection,
|
|
21736
|
+
onSelectAllRows: this.onSelectAllRows,
|
|
21737
|
+
selectedAllRef: this.selectAllRef,
|
|
21738
|
+
uniqueColumnName: uniqueColumnName
|
|
21437
21739
|
}, headerAttr), headerChildren)), /*#__PURE__*/React.createElement("div", {
|
|
21438
21740
|
className: "Table-grid"
|
|
21439
21741
|
}, /*#__PURE__*/React.createElement(Grid, _extends$2({}, this.state, {
|
|
@@ -26236,6 +26538,6 @@ Menu.defaultProps = {
|
|
|
26236
26538
|
position: 'bottom-start'
|
|
26237
26539
|
};
|
|
26238
26540
|
|
|
26239
|
-
var version = "2.
|
|
26541
|
+
var version = "2.31.1";
|
|
26240
26542
|
|
|
26241
26543
|
export { ActionCard, Avatar, AvatarGroup, AvatarSelection, Backdrop, Badge, Breadcrumbs, Button, Calendar, Caption, Card, CardBody, CardFooter, CardHeader, CardSubdued, ChatMessage, Checkbox, Chip, ChipGroup, ChipInput, ChoiceList, Collapsible, Column, Combobox, DatePicker, DateRangePicker, Dialog, Divider, Dropdown, Dropzone, EditableChipInput, EditableDropdown, EditableInput, EmptyState, FileList, FileUploader, FileUploaderList, FullscreenModal, Grid, GridCell, Heading, HelpText, HorizontalNav, Icon, InlineMessage, Input, X as InputMask, Label, Legend, Link, LinkButton, List, Listbox, Menu, Message, MetaList, MetricInput, Modal, ModalBody, ModalDescription, ModalFooter, ModalHeader, MultiSlider, Navigation, OutsideClick, PageHeader, Pagination, Paragraph, Pills, Placeholder, PlaceholderImage, PlaceholderParagraph, Popover, ProgressBar, ProgressRing, Radio, RangeSlider, Row, Select, SelectionCard, Sidesheet, Slider, Spinner, StatusHint, Stepper, Subheading, Switch, Tab, Table, Tabs, TabsWrapper, Text, TextField, Textarea, TimePicker, Toast, Tooltip, index as Utils, VerificationCodeInput, VerticalNav, version };
|