@bikdotai/bik-component-library 0.0.875 → 0.0.876-beta.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.
Files changed (46) hide show
  1. package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
  2. package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js.map +1 -1
  3. package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +27 -10
  4. package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.js.map +1 -1
  5. package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuList.js +1 -1
  6. package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuList.js.map +1 -1
  7. package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js +1 -1
  8. package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js.map +1 -1
  9. package/dist/cjs/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js +1 -1
  10. package/dist/cjs/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js.map +1 -1
  11. package/dist/cjs/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js +1 -1
  12. package/dist/cjs/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js.map +1 -1
  13. package/dist/cjs/components/dropdown/hooks/useDropdown.js +1 -1
  14. package/dist/cjs/components/dropdown/hooks/useDropdown.js.map +1 -1
  15. package/dist/cjs/components/multi-level-dropdown/MultiLevelDropdown.js +1 -1
  16. package/dist/cjs/components/multi-level-dropdown/MultiLevelDropdown.js.map +1 -1
  17. package/dist/cjs/components/multi-level-dropdown/MultiLevelDropdown.styled.js +14 -11
  18. package/dist/cjs/components/multi-level-dropdown/MultiLevelDropdown.styled.js.map +1 -1
  19. package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +300 -278
  20. package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js.map +1 -1
  21. package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.d.ts +8 -0
  22. package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +170 -126
  23. package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.js.map +1 -1
  24. package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.d.ts +4 -0
  25. package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.js +144 -112
  26. package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.js.map +1 -1
  27. package/dist/esm/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.d.ts +1 -0
  28. package/dist/esm/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js +32 -31
  29. package/dist/esm/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js.map +1 -1
  30. package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.d.ts +2 -0
  31. package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js +54 -39
  32. package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js.map +1 -1
  33. package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.d.ts +18 -16
  34. package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js +73 -27
  35. package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js.map +1 -1
  36. package/dist/esm/components/dropdown/hooks/useDropdown.d.ts +4 -17
  37. package/dist/esm/components/dropdown/hooks/useDropdown.js +176 -163
  38. package/dist/esm/components/dropdown/hooks/useDropdown.js.map +1 -1
  39. package/dist/esm/components/dropdown/type.d.ts +22 -0
  40. package/dist/esm/components/multi-level-dropdown/MultiLevelDropdown.js +46 -44
  41. package/dist/esm/components/multi-level-dropdown/MultiLevelDropdown.js.map +1 -1
  42. package/dist/esm/components/multi-level-dropdown/MultiLevelDropdown.styled.d.ts +3 -0
  43. package/dist/esm/components/multi-level-dropdown/MultiLevelDropdown.styled.js +29 -25
  44. package/dist/esm/components/multi-level-dropdown/MultiLevelDropdown.styled.js.map +1 -1
  45. package/dist/esm/components/multi-level-dropdown/type.d.ts +5 -0
  46. package/package.json +1 -1
