@innovaccer/design-system 2.30.0 → 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 +79 -0
- package/css/dist/index.css +74 -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/css/src/variables/index.css +14 -0
- package/dist/.lib/tsconfig.type.tsbuildinfo +28 -13
- package/dist/core/components/css-utilities/designTokens/Data.d.ts +4 -0
- 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 +374 -76
- package/dist/index.js +347 -61
- 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: 1713188219337
|
|
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
|
*/
|
|
@@ -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,19 +20992,32 @@ 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
|
+
}
|
|
21011
|
+
|
|
21012
|
+
return;
|
|
21013
|
+
};
|
|
21014
|
+
|
|
20931
21015
|
return /*#__PURE__*/React.createElement("div", {
|
|
20932
21016
|
className: "Header"
|
|
20933
21017
|
}, /*#__PURE__*/React.createElement("div", {
|
|
20934
21018
|
className: "Header-content Header-content--top"
|
|
20935
21019
|
}, /*#__PURE__*/React.createElement("div", {
|
|
20936
|
-
className: "d-flex"
|
|
21020
|
+
className: "d-flex w-100"
|
|
20937
21021
|
}, withSearch && /*#__PURE__*/React.createElement("div", {
|
|
20938
21022
|
className: "Header-search"
|
|
20939
21023
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
@@ -20991,21 +21075,33 @@ var Header = function Header(props) {
|
|
|
20991
21075
|
}, /*#__PURE__*/React.createElement(PlaceholderParagraph, {
|
|
20992
21076
|
length: 'small',
|
|
20993
21077
|
size: 's'
|
|
20994
|
-
})) : /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
20995
|
-
className:
|
|
20996
|
-
|
|
21078
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, showSelectedLabel ? /*#__PURE__*/React.createElement("span", {
|
|
21079
|
+
className: selectedRowLabelClass,
|
|
21080
|
+
onAnimationEnd: onSelectAnimationEnd
|
|
21081
|
+
}, /*#__PURE__*/React.createElement(Label, null, getSelectedRowLabel())) : /*#__PURE__*/React.createElement("span", {
|
|
21082
|
+
className: unselectedRowLabelClass,
|
|
21083
|
+
onAnimationEnd: onUnSelectAnimationEnd
|
|
21084
|
+
}, /*#__PURE__*/React.createElement(Label, null, getUnSelectedRowLabel())), selectedRowsCount > 0 && allowSelectAll && showSelectedLabel && /*#__PURE__*/React.createElement("div", {
|
|
21085
|
+
className: selectedRowLabelClass
|
|
21086
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
21087
|
+
className: "ml-4 d-flex"
|
|
21088
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
20997
21089
|
"data-test": "DesignSystem-Table-Header--selectAllItemsButton",
|
|
20998
21090
|
size: "tiny",
|
|
20999
|
-
|
|
21000
|
-
|
|
21001
|
-
|
|
21002
|
-
}, "Select all ".concat(totalRecords, " ").concat(customLabel, "s")) : /*#__PURE__*/React.createElement(Button, {
|
|
21091
|
+
disabled: selectedRowsCount === totalRecords,
|
|
21092
|
+
onClick: onSelectAllRows
|
|
21093
|
+
}, "Select ".concat(totalRecords, " ").concat(customLabel, "s")), /*#__PURE__*/React.createElement(Button, {
|
|
21003
21094
|
"data-test": "DesignSystem-Table-Header--clearSelectionItemsButton",
|
|
21004
21095
|
size: "tiny",
|
|
21005
|
-
|
|
21006
|
-
|
|
21007
|
-
|
|
21008
|
-
|
|
21096
|
+
className: "ml-4",
|
|
21097
|
+
onClick: onClearSelection
|
|
21098
|
+
}, "Clear Selection"), selectionActionRenderer && /*#__PURE__*/React.createElement(Divider, {
|
|
21099
|
+
vertical: true,
|
|
21100
|
+
className: "mx-4 Table-Header--Divider"
|
|
21101
|
+
}))), selectionActionRenderer && selectedRowsCount > 0 && showSelectedLabel && /*#__PURE__*/React.createElement("div", {
|
|
21102
|
+
"data-test": "DesignSystem-Table-Header--ActionRenderer",
|
|
21103
|
+
className: selectedRowLabelClass
|
|
21104
|
+
}, 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
21105
|
className: "Header-hideColumns"
|
|
21010
21106
|
}, /*#__PURE__*/React.createElement(DraggableDropdown, {
|
|
21011
21107
|
options: columnOptions,
|
|
@@ -21020,6 +21116,46 @@ Header.defaultProps = {
|
|
|
21020
21116
|
showFilters: true
|
|
21021
21117
|
};
|
|
21022
21118
|
|
|
21119
|
+
var isElementPresent = function isElementPresent(list, uniqueColumnName, value) {
|
|
21120
|
+
var arr = list === null || list === void 0 ? void 0 : list.filter(function (item) {
|
|
21121
|
+
return item[uniqueColumnName] === value;
|
|
21122
|
+
});
|
|
21123
|
+
return arr.length > 0;
|
|
21124
|
+
};
|
|
21125
|
+
|
|
21126
|
+
var getUpdatedData = function getUpdatedData(data, uniqueColumnName, selectedList, isCancelSelection, isSelectAll) {
|
|
21127
|
+
var updatedData = data.map(function (item) {
|
|
21128
|
+
if (isSelectAll || item._selected && !isCancelSelection || item[uniqueColumnName] && selectedList && isElementPresent(selectedList, uniqueColumnName, item[uniqueColumnName]) && !isCancelSelection) {
|
|
21129
|
+
item._selected = true;
|
|
21130
|
+
} else if (isCancelSelection) {
|
|
21131
|
+
item._selected = false;
|
|
21132
|
+
} else {
|
|
21133
|
+
item._selected = false;
|
|
21134
|
+
}
|
|
21135
|
+
|
|
21136
|
+
return item;
|
|
21137
|
+
});
|
|
21138
|
+
return updatedData;
|
|
21139
|
+
};
|
|
21140
|
+
|
|
21141
|
+
var uniqueByKey = function uniqueByKey(arr, key) {
|
|
21142
|
+
var list = new Set();
|
|
21143
|
+
return arr.filter(function (obj) {
|
|
21144
|
+
var value = obj[key];
|
|
21145
|
+
|
|
21146
|
+
if (list.has(value)) {
|
|
21147
|
+
return false;
|
|
21148
|
+
} else {
|
|
21149
|
+
list.add(value);
|
|
21150
|
+
return true;
|
|
21151
|
+
}
|
|
21152
|
+
});
|
|
21153
|
+
};
|
|
21154
|
+
|
|
21155
|
+
var removeDuplicate = function removeDuplicate(data, uniqueColumnName) {
|
|
21156
|
+
return uniqueByKey(data, uniqueColumnName);
|
|
21157
|
+
};
|
|
21158
|
+
|
|
21023
21159
|
var _excluded$l = ["children"];
|
|
21024
21160
|
|
|
21025
21161
|
var defaultErrorTemplate = function defaultErrorTemplate(props) {
|
|
@@ -21099,6 +21235,12 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21099
21235
|
|
|
21100
21236
|
_defineProperty$1(_assertThisInitialized$1(_this), "debounceUpdate", void 0);
|
|
21101
21237
|
|
|
21238
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "selectedRowsRef", /*#__PURE__*/React.createRef());
|
|
21239
|
+
|
|
21240
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "clearSelectionRef", /*#__PURE__*/React.createRef());
|
|
21241
|
+
|
|
21242
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "selectAllRef", /*#__PURE__*/React.createRef());
|
|
21243
|
+
|
|
21102
21244
|
_defineProperty$1(_assertThisInitialized$1(_this), "updateData", function (searchUpdate) {
|
|
21103
21245
|
if (_this.state.async) {
|
|
21104
21246
|
_this.setState({
|
|
@@ -21119,7 +21261,9 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21119
21261
|
pageSize = _this$props.pageSize,
|
|
21120
21262
|
withPagination = _this$props.withPagination,
|
|
21121
21263
|
dataProp = _this$props.data,
|
|
21122
|
-
onSearch = _this$props.onSearch
|
|
21264
|
+
onSearch = _this$props.onSearch,
|
|
21265
|
+
_this$props$uniqueCol = _this$props.uniqueColumnName,
|
|
21266
|
+
uniqueColumnName = _this$props$uniqueCol === void 0 ? 'id' : _this$props$uniqueCol;
|
|
21123
21267
|
var _this$state = _this.state,
|
|
21124
21268
|
async = _this$state.async,
|
|
21125
21269
|
page = _this$state.page,
|
|
@@ -21147,13 +21291,26 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21147
21291
|
fetchData(opts).then(function (res) {
|
|
21148
21292
|
if (!res.searchTerm || res.searchTerm && res.searchTerm === _this.state.searchTerm) {
|
|
21149
21293
|
var _data2 = res.data;
|
|
21294
|
+
var dataReplica = JSON.parse(JSON.stringify(_data2));
|
|
21150
21295
|
var schema = _this.state.schema.length ? _this.state.schema : res.schema;
|
|
21151
21296
|
|
|
21297
|
+
var preSelectedRows = _data2.filter(function (item) {
|
|
21298
|
+
return item._selected;
|
|
21299
|
+
});
|
|
21300
|
+
|
|
21301
|
+
if (_this.clearSelectionRef.current) {
|
|
21302
|
+
_this.selectedRowsRef.current = [];
|
|
21303
|
+
} else {
|
|
21304
|
+
_this.selectedRowsRef.current = _this.selectedRowsRef.current ? removeDuplicate([].concat(_toConsumableArray(_this.selectedRowsRef.current), _toConsumableArray(preSelectedRows)), uniqueColumnName) : removeDuplicate(_toConsumableArray(preSelectedRows), uniqueColumnName);
|
|
21305
|
+
}
|
|
21306
|
+
|
|
21307
|
+
var selectedData = getUpdatedData(dataReplica, uniqueColumnName, _this.selectedRowsRef.current, _this.clearSelectionRef.current, _this.selectAllRef.current);
|
|
21308
|
+
|
|
21152
21309
|
_this.setState({
|
|
21153
|
-
data:
|
|
21310
|
+
data: selectedData,
|
|
21154
21311
|
displayData: _data2,
|
|
21155
21312
|
schema: schema,
|
|
21156
|
-
selectAll: getSelectAll(
|
|
21313
|
+
selectAll: getSelectAll(selectedData, _this.props.selectDisabledRow, _this.clearSelectionRef.current),
|
|
21157
21314
|
totalRecords: res.count,
|
|
21158
21315
|
loading: false,
|
|
21159
21316
|
error: !_data2.length,
|
|
@@ -21181,23 +21338,76 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21181
21338
|
}
|
|
21182
21339
|
|
|
21183
21340
|
var renderedSchema = _this.state.schema.length ? _this.state.schema : schema;
|
|
21341
|
+
var preSelectedRows = renderedData.filter(function (item) {
|
|
21342
|
+
return item._selected;
|
|
21343
|
+
});
|
|
21344
|
+
|
|
21345
|
+
if (_this.clearSelectionRef.current) {
|
|
21346
|
+
_this.selectedRowsRef.current = [];
|
|
21347
|
+
} else {
|
|
21348
|
+
_this.selectedRowsRef.current = _this.selectedRowsRef.current ? removeDuplicate([].concat(_toConsumableArray(_this.selectedRowsRef.current), _toConsumableArray(preSelectedRows)), uniqueColumnName) : removeDuplicate(_toConsumableArray(preSelectedRows), uniqueColumnName);
|
|
21349
|
+
}
|
|
21350
|
+
|
|
21351
|
+
var selectedData = getUpdatedData(renderedData, uniqueColumnName, _this.selectedRowsRef.current, _this.clearSelectionRef.current, _this.selectAllRef.current);
|
|
21184
21352
|
|
|
21185
21353
|
_this.setState({
|
|
21186
21354
|
totalRecords: totalRecords,
|
|
21187
21355
|
error: !renderedData.length,
|
|
21188
21356
|
errorType: 'NO_RECORDS_FOUND',
|
|
21189
|
-
selectAll: getSelectAll(renderedData, _this.props.selectDisabledRow),
|
|
21357
|
+
selectAll: getSelectAll(renderedData, _this.props.selectDisabledRow, _this.clearSelectionRef.current),
|
|
21190
21358
|
schema: renderedSchema,
|
|
21191
21359
|
displayData: sortedData,
|
|
21192
|
-
data:
|
|
21360
|
+
data: selectedData
|
|
21193
21361
|
});
|
|
21194
21362
|
}
|
|
21195
21363
|
});
|
|
21196
21364
|
|
|
21197
21365
|
_defineProperty$1(_assertThisInitialized$1(_this), "onSelect", function (rowIndexes, selected) {
|
|
21198
21366
|
var data = _this.state.data;
|
|
21199
|
-
var
|
|
21367
|
+
var _this$props2 = _this.props,
|
|
21368
|
+
onSelect = _this$props2.onSelect,
|
|
21369
|
+
_this$props2$uniqueCo = _this$props2.uniqueColumnName,
|
|
21370
|
+
uniqueColumnName = _this$props2$uniqueCo === void 0 ? 'id' : _this$props2$uniqueCo;
|
|
21371
|
+
|
|
21372
|
+
if (_this.selectAllRef.current && rowIndexes !== -1 && !selected) {
|
|
21373
|
+
_this.selectAllRef.current = false;
|
|
21374
|
+
_this.selectedRowsRef.current = [];
|
|
21375
|
+
|
|
21376
|
+
var _indexes = Array.from({
|
|
21377
|
+
length: data.length
|
|
21378
|
+
}, function (_, i) {
|
|
21379
|
+
return i;
|
|
21380
|
+
});
|
|
21381
|
+
|
|
21382
|
+
var _newData = updateBatchData(data, _indexes, {
|
|
21383
|
+
_selected: false
|
|
21384
|
+
}, _this.props.selectDisabledRow);
|
|
21385
|
+
|
|
21386
|
+
_this.setState({
|
|
21387
|
+
data: _newData,
|
|
21388
|
+
selectAll: {
|
|
21389
|
+
checked: false,
|
|
21390
|
+
indeterminate: false
|
|
21391
|
+
}
|
|
21392
|
+
});
|
|
21393
|
+
|
|
21394
|
+
if (onSelect) {
|
|
21395
|
+
if (_this.props.uniqueColumnName) {
|
|
21396
|
+
onSelect(_indexes, selected, _this.selectedRowsRef.current, _this.selectAllRef.current);
|
|
21397
|
+
} else {
|
|
21398
|
+
// To avoid breaking the current selection flow
|
|
21399
|
+
onSelect(_indexes, selected, rowIndexes === -1 ? [] : _newData.filter(function (d) {
|
|
21400
|
+
return d._selected;
|
|
21401
|
+
}));
|
|
21402
|
+
}
|
|
21403
|
+
}
|
|
21404
|
+
|
|
21405
|
+
return;
|
|
21406
|
+
}
|
|
21407
|
+
|
|
21200
21408
|
var indexes = [rowIndexes];
|
|
21409
|
+
var rowData = data[rowIndexes];
|
|
21410
|
+
var selectedItemList = rowIndexes === -1 ? [] : [rowData];
|
|
21201
21411
|
var newData = data;
|
|
21202
21412
|
|
|
21203
21413
|
if (rowIndexes >= 0) {
|
|
@@ -21205,21 +21415,49 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21205
21415
|
_selected: selected
|
|
21206
21416
|
}, _this.props.selectDisabledRow);
|
|
21207
21417
|
|
|
21418
|
+
_this.resetClearSelection();
|
|
21419
|
+
|
|
21208
21420
|
_this.setState({
|
|
21209
21421
|
data: newData,
|
|
21210
|
-
selectAll: getSelectAll(newData, _this.props.selectDisabledRow)
|
|
21422
|
+
selectAll: getSelectAll(newData, _this.props.selectDisabledRow, _this.clearSelectionRef.current)
|
|
21211
21423
|
});
|
|
21424
|
+
|
|
21425
|
+
if (_this.selectedRowsRef.current && selected) {
|
|
21426
|
+
selectedItemList = [_objectSpread2(_objectSpread2({}, rowData), {}, {
|
|
21427
|
+
_selected: selected
|
|
21428
|
+
})].concat(_toConsumableArray(_this.selectedRowsRef.current));
|
|
21429
|
+
}
|
|
21430
|
+
|
|
21431
|
+
if (!selected) {
|
|
21432
|
+
selectedItemList = _this.selectedRowsRef.current.filter(function (item) {
|
|
21433
|
+
return item[uniqueColumnName] !== rowData[uniqueColumnName];
|
|
21434
|
+
});
|
|
21435
|
+
}
|
|
21436
|
+
|
|
21437
|
+
_this.selectedRowsRef.current = removeDuplicate(selectedItemList, uniqueColumnName);
|
|
21438
|
+
} else if (rowIndexes === -1 && _this.selectedRowsRef.current) {
|
|
21439
|
+
selectedItemList = _this.selectedRowsRef.current;
|
|
21212
21440
|
}
|
|
21213
21441
|
|
|
21214
21442
|
if (onSelect) {
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
|
|
21443
|
+
if (_this.props.uniqueColumnName) {
|
|
21444
|
+
var _selectedItemList;
|
|
21445
|
+
|
|
21446
|
+
onSelect(indexes, selected, rowIndexes === -1 && ((_selectedItemList = selectedItemList) === null || _selectedItemList === void 0 ? void 0 : _selectedItemList.length) === 0 ? [] : _this.selectedRowsRef.current, _this.selectAllRef.current);
|
|
21447
|
+
} else {
|
|
21448
|
+
// To avoid breaking the current selection flow
|
|
21449
|
+
onSelect(indexes, selected, rowIndexes === -1 ? [] : newData.filter(function (d) {
|
|
21450
|
+
return d._selected;
|
|
21451
|
+
}));
|
|
21452
|
+
}
|
|
21218
21453
|
}
|
|
21219
21454
|
});
|
|
21220
21455
|
|
|
21221
|
-
_defineProperty$1(_assertThisInitialized$1(_this), "onSelectAll", function (selected, selectAll) {
|
|
21222
|
-
var
|
|
21456
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "onSelectAll", function (selected, selectAll, headerCheckbox) {
|
|
21457
|
+
var _this$props3 = _this.props,
|
|
21458
|
+
onSelect = _this$props3.onSelect,
|
|
21459
|
+
_this$props3$uniqueCo = _this$props3.uniqueColumnName,
|
|
21460
|
+
uniqueColumnName = _this$props3$uniqueCo === void 0 ? 'id' : _this$props3$uniqueCo;
|
|
21223
21461
|
var data = _this.state.data;
|
|
21224
21462
|
var indexes = Array.from({
|
|
21225
21463
|
length: data.length
|
|
@@ -21235,11 +21473,43 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21235
21473
|
selectedIndex.push(key);
|
|
21236
21474
|
}
|
|
21237
21475
|
});
|
|
21476
|
+
var selectedData = [];
|
|
21238
21477
|
|
|
21239
|
-
if (
|
|
21240
|
-
|
|
21478
|
+
if (selected) {
|
|
21479
|
+
_this.resetClearSelection();
|
|
21480
|
+
|
|
21481
|
+
selectedData = selectAll === undefined ? [].concat(_toConsumableArray(_this.selectedRowsRef.current || []), _toConsumableArray(newData.filter(function (d) {
|
|
21241
21482
|
return d._selected;
|
|
21242
|
-
})
|
|
21483
|
+
}))) : _this.selectedRowsRef.current;
|
|
21484
|
+
} else if (!selected && headerCheckbox) {
|
|
21485
|
+
_this.selectAllRef.current = false;
|
|
21486
|
+
_this.selectedRowsRef.current = [].concat(_toConsumableArray(_this.selectedRowsRef.current || []), _toConsumableArray(newData));
|
|
21487
|
+
_this.selectedRowsRef.current = _this.selectedRowsRef.current.filter(function (item1) {
|
|
21488
|
+
return !newData.some(function (item2) {
|
|
21489
|
+
return item1[uniqueColumnName] === item2[uniqueColumnName];
|
|
21490
|
+
});
|
|
21491
|
+
});
|
|
21492
|
+
} else {
|
|
21493
|
+
_this.selectedRowsRef.current = [];
|
|
21494
|
+
_this.selectAllRef.current = false;
|
|
21495
|
+
}
|
|
21496
|
+
|
|
21497
|
+
if (!(headerCheckbox && !selected)) {
|
|
21498
|
+
_this.selectedRowsRef.current = removeDuplicate(selectedData, uniqueColumnName);
|
|
21499
|
+
}
|
|
21500
|
+
|
|
21501
|
+
if (onSelect) {
|
|
21502
|
+
if (_this.props.uniqueColumnName) {
|
|
21503
|
+
if (headerCheckbox && !selected) {
|
|
21504
|
+
onSelect(selectedIndex, selected, removeDuplicate(_this.selectedRowsRef.current, uniqueColumnName), _this.selectAllRef.current);
|
|
21505
|
+
} else {
|
|
21506
|
+
onSelect(selectedIndex, selected, removeDuplicate(selectedData, uniqueColumnName), _this.selectAllRef.current);
|
|
21507
|
+
}
|
|
21508
|
+
} else {
|
|
21509
|
+
onSelect(selectedIndex, selected, newData.filter(function (d) {
|
|
21510
|
+
return d._selected;
|
|
21511
|
+
}), selectAll);
|
|
21512
|
+
}
|
|
21243
21513
|
}
|
|
21244
21514
|
|
|
21245
21515
|
_this.setState({
|
|
@@ -21283,6 +21553,28 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21283
21553
|
});
|
|
21284
21554
|
});
|
|
21285
21555
|
|
|
21556
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "onClearSelection", function () {
|
|
21557
|
+
_this.selectedRowsRef.current = [];
|
|
21558
|
+
_this.clearSelectionRef.current = true;
|
|
21559
|
+
_this.selectAllRef.current = false;
|
|
21560
|
+
|
|
21561
|
+
_this.onSelectAll(false);
|
|
21562
|
+
|
|
21563
|
+
_this.setState({
|
|
21564
|
+
selectAll: getSelectAll([], _this.props.selectDisabledRow, _this.clearSelectionRef.current)
|
|
21565
|
+
});
|
|
21566
|
+
});
|
|
21567
|
+
|
|
21568
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "resetClearSelection", function () {
|
|
21569
|
+
_this.clearSelectionRef.current = false;
|
|
21570
|
+
});
|
|
21571
|
+
|
|
21572
|
+
_defineProperty$1(_assertThisInitialized$1(_this), "onSelectAllRows", function () {
|
|
21573
|
+
_this.selectAllRef.current = _this.props.uniqueColumnName ? true : false;
|
|
21574
|
+
|
|
21575
|
+
_this.onSelectAll(true, true);
|
|
21576
|
+
});
|
|
21577
|
+
|
|
21286
21578
|
var _async = ('fetchData' in _this.props);
|
|
21287
21579
|
|
|
21288
21580
|
var _data = props.data || [];
|
|
@@ -21320,11 +21612,11 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21320
21612
|
|
|
21321
21613
|
if (!this.state.async) {
|
|
21322
21614
|
if (prevProps.error !== this.props.error) {
|
|
21323
|
-
var _this$
|
|
21324
|
-
_this$
|
|
21325
|
-
_data3 = _this$
|
|
21326
|
-
_this$
|
|
21327
|
-
schema = _this$
|
|
21615
|
+
var _this$props4 = this.props,
|
|
21616
|
+
_this$props4$data = _this$props4.data,
|
|
21617
|
+
_data3 = _this$props4$data === void 0 ? [] : _this$props4$data,
|
|
21618
|
+
_this$props4$schema = _this$props4.schema,
|
|
21619
|
+
schema = _this$props4$schema === void 0 ? [] : _this$props4$schema;
|
|
21328
21620
|
|
|
21329
21621
|
this.setState({
|
|
21330
21622
|
data: _data3,
|
|
@@ -21339,11 +21631,11 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21339
21631
|
}
|
|
21340
21632
|
|
|
21341
21633
|
if (prevProps.loading !== this.props.loading) {
|
|
21342
|
-
var _this$
|
|
21343
|
-
_this$
|
|
21344
|
-
_data4 = _this$
|
|
21345
|
-
_this$
|
|
21346
|
-
_schema2 = _this$
|
|
21634
|
+
var _this$props5 = this.props,
|
|
21635
|
+
_this$props5$data = _this$props5.data,
|
|
21636
|
+
_data4 = _this$props5$data === void 0 ? [] : _this$props5$data,
|
|
21637
|
+
_this$props5$schema = _this$props5.schema,
|
|
21638
|
+
_schema2 = _this$props5$schema === void 0 ? [] : _this$props5$schema;
|
|
21347
21639
|
|
|
21348
21640
|
this.setState({
|
|
21349
21641
|
data: _data4,
|
|
@@ -21385,28 +21677,29 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21385
21677
|
}, {
|
|
21386
21678
|
key: "render",
|
|
21387
21679
|
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$
|
|
21680
|
+
var _this$props6 = this.props,
|
|
21681
|
+
showHead = _this$props6.showHead,
|
|
21682
|
+
type = _this$props6.type,
|
|
21683
|
+
size = _this$props6.size,
|
|
21684
|
+
headCellTooltip = _this$props6.headCellTooltip,
|
|
21685
|
+
separator = _this$props6.separator,
|
|
21686
|
+
draggable = _this$props6.draggable,
|
|
21687
|
+
nestedRows = _this$props6.nestedRows,
|
|
21688
|
+
nestedRowRenderer = _this$props6.nestedRowRenderer,
|
|
21689
|
+
withHeader = _this$props6.withHeader,
|
|
21690
|
+
headerOptions = _this$props6.headerOptions,
|
|
21691
|
+
withCheckbox = _this$props6.withCheckbox,
|
|
21692
|
+
showMenu = _this$props6.showMenu,
|
|
21693
|
+
withPagination = _this$props6.withPagination,
|
|
21694
|
+
paginationType = _this$props6.paginationType,
|
|
21695
|
+
pageSize = _this$props6.pageSize,
|
|
21696
|
+
pageJumpDebounceDuration = _this$props6.pageJumpDebounceDuration,
|
|
21697
|
+
onRowClick = _this$props6.onRowClick,
|
|
21698
|
+
loaderSchema = _this$props6.loaderSchema,
|
|
21699
|
+
errorTemplate = _this$props6.errorTemplate,
|
|
21700
|
+
className = _this$props6.className,
|
|
21701
|
+
filterPosition = _this$props6.filterPosition,
|
|
21702
|
+
uniqueColumnName = _this$props6.uniqueColumnName;
|
|
21410
21703
|
var baseProps = extractBaseProps(this.props);
|
|
21411
21704
|
|
|
21412
21705
|
var _ref = headerOptions,
|
|
@@ -21433,7 +21726,12 @@ var Table = /*#__PURE__*/function (_React$Component) {
|
|
|
21433
21726
|
withCheckbox: withCheckbox,
|
|
21434
21727
|
withPagination: withPagination,
|
|
21435
21728
|
pageSize: pageSize,
|
|
21436
|
-
showFilters: filterPosition === 'HEADER'
|
|
21729
|
+
showFilters: filterPosition === 'HEADER',
|
|
21730
|
+
selectedRowsRef: this.selectedRowsRef,
|
|
21731
|
+
onClearSelection: this.onClearSelection,
|
|
21732
|
+
onSelectAllRows: this.onSelectAllRows,
|
|
21733
|
+
selectedAllRef: this.selectAllRef,
|
|
21734
|
+
uniqueColumnName: uniqueColumnName
|
|
21437
21735
|
}, headerAttr), headerChildren)), /*#__PURE__*/React.createElement("div", {
|
|
21438
21736
|
className: "Table-grid"
|
|
21439
21737
|
}, /*#__PURE__*/React.createElement(Grid, _extends$2({}, this.state, {
|
|
@@ -26236,6 +26534,6 @@ Menu.defaultProps = {
|
|
|
26236
26534
|
position: 'bottom-start'
|
|
26237
26535
|
};
|
|
26238
26536
|
|
|
26239
|
-
var version = "2.
|
|
26537
|
+
var version = "2.31.0";
|
|
26240
26538
|
|
|
26241
26539
|
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 };
|