playbook_ui 12.26.0.pre.alpha.alphafix812 → 12.26.0.pre.alpha.multiselectfixes795

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c56ba5f2f20b82f0ce689ffbb9ce62e880f5654cd17af5b1b86e16b675a28df
4
- data.tar.gz: 0cc51604bbbe74db733521c1f62833449cfac742149346f72d8523a9d4a552cc
3
+ metadata.gz: 24795b41021899f723ab47809e4987e826064828a5d04c4c6632f41e209e568b
4
+ data.tar.gz: 5ea835ee66ecfcb7c757d3210bda91b4fc934df28c645351ced49d81a67c8e36
5
5
  SHA512:
6
- metadata.gz: 4c991cb7d0561b7383d8f615c31b6410803a069a1200d94a48dd28ba98f7cbf2bfcd11a6798259a2a39c00a079bcc55e0a26cbd6e1b933a72aca1b6d3660367e
7
- data.tar.gz: 7281c852cd6fd71d5967790691f3230a375f60a8a8a2b1572241f5a62edd3537f74489f22f37f40db143d30ad2465ef159f59c92529d4d2024f23ffd86f413bc
6
+ metadata.gz: 6e84b9df359d0ea6233755ce067b1941b1496d4f2604de1aa5c817b46dff1e1b1010279cadb899c0dfdb0094ae85ef955dd3dd73e2743b82a1c1dec70c390592
7
+ data.tar.gz: 1f51d591dd29ea949f2c2d67d081d16dfe6d3a12203041f7aea5558a9a98c9fc0b126e92cf4424b1e96c9174f1e618c3192d7726d0586d33d7805c96208e3b7a
@@ -210,3 +210,19 @@ export const removeChildrenIfParentChecked = (
210
210
  );
211
211
  setDefaultReturn([...filteredDefaultArray, items]);
212
212
  };
213
+
214
+ export const areAllCheckedFalse = (data:any) => {
215
+ for (const item of data) {
216
+ if (item.checked !== false) {
217
+ return false; // Return false if any item is not checked: false
218
+ }
219
+
220
+ if (Array.isArray(item.children && item.children.length > 0)) {
221
+ if (!areAllCheckedFalse(item.children)) {
222
+ return false; // Return false if any nested item is not checked: false
223
+ }
224
+ }
225
+ }
226
+
227
+ return true; // Return true if all items are checked: false
228
+ };
@@ -18,6 +18,7 @@ import {
18
18
  recursiveReturnOnlyParent,
19
19
  removeChildrenIfParentChecked,
20
20
  getChildIds,
21
+ areAllCheckedFalse
21
22
  } from "./_helper_functions";
22
23
 
23
24
  type MultiLevelSelectProps = {
@@ -94,8 +95,11 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
94
95
  };
95
96
  //if any items already checked in first render, set return accordingly
96
97
  const initialChecked = getCheckedItems(treeData)
98
+ const initialUnchecked = areAllCheckedFalse(treeData)
97
99
  initialChecked && returnAllSelected && setReturnedArray(initialChecked)
98
100
  initialChecked && !returnAllSelected && setDefaultReturn(initialChecked)
101
+ initialUnchecked && returnAllSelected && setReturnedArray([])
102
+ initialUnchecked && !returnAllSelected && setDefaultReturn([])
99
103
 
100
104
  // Attach the event listener
101
105
  window.addEventListener("click", handleClickOutside);