@@ -1,242 +1,255 @@
1
- import X from "lodash/debounce";
2
- import { useState as E, useRef as j, useEffect as A, useCallback as Y, useMemo as Z } from "react";
3
- import { iterateOnOptionsRaw as _, iterateOnOptions as O } from "../OpenedDropdown/utils/iterationOnOptions.js";
4
- const S = (h = "1.0", b, y, I, g, w, k, q = [], a) => {
5
- const [c, i] = E(b ?? []), [v, p] = E([]), [n, z] = E(""), [B, m] = E(void 0), C = j(c), P = j(w);
6
- A(() => {
7
- P.current = w;
8
- }, [w]), A(() => {
9
- if (C.current = c, v.length && n && w) {
10
- let t = [...v];
11
- const r = c.map((e) => {
1
+ import Z from "lodash/debounce";
2
+ import { useState as D, useRef as k, useEffect as E, useCallback as _, useMemo as $ } from "react";
3
+ import { iterateOnOptionsRaw as K, getSelectionLeaves as x, iterateOnOptions as O } from "../OpenedDropdown/utils/iterationOnOptions.js";
4
+ const re = (h = "1.0", m, I, P, b, g, q, z = [], i, B) => {
5
+ const v = B === "nested", [f, d] = D(m ?? []), [p, w] = D([]), [n, G] = D(""), [J, C] = D(void 0), L = k(f), H = k(g);
6
+ E(() => {
7
+ H.current = g;
8
+ }, [g]), E(() => {
9
+ if (L.current = f, p.length && n && g) {
10
+ let t = [...p];
11
+ const s = f.map((e) => {
12
12
  if (e.options)
13
13
  return e.options.map((l) => ({
14
14
  value: l.value,
15
15
  selected: l.selected
16
16
  }));
17
- const s = e;
17
+ const r = e;
18
18
  return {
19
- value: s.value,
20
- selected: s.selected
19
+ value: r.value,
20
+ selected: r.selected
21
21
  };
22
22
  }).flat();
23
23
  t = t.map((e) => {
24
- const s = r.find(
24
+ const r = s.find(
25
25
  (l) => e.value === l.value
26
26
  );
27
- return s ? {
27
+ return r ? {
28
28
  ...e,
29
- selected: s.selected
29
+ selected: r.selected
30
30
  } : e;
31
- }), k && (t = t.map((e) => ({
31
+ }), q && (t = t.map((e) => ({
32
32
  ...e,
33
- disabled: !q.includes(e.value)
34
- }))), p(g && !I ? [
33
+ disabled: !z.includes(e.value)
34
+ }))), w(b && !P ? [
35
35
  ...t.sort(
36
36
  (e) => e.selected ? -1 : 1
37
37
  )
38
38
  ] : [...t]);
39
39
  }
40
- }, [c]), A(() => {
41
- if (b) {
42
- const t = [...b];
43
- i(g && !I ? [
40
+ }, [f]), E(() => {
41
+ if (m) {
42
+ const t = [...m];
43
+ d(b && !P ? [
44
44
  ...t.sort(
45
- (r) => r.selected ? -1 : 1
45
+ (s) => s.selected ? -1 : 1
46
46
  )
47
47
  ] : [...t]);
48
48
  }
49
- }, [b]);
50
- const H = (t) => {
51
- const r = [];
49
+ }, [m]);
50
+ const T = (t) => {
51
+ const s = [];
52
52
  return t.forEach((e) => {
53
53
  if (e.options) {
54
- const s = e.options.filter(
54
+ const r = e.options.filter(
55
55
  (l) => l.selected === !0
56
56
  );
57
- r.push({
57
+ s.push({
58
58
  ...e,
59
- options: [...s]
59
+ options: [...r]
60
60
  });
61
- } else
62
- e.selected && r.push({ ...e });
63
- }), r;
64
- }, L = (t) => {
65
- let r = 0;
66
- return t.forEach((e) => {
67
- e.options ? r += e.options.filter(
68
- (s) => s.selected === !0
69
- ).length : e.selected && r++;
70
- }), r;
71
- }, D = (t) => !g || !a && a !== 0 ? !1 : L(t) >= a, R = Y(async (t) => {
72
- const r = P.current;
73
- if (!t || !r) return;
61
+ } else {
62
+ const r = e;
63
+ if (v && r.children?.length) {
64
+ const l = r.children.filter(
65
+ (c) => c.selected
66
+ );
67
+ l.length && s.push({
68
+ ...r,
69
+ children: l
70
+ });
71
+ } else r.selected && s.push({ ...e });
72
+ }
73
+ }), s;
74
+ }, F = (t) => x(t, v).filter((s) => s.selected).length, R = (t) => !b || !i && i !== 0 ? !1 : F(t) >= i, y = _(async (t) => {
75
+ const s = H.current;
76
+ if (!t || !s) return;
74
77
  const e = [];
75
- _(C.current, (s) => {
76
- s.selected && !e.includes(s.value) && e.push(s.value);
78
+ K(L.current, (r) => {
79
+ r.selected && !e.includes(r.value) && e.push(r.value);
77
80
  });
78
81
  try {
79
- const s = await r(t);
80
- if (m(void 0), s) {
81
- const l = s.map((f) => {
82
- if (f.options) {
83
- const d = f;
82
+ const r = await s(t);
83
+ if (C(void 0), r) {
84
+ const l = r.map((c) => {
85
+ if (c.options) {
86
+ const a = c;
84
87
  return {
85
- ...d,
86
- options: d.options.map((u) => ({
88
+ ...a,
89
+ options: a.options.map((u) => ({
87
90
  ...u,
88
91
  selected: e.includes(u.value)
89
92
  }))
90
93
  };
91
94
  }
92
95
  return {
93
- ...f,
94
- selected: e.includes(f.value)
96
+ ...c,
97
+ selected: e.includes(c.value)
95
98
  };
96
99
  });
97
- p([...l]);
100
+ w([...l]);
98
101
  } else
99
- p([]);
100
- } catch (s) {
101
- p([]), m(
102
- s instanceof Error ? s.message : "Something went wrong while fetching the list. Please try again"
102
+ w([]);
103
+ } catch (r) {
104
+ w([]), C(
105
+ r instanceof Error ? r.message : "Something went wrong while fetching the list. Please try again"
103
106
  );
104
107
  }
105
- }, []), F = Z(
106
- () => X(R, 300),
107
- [R]
108
+ }, []), A = $(
109
+ () => Z(y, 300),
110
+ [y]
108
111
  );
109
- A(() => () => F?.cancel(), [F]);
110
- function G(t) {
111
- if (z(t), p([]), m(void 0), !t) {
112
- F?.cancel();
112
+ E(() => () => A?.cancel(), [A]);
113
+ function M(t) {
114
+ if (G(t), w([]), C(void 0), !t) {
115
+ A?.cancel();
113
116
  return;
114
117
  }
115
- F(t);
118
+ A(t);
116
119
  }
117
- function J() {
118
- n && (m(void 0), R(n));
120
+ function N() {
121
+ n && (C(void 0), y(n));
119
122
  }
120
- function T(t, r) {
121
- if (!g)
122
- y?.(t);
123
+ function W(t, s) {
124
+ if (!b)
125
+ I?.(t);
123
126
  else {
124
- if (t.selected && a && D(c))
127
+ if (t.selected && i && R(f))
125
128
  return;
126
- if (v.length && n && w)
129
+ if (p.length && n && g)
127
130
  if (t.selected) {
128
- if (a && D(c))
131
+ if (i && R(f))
129
132
  return;
130
133
  let e = !1;
131
- const s = O(
132
- c,
134
+ const r = O(
135
+ f,
133
136
  { selected: t.selected },
134
- (l) => l.value === t.value ? (e = !0, !0) : !1
137
+ (l) => l.value === t.value ? (e = !0, !0) : !1,
138
+ v
135
139
  );
136
- if (e || s.push(t), r)
137
- return [...s];
138
- i([...s]), h === "2.0" && o(s);
140
+ if (e || r.push(t), s)
141
+ return [...r];
142
+ d([...r]), h === "2.0" && o(r);
139
143
  } else {
140
- let e = !1, s = O(
141
- c,
144
+ let e = !1, r = O(
145
+ f,
142
146
  { selected: t.selected },
143
- (l) => l.value === t.value ? (e = !0, !0) : !1
147
+ (l) => l.value === t.value ? (e = !0, !0) : !1,
148
+ v
144
149
  );
145
- if (e && (s = s.filter((l) => l.value !== t.value)), r)
146
- return [...s];
147
- i([...s]), h === "2.0" && o(s);
150
+ if (e && (r = r.filter((l) => l.value !== t.value)), s)
151
+ return [...r];
152
+ d([...r]), h === "2.0" && o(r);
148
153
  }
149
154
  else {
150
155
  const e = O(
151
- c,
156
+ f,
152
157
  { selected: t.selected },
153
- (s) => s.value === t.value
158
+ (r) => r.value === t.value,
159
+ v
154
160
  );
155
- if (r)
161
+ if (s)
156
162
  return [...e];
157
- i([...e]), h === "2.0" && o(e);
163
+ d([...e]), h === "2.0" && o(e);
158
164
  }
159
165
  }
160
166
  }
161
- function M(t) {
162
- let r = [...c];
163
- v.forEach((e) => {
164
- r = r.map((s) => {
167
+ function Q(t) {
168
+ let s = [...f];
169
+ p.forEach((e) => {
170
+ s = s.map((r) => {
165
171
  const l = e;
166
- return typeof l.value < "u" && l.value === s.value ? {
167
- ...s,
172
+ return typeof l.value < "u" && l.value === r.value ? {
173
+ ...r,
168
174
  selected: !1
169
- } : s;
175
+ } : r;
170
176
  });
171
- }), i([...r]), h === "2.0" && o(r);
177
+ }), d([...s]), h === "2.0" && o(s);
172
178
  }
173
- function N(t) {
174
- let r = [...c];
175
- if (a && a > 0) {
176
- const e = L(r), s = a - e;
177
- if (s <= 0)
179
+ function U(t) {
180
+ let s = [...f];
181
+ if (i && i > 0) {
182
+ const e = F(s), r = i - e;
183
+ if (r <= 0)
178
184
  return;
179
185
  let l = 0;
180
- v.forEach((f) => {
181
- if (l >= s)
186
+ p.forEach((c) => {
187
+ if (l >= r)
182
188
  return;
183
- let d = !1;
184
- r = r.map((u) => {
185
- const W = f;
186
- return u.selected || u.disabled ? u : typeof W.value < "u" && W.value === u.value ? (d = !0, l++, {
189
+ let a = !1;
190
+ s = s.map((u) => {
191
+ const j = c;
192
+ return u.selected || u.disabled ? u : typeof j.value < "u" && j.value === u.value ? (a = !0, l++, {
187
193
  ...u,
188
194
  selected: !0
189
195
  }) : u;
190
- }), !d && l < s && (f.disabled || (r.push({ ...f, selected: !0 }), l++));
191
- }), i([...r]), h === "2.0" && o(r);
196
+ }), !a && l < r && (c.disabled || (s.push({ ...c, selected: !0 }), l++));
197
+ }), d([...s]), h === "2.0" && o(s);
192
198
  }
193
199
  }
194
- function Q(t) {
195
- if (v.length && n && w)
196
- t === "selectAll" ? N() : M();
200
+ function V(t) {
201
+ if (p.length && n && g)
202
+ t === "selectAll" ? U() : Q();
197
203
  else if (t === "selectAll")
198
- if (a && a > 0) {
199
- const r = L(c), e = a - r;
204
+ if (i && i > 0) {
205
+ const s = F(f), e = i - s;
200
206
  if (e <= 0)
201
207
  return;
202
- let s = 0;
203
- const l = c.map((f) => {
204
- if (f.options) {
205
- const d = f;
208
+ let r = 0;
209
+ const l = f.map((c) => {
210
+ if (c.options) {
211
+ const a = c;
206
212
  return {
207
- ...d,
208
- options: d.options.map((u) => u.disabled || u.selected || n && !u.label?.toLowerCase().includes(n.toLowerCase()) ? u : s < e ? (s++, { ...u, selected: !0 }) : u)
213
+ ...a,
214
+ options: a.options.map((u) => u.disabled || u.selected || n && !u.label?.toLowerCase().includes(n.toLowerCase()) ? u : r < e ? (r++, { ...u, selected: !0 }) : u)
209
215
  };
210
216
  } else {
211
- const d = f;
212
- return d.disabled || d.selected || n && !d.label?.toLowerCase().includes(n.toLowerCase()) ? f : s < e ? (s++, { ...f, selected: !0 }) : f;
217
+ const a = c;
218
+ return a.disabled || a.selected || n && !a.label?.toLowerCase().includes(n.toLowerCase()) ? c : r < e ? (r++, { ...c, selected: !0 }) : c;
213
219
  }
214
220
  });
215
- i([...l]), h === "2.0" && o(l);
221
+ d([...l]), h === "2.0" && o(l);
216
222
  } else {
217
- const r = O(
218
- c,
223
+ const s = O(
224
+ f,
219
225
  { selected: !0 },
220
- (e) => n ? e.label?.toLowerCase().includes(n.toLowerCase()) && !e.disabled : !e.disabled
226
+ (e) => n ? e.label?.toLowerCase().includes(n.toLowerCase()) && !e.disabled : !e.disabled,
227
+ v
221
228
  );
222
- i([...r]), h === "2.0" && o(r);
229
+ d([...s]), h === "2.0" && o(s);
223
230
  }
224
231
  else if (t === "notSelected") {
225
- const r = O(
226
- c,
232
+ const s = O(
233
+ f,
227
234
  { selected: !1 },
228
- (e) => !e.disabled
235
+ (e) => !e.disabled,
236
+ v
229
237
  );
230
- i([...r]), h === "2.0" && o(r);
238
+ d([...s]), h === "2.0" && o(s);
231
239
  }
232
240
  }
233
- function U() {
234
- const t = O(c, { selected: !1 });
235
- i([...t]), h === "2.0" && o(t);
241
+ function X() {
242
+ const t = O(
243
+ f,
244
+ { selected: !1 },
245
+ void 0,
246
+ v
247
+ );
248
+ d([...t]), h === "2.0" && o(t);
236
249
  }
237
- function V(t) {
238
- if (!g) {
239
- T({
250
+ function Y(t) {
251
+ if (!b) {
252
+ W({
240
253
  label: n,
241
254
  value: n,
242
255
  isFreeForm: !0,
@@ -244,7 +257,7 @@ const S = (h = "1.0", b, y, I, g, w, k, q = [], a) => {
244
257
  });
245
258
  return;
246
259
  }
247
- const r = c.map(
260
+ const s = f.map(
248
261
  (e) => e.options ? e : {
249
262
  ...e,
250
263
  selected: (
@@ -256,41 +269,41 @@ const S = (h = "1.0", b, y, I, g, w, k, q = [], a) => {
256
269
  )
257
270
  }
258
271
  );
259
- t && (r.some(
272
+ t && (s.some(
260
273
  (e) => e.label === n && e.value === n
261
- ) || r.unshift({
274
+ ) || s.unshift({
262
275
  label: n,
263
276
  value: n,
264
277
  isFreeForm: !0,
265
278
  selected: !0
266
- })), i([...r]), h === "2.0" && o(r);
279
+ })), d([...s]), h === "2.0" && o(s);
267
280
  }
268
281
  function o(t) {
269
- const r = H(
270
- t ?? C.current
282
+ const s = T(
283
+ t ?? L.current
271
284
  );
272
- y?.([...r]);
285
+ I?.([...s]);
273
286
  }
274
287
  return {
275
- latestDropdownOptionsRef: C,
276
- dropdownOptions: c,
277
- search: G,
288
+ latestDropdownOptionsRef: L,
289
+ dropdownOptions: f,
290
+ search: M,
278
291
  searchedString: n,
279
- searchedOptions: v,
280
- searchError: B,
281
- retrySearch: J,
282
- onApplyHandler: T,
283
- selectAllHandler: Q,
284
- onMultiSelectClear: U,
285
- onFreeFormSelect: V,
292
+ searchedOptions: p,
293
+ searchError: J,
294
+ retrySearch: N,
295
+ onApplyHandler: W,
296
+ selectAllHandler: V,
297
+ onMultiSelectClear: X,
298
+ onFreeFormSelect: Y,
286
299
  onMultiSelectApply: o,
287
- getSelectedOptions: H,
288
- getCurrentSelectionCount: L,
289
- isMaxSelectionsReached: D,
290
- maxSelections: a
300
+ getSelectedOptions: T,
301
+ getCurrentSelectionCount: F,
302
+ isMaxSelectionsReached: R,
303
+ maxSelections: i
291
304
  };
292
305
  };
293
306
  export {
294
- S as useDropdown
307
+ re as useDropdown
295
308
  };
296
309
  //# sourceMappingURL=useDropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDropdown.js","sources":["../../../../../src/components/dropdown/hooks/useDropdown.tsx"],"sourcesContent":["import debounce from 'lodash/debounce';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { SelectAllCheckboxState } from '../OpenedDropdown/components/menu/SelectAllMenu';\nimport {\n\titerateOnOptions,\n\titerateOnOptionsRaw,\n} from '../OpenedDropdown/utils/iterationOnOptions';\nimport { DropdownOption, GroupedOption, SingleOption } from '../type';\n\nexport const useDropdown = (\n\tversion = '1.0',\n\toptions: DropdownOption[],\n\tonSelect: ((option: DropdownOption | DropdownOption[]) => void) | undefined,\n\tskipSorting?: boolean,\n\tisMultiSelect?: boolean,\n\tonSearch?: (searchKey: string) => Promise<DropdownOption[]>,\n\tdisableOtherSearchedOption?: boolean,\n\tdisableSearchedOptionExcept: string[] = [],\n\tmaxSelections?: number,\n) => {\n\tconst [dropdownOptions, setDropdownOptions] = useState(options ?? []);\n\tconst [searchedOptions, setSearchedOptions] = useState<DropdownOption[]>([]);\n\tconst [searchedString, setSearchedString] = useState('');\n\tconst [searchError, setSearchError] = useState<string | undefined>(undefined);\n\tconst latestDropdownOptionsRef = useRef(dropdownOptions);\n\t/** Store latest onSearch so performSearch/debouncedSearch stay stable when parent re-renders with new callback reference. */\n\tconst onSearchRef = useRef(onSearch);\n\n\tuseEffect(() => {\n\t\tonSearchRef.current = onSearch;\n\t}, [onSearch]);\n\n\tuseEffect(() => {\n\t\tlatestDropdownOptionsRef.current = dropdownOptions;\n\n\t\tif (searchedOptions.length && searchedString && onSearch) {\n\t\t\tlet searchedOptionsClone = [...searchedOptions] as SingleOption[];\n\t\t\tconst dropdownOptionFlat = dropdownOptions\n\t\t\t\t.map((option) => {\n\t\t\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\t\t\treturn (option as GroupedOption).options.map((op) => ({\n\t\t\t\t\t\t\tvalue: op.value,\n\t\t\t\t\t\t\tselected: op.selected,\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t\tconst op = option as SingleOption;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: op.value,\n\t\t\t\t\t\tselected: op.selected,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.flat();\n\n\t\t\tsearchedOptionsClone = searchedOptionsClone.map((option) => {\n\t\t\t\tconst selectedDropdownOption = dropdownOptionFlat.find(\n\t\t\t\t\t(dropdownOption) => {\n\t\t\t\t\t\tif (option.value === dropdownOption.value) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tif (selectedDropdownOption) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\tselected: selectedDropdownOption.selected,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn option;\n\t\t\t});\n\n\t\t\t// disable other options except selected in searched options\n\t\t\tif (disableOtherSearchedOption) {\n\t\t\t\tsearchedOptionsClone = searchedOptionsClone.map((option) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\tdisabled: !disableSearchedOptionExcept.includes(option.value),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (isMultiSelect && !skipSorting) {\n\t\t\t\tsetSearchedOptions([\n\t\t\t\t\t...searchedOptionsClone.sort((option) =>\n\t\t\t\t\t\t(option as SingleOption).selected ? -1 : 1,\n\t\t\t\t\t),\n\t\t\t\t]);\n\t\t\t} else {\n\t\t\t\tsetSearchedOptions([...searchedOptionsClone]);\n\t\t\t}\n\t\t}\n\t}, [dropdownOptions]);\n\n\tuseEffect(() => {\n\t\tif (options) {\n\t\t\tconst writeOptions = [...options];\n\t\t\tif (isMultiSelect && !skipSorting) {\n\t\t\t\tsetDropdownOptions([\n\t\t\t\t\t...writeOptions.sort((option) =>\n\t\t\t\t\t\t(option as SingleOption).selected ? -1 : 1,\n\t\t\t\t\t),\n\t\t\t\t]);\n\t\t\t} else {\n\t\t\t\tsetDropdownOptions([...writeOptions]);\n\t\t\t}\n\t\t}\n\t}, [options]);\n\n\tconst getSelectedOptions = (data: DropdownOption[]) => {\n\t\tconst selectedOptions: DropdownOption[] = [];\n\t\tdata.forEach((option) => {\n\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\tconst groupedOptions = (option as GroupedOption).options.filter(\n\t\t\t\t\t(op) => op.selected === true,\n\t\t\t\t);\n\t\t\t\tselectedOptions.push({\n\t\t\t\t\t...option,\n\t\t\t\t\toptions: [...groupedOptions],\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tif ((option as SingleOption).selected) {\n\t\t\t\t\tselectedOptions.push({ ...option });\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn selectedOptions;\n\t};\n\n\t// Count current selections for max selection limit\n\tconst getCurrentSelectionCount = (data: DropdownOption[]) => {\n\t\tlet count = 0;\n\t\tdata.forEach((option) => {\n\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\tcount += (option as GroupedOption).options.filter(\n\t\t\t\t\t(op) => op.selected === true,\n\t\t\t\t).length;\n\t\t\t} else {\n\t\t\t\tif ((option as SingleOption).selected) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn count;\n\t};\n\n\t// Check if max selections limit is reached\n\tconst isMaxSelectionsReached = (data: DropdownOption[]) => {\n\t\tif (!isMultiSelect || (!maxSelections && maxSelections !== 0)) return false;\n\t\treturn getCurrentSelectionCount(data) >= maxSelections;\n\t};\n\n\t/** Reads onSearch from ref so it stays stable ([] deps). No-ops when onSearchRef.current is undefined. */\n\tconst performSearch = useCallback(async (searchKey: string) => {\n\t\tconst onSearchFn = onSearchRef.current;\n\t\tif (!searchKey || !onSearchFn) return;\n\n\t\tconst selectedIds: (string | number)[] = [];\n\t\titerateOnOptionsRaw(latestDropdownOptionsRef.current, (option) => {\n\t\t\tif (option.selected && !selectedIds.includes(option.value)) {\n\t\t\t\tselectedIds.push(option.value);\n\t\t\t}\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await onSearchFn(searchKey);\n\t\t\tsetSearchError(undefined);\n\t\t\tif (response) {\n\t\t\t\tconst updatedResponseData = response.map((option) => {\n\t\t\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\t\t\tconst groupedOption = option as GroupedOption;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...groupedOption,\n\t\t\t\t\t\t\toptions: groupedOption.options.map((op) => ({\n\t\t\t\t\t\t\t\t...op,\n\t\t\t\t\t\t\t\tselected: selectedIds.includes(op.value),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\tselected: selectedIds.includes((option as SingleOption).value),\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tsetSearchedOptions([...updatedResponseData]);\n\t\t\t} else {\n\t\t\t\tsetSearchedOptions([]);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tsetSearchedOptions([]);\n\t\t\tsetSearchError(\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? error.message\n\t\t\t\t\t: 'Something went wrong while fetching the list. Please try again',\n\t\t\t);\n\t\t}\n\t}, []);\n\n\t/** Independent of onSearch so debounce is stable when callers pass inline functions. Pending searches are preserved across parent re-renders. performSearch no-ops when onSearchRef.current is undefined. */\n\tconst debouncedSearch = useMemo(\n\t\t() => debounce(performSearch, 300),\n\t\t[performSearch],\n\t);\n\n\tuseEffect(() => () => debouncedSearch?.cancel(), [debouncedSearch]);\n\n\tfunction search(searchKey: string) {\n\t\tsetSearchedString(searchKey);\n\t\tsetSearchedOptions([]);\n\t\tsetSearchError(undefined);\n\n\t\tif (!searchKey) {\n\t\t\tdebouncedSearch?.cancel();\n\t\t\treturn;\n\t\t}\n\n\t\tdebouncedSearch(searchKey);\n\t}\n\n\tfunction retrySearch() {\n\t\tif (searchedString) {\n\t\t\tsetSearchError(undefined);\n\t\t\tperformSearch(searchedString);\n\t\t}\n\t}\n\n\t/**\n\t * wrapper to prepare option for onSelect\n\t * for single select, this will call the onClose handler ,\n\t * for multiselect, it will do state update for options list\n\t * \t\tto make any option select,\n\t * \t\t\t\tonApplyHandler({ label, value: selected: true })\n\t * to deselect any option\n\t * \t\t\t\tonApplyHandler({ label, value: selected: false })\n\t * @param optionSelect\n\t */\n\tfunction onApplyHandler(optionSelect: SingleOption, returnOnly?: boolean) {\n\t\tif (!isMultiSelect) {\n\t\t\tonSelect?.(optionSelect);\n\t\t} else {\n\t\t\t// Check if trying to select and max selections is reached\n\t\t\tif (\n\t\t\t\toptionSelect.selected &&\n\t\t\t\tmaxSelections &&\n\t\t\t\tisMaxSelectionsReached(dropdownOptions)\n\t\t\t) {\n\t\t\t\t// Max selections reached, don't allow new selections\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (searchedOptions.length && searchedString && onSearch) {\n\t\t\t\t/** Search mode */\n\t\t\t\t/**\n\t\t\t\t * on selected, push it to dropdown options,\n\t\t\t\t * on un-select, remove from dropdown option\n\t\t\t\t */\n\n\t\t\t\tif (optionSelect.selected) {\n\t\t\t\t\t// Check max selections for search mode too\n\t\t\t\t\tif (maxSelections && isMaxSelectionsReached(dropdownOptions)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t/** check if already there or not,\n\t\t\t\t\t * if yes, just update\n\t\t\t\t\t * else ,\n\t\t\t\t\t * \tappend\n\t\t\t\t\t */\n\n\t\t\t\t\tlet alreadyPresentInInitialOptions = false;\n\t\t\t\t\tconst currList = iterateOnOptions(\n\t\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t\t{ selected: optionSelect.selected } as Partial<SingleOption>,\n\t\t\t\t\t\t(optionForValidation: SingleOption) => {\n\t\t\t\t\t\t\tif (optionForValidation.value === optionSelect.value) {\n\t\t\t\t\t\t\t\talreadyPresentInInitialOptions = true;\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tif (!alreadyPresentInInitialOptions) {\n\t\t\t\t\t\tcurrList.push(optionSelect);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (returnOnly) {\n\t\t\t\t\t\treturn [...currList];\n\t\t\t\t\t}\n\t\t\t\t\tsetDropdownOptions([...currList]);\n\t\t\t\t\tif (version === '2.0') {\n\t\t\t\t\t\tonMultiSelectApply(currList);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/** un-select,\n\t\t\t\t\t * if already present in initial data,\n\t\t\t\t\t * yes, just update\n\t\t\t\t\t * else,\n\t\t\t\t\t * \tremove\n\t\t\t\t\t */\n\n\t\t\t\t\tlet alreadyPresentInInitialOptions = false;\n\t\t\t\t\tlet currList = iterateOnOptions(\n\t\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t\t{ selected: optionSelect.selected } as Partial<SingleOption>,\n\t\t\t\t\t\t(optionForValidation: SingleOption) => {\n\t\t\t\t\t\t\tif (optionForValidation.value === optionSelect.value) {\n\t\t\t\t\t\t\t\talreadyPresentInInitialOptions = true;\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tif (alreadyPresentInInitialOptions) {\n\t\t\t\t\t\tcurrList = currList.filter((option) => {\n\t\t\t\t\t\t\tif (option.value === optionSelect.value) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tif (returnOnly) {\n\t\t\t\t\t\treturn [...currList];\n\t\t\t\t\t}\n\t\t\t\t\tsetDropdownOptions([...currList]);\n\t\t\t\t\tif (version === '2.0') {\n\t\t\t\t\t\tonMultiSelectApply(currList);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst currList = iterateOnOptions(\n\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t{ selected: optionSelect.selected } as Partial<SingleOption>,\n\t\t\t\t\t(optionForValidation: SingleOption) =>\n\t\t\t\t\t\toptionForValidation.value === optionSelect.value,\n\t\t\t\t);\n\n\t\t\t\tif (returnOnly) {\n\t\t\t\t\treturn [...currList];\n\t\t\t\t}\n\t\t\t\tsetDropdownOptions([...currList]);\n\t\t\t\tif (version === '2.0') {\n\t\t\t\t\tonMultiSelectApply(currList);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction selectAllForSearch(select: boolean) {\n\t\t// const allSearchedValues = searchedOptions.map(option => option.value);\n\t\tlet clonedDropdownOptions = [...dropdownOptions];\n\n\t\tif (select) {\n\t\t\tsearchedOptions.forEach((option) => {\n\t\t\t\tlet found = false;\n\t\t\t\tclonedDropdownOptions = clonedDropdownOptions.map((dOption) => {\n\t\t\t\t\tconst singleOption = option as SingleOption;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof singleOption.value !== 'undefined' &&\n\t\t\t\t\t\tsingleOption.value === (dOption as SingleOption).value\n\t\t\t\t\t) {\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...dOption,\n\t\t\t\t\t\t\tselected: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn dOption;\n\t\t\t\t});\n\n\t\t\t\tif (!found) {\n\t\t\t\t\tclonedDropdownOptions.push({ ...option, selected: true });\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tsearchedOptions.forEach((option) => {\n\t\t\t\tclonedDropdownOptions = clonedDropdownOptions.map((dOption) => {\n\t\t\t\t\tconst singleOption = option as SingleOption;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof singleOption.value !== 'undefined' &&\n\t\t\t\t\t\tsingleOption.value === (dOption as SingleOption).value\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...dOption,\n\t\t\t\t\t\t\tselected: false,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn dOption;\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tsetDropdownOptions([...clonedDropdownOptions]);\n\t\tif (version === '2.0') {\n\t\t\tonMultiSelectApply(clonedDropdownOptions);\n\t\t}\n\t}\n\n\tfunction selectAllForSearchWithLimit(select: boolean) {\n\t\tlet clonedDropdownOptions = [...dropdownOptions];\n\n\t\tif (select && maxSelections && maxSelections > 0) {\n\t\t\tconst currentCount = getCurrentSelectionCount(clonedDropdownOptions);\n\t\t\tconst remainingSlots = maxSelections - currentCount;\n\n\t\t\tif (remainingSlots <= 0) {\n\t\t\t\t// Already at max, don't select any more\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet selectedCount = 0;\n\t\t\tsearchedOptions.forEach((option) => {\n\t\t\t\tif (selectedCount >= remainingSlots) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet found = false;\n\t\t\t\tclonedDropdownOptions = clonedDropdownOptions.map((dOption) => {\n\t\t\t\t\tconst singleOption = option as SingleOption;\n\t\t\t\t\t// Skip if already selected\n\t\t\t\t\tif ((dOption as SingleOption).selected) {\n\t\t\t\t\t\treturn dOption;\n\t\t\t\t\t}\n\t\t\t\t\t// Skip if disabled\n\t\t\t\t\tif ((dOption as SingleOption).disabled) {\n\t\t\t\t\t\treturn dOption;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof singleOption.value !== 'undefined' &&\n\t\t\t\t\t\tsingleOption.value === (dOption as SingleOption).value\n\t\t\t\t\t) {\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tselectedCount++;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...dOption,\n\t\t\t\t\t\t\tselected: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn dOption;\n\t\t\t\t});\n\n\t\t\t\tif (!found && selectedCount < remainingSlots) {\n\t\t\t\t\tconst newOption = option as SingleOption;\n\t\t\t\t\tif (!newOption.disabled) {\n\t\t\t\t\t\tclonedDropdownOptions.push({ ...option, selected: true });\n\t\t\t\t\t\tselectedCount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tsetDropdownOptions([...clonedDropdownOptions]);\n\t\t\tif (version === '2.0') {\n\t\t\t\tonMultiSelectApply(clonedDropdownOptions);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction selectAllHandler(newState: SelectAllCheckboxState) {\n\t\tif (searchedOptions.length && searchedString && onSearch) {\n\t\t\tif (newState === 'selectAll') {\n\t\t\t\tselectAllForSearchWithLimit(true);\n\t\t\t} else {\n\t\t\t\tselectAllForSearch(false);\n\t\t\t}\n\t\t} else {\n\t\t\tif (newState === 'selectAll') {\n\t\t\t\tif (maxSelections && maxSelections > 0) {\n\t\t\t\t\t// Only select up to maxSelections limit\n\t\t\t\t\tconst currentCount = getCurrentSelectionCount(dropdownOptions);\n\t\t\t\t\tconst remainingSlots = maxSelections - currentCount;\n\n\t\t\t\t\tif (remainingSlots <= 0) {\n\t\t\t\t\t\t// Already at max, don't select any more\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet selectedCount = 0;\n\t\t\t\t\tconst newOptions = dropdownOptions.map((option) => {\n\t\t\t\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\t\t\t\t// Handle grouped options\n\t\t\t\t\t\t\tconst groupedOption = option as GroupedOption;\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...groupedOption,\n\t\t\t\t\t\t\t\toptions: groupedOption.options.map((op) => {\n\t\t\t\t\t\t\t\t\t// Skip disabled options\n\t\t\t\t\t\t\t\t\tif (op.disabled) {\n\t\t\t\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Check if already selected\n\t\t\t\t\t\t\t\t\tif (op.selected) {\n\t\t\t\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Check search filter\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tsearchedString &&\n\t\t\t\t\t\t\t\t\t\t!op.label\n\t\t\t\t\t\t\t\t\t\t\t?.toLowerCase()\n\t\t\t\t\t\t\t\t\t\t\t.includes(searchedString.toLowerCase())\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Select if we have remaining slots\n\t\t\t\t\t\t\t\t\tif (selectedCount < remainingSlots) {\n\t\t\t\t\t\t\t\t\t\tselectedCount++;\n\t\t\t\t\t\t\t\t\t\treturn { ...op, selected: true };\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst singleOption = option as SingleOption;\n\t\t\t\t\t\t\t// Skip disabled options\n\t\t\t\t\t\t\tif (singleOption.disabled) {\n\t\t\t\t\t\t\t\treturn option;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Check if already selected\n\t\t\t\t\t\t\tif (singleOption.selected) {\n\t\t\t\t\t\t\t\treturn option;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Check search filter\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tsearchedString &&\n\t\t\t\t\t\t\t\t!singleOption.label\n\t\t\t\t\t\t\t\t\t?.toLowerCase()\n\t\t\t\t\t\t\t\t\t.includes(searchedString.toLowerCase())\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn option;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Select if we have remaining slots\n\t\t\t\t\t\t\tif (selectedCount < remainingSlots) {\n\t\t\t\t\t\t\t\tselectedCount++;\n\t\t\t\t\t\t\t\treturn { ...option, selected: true };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn option;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tsetDropdownOptions([...newOptions]);\n\t\t\t\t\tif (version === '2.0') {\n\t\t\t\t\t\tonMultiSelectApply(newOptions);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// No max selection limit, select all\n\t\t\t\t\tconst newOptions = iterateOnOptions(\n\t\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t\t{ selected: true },\n\t\t\t\t\t\t(option) =>\n\t\t\t\t\t\t\tsearchedString\n\t\t\t\t\t\t\t\t? option.label\n\t\t\t\t\t\t\t\t\t\t?.toLowerCase()\n\t\t\t\t\t\t\t\t\t\t.includes(searchedString.toLowerCase()) && !option.disabled\n\t\t\t\t\t\t\t\t: !option.disabled,\n\t\t\t\t\t);\n\t\t\t\t\tsetDropdownOptions([...newOptions]);\n\t\t\t\t\tif (version === '2.0') {\n\t\t\t\t\t\tonMultiSelectApply(newOptions);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (newState === 'notSelected') {\n\t\t\t\tconst newOptions = iterateOnOptions(\n\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t{ selected: false },\n\t\t\t\t\t(option) => !option.disabled,\n\t\t\t\t);\n\t\t\t\tsetDropdownOptions([...newOptions]);\n\t\t\t\tif (version === '2.0') {\n\t\t\t\t\tonMultiSelectApply(newOptions);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onMultiSelectClear() {\n\t\tconst newOptions = iterateOnOptions(dropdownOptions, { selected: false });\n\t\tsetDropdownOptions([...newOptions]);\n\t\tif (version === '2.0') {\n\t\t\tonMultiSelectApply(newOptions);\n\t\t}\n\t}\n\n\tfunction onFreeFormSelect(selected: boolean) {\n\t\tif (!isMultiSelect) {\n\t\t\tonApplyHandler({\n\t\t\t\tlabel: searchedString,\n\t\t\t\tvalue: searchedString,\n\t\t\t\tisFreeForm: true,\n\t\t\t\tselected: true,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst updatedList = dropdownOptions.map((option) =>\n\t\t\t(option as GroupedOption).options\n\t\t\t\t? option\n\t\t\t\t: {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\tselected:\n\t\t\t\t\t\t\t/** free form check */\n\t\t\t\t\t\t\toption.label === searchedString &&\n\t\t\t\t\t\t\t(option as SingleOption).value === searchedString\n\t\t\t\t\t\t\t\t? /** to mark as selected or not */\n\t\t\t\t\t\t\t\t selected\n\t\t\t\t\t\t\t\t: (option as SingleOption).selected,\n\t\t\t\t },\n\t\t);\n\n\t\tif (selected) {\n\t\t\tif (\n\t\t\t\t!updatedList.some(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\toption.label === searchedString &&\n\t\t\t\t\t\t(option as SingleOption).value === searchedString,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedList.unshift({\n\t\t\t\t\tlabel: searchedString,\n\t\t\t\t\tvalue: searchedString,\n\t\t\t\t\tisFreeForm: true,\n\t\t\t\t\tselected: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tsetDropdownOptions([...updatedList]);\n\t\tif (version === '2.0') {\n\t\t\tonMultiSelectApply(updatedList);\n\t\t}\n\t}\n\n\t/**\n\t * This is called when appy button is called,\n\t * here iterate and pick all options where selected if true.\n\t */\n\tfunction onMultiSelectApply(options?: DropdownOption[]) {\n\t\tconst optionsToSend: DropdownOption[] = getSelectedOptions(\n\t\t\toptions ?? latestDropdownOptionsRef.current,\n\t\t);\n\n\t\tonSelect?.([...optionsToSend]);\n\t}\n\n\treturn {\n\t\tlatestDropdownOptionsRef,\n\t\tdropdownOptions,\n\t\tsearch,\n\t\tsearchedString,\n\t\tsearchedOptions,\n\t\tsearchError,\n\t\tretrySearch,\n\t\tonApplyHandler,\n\t\tselectAllHandler,\n\t\tonMultiSelectClear,\n\t\tonFreeFormSelect,\n\t\tonMultiSelectApply,\n\t\tgetSelectedOptions,\n\t\tgetCurrentSelectionCount,\n\t\tisMaxSelectionsReached,\n\t\tmaxSelections,\n\t};\n};\n"],"names":["useDropdown","version","options","onSelect","skipSorting","isMultiSelect","onSearch","disableOtherSearchedOption","disableSearchedOptionExcept","maxSelections","dropdownOptions","setDropdownOptions","useState","searchedOptions","setSearchedOptions","searchedString","setSearchedString","searchError","setSearchError","latestDropdownOptionsRef","useRef","onSearchRef","useEffect","searchedOptionsClone","dropdownOptionFlat","option","op","selectedDropdownOption","dropdownOption","writeOptions","getSelectedOptions","data","selectedOptions","groupedOptions","getCurrentSelectionCount","count","isMaxSelectionsReached","performSearch","useCallback","searchKey","onSearchFn","selectedIds","iterateOnOptionsRaw","response","updatedResponseData","groupedOption","error","debouncedSearch","useMemo","debounce","search","retrySearch","onApplyHandler","optionSelect","returnOnly","alreadyPresentInInitialOptions","currList","iterateOnOptions","optionForValidation","onMultiSelectApply","selectAllForSearch","select","clonedDropdownOptions","dOption","singleOption","selectAllForSearchWithLimit","currentCount","remainingSlots","selectedCount","found","selectAllHandler","newState","newOptions","onMultiSelectClear","onFreeFormSelect","selected","updatedList","optionsToSend"],"mappings":";;;AASO,MAAMA,IAAc,CAC1BC,IAAU,OACVC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,IAAwC,CAAA,GACxCC,MACI;AACJ,QAAM,CAACC,GAAiBC,CAAkB,IAAIC,EAASV,KAAW,CAAA,CAAE,GAC9D,CAACW,GAAiBC,CAAkB,IAAIF,EAA2B,CAAA,CAAE,GACrE,CAACG,GAAgBC,CAAiB,IAAIJ,EAAS,EAAE,GACjD,CAACK,GAAaC,CAAc,IAAIN,EAA6B,MAAS,GACtEO,IAA2BC,EAAOV,CAAe,GAEjDW,IAAcD,EAAOd,CAAQ;AAEnC,EAAAgB,EAAU,MAAM;AACf,IAAAD,EAAY,UAAUf;AAAA,EACvB,GAAG,CAACA,CAAQ,CAAC,GAEbgB,EAAU,MAAM;AAGf,QAFAH,EAAyB,U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,GAAG0E,CAAa,CAAC;AAAA,EAC9B;AAEA,SAAO;AAAA,IACN,0BAAA1D;AAAA,IACA,iBAAAT;AAAA,IACA,QAAAwC;AAAA,IACA,gBAAAnC;AAAA,IACA,iBAAAF;AAAA,IACA,aAAAI;AAAA,IACA,aAAAkC;AAAA,IACA,gBAAAC;AAAA,IACA,kBAAAkB;AAAA,IACA,oBAAAG;AAAA,IACA,kBAAAC;AAAA,IACA,oBAAAf;AAAA,IACA,oBAAA7B;AAAA,IACA,0BAAAI;AAAA,IACA,wBAAAE;AAAA,IACA,eAAA3B;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"useDropdown.js","sources":["../../../../../src/components/dropdown/hooks/useDropdown.tsx"],"sourcesContent":["import debounce from 'lodash/debounce';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { SelectAllCheckboxState } from '../OpenedDropdown/components/menu/SelectAllMenu';\nimport {\n\tgetSelectionLeaves,\n\titerateOnOptions,\n\titerateOnOptionsRaw,\n} from '../OpenedDropdown/utils/iterationOnOptions';\nimport { DropdownOption, GroupedOption, SingleOption } from '../type';\n\nexport const useDropdown = (\n\tversion = '1.0',\n\toptions: DropdownOption[],\n\tonSelect: ((option: DropdownOption | DropdownOption[]) => void) | undefined,\n\tskipSorting?: boolean,\n\tisMultiSelect?: boolean,\n\tonSearch?: (searchKey: string) => Promise<DropdownOption[]>,\n\tdisableOtherSearchedOption?: boolean,\n\tdisableSearchedOptionExcept: string[] = [],\n\tmaxSelections?: number,\n\tchildrenLayout?: 'flyout' | 'nested',\n) => {\n\t// Only the nested layout makes children selectable; a flyout submenu click\n\t// marks the parent instead.\n\tconst nestedChildren = childrenLayout === 'nested';\n\tconst [dropdownOptions, setDropdownOptions] = useState(options ?? []);\n\tconst [searchedOptions, setSearchedOptions] = useState<DropdownOption[]>([]);\n\tconst [searchedString, setSearchedString] = useState('');\n\tconst [searchError, setSearchError] = useState<string | undefined>(undefined);\n\tconst latestDropdownOptionsRef = useRef(dropdownOptions);\n\t/** Store latest onSearch so performSearch/debouncedSearch stay stable when parent re-renders with new callback reference. */\n\tconst onSearchRef = useRef(onSearch);\n\n\tuseEffect(() => {\n\t\tonSearchRef.current = onSearch;\n\t}, [onSearch]);\n\n\tuseEffect(() => {\n\t\tlatestDropdownOptionsRef.current = dropdownOptions;\n\n\t\tif (searchedOptions.length && searchedString && onSearch) {\n\t\t\tlet searchedOptionsClone = [...searchedOptions] as SingleOption[];\n\t\t\tconst dropdownOptionFlat = dropdownOptions\n\t\t\t\t.map((option) => {\n\t\t\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\t\t\treturn (option as GroupedOption).options.map((op) => ({\n\t\t\t\t\t\t\tvalue: op.value,\n\t\t\t\t\t\t\tselected: op.selected,\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t\tconst op = option as SingleOption;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: op.value,\n\t\t\t\t\t\tselected: op.selected,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.flat();\n\n\t\t\tsearchedOptionsClone = searchedOptionsClone.map((option) => {\n\t\t\t\tconst selectedDropdownOption = dropdownOptionFlat.find(\n\t\t\t\t\t(dropdownOption) => {\n\t\t\t\t\t\tif (option.value === dropdownOption.value) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tif (selectedDropdownOption) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\tselected: selectedDropdownOption.selected,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn option;\n\t\t\t});\n\n\t\t\t// disable other options except selected in searched options\n\t\t\tif (disableOtherSearchedOption) {\n\t\t\t\tsearchedOptionsClone = searchedOptionsClone.map((option) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\tdisabled: !disableSearchedOptionExcept.includes(option.value),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (isMultiSelect && !skipSorting) {\n\t\t\t\tsetSearchedOptions([\n\t\t\t\t\t...searchedOptionsClone.sort((option) =>\n\t\t\t\t\t\t(option as SingleOption).selected ? -1 : 1,\n\t\t\t\t\t),\n\t\t\t\t]);\n\t\t\t} else {\n\t\t\t\tsetSearchedOptions([...searchedOptionsClone]);\n\t\t\t}\n\t\t}\n\t}, [dropdownOptions]);\n\n\tuseEffect(() => {\n\t\tif (options) {\n\t\t\tconst writeOptions = [...options];\n\t\t\tif (isMultiSelect && !skipSorting) {\n\t\t\t\tsetDropdownOptions([\n\t\t\t\t\t...writeOptions.sort((option) =>\n\t\t\t\t\t\t(option as SingleOption).selected ? -1 : 1,\n\t\t\t\t\t),\n\t\t\t\t]);\n\t\t\t} else {\n\t\t\t\tsetDropdownOptions([...writeOptions]);\n\t\t\t}\n\t\t}\n\t}, [options]);\n\n\tconst getSelectedOptions = (data: DropdownOption[]) => {\n\t\tconst selectedOptions: DropdownOption[] = [];\n\t\tdata.forEach((option) => {\n\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\tconst groupedOptions = (option as GroupedOption).options.filter(\n\t\t\t\t\t(op) => op.selected === true,\n\t\t\t\t);\n\t\t\t\tselectedOptions.push({\n\t\t\t\t\t...option,\n\t\t\t\t\toptions: [...groupedOptions],\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst singleOption = option as SingleOption;\n\t\t\t\tif (nestedChildren && singleOption.children?.length) {\n\t\t\t\t\t// A partly selected parent is itself unselected, so report it\n\t\t\t\t\t// whenever any child is selected, carrying only those children.\n\t\t\t\t\tconst selectedChildren = singleOption.children.filter(\n\t\t\t\t\t\t(child) => child.selected,\n\t\t\t\t\t);\n\t\t\t\t\tif (selectedChildren.length) {\n\t\t\t\t\t\tselectedOptions.push({\n\t\t\t\t\t\t\t...singleOption,\n\t\t\t\t\t\t\tchildren: selectedChildren,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else if (singleOption.selected) {\n\t\t\t\t\tselectedOptions.push({ ...option });\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn selectedOptions;\n\t};\n\n\t// Count current selections for max selection limit\n\tconst getCurrentSelectionCount = (data: DropdownOption[]) =>\n\t\tgetSelectionLeaves(data, nestedChildren).filter((leaf) => leaf.selected)\n\t\t\t.length;\n\n\t// Check if max selections limit is reached\n\tconst isMaxSelectionsReached = (data: DropdownOption[]) => {\n\t\tif (!isMultiSelect || (!maxSelections && maxSelections !== 0)) return false;\n\t\treturn getCurrentSelectionCount(data) >= maxSelections;\n\t};\n\n\t/** Reads onSearch from ref so it stays stable ([] deps). No-ops when onSearchRef.current is undefined. */\n\tconst performSearch = useCallback(async (searchKey: string) => {\n\t\tconst onSearchFn = onSearchRef.current;\n\t\tif (!searchKey || !onSearchFn) return;\n\n\t\tconst selectedIds: (string | number)[] = [];\n\t\titerateOnOptionsRaw(latestDropdownOptionsRef.current, (option) => {\n\t\t\tif (option.selected && !selectedIds.includes(option.value)) {\n\t\t\t\tselectedIds.push(option.value);\n\t\t\t}\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await onSearchFn(searchKey);\n\t\t\tsetSearchError(undefined);\n\t\t\tif (response) {\n\t\t\t\tconst updatedResponseData = response.map((option) => {\n\t\t\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\t\t\tconst groupedOption = option as GroupedOption;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...groupedOption,\n\t\t\t\t\t\t\toptions: groupedOption.options.map((op) => ({\n\t\t\t\t\t\t\t\t...op,\n\t\t\t\t\t\t\t\tselected: selectedIds.includes(op.value),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\tselected: selectedIds.includes((option as SingleOption).value),\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tsetSearchedOptions([...updatedResponseData]);\n\t\t\t} else {\n\t\t\t\tsetSearchedOptions([]);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tsetSearchedOptions([]);\n\t\t\tsetSearchError(\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? error.message\n\t\t\t\t\t: 'Something went wrong while fetching the list. Please try again',\n\t\t\t);\n\t\t}\n\t}, []);\n\n\t/** Independent of onSearch so debounce is stable when callers pass inline functions. Pending searches are preserved across parent re-renders. performSearch no-ops when onSearchRef.current is undefined. */\n\tconst debouncedSearch = useMemo(\n\t\t() => debounce(performSearch, 300),\n\t\t[performSearch],\n\t);\n\n\tuseEffect(() => () => debouncedSearch?.cancel(), [debouncedSearch]);\n\n\tfunction search(searchKey: string) {\n\t\tsetSearchedString(searchKey);\n\t\tsetSearchedOptions([]);\n\t\tsetSearchError(undefined);\n\n\t\tif (!searchKey) {\n\t\t\tdebouncedSearch?.cancel();\n\t\t\treturn;\n\t\t}\n\n\t\tdebouncedSearch(searchKey);\n\t}\n\n\tfunction retrySearch() {\n\t\tif (searchedString) {\n\t\t\tsetSearchError(undefined);\n\t\t\tperformSearch(searchedString);\n\t\t}\n\t}\n\n\t/**\n\t * wrapper to prepare option for onSelect\n\t * for single select, this will call the onClose handler ,\n\t * for multiselect, it will do state update for options list\n\t * \t\tto make any option select,\n\t * \t\t\t\tonApplyHandler({ label, value: selected: true })\n\t * to deselect any option\n\t * \t\t\t\tonApplyHandler({ label, value: selected: false })\n\t * @param optionSelect\n\t */\n\tfunction onApplyHandler(optionSelect: SingleOption, returnOnly?: boolean) {\n\t\tif (!isMultiSelect) {\n\t\t\tonSelect?.(optionSelect);\n\t\t} else {\n\t\t\t// Check if trying to select and max selections is reached\n\t\t\tif (\n\t\t\t\toptionSelect.selected &&\n\t\t\t\tmaxSelections &&\n\t\t\t\tisMaxSelectionsReached(dropdownOptions)\n\t\t\t) {\n\t\t\t\t// Max selections reached, don't allow new selections\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (searchedOptions.length && searchedString && onSearch) {\n\t\t\t\t/** Search mode */\n\t\t\t\t/**\n\t\t\t\t * on selected, push it to dropdown options,\n\t\t\t\t * on un-select, remove from dropdown option\n\t\t\t\t */\n\n\t\t\t\tif (optionSelect.selected) {\n\t\t\t\t\t// Check max selections for search mode too\n\t\t\t\t\tif (maxSelections && isMaxSelectionsReached(dropdownOptions)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t/** check if already there or not,\n\t\t\t\t\t * if yes, just update\n\t\t\t\t\t * else ,\n\t\t\t\t\t * \tappend\n\t\t\t\t\t */\n\n\t\t\t\t\tlet alreadyPresentInInitialOptions = false;\n\t\t\t\t\tconst currList = iterateOnOptions(\n\t\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t\t{ selected: optionSelect.selected } as Partial<SingleOption>,\n\t\t\t\t\t\t(optionForValidation: SingleOption) => {\n\t\t\t\t\t\t\tif (optionForValidation.value === optionSelect.value) {\n\t\t\t\t\t\t\t\talreadyPresentInInitialOptions = true;\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnestedChildren,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (!alreadyPresentInInitialOptions) {\n\t\t\t\t\t\tcurrList.push(optionSelect);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (returnOnly) {\n\t\t\t\t\t\treturn [...currList];\n\t\t\t\t\t}\n\t\t\t\t\tsetDropdownOptions([...currList]);\n\t\t\t\t\tif (version === '2.0') {\n\t\t\t\t\t\tonMultiSelectApply(currList);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/** un-select,\n\t\t\t\t\t * if already present in initial data,\n\t\t\t\t\t * yes, just update\n\t\t\t\t\t * else,\n\t\t\t\t\t * \tremove\n\t\t\t\t\t */\n\n\t\t\t\t\tlet alreadyPresentInInitialOptions = false;\n\t\t\t\t\tlet currList = iterateOnOptions(\n\t\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t\t{ selected: optionSelect.selected } as Partial<SingleOption>,\n\t\t\t\t\t\t(optionForValidation: SingleOption) => {\n\t\t\t\t\t\t\tif (optionForValidation.value === optionSelect.value) {\n\t\t\t\t\t\t\t\talreadyPresentInInitialOptions = true;\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnestedChildren,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (alreadyPresentInInitialOptions) {\n\t\t\t\t\t\tcurrList = currList.filter((option) => {\n\t\t\t\t\t\t\tif ((option as SingleOption).value === optionSelect.value) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tif (returnOnly) {\n\t\t\t\t\t\treturn [...currList];\n\t\t\t\t\t}\n\t\t\t\t\tsetDropdownOptions([...currList]);\n\t\t\t\t\tif (version === '2.0') {\n\t\t\t\t\t\tonMultiSelectApply(currList);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst currList = iterateOnOptions(\n\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t{ selected: optionSelect.selected } as Partial<SingleOption>,\n\t\t\t\t\t(optionForValidation: SingleOption) =>\n\t\t\t\t\t\toptionForValidation.value === optionSelect.value,\n\t\t\t\t\tnestedChildren,\n\t\t\t\t);\n\n\t\t\t\tif (returnOnly) {\n\t\t\t\t\treturn [...currList];\n\t\t\t\t}\n\t\t\t\tsetDropdownOptions([...currList]);\n\t\t\t\tif (version === '2.0') {\n\t\t\t\t\tonMultiSelectApply(currList);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction selectAllForSearch(select: boolean) {\n\t\t// const allSearchedValues = searchedOptions.map(option => option.value);\n\t\tlet clonedDropdownOptions = [...dropdownOptions];\n\n\t\tif (select) {\n\t\t\tsearchedOptions.forEach((option) => {\n\t\t\t\tlet found = false;\n\t\t\t\tclonedDropdownOptions = clonedDropdownOptions.map((dOption) => {\n\t\t\t\t\tconst singleOption = option as SingleOption;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof singleOption.value !== 'undefined' &&\n\t\t\t\t\t\tsingleOption.value === (dOption as SingleOption).value\n\t\t\t\t\t) {\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...dOption,\n\t\t\t\t\t\t\tselected: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn dOption;\n\t\t\t\t});\n\n\t\t\t\tif (!found) {\n\t\t\t\t\tclonedDropdownOptions.push({ ...option, selected: true });\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tsearchedOptions.forEach((option) => {\n\t\t\t\tclonedDropdownOptions = clonedDropdownOptions.map((dOption) => {\n\t\t\t\t\tconst singleOption = option as SingleOption;\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof singleOption.value !== 'undefined' &&\n\t\t\t\t\t\tsingleOption.value === (dOption as SingleOption).value\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...dOption,\n\t\t\t\t\t\t\tselected: false,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn dOption;\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tsetDropdownOptions([...clonedDropdownOptions]);\n\t\tif (version === '2.0') {\n\t\t\tonMultiSelectApply(clonedDropdownOptions);\n\t\t}\n\t}\n\n\tfunction selectAllForSearchWithLimit(select: boolean) {\n\t\tlet clonedDropdownOptions = [...dropdownOptions];\n\n\t\tif (select && maxSelections && maxSelections > 0) {\n\t\t\tconst currentCount = getCurrentSelectionCount(clonedDropdownOptions);\n\t\t\tconst remainingSlots = maxSelections - currentCount;\n\n\t\t\tif (remainingSlots <= 0) {\n\t\t\t\t// Already at max, don't select any more\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet selectedCount = 0;\n\t\t\tsearchedOptions.forEach((option) => {\n\t\t\t\tif (selectedCount >= remainingSlots) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet found = false;\n\t\t\t\tclonedDropdownOptions = clonedDropdownOptions.map((dOption) => {\n\t\t\t\t\tconst singleOption = option as SingleOption;\n\t\t\t\t\t// Skip if already selected\n\t\t\t\t\tif ((dOption as SingleOption).selected) {\n\t\t\t\t\t\treturn dOption;\n\t\t\t\t\t}\n\t\t\t\t\t// Skip if disabled\n\t\t\t\t\tif ((dOption as SingleOption).disabled) {\n\t\t\t\t\t\treturn dOption;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof singleOption.value !== 'undefined' &&\n\t\t\t\t\t\tsingleOption.value === (dOption as SingleOption).value\n\t\t\t\t\t) {\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tselectedCount++;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...dOption,\n\t\t\t\t\t\t\tselected: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn dOption;\n\t\t\t\t});\n\n\t\t\t\tif (!found && selectedCount < remainingSlots) {\n\t\t\t\t\tconst newOption = option as SingleOption;\n\t\t\t\t\tif (!newOption.disabled) {\n\t\t\t\t\t\tclonedDropdownOptions.push({ ...option, selected: true });\n\t\t\t\t\t\tselectedCount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tsetDropdownOptions([...clonedDropdownOptions]);\n\t\t\tif (version === '2.0') {\n\t\t\t\tonMultiSelectApply(clonedDropdownOptions);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction selectAllHandler(newState: SelectAllCheckboxState) {\n\t\tif (searchedOptions.length && searchedString && onSearch) {\n\t\t\tif (newState === 'selectAll') {\n\t\t\t\tselectAllForSearchWithLimit(true);\n\t\t\t} else {\n\t\t\t\tselectAllForSearch(false);\n\t\t\t}\n\t\t} else {\n\t\t\tif (newState === 'selectAll') {\n\t\t\t\tif (maxSelections && maxSelections > 0) {\n\t\t\t\t\t// Only select up to maxSelections limit\n\t\t\t\t\tconst currentCount = getCurrentSelectionCount(dropdownOptions);\n\t\t\t\t\tconst remainingSlots = maxSelections - currentCount;\n\n\t\t\t\t\tif (remainingSlots <= 0) {\n\t\t\t\t\t\t// Already at max, don't select any more\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet selectedCount = 0;\n\t\t\t\t\tconst newOptions = dropdownOptions.map((option) => {\n\t\t\t\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\t\t\t\t// Handle grouped options\n\t\t\t\t\t\t\tconst groupedOption = option as GroupedOption;\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...groupedOption,\n\t\t\t\t\t\t\t\toptions: groupedOption.options.map((op) => {\n\t\t\t\t\t\t\t\t\t// Skip disabled options\n\t\t\t\t\t\t\t\t\tif (op.disabled) {\n\t\t\t\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Check if already selected\n\t\t\t\t\t\t\t\t\tif (op.selected) {\n\t\t\t\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Check search filter\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tsearchedString &&\n\t\t\t\t\t\t\t\t\t\t!op.label\n\t\t\t\t\t\t\t\t\t\t\t?.toLowerCase()\n\t\t\t\t\t\t\t\t\t\t\t.includes(searchedString.toLowerCase())\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Select if we have remaining slots\n\t\t\t\t\t\t\t\t\tif (selectedCount < remainingSlots) {\n\t\t\t\t\t\t\t\t\t\tselectedCount++;\n\t\t\t\t\t\t\t\t\t\treturn { ...op, selected: true };\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn op;\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst singleOption = option as SingleOption;\n\t\t\t\t\t\t\t// Skip disabled options\n\t\t\t\t\t\t\tif (singleOption.disabled) {\n\t\t\t\t\t\t\t\treturn option;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Check if already selected\n\t\t\t\t\t\t\tif (singleOption.selected) {\n\t\t\t\t\t\t\t\treturn option;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Check search filter\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tsearchedString &&\n\t\t\t\t\t\t\t\t!singleOption.label\n\t\t\t\t\t\t\t\t\t?.toLowerCase()\n\t\t\t\t\t\t\t\t\t.includes(searchedString.toLowerCase())\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn option;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Select if we have remaining slots\n\t\t\t\t\t\t\tif (selectedCount < remainingSlots) {\n\t\t\t\t\t\t\t\tselectedCount++;\n\t\t\t\t\t\t\t\treturn { ...option, selected: true };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn option;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tsetDropdownOptions([...newOptions]);\n\t\t\t\t\tif (version === '2.0') {\n\t\t\t\t\t\tonMultiSelectApply(newOptions);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// No max selection limit, select all\n\t\t\t\t\tconst newOptions = iterateOnOptions(\n\t\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t\t{ selected: true },\n\t\t\t\t\t\t(option) =>\n\t\t\t\t\t\t\tsearchedString\n\t\t\t\t\t\t\t\t? option.label\n\t\t\t\t\t\t\t\t\t\t?.toLowerCase()\n\t\t\t\t\t\t\t\t\t\t.includes(searchedString.toLowerCase()) && !option.disabled\n\t\t\t\t\t\t\t\t: !option.disabled,\n\t\t\t\t\t\tnestedChildren,\n\t\t\t\t\t);\n\t\t\t\t\tsetDropdownOptions([...newOptions]);\n\t\t\t\t\tif (version === '2.0') {\n\t\t\t\t\t\tonMultiSelectApply(newOptions);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (newState === 'notSelected') {\n\t\t\t\tconst newOptions = iterateOnOptions(\n\t\t\t\t\tdropdownOptions,\n\t\t\t\t\t{ selected: false },\n\t\t\t\t\t(option) => !option.disabled,\n\t\t\t\t\tnestedChildren,\n\t\t\t\t);\n\t\t\t\tsetDropdownOptions([...newOptions]);\n\t\t\t\tif (version === '2.0') {\n\t\t\t\t\tonMultiSelectApply(newOptions);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onMultiSelectClear() {\n\t\tconst newOptions = iterateOnOptions(\n\t\t\tdropdownOptions,\n\t\t\t{ selected: false },\n\t\t\tundefined,\n\t\t\tnestedChildren,\n\t\t);\n\t\tsetDropdownOptions([...newOptions]);\n\t\tif (version === '2.0') {\n\t\t\tonMultiSelectApply(newOptions);\n\t\t}\n\t}\n\n\tfunction onFreeFormSelect(selected: boolean) {\n\t\tif (!isMultiSelect) {\n\t\t\tonApplyHandler({\n\t\t\t\tlabel: searchedString,\n\t\t\t\tvalue: searchedString,\n\t\t\t\tisFreeForm: true,\n\t\t\t\tselected: true,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst updatedList = dropdownOptions.map((option) =>\n\t\t\t(option as GroupedOption).options\n\t\t\t\t? option\n\t\t\t\t: {\n\t\t\t\t\t\t...option,\n\t\t\t\t\t\tselected:\n\t\t\t\t\t\t\t/** free form check */\n\t\t\t\t\t\t\toption.label === searchedString &&\n\t\t\t\t\t\t\t(option as SingleOption).value === searchedString\n\t\t\t\t\t\t\t\t? /** to mark as selected or not */\n\t\t\t\t\t\t\t\t selected\n\t\t\t\t\t\t\t\t: (option as SingleOption).selected,\n\t\t\t\t },\n\t\t);\n\n\t\tif (selected) {\n\t\t\tif (\n\t\t\t\t!updatedList.some(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\toption.label === searchedString &&\n\t\t\t\t\t\t(option as SingleOption).value === searchedString,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedList.unshift({\n\t\t\t\t\tlabel: searchedString,\n\t\t\t\t\tvalue: searchedString,\n\t\t\t\t\tisFreeForm: true,\n\t\t\t\t\tselected: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tsetDropdownOptions([...updatedList]);\n\t\tif (version === '2.0') {\n\t\t\tonMultiSelectApply(updatedList);\n\t\t}\n\t}\n\n\t/**\n\t * This is called when appy button is called,\n\t * here iterate and pick all options where selected if true.\n\t */\n\tfunction onMultiSelectApply(options?: DropdownOption[]) {\n\t\tconst optionsToSend: DropdownOption[] = getSelectedOptions(\n\t\t\toptions ?? latestDropdownOptionsRef.current,\n\t\t);\n\n\t\tonSelect?.([...optionsToSend]);\n\t}\n\n\treturn {\n\t\tlatestDropdownOptionsRef,\n\t\tdropdownOptions,\n\t\tsearch,\n\t\tsearchedString,\n\t\tsearchedOptions,\n\t\tsearchError,\n\t\tretrySearch,\n\t\tonApplyHandler,\n\t\tselectAllHandler,\n\t\tonMultiSelectClear,\n\t\tonFreeFormSelect,\n\t\tonMultiSelectApply,\n\t\tgetSelectedOptions,\n\t\tgetCurrentSelectionCount,\n\t\tisMaxSelectionsReached,\n\t\tmaxSelections,\n\t};\n};\n"],"names":["useDropdown","version","options","onSelect","skipSorting","isMultiSelect","onSearch","disableOtherSearchedOption","disableSearchedOptionExcept","maxSelections","childrenLayout","nestedChildren","dropdownOptions","setDropdownOptions","useState","searchedOptions","setSearchedOptions","searchedString","setSearchedString","searchError","setSearchError","latestDropdownOptionsRef","useRef","onSearchRef","useEffect","searchedOptionsClone","dropdownOptionFlat","option","op","selectedDropdownOption","dropdownOption","writeOptions","getSelectedOptions","data","selectedOptions","groupedOptions","singleOption","selectedChildren","child","getCurrentSelectionCount","getSelectionLeaves","leaf","isMaxSelectionsReached","performSearch","useCallback","searchKey","onSearchFn","selectedIds","iterateOnOptionsRaw","response","updatedResponseData","groupedOption","error","debouncedSearch","useMemo","debounce","search","retrySearch","onApplyHandler","optionSelect","returnOnly","alreadyPresentInInitialOptions","currList","iterateOnOptions","optionForValidation","onMultiSelectApply","selectAllForSearch","select","clonedDropdownOptions","dOption","selectAllForSearchWithLimit","currentCount","remainingSlots","selectedCount","found","selectAllHandler","newState","newOptions","onMultiSelectClear","onFreeFormSelect","selected","updatedList","optionsToSend"],"mappings":";;;AAUO,MAAMA,KAAc,CAC1BC,IAAU,OACVC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,IAAwC,CAAA,GACxCC,GACAC,MACI;AAGJ,QAAMC,IAAiBD,MAAmB,UACpC,CAACE,GAAiBC,CAAkB,IAAIC,EAASZ,KAAW,CAAA,CAAE,GAC9D,CAACa,GAAiBC,CAAkB,IAAIF,EAA2B,CAAA,CAAE,GACrE,CAACG,GAAgBC,CAAiB,IAAIJ,EAAS,EAAE,GACjD,CAACK,GAAaC,CAAc,IAAIN,EAA6B,MAAS,GACtEO,IAA2BC,EAAOV,CAAe,GAEjDW,IAAcD,EAAOhB,CAAQ;AAEnC,EAAAkB,EAAU,MAAM;AACf,IAAAD,EAAY,UAAUjB;AAAA,EACvB,GAAG,CAACA,CAAQ,CAAC,GAEbkB,EAAU,MAAM;AAGf,QAFAH,EAAyB,UAAUT,GAE/BG,EAAgB,UAAUE,KAAkBX,GAAU;AACzD,UAAImB,IAAuB,CAAC,GAAGV,CAAe;AAC9C,YAAMW,IAAqBd,EACzB,IAAI,CAACe,MAAW;AAChB,YAAKA,EAAyB;AAC7B,iBAAQA,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