@bikdotai/bik-component-library 0.0.868-beta.10 → 0.0.868-beta.11
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/README.md +0 -3
- package/dist/cjs/components/datePicker/DatePickerWrapper.js +1 -1
- package/dist/cjs/components/datePicker/DatePickerWrapper.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +23 -10
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuList.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuList.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js.map +1 -1
- package/dist/cjs/components/dropdown/hooks/useDropdown.js +1 -1
- package/dist/cjs/components/dropdown/hooks/useDropdown.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/datePicker/DatePickerWrapper.d.ts +0 -7
- package/dist/esm/components/datePicker/DatePickerWrapper.js +64 -66
- package/dist/esm/components/datePicker/DatePickerWrapper.js.map +1 -1
- package/dist/esm/components/datePicker/index.d.ts +0 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +74 -68
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.d.ts +9 -0
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +157 -123
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.d.ts +2 -0
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.js +145 -104
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js +36 -29
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.d.ts +1 -0
- package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js +39 -30
- package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.d.ts +3 -16
- package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js +41 -24
- package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js.map +1 -1
- package/dist/esm/components/dropdown/hooks/useDropdown.d.ts +3 -16
- package/dist/esm/components/dropdown/hooks/useDropdown.js +159 -149
- package/dist/esm/components/dropdown/hooks/useDropdown.js.map +1 -1
- package/dist/esm/components/dropdown/type.d.ts +17 -0
- package/dist/esm/index.d.ts +0 -3
- package/dist/esm/index.js +675 -716
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/components/chip-selector/ChipSelector.js +0 -2
- package/dist/cjs/components/chip-selector/ChipSelector.js.map +0 -1
- package/dist/cjs/components/chip-selector/ChipSelector.styled.js +0 -36
- package/dist/cjs/components/chip-selector/ChipSelector.styled.js.map +0 -1
- package/dist/cjs/components/chip-selector/ChipSelectorGroup.js +0 -2
- package/dist/cjs/components/chip-selector/ChipSelectorGroup.js.map +0 -1
- package/dist/cjs/components/combo-box/ComboBox.js +0 -2
- package/dist/cjs/components/combo-box/ComboBox.js.map +0 -1
- package/dist/cjs/components/combo-box/ComboBox.styled.js +0 -33
- package/dist/cjs/components/combo-box/ComboBox.styled.js.map +0 -1
- package/dist/cjs/components/schedule-builder/RefreshSegmentToggle.js +0 -2
- package/dist/cjs/components/schedule-builder/RefreshSegmentToggle.js.map +0 -1
- package/dist/cjs/components/schedule-builder/ScheduleBuilder.js +0 -2
- package/dist/cjs/components/schedule-builder/ScheduleBuilder.js.map +0 -1
- package/dist/cjs/components/schedule-builder/ScheduleBuilder.styled.js +0 -138
- package/dist/cjs/components/schedule-builder/ScheduleBuilder.styled.js.map +0 -1
- package/dist/cjs/components/schedule-builder/ScheduleEndPicker.js +0 -2
- package/dist/cjs/components/schedule-builder/ScheduleEndPicker.js.map +0 -1
- package/dist/cjs/components/schedule-builder/ScheduleFrequencyPicker.js +0 -2
- package/dist/cjs/components/schedule-builder/ScheduleFrequencyPicker.js.map +0 -1
- package/dist/cjs/components/schedule-builder/ScheduleHelper.js +0 -2
- package/dist/cjs/components/schedule-builder/ScheduleHelper.js.map +0 -1
- package/dist/cjs/components/schedule-builder/SendModeSelector.js +0 -2
- package/dist/cjs/components/schedule-builder/SendModeSelector.js.map +0 -1
- package/dist/cjs/components/schedule-builder/StartDateTimePicker.js +0 -2
- package/dist/cjs/components/schedule-builder/StartDateTimePicker.js.map +0 -1
- package/dist/cjs/components/schedule-builder/UpcomingRunsPreview.js +0 -2
- package/dist/cjs/components/schedule-builder/UpcomingRunsPreview.js.map +0 -1
- package/dist/cjs/components/schedule-builder/model.js +0 -2
- package/dist/cjs/components/schedule-builder/model.js.map +0 -1
- package/dist/esm/components/chip-selector/ChipSelector.d.ts +0 -9
- package/dist/esm/components/chip-selector/ChipSelector.js +0 -27
- package/dist/esm/components/chip-selector/ChipSelector.js.map +0 -1
- package/dist/esm/components/chip-selector/ChipSelector.styled.d.ts +0 -10
- package/dist/esm/components/chip-selector/ChipSelector.styled.js +0 -48
- package/dist/esm/components/chip-selector/ChipSelector.styled.js.map +0 -1
- package/dist/esm/components/chip-selector/ChipSelectorGroup.d.ts +0 -10
- package/dist/esm/components/chip-selector/ChipSelectorGroup.js +0 -48
- package/dist/esm/components/chip-selector/ChipSelectorGroup.js.map +0 -1
- package/dist/esm/components/chip-selector/index.d.ts +0 -4
- package/dist/esm/components/chip-selector/model.d.ts +0 -106
- package/dist/esm/components/combo-box/ComboBox.d.ts +0 -15
- package/dist/esm/components/combo-box/ComboBox.js +0 -118
- package/dist/esm/components/combo-box/ComboBox.js.map +0 -1
- package/dist/esm/components/combo-box/ComboBox.styled.d.ts +0 -12
- package/dist/esm/components/combo-box/ComboBox.styled.js +0 -40
- package/dist/esm/components/combo-box/ComboBox.styled.js.map +0 -1
- package/dist/esm/components/combo-box/index.d.ts +0 -3
- package/dist/esm/components/combo-box/model.d.ts +0 -55
- package/dist/esm/components/schedule-builder/RefreshSegmentToggle.d.ts +0 -22
- package/dist/esm/components/schedule-builder/RefreshSegmentToggle.js +0 -31
- package/dist/esm/components/schedule-builder/RefreshSegmentToggle.js.map +0 -1
- package/dist/esm/components/schedule-builder/ScheduleBuilder.d.ts +0 -88
- package/dist/esm/components/schedule-builder/ScheduleBuilder.js +0 -105
- package/dist/esm/components/schedule-builder/ScheduleBuilder.js.map +0 -1
- package/dist/esm/components/schedule-builder/ScheduleBuilder.styled.d.ts +0 -81
- package/dist/esm/components/schedule-builder/ScheduleBuilder.styled.js +0 -168
- package/dist/esm/components/schedule-builder/ScheduleBuilder.styled.js.map +0 -1
- package/dist/esm/components/schedule-builder/ScheduleEndPicker.d.ts +0 -17
- package/dist/esm/components/schedule-builder/ScheduleEndPicker.js +0 -105
- package/dist/esm/components/schedule-builder/ScheduleEndPicker.js.map +0 -1
- package/dist/esm/components/schedule-builder/ScheduleFrequencyPicker.d.ts +0 -21
- package/dist/esm/components/schedule-builder/ScheduleFrequencyPicker.js +0 -136
- package/dist/esm/components/schedule-builder/ScheduleFrequencyPicker.js.map +0 -1
- package/dist/esm/components/schedule-builder/ScheduleHelper.d.ts +0 -110
- package/dist/esm/components/schedule-builder/ScheduleHelper.js +0 -196
- package/dist/esm/components/schedule-builder/ScheduleHelper.js.map +0 -1
- package/dist/esm/components/schedule-builder/SendModeSelector.d.ts +0 -29
- package/dist/esm/components/schedule-builder/SendModeSelector.js +0 -41
- package/dist/esm/components/schedule-builder/SendModeSelector.js.map +0 -1
- package/dist/esm/components/schedule-builder/StartDateTimePicker.d.ts +0 -44
- package/dist/esm/components/schedule-builder/StartDateTimePicker.js +0 -119
- package/dist/esm/components/schedule-builder/StartDateTimePicker.js.map +0 -1
- package/dist/esm/components/schedule-builder/UpcomingRunsPreview.d.ts +0 -19
- package/dist/esm/components/schedule-builder/UpcomingRunsPreview.js +0 -44
- package/dist/esm/components/schedule-builder/UpcomingRunsPreview.js.map +0 -1
- package/dist/esm/components/schedule-builder/index.d.ts +0 -17
- package/dist/esm/components/schedule-builder/model.d.ts +0 -69
- package/dist/esm/components/schedule-builder/model.js +0 -8
- package/dist/esm/components/schedule-builder/model.js.map +0 -1
|
@@ -1,105 +1,115 @@
|
|
|
1
1
|
import X from "lodash/debounce";
|
|
2
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
|
|
4
|
-
const S = (h = "1.0", b, y, I,
|
|
5
|
-
const [
|
|
3
|
+
import { iterateOnOptionsRaw as _, iterateOnOptions as g } from "../OpenedDropdown/utils/iterationOnOptions.js";
|
|
4
|
+
const S = (h = "1.0", b, y, I, O, v, k, q = [], i) => {
|
|
5
|
+
const [f, d] = E(b ?? []), [p, w] = E([]), [n, z] = E(""), [B, m] = E(void 0), C = j(f), P = j(v);
|
|
6
6
|
A(() => {
|
|
7
|
-
P.current =
|
|
8
|
-
}, [
|
|
9
|
-
if (C.current =
|
|
10
|
-
let
|
|
11
|
-
const
|
|
7
|
+
P.current = v;
|
|
8
|
+
}, [v]), A(() => {
|
|
9
|
+
if (C.current = f, p.length && n && v) {
|
|
10
|
+
let r = [...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
|
|
17
|
+
const t = e;
|
|
18
18
|
return {
|
|
19
|
-
value:
|
|
20
|
-
selected:
|
|
19
|
+
value: t.value,
|
|
20
|
+
selected: t.selected
|
|
21
21
|
};
|
|
22
22
|
}).flat();
|
|
23
|
-
|
|
24
|
-
const
|
|
23
|
+
r = r.map((e) => {
|
|
24
|
+
const t = s.find(
|
|
25
25
|
(l) => e.value === l.value
|
|
26
26
|
);
|
|
27
|
-
return
|
|
27
|
+
return t ? {
|
|
28
28
|
...e,
|
|
29
|
-
selected:
|
|
29
|
+
selected: t.selected
|
|
30
30
|
} : e;
|
|
31
|
-
}), k && (
|
|
31
|
+
}), k && (r = r.map((e) => ({
|
|
32
32
|
...e,
|
|
33
33
|
disabled: !q.includes(e.value)
|
|
34
|
-
}))),
|
|
35
|
-
...
|
|
34
|
+
}))), w(O && !I ? [
|
|
35
|
+
...r.sort(
|
|
36
36
|
(e) => e.selected ? -1 : 1
|
|
37
37
|
)
|
|
38
|
-
] : [...
|
|
38
|
+
] : [...r]);
|
|
39
39
|
}
|
|
40
|
-
}, [
|
|
40
|
+
}, [f]), A(() => {
|
|
41
41
|
if (b) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
...
|
|
45
|
-
(
|
|
42
|
+
const r = [...b];
|
|
43
|
+
d(O && !I ? [
|
|
44
|
+
...r.sort(
|
|
45
|
+
(s) => s.selected ? -1 : 1
|
|
46
46
|
)
|
|
47
|
-
] : [...
|
|
47
|
+
] : [...r]);
|
|
48
48
|
}
|
|
49
49
|
}, [b]);
|
|
50
|
-
const H = (
|
|
51
|
-
const
|
|
52
|
-
return
|
|
50
|
+
const H = (r) => {
|
|
51
|
+
const s = [];
|
|
52
|
+
return r.forEach((e) => {
|
|
53
53
|
if (e.options) {
|
|
54
|
-
const
|
|
54
|
+
const t = e.options.filter(
|
|
55
55
|
(l) => l.selected === !0
|
|
56
56
|
);
|
|
57
|
-
|
|
57
|
+
s.push({
|
|
58
58
|
...e,
|
|
59
|
-
options: [...
|
|
59
|
+
options: [...t]
|
|
60
60
|
});
|
|
61
|
-
} else
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
} else {
|
|
62
|
+
const t = e;
|
|
63
|
+
if (t.children?.length) {
|
|
64
|
+
const l = t.children.filter(
|
|
65
|
+
(c) => c.selected
|
|
66
|
+
);
|
|
67
|
+
l.length && s.push({
|
|
68
|
+
...t,
|
|
69
|
+
children: l
|
|
70
|
+
});
|
|
71
|
+
} else t.selected && s.push({ ...e });
|
|
72
|
+
}
|
|
73
|
+
}), s;
|
|
74
|
+
}, L = (r) => {
|
|
75
|
+
let s = 0;
|
|
76
|
+
return r.forEach((e) => {
|
|
77
|
+
e.options ? s += e.options.filter(
|
|
78
|
+
(t) => t.selected === !0
|
|
79
|
+
).length : e.selected && s++;
|
|
80
|
+
}), s;
|
|
81
|
+
}, D = (r) => !O || !i && i !== 0 ? !1 : L(r) >= i, R = Y(async (r) => {
|
|
82
|
+
const s = P.current;
|
|
83
|
+
if (!r || !s) return;
|
|
74
84
|
const e = [];
|
|
75
|
-
_(C.current, (
|
|
76
|
-
|
|
85
|
+
_(C.current, (t) => {
|
|
86
|
+
t.selected && !e.includes(t.value) && e.push(t.value);
|
|
77
87
|
});
|
|
78
88
|
try {
|
|
79
|
-
const
|
|
80
|
-
if (m(void 0),
|
|
81
|
-
const l =
|
|
82
|
-
if (
|
|
83
|
-
const
|
|
89
|
+
const t = await s(r);
|
|
90
|
+
if (m(void 0), t) {
|
|
91
|
+
const l = t.map((c) => {
|
|
92
|
+
if (c.options) {
|
|
93
|
+
const a = c;
|
|
84
94
|
return {
|
|
85
|
-
...
|
|
86
|
-
options:
|
|
95
|
+
...a,
|
|
96
|
+
options: a.options.map((u) => ({
|
|
87
97
|
...u,
|
|
88
98
|
selected: e.includes(u.value)
|
|
89
99
|
}))
|
|
90
100
|
};
|
|
91
101
|
}
|
|
92
102
|
return {
|
|
93
|
-
...
|
|
94
|
-
selected: e.includes(
|
|
103
|
+
...c,
|
|
104
|
+
selected: e.includes(c.value)
|
|
95
105
|
};
|
|
96
106
|
});
|
|
97
|
-
|
|
107
|
+
w([...l]);
|
|
98
108
|
} else
|
|
99
|
-
|
|
100
|
-
} catch (
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
w([]);
|
|
110
|
+
} catch (t) {
|
|
111
|
+
w([]), m(
|
|
112
|
+
t instanceof Error ? t.message : "Something went wrong while fetching the list. Please try again"
|
|
103
113
|
);
|
|
104
114
|
}
|
|
105
115
|
}, []), F = Z(
|
|
@@ -107,135 +117,135 @@ const S = (h = "1.0", b, y, I, g, w, k, q = [], a) => {
|
|
|
107
117
|
[R]
|
|
108
118
|
);
|
|
109
119
|
A(() => () => F?.cancel(), [F]);
|
|
110
|
-
function G(
|
|
111
|
-
if (z(
|
|
120
|
+
function G(r) {
|
|
121
|
+
if (z(r), w([]), m(void 0), !r) {
|
|
112
122
|
F?.cancel();
|
|
113
123
|
return;
|
|
114
124
|
}
|
|
115
|
-
F(
|
|
125
|
+
F(r);
|
|
116
126
|
}
|
|
117
127
|
function J() {
|
|
118
128
|
n && (m(void 0), R(n));
|
|
119
129
|
}
|
|
120
|
-
function T(
|
|
121
|
-
if (!
|
|
122
|
-
y?.(
|
|
130
|
+
function T(r, s) {
|
|
131
|
+
if (!O)
|
|
132
|
+
y?.(r);
|
|
123
133
|
else {
|
|
124
|
-
if (
|
|
134
|
+
if (r.selected && i && D(f))
|
|
125
135
|
return;
|
|
126
|
-
if (
|
|
127
|
-
if (
|
|
128
|
-
if (
|
|
136
|
+
if (p.length && n && v)
|
|
137
|
+
if (r.selected) {
|
|
138
|
+
if (i && D(f))
|
|
129
139
|
return;
|
|
130
140
|
let e = !1;
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
{ selected:
|
|
134
|
-
(l) => l.value ===
|
|
141
|
+
const t = g(
|
|
142
|
+
f,
|
|
143
|
+
{ selected: r.selected },
|
|
144
|
+
(l) => l.value === r.value ? (e = !0, !0) : !1
|
|
135
145
|
);
|
|
136
|
-
if (e ||
|
|
137
|
-
return [...
|
|
138
|
-
|
|
146
|
+
if (e || t.push(r), s)
|
|
147
|
+
return [...t];
|
|
148
|
+
d([...t]), h === "2.0" && o(t);
|
|
139
149
|
} else {
|
|
140
|
-
let e = !1,
|
|
141
|
-
|
|
142
|
-
{ selected:
|
|
143
|
-
(l) => l.value ===
|
|
150
|
+
let e = !1, t = g(
|
|
151
|
+
f,
|
|
152
|
+
{ selected: r.selected },
|
|
153
|
+
(l) => l.value === r.value ? (e = !0, !0) : !1
|
|
144
154
|
);
|
|
145
|
-
if (e && (
|
|
146
|
-
return [...
|
|
147
|
-
|
|
155
|
+
if (e && (t = t.filter((l) => l.value !== r.value)), s)
|
|
156
|
+
return [...t];
|
|
157
|
+
d([...t]), h === "2.0" && o(t);
|
|
148
158
|
}
|
|
149
159
|
else {
|
|
150
|
-
const e =
|
|
151
|
-
|
|
152
|
-
{ selected:
|
|
153
|
-
(
|
|
160
|
+
const e = g(
|
|
161
|
+
f,
|
|
162
|
+
{ selected: r.selected },
|
|
163
|
+
(t) => t.value === r.value
|
|
154
164
|
);
|
|
155
|
-
if (
|
|
165
|
+
if (s)
|
|
156
166
|
return [...e];
|
|
157
|
-
|
|
167
|
+
d([...e]), h === "2.0" && o(e);
|
|
158
168
|
}
|
|
159
169
|
}
|
|
160
170
|
}
|
|
161
|
-
function M(
|
|
162
|
-
let
|
|
163
|
-
|
|
164
|
-
|
|
171
|
+
function M(r) {
|
|
172
|
+
let s = [...f];
|
|
173
|
+
p.forEach((e) => {
|
|
174
|
+
s = s.map((t) => {
|
|
165
175
|
const l = e;
|
|
166
|
-
return typeof l.value < "u" && l.value ===
|
|
167
|
-
...
|
|
176
|
+
return typeof l.value < "u" && l.value === t.value ? {
|
|
177
|
+
...t,
|
|
168
178
|
selected: !1
|
|
169
|
-
} :
|
|
179
|
+
} : t;
|
|
170
180
|
});
|
|
171
|
-
}),
|
|
181
|
+
}), d([...s]), h === "2.0" && o(s);
|
|
172
182
|
}
|
|
173
|
-
function N(
|
|
174
|
-
let
|
|
175
|
-
if (
|
|
176
|
-
const e = L(
|
|
177
|
-
if (
|
|
183
|
+
function N(r) {
|
|
184
|
+
let s = [...f];
|
|
185
|
+
if (i && i > 0) {
|
|
186
|
+
const e = L(s), t = i - e;
|
|
187
|
+
if (t <= 0)
|
|
178
188
|
return;
|
|
179
189
|
let l = 0;
|
|
180
|
-
|
|
181
|
-
if (l >=
|
|
190
|
+
p.forEach((c) => {
|
|
191
|
+
if (l >= t)
|
|
182
192
|
return;
|
|
183
|
-
let
|
|
184
|
-
|
|
185
|
-
const W =
|
|
186
|
-
return u.selected || u.disabled ? u : typeof W.value < "u" && W.value === u.value ? (
|
|
193
|
+
let a = !1;
|
|
194
|
+
s = s.map((u) => {
|
|
195
|
+
const W = c;
|
|
196
|
+
return u.selected || u.disabled ? u : typeof W.value < "u" && W.value === u.value ? (a = !0, l++, {
|
|
187
197
|
...u,
|
|
188
198
|
selected: !0
|
|
189
199
|
}) : u;
|
|
190
|
-
}), !
|
|
191
|
-
}),
|
|
200
|
+
}), !a && l < t && (c.disabled || (s.push({ ...c, selected: !0 }), l++));
|
|
201
|
+
}), d([...s]), h === "2.0" && o(s);
|
|
192
202
|
}
|
|
193
203
|
}
|
|
194
|
-
function Q(
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
else if (
|
|
198
|
-
if (
|
|
199
|
-
const
|
|
204
|
+
function Q(r) {
|
|
205
|
+
if (p.length && n && v)
|
|
206
|
+
r === "selectAll" ? N() : M();
|
|
207
|
+
else if (r === "selectAll")
|
|
208
|
+
if (i && i > 0) {
|
|
209
|
+
const s = L(f), e = i - s;
|
|
200
210
|
if (e <= 0)
|
|
201
211
|
return;
|
|
202
|
-
let
|
|
203
|
-
const l =
|
|
204
|
-
if (
|
|
205
|
-
const
|
|
212
|
+
let t = 0;
|
|
213
|
+
const l = f.map((c) => {
|
|
214
|
+
if (c.options) {
|
|
215
|
+
const a = c;
|
|
206
216
|
return {
|
|
207
|
-
...
|
|
208
|
-
options:
|
|
217
|
+
...a,
|
|
218
|
+
options: a.options.map((u) => u.disabled || u.selected || n && !u.label?.toLowerCase().includes(n.toLowerCase()) ? u : t < e ? (t++, { ...u, selected: !0 }) : u)
|
|
209
219
|
};
|
|
210
220
|
} else {
|
|
211
|
-
const
|
|
212
|
-
return
|
|
221
|
+
const a = c;
|
|
222
|
+
return a.disabled || a.selected || n && !a.label?.toLowerCase().includes(n.toLowerCase()) ? c : t < e ? (t++, { ...c, selected: !0 }) : c;
|
|
213
223
|
}
|
|
214
224
|
});
|
|
215
|
-
|
|
225
|
+
d([...l]), h === "2.0" && o(l);
|
|
216
226
|
} else {
|
|
217
|
-
const
|
|
218
|
-
|
|
227
|
+
const s = g(
|
|
228
|
+
f,
|
|
219
229
|
{ selected: !0 },
|
|
220
230
|
(e) => n ? e.label?.toLowerCase().includes(n.toLowerCase()) && !e.disabled : !e.disabled
|
|
221
231
|
);
|
|
222
|
-
|
|
232
|
+
d([...s]), h === "2.0" && o(s);
|
|
223
233
|
}
|
|
224
|
-
else if (
|
|
225
|
-
const
|
|
226
|
-
|
|
234
|
+
else if (r === "notSelected") {
|
|
235
|
+
const s = g(
|
|
236
|
+
f,
|
|
227
237
|
{ selected: !1 },
|
|
228
238
|
(e) => !e.disabled
|
|
229
239
|
);
|
|
230
|
-
|
|
240
|
+
d([...s]), h === "2.0" && o(s);
|
|
231
241
|
}
|
|
232
242
|
}
|
|
233
243
|
function U() {
|
|
234
|
-
const
|
|
235
|
-
|
|
244
|
+
const r = g(f, { selected: !1 });
|
|
245
|
+
d([...r]), h === "2.0" && o(r);
|
|
236
246
|
}
|
|
237
|
-
function V(
|
|
238
|
-
if (!
|
|
247
|
+
function V(r) {
|
|
248
|
+
if (!O) {
|
|
239
249
|
T({
|
|
240
250
|
label: n,
|
|
241
251
|
value: n,
|
|
@@ -244,39 +254,39 @@ const S = (h = "1.0", b, y, I, g, w, k, q = [], a) => {
|
|
|
244
254
|
});
|
|
245
255
|
return;
|
|
246
256
|
}
|
|
247
|
-
const
|
|
257
|
+
const s = f.map(
|
|
248
258
|
(e) => e.options ? e : {
|
|
249
259
|
...e,
|
|
250
260
|
selected: (
|
|
251
261
|
/** free form check */
|
|
252
262
|
e.label === n && e.value === n ? (
|
|
253
263
|
/** to mark as selected or not */
|
|
254
|
-
|
|
264
|
+
r
|
|
255
265
|
) : e.selected
|
|
256
266
|
)
|
|
257
267
|
}
|
|
258
268
|
);
|
|
259
|
-
|
|
269
|
+
r && (s.some(
|
|
260
270
|
(e) => e.label === n && e.value === n
|
|
261
|
-
) ||
|
|
271
|
+
) || s.unshift({
|
|
262
272
|
label: n,
|
|
263
273
|
value: n,
|
|
264
274
|
isFreeForm: !0,
|
|
265
275
|
selected: !0
|
|
266
|
-
})),
|
|
276
|
+
})), d([...s]), h === "2.0" && o(s);
|
|
267
277
|
}
|
|
268
|
-
function o(
|
|
269
|
-
const
|
|
270
|
-
|
|
278
|
+
function o(r) {
|
|
279
|
+
const s = H(
|
|
280
|
+
r ?? C.current
|
|
271
281
|
);
|
|
272
|
-
y?.([...
|
|
282
|
+
y?.([...s]);
|
|
273
283
|
}
|
|
274
284
|
return {
|
|
275
285
|
latestDropdownOptionsRef: C,
|
|
276
|
-
dropdownOptions:
|
|
286
|
+
dropdownOptions: f,
|
|
277
287
|
search: G,
|
|
278
288
|
searchedString: n,
|
|
279
|
-
searchedOptions:
|
|
289
|
+
searchedOptions: p,
|
|
280
290
|
searchError: B,
|
|
281
291
|
retrySearch: J,
|
|
282
292
|
onApplyHandler: T,
|
|
@@ -287,7 +297,7 @@ const S = (h = "1.0", b, y, I, g, w, k, q = [], a) => {
|
|
|
287
297
|
getSelectedOptions: H,
|
|
288
298
|
getCurrentSelectionCount: L,
|
|
289
299
|
isMaxSelectionsReached: D,
|
|
290
|
-
maxSelections:
|
|
300
|
+
maxSelections: i
|
|
291
301
|
};
|
|
292
302
|
};
|
|
293
303
|
export {
|
|
@@ -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,UAAUT,GAE/BG,EAAgB,UAAUE,KAAkBT,GAAU;AACzD,UAAIiB,IAAuB,CAAC,GAAGV,CAAe;AAC9C,YAAMW,IAAqBd,EACzB,IAAI,CAACe,MAAW;AAChB,YAAKA,EAAyB;AAC7B,iBAAQA,EAAyB,QAAQ,IAAI,CAACC,OAAQ;AAAA,YACrD,OAAOA,EAAG;AAAA,YACV,UAAUA,EAAG;AAAA,UAAA,EACZ;AAEH,cAAMA,IAAKD;AACX,eAAO;AAAA,UACN,OAAOC,EAAG;AAAA,UACV,UAAUA,EAAG;AAAA,QAAA;AAAA,MAEf,CAAC,EACA,KAAA;AAEF,MAAAH,IAAuBA,EAAqB,IAAI,CAACE,MAAW;AAC3D,cAAME,IAAyBH,EAAmB;AAAA,UACjD,CAACI,MACIH,EAAO,UAAUG,EAAe;AAAA,QAIrC;AAGD,eAAID,IACI;AAAA,UACN,GAAGF;AAAA,UACH,UAAUE,EAAuB;AAAA,QAAA,IAI5BF;AAAA,MACR,CAAC,G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,MACvCA,EAAyB,UACvBA,IACA;AAAA,QACA,GAAGA;AAAA,QACH;AAAA;AAAA,UAECA,EAAO,UAAUV,KAChBU,EAAwB,UAAUV;AAAA;AAAA,YAEhC4D;AAAA,cACClD,EAAwB;AAAA;AAAA,MAAA;AAAA,IAC7B;AAGJ,IAAIkD,MAEDC,EAAY;AAAA,MACZ,CAACnD,MACAA,EAAO,UAAUV,KAChBU,EAAwB,UAAUV;AAAA,IAAA,KAGrC6D,EAAY,QAAQ;AAAA,MACnB,OAAO7D;AAAA,MACP,OAAOA;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IAAA,CACV,IAIHJ,EAAmB,CAAC,GAAGiE,CAAW,CAAC,GAC/B3E,MAAY,SACf0D,EAAmBiB,CAAW;AAAA,EAEhC;AAMA,WAASjB,EAAmBzD,GAA4B;AACvD,UAAM2E,IAAkC/C;AAAA,MACvC5B,KAAWiB,EAAyB;AAAA,IAAA;AAGrC,IAAAhB,IAAW,CAAC,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\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\tconst singleOption = option as SingleOption;\n\t\t\t\tif (singleOption.children?.length) {\n\t\t\t\t\t// Report the parent whenever any child is selected, carrying only\n\t\t\t\t\t// the selected children — a partly-selected parent is itself\n\t\t\t\t\t// unselected, so testing it alone would drop the whole group.\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\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 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);\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","singleOption","selectedChildren","child","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","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,EAA2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AA,QACH;AAAA;AAAA,UAECA,EAAO,UAAUV,KAChBU,EAAwB,UAAUV;AAAA;AAAA,YAEhC8D;AAAA,cACCpD,EAAwB;AAAA;AAAA,MAAA;AAAA,IAC7B;AAGJ,IAAIoD,MAEDC,EAAY;AAAA,MACZ,CAACrD,MACAA,EAAO,UAAUV,KAChBU,EAAwB,UAAUV;AAAA,IAAA,KAGrC+D,EAAY,QAAQ;AAAA,MACnB,OAAO/D;AAAA,MACP,OAAOA;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IAAA,CACV,IAIHJ,EAAmB,CAAC,GAAGmE,CAAW,CAAC,GAC/B7E,MAAY,SACf6D,EAAmBgB,CAAW;AAAA,EAEhC;AAMA,WAAShB,EAAmB5D,GAA4B;AACvD,UAAM6E,IAAkCjD;AAAA,MACvC5B,KAAWiB,EAAyB;AAAA,IAAA;AAGrC,IAAAhB,IAAW,CAAC,GAAG4E,CAAa,CAAC;AAAA,EAC9B;AAEA,SAAO;AAAA,IACN,0BAAA5D;AAAA,IACA,iBAAAT;AAAA,IACA,QAAA2C;AAAA,IACA,gBAAAtC;AAAA,IACA,iBAAAF;AAAA,IACA,aAAAI;AAAA,IACA,aAAAqC;AAAA,IACA,gBAAAC;AAAA,IACA,kBAAAiB;AAAA,IACA,oBAAAG;AAAA,IACA,kBAAAC;AAAA,IACA,oBAAAd;AAAA,IACA,oBAAAhC;AAAA,IACA,0BAAAO;AAAA,IACA,wBAAAE;AAAA,IACA,eAAA9B;AAAA,EAAA;AAEF;"}
|
|
@@ -65,6 +65,23 @@ export interface OpenDropdownProps {
|
|
|
65
65
|
checkboxActiveColor?: string;
|
|
66
66
|
/** Renders rows with the brand selected theme (brandLight bg + primary text), square corners and flush spacing */
|
|
67
67
|
brandSelectedRow?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* How options that declare `children` are laid out.
|
|
70
|
+
*
|
|
71
|
+
* - `'flyout'` (default) — the parent row shows a chevron and its children
|
|
72
|
+
* open in a submenu to the right on hover. The parent is not selectable.
|
|
73
|
+
* - `'nested'` — children render inline, indented under the parent and joined
|
|
74
|
+
* by an elbow connector. With `isMultiSelect` the parent carries a
|
|
75
|
+
* tri-state checkbox that selects or clears all of its children.
|
|
76
|
+
*/
|
|
77
|
+
childrenLayout?: 'flyout' | 'nested';
|
|
78
|
+
/**
|
|
79
|
+
* With `childrenLayout='nested'`, gives every parent row a chevron that
|
|
80
|
+
* collapses and expands its children. Groups start expanded.
|
|
81
|
+
*/
|
|
82
|
+
collapsibleChildren?: boolean;
|
|
83
|
+
/** Hides the "N selected" text in the multiselect bottom bar. */
|
|
84
|
+
hideSelectedCount?: boolean;
|
|
68
85
|
}
|
|
69
86
|
export type GroupedOption = {
|
|
70
87
|
label?: string;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -88,9 +88,6 @@ export * from './utils/validator';
|
|
|
88
88
|
export * from './components/carousel-preview';
|
|
89
89
|
export * from './components/floater';
|
|
90
90
|
export * from './components/card-selector';
|
|
91
|
-
export * from './components/chip-selector';
|
|
92
|
-
export * from './components/combo-box';
|
|
93
|
-
export * from './components/schedule-builder';
|
|
94
91
|
export * from './components/variable-picker-v3';
|
|
95
92
|
export * from './components/action-button';
|
|
96
93
|
export * from './components/ai-modals';
|