@devtron-labs/devtron-fe-common-lib 0.0.61-beta-1 → 0.0.61-beta-3
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/dist/index.js
CHANGED
|
@@ -29032,6 +29032,8 @@ var useBulkSelection = function () {
|
|
|
29032
29032
|
var BulkSelectionProvider = function (_a) {
|
|
29033
29033
|
var children = _a.children, identifiers = _a.identifiers, getSelectAllDialogStatus = _a.getSelectAllDialogStatus;
|
|
29034
29034
|
var _b = __read(React.useState({}), 2), selectedIdentifiers = _b[0], setSelectedIdentifiers = _b[1];
|
|
29035
|
+
var isBulkSelectionApplied = selectedIdentifiers[SELECT_ALL_ACROSS_PAGES_LOCATOR];
|
|
29036
|
+
var getSelectedIdentifiersCount = function () { return Object.keys(selectedIdentifiers).length; };
|
|
29035
29037
|
var setIdentifiersAfterClear = function (newIdentifiers, selectedIds) {
|
|
29036
29038
|
var _newIdentifiers = JSON.parse(JSON.stringify(newIdentifiers));
|
|
29037
29039
|
selectedIds.forEach(function (id) {
|
|
@@ -29042,7 +29044,7 @@ var BulkSelectionProvider = function (_a) {
|
|
|
29042
29044
|
var setIdentifiersAfterPageSelection = function (baseObject) {
|
|
29043
29045
|
var _selectedIdentifiers = JSON.parse(JSON.stringify(selectedIdentifiers));
|
|
29044
29046
|
// removing bulk selection across pages if present
|
|
29045
|
-
if (
|
|
29047
|
+
if (isBulkSelectionApplied) {
|
|
29046
29048
|
delete _selectedIdentifiers[SELECT_ALL_ACROSS_PAGES_LOCATOR];
|
|
29047
29049
|
}
|
|
29048
29050
|
setSelectedIdentifiers(__assign(__assign({}, _selectedIdentifiers), baseObject));
|
|
@@ -29066,10 +29068,10 @@ var BulkSelectionProvider = function (_a) {
|
|
|
29066
29068
|
break;
|
|
29067
29069
|
}
|
|
29068
29070
|
case exports.BulkSelectionEvents.SELECT_ALL_ACROSS_PAGES: {
|
|
29069
|
-
if (
|
|
29071
|
+
if (isBulkSelectionApplied) {
|
|
29070
29072
|
return;
|
|
29071
29073
|
}
|
|
29072
|
-
var selectedIdentifiersLength =
|
|
29074
|
+
var selectedIdentifiersLength = getSelectedIdentifiersCount();
|
|
29073
29075
|
// This is for showing a modal dialog if applicable to confirm if bulk selection is to be applied
|
|
29074
29076
|
// Do note that the 'getSelectAllDialogStatus' should be called after the length check explicitly
|
|
29075
29077
|
// otherwise the modal will open each time
|
|
@@ -29107,7 +29109,7 @@ var BulkSelectionProvider = function (_a) {
|
|
|
29107
29109
|
};
|
|
29108
29110
|
}
|
|
29109
29111
|
// if selectedIdentifiers contains select all across pages locator then it means all are selected
|
|
29110
|
-
if (
|
|
29112
|
+
if (isBulkSelectionApplied) {
|
|
29111
29113
|
return {
|
|
29112
29114
|
isChecked: true,
|
|
29113
29115
|
checkboxValue: exports.CHECKBOX_VALUE.BULK_CHECKED,
|
|
@@ -29132,7 +29134,9 @@ var BulkSelectionProvider = function (_a) {
|
|
|
29132
29134
|
handleBulkSelection: handleBulkSelection,
|
|
29133
29135
|
isChecked: isChecked,
|
|
29134
29136
|
checkboxValue: checkboxValue,
|
|
29135
|
-
|
|
29137
|
+
isBulkSelectionApplied: isBulkSelectionApplied,
|
|
29138
|
+
getSelectedIdentifiersCount: getSelectedIdentifiersCount,
|
|
29139
|
+
}); }, [selectedIdentifiers, handleBulkSelection, isChecked, checkboxValue, getSelectedIdentifiersCount]);
|
|
29136
29140
|
return jsxRuntime.jsx(BulkSelectionContext.Provider, __assign({ value: value }, { children: children }));
|
|
29137
29141
|
};
|
|
29138
29142
|
|
package/package.json
CHANGED
|
@@ -33,6 +33,10 @@ export const BulkSelectionProvider = <T,>({
|
|
|
33
33
|
}: UseBulkSelectionProps<T>) => {
|
|
34
34
|
const [selectedIdentifiers, setSelectedIdentifiers] = useState<T>({} as T)
|
|
35
35
|
|
|
36
|
+
const isBulkSelectionApplied = selectedIdentifiers[SELECT_ALL_ACROSS_PAGES_LOCATOR]
|
|
37
|
+
|
|
38
|
+
const getSelectedIdentifiersCount = () => Object.keys(selectedIdentifiers).length
|
|
39
|
+
|
|
36
40
|
const setIdentifiersAfterClear = (newIdentifiers: T, selectedIds: (number | string)[]) => {
|
|
37
41
|
const _newIdentifiers = JSON.parse(JSON.stringify(newIdentifiers))
|
|
38
42
|
selectedIds.forEach((id) => {
|
|
@@ -44,7 +48,7 @@ export const BulkSelectionProvider = <T,>({
|
|
|
44
48
|
const setIdentifiersAfterPageSelection = (baseObject: T) => {
|
|
45
49
|
const _selectedIdentifiers = JSON.parse(JSON.stringify(selectedIdentifiers))
|
|
46
50
|
// removing bulk selection across pages if present
|
|
47
|
-
if (
|
|
51
|
+
if (isBulkSelectionApplied) {
|
|
48
52
|
delete _selectedIdentifiers[SELECT_ALL_ACROSS_PAGES_LOCATOR]
|
|
49
53
|
}
|
|
50
54
|
|
|
@@ -74,10 +78,10 @@ export const BulkSelectionProvider = <T,>({
|
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
case BulkSelectionEvents.SELECT_ALL_ACROSS_PAGES: {
|
|
77
|
-
if (
|
|
81
|
+
if (isBulkSelectionApplied) {
|
|
78
82
|
return
|
|
79
83
|
}
|
|
80
|
-
const selectedIdentifiersLength =
|
|
84
|
+
const selectedIdentifiersLength = getSelectedIdentifiersCount()
|
|
81
85
|
// This is for showing a modal dialog if applicable to confirm if bulk selection is to be applied
|
|
82
86
|
// Do note that the 'getSelectAllDialogStatus' should be called after the length check explicitly
|
|
83
87
|
// otherwise the modal will open each time
|
|
@@ -122,7 +126,7 @@ export const BulkSelectionProvider = <T,>({
|
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
// if selectedIdentifiers contains select all across pages locator then it means all are selected
|
|
125
|
-
if (
|
|
129
|
+
if (isBulkSelectionApplied) {
|
|
126
130
|
return {
|
|
127
131
|
isChecked: true,
|
|
128
132
|
checkboxValue: CHECKBOX_VALUE.BULK_CHECKED,
|
|
@@ -155,8 +159,10 @@ export const BulkSelectionProvider = <T,>({
|
|
|
155
159
|
handleBulkSelection,
|
|
156
160
|
isChecked,
|
|
157
161
|
checkboxValue,
|
|
162
|
+
isBulkSelectionApplied,
|
|
163
|
+
getSelectedIdentifiersCount,
|
|
158
164
|
}),
|
|
159
|
-
[selectedIdentifiers, handleBulkSelection, isChecked, checkboxValue],
|
|
165
|
+
[selectedIdentifiers, handleBulkSelection, isChecked, checkboxValue, getSelectedIdentifiersCount],
|
|
160
166
|
)
|
|
161
167
|
|
|
162
168
|
return <BulkSelectionContext.Provider value={value}>{children}</BulkSelectionContext.Provider>
|