@ironsource/shared-ui 2.1.11-rc.0 → 2.1.11-rc.1
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useToggle as
|
|
2
|
-
import { inject as
|
|
1
|
+
import { useToggle as Ve } from "../../../composables/useToggle.js";
|
|
2
|
+
import { inject as ke, ref as i, computed as r, watch as A, useSlots as _e, toRaw as P, nextTick as C, provide as Ge, onMounted as He } from "vue";
|
|
3
3
|
import { isObjectInArray as ee } from "../../../utils/array.js";
|
|
4
4
|
import { objectsEqual as Be } from "../../../utils/object.js";
|
|
5
5
|
import { useClamp as Le, useVirtualList as Ue, onClickOutside as le } from "@vueuse/core";
|
|
@@ -7,17 +7,17 @@ import { Mode as T, Type as _, DropdownContext as qe } from "./DropdownContext.j
|
|
|
7
7
|
import { pxToRem as $e } from "../../../utils/style.js";
|
|
8
8
|
import { useEditableContext as je } from "../../table-cells/common/EditableContext.js";
|
|
9
9
|
import { useGroupedOptions as Xe } from "./useGroupedOptions.js";
|
|
10
|
-
const ll = (l,
|
|
11
|
-
const te =
|
|
10
|
+
const ll = (l, b, h) => {
|
|
11
|
+
const te = ke("isTreeDropdown", !1), {
|
|
12
12
|
sortOutGroups: G,
|
|
13
13
|
flattenAndMarkGroupOptions: ae,
|
|
14
14
|
isGroup: H,
|
|
15
|
-
selectAllWithGroups:
|
|
16
|
-
isIndeterminateGrouped:
|
|
15
|
+
selectAllWithGroups: ue,
|
|
16
|
+
isIndeterminateGrouped: ne,
|
|
17
17
|
allSelectedGrouped: ie,
|
|
18
18
|
areAllPreviousSelected: re
|
|
19
19
|
} = Xe(l), oe = (e, t) => l.multi ? l.comparingKey ? e.findIndex(
|
|
20
|
-
(
|
|
20
|
+
(n) => n[l.comparingKey] === t[l.comparingKey]
|
|
21
21
|
) > -1 : ee(e, t) : l.comparingKey ? e[l.comparingKey] === t[l.comparingKey] : P(e) === t;
|
|
22
22
|
let B;
|
|
23
23
|
((e) => {
|
|
@@ -25,25 +25,25 @@ const ll = (l, S, A) => {
|
|
|
25
25
|
})(B || (B = {}));
|
|
26
26
|
const a = i(
|
|
27
27
|
l.selected
|
|
28
|
-
), R = je(),
|
|
28
|
+
), R = je(), u = r({
|
|
29
29
|
get() {
|
|
30
30
|
return R?.value?.value ?? a.value;
|
|
31
31
|
},
|
|
32
32
|
set(e) {
|
|
33
|
-
R.onChange?.(e), R.onClose?.(),
|
|
33
|
+
R.onChange?.(e), R.onClose?.(), b("update:selected", e);
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
|
|
36
|
+
A(
|
|
37
37
|
() => l.selected,
|
|
38
38
|
() => {
|
|
39
39
|
a.value = l.selected, s.value = l.selected;
|
|
40
40
|
}
|
|
41
41
|
);
|
|
42
|
-
const ce = _e(), w = i(null),
|
|
42
|
+
const ce = _e(), w = i(null), O = i(null), L = i(null), E = i(null), U = i(null), I = i(null), se = i(), q = i(null), $ = i(null), j = i(null), de = 8, ve = r(() => I.value ? I.value.getBoundingClientRect().height + de + l.distance : 0), X = i(!1), f = i([]), x = i(-1), S = i(""), s = i(l.selected || []), z = () => I.value?.focus(), [g, fe, ge] = Ve({
|
|
43
43
|
disabled: l.disabled,
|
|
44
44
|
initialValue: l.defaultOpen
|
|
45
45
|
});
|
|
46
|
-
|
|
46
|
+
A(
|
|
47
47
|
() => l.disabled,
|
|
48
48
|
(e) => {
|
|
49
49
|
e !== void 0 && ge(e);
|
|
@@ -56,27 +56,27 @@ const ll = (l, S, A) => {
|
|
|
56
56
|
return l.isOpen;
|
|
57
57
|
},
|
|
58
58
|
set(e) {
|
|
59
|
-
|
|
59
|
+
b("update:isOpen", e);
|
|
60
60
|
}
|
|
61
|
-
}), he = r(() => o.value.length - 1),
|
|
61
|
+
}), he = r(() => o.value.length - 1), v = Le(0, 0, he), J = r(() => u.value ? l.displayValue(u.value) : ""), Oe = (e) => {
|
|
62
62
|
if (!e.value.length && !l.multiOptionsPlaceholderPrefix && !l.multiOptionsPlaceholderSuffix)
|
|
63
63
|
return l.placeholder;
|
|
64
64
|
const t = !l.multiOptionsPlaceholderPrefix && !l.multiOptionsPlaceholderSuffix ? `${e.value.length} selected` : `${l.multiOptionsPlaceholderPrefix ?? ""}${e.value.length ?? "0"}${l.multiOptionsPlaceholderSuffix ?? ""}`;
|
|
65
65
|
return e.value.length == 1 && l.displayValue ? l.displayValue(e.value[0]) : t;
|
|
66
|
-
},
|
|
66
|
+
}, Se = r(() => {
|
|
67
67
|
if (!l.multi)
|
|
68
|
-
return
|
|
68
|
+
return u.value ? l.displayValue(u.value) : l.placeholder;
|
|
69
69
|
if (Array.isArray(a.value))
|
|
70
70
|
return Oe(a);
|
|
71
71
|
}), K = r(() => {
|
|
72
72
|
if (Array.isArray(a.value))
|
|
73
73
|
return l.groupedOptions ? ie(o, a) : a.value.length === o.value.length;
|
|
74
|
-
}),
|
|
74
|
+
}), me = r(() => !l.multi || !Array.isArray(a.value) ? !1 : l.groupedOptions ? ne(
|
|
75
75
|
o,
|
|
76
76
|
a
|
|
77
77
|
) : a.value.length > 0 && a.value.length < o.value.length), M = (e) => {
|
|
78
|
-
|
|
79
|
-
}, D = r(() => l.groupedOptions ? ae(l.options) : l.options),
|
|
78
|
+
S.value = e;
|
|
79
|
+
}, D = r(() => l.groupedOptions ? ae(l.options) : l.options), be = r(() => {
|
|
80
80
|
if (re(
|
|
81
81
|
D,
|
|
82
82
|
s
|
|
@@ -86,59 +86,59 @@ const ll = (l, S, A) => {
|
|
|
86
86
|
selected: [],
|
|
87
87
|
notSelected: []
|
|
88
88
|
};
|
|
89
|
-
P(D).value.forEach((
|
|
90
|
-
const
|
|
91
|
-
(
|
|
92
|
-
) > -1 : s.value.includes(
|
|
93
|
-
e[
|
|
89
|
+
P(D).value.forEach((n) => {
|
|
90
|
+
const d = (l.comparingKey ? s.value.findIndex(
|
|
91
|
+
(k) => k[l.comparingKey] === n[l.comparingKey]
|
|
92
|
+
) > -1 : s.value.includes(n)) ? "selected" : "notSelected";
|
|
93
|
+
e[d].push(n);
|
|
94
94
|
});
|
|
95
95
|
const t = l.groupedOptions ? G(e.notSelected) : e.notSelected;
|
|
96
96
|
return [].concat(e.selected, t);
|
|
97
97
|
}), o = r(() => {
|
|
98
|
-
const e = Array.isArray(s.value) && l.multi &&
|
|
98
|
+
const e = Array.isArray(s.value) && l.multi && h.VERSION === 4 && !te ? be.value : D.value;
|
|
99
99
|
if (l.onSearch) {
|
|
100
|
-
const t = e.filter((
|
|
100
|
+
const t = e.filter((n) => l.groupedOptions && H(n) ? n : l.onSearch(n, S.value));
|
|
101
101
|
return l.groupedOptions ? G(t) : t;
|
|
102
102
|
} else
|
|
103
103
|
return e;
|
|
104
|
-
}),
|
|
105
|
-
() =>
|
|
104
|
+
}), Ae = r(() => f.value[0]?.hasSubtitle), Q = r(() => c.mode === T.Multi), Y = r(
|
|
105
|
+
() => Ae.value ? h.MULTILINE_LIST_HEIGHT : h.LIST_HEIGHT
|
|
106
106
|
), {
|
|
107
107
|
list: Z,
|
|
108
108
|
containerProps: F,
|
|
109
109
|
wrapperProps: Pe,
|
|
110
|
-
scrollTo:
|
|
110
|
+
scrollTo: N
|
|
111
111
|
} = Ue(o, {
|
|
112
112
|
itemHeight: Y.value,
|
|
113
113
|
overscan: l.disableVirtualScroll ? 1 / 0 : 2
|
|
114
114
|
});
|
|
115
|
-
|
|
115
|
+
A(
|
|
116
116
|
() => l.isOpen,
|
|
117
117
|
(e) => {
|
|
118
118
|
W(e);
|
|
119
119
|
}
|
|
120
|
-
),
|
|
121
|
-
await
|
|
122
|
-
}),
|
|
123
|
-
[g,
|
|
120
|
+
), A([x], async () => {
|
|
121
|
+
await C();
|
|
122
|
+
}), A(
|
|
123
|
+
[g, v, x],
|
|
124
124
|
async ([e], [t]) => {
|
|
125
|
-
g.value && (await
|
|
126
|
-
l.multi &&
|
|
127
|
-
}),
|
|
128
|
-
|
|
125
|
+
g.value && (await C(), x.value !== -1 && e !== t && setTimeout(() => {
|
|
126
|
+
l.multi && h.VERSION === 4 || N(x.value);
|
|
127
|
+
}), v.value && setTimeout(() => {
|
|
128
|
+
N(v.value);
|
|
129
129
|
}));
|
|
130
130
|
}
|
|
131
|
-
),
|
|
132
|
-
|
|
131
|
+
), A(S, () => {
|
|
132
|
+
b("onsearch", S.value), N(0);
|
|
133
133
|
});
|
|
134
134
|
const m = (e, t = !1) => {
|
|
135
|
-
l.disabled || (W(e),
|
|
136
|
-
g.value &&
|
|
135
|
+
l.disabled || (W(e), C(() => {
|
|
136
|
+
g.value && b("opened"), g.value || b("closed"), w.value && t && w.value.focus();
|
|
137
137
|
}));
|
|
138
138
|
};
|
|
139
|
-
|
|
139
|
+
A(g, (e) => {
|
|
140
140
|
if (e) {
|
|
141
|
-
|
|
141
|
+
S.value = "", Q.value && Array.isArray(u.value) && (s.value = P(u.value).slice());
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
z();
|
|
@@ -150,7 +150,7 @@ const ll = (l, S, A) => {
|
|
|
150
150
|
}
|
|
151
151
|
if (Array.isArray(a.value)) {
|
|
152
152
|
if (l.groupedOptions)
|
|
153
|
-
|
|
153
|
+
ue(o, a);
|
|
154
154
|
else {
|
|
155
155
|
if (a.value.length === o.value.length) {
|
|
156
156
|
a.value = [];
|
|
@@ -158,31 +158,31 @@ const ll = (l, S, A) => {
|
|
|
158
158
|
}
|
|
159
159
|
a.value = o.value;
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
b("selectAll");
|
|
162
162
|
}
|
|
163
163
|
}, we = () => {
|
|
164
|
-
Te(),
|
|
164
|
+
Te(), h.VERSION !== 4 && (u.value = a.value);
|
|
165
165
|
}, Ie = (e = !0) => {
|
|
166
|
-
a.value = [], e && (
|
|
167
|
-
},
|
|
168
|
-
if (e = P(e), f.value[t]?.disabled)
|
|
166
|
+
a.value = [], e && (u.value = [], s.value = []), b("clear");
|
|
167
|
+
}, V = (e, t) => {
|
|
168
|
+
if (e = P(e), h.VERSION === 4 ? e[l.disabledOptionKey] : f.value[t]?.disabled)
|
|
169
169
|
return;
|
|
170
170
|
if (x.value = t, c.mode !== T.Multi) {
|
|
171
171
|
l.keepOpen || m(!1), c.goToOption(
|
|
172
172
|
0
|
|
173
173
|
/* None */
|
|
174
|
-
),
|
|
174
|
+
), u.value = e, M(""), z(), c.type === _.Search && O.value && (O.value.value = l.displayValue(e));
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
177
|
if (!Array.isArray(a.value))
|
|
178
178
|
return;
|
|
179
|
-
|
|
179
|
+
O.value?.focus();
|
|
180
180
|
const y = P(a.value);
|
|
181
181
|
if (ee(y, e) || l.comparingKey && y.findIndex(
|
|
182
|
-
(
|
|
182
|
+
(d) => d[l.comparingKey] === e[l.comparingKey]
|
|
183
183
|
) > -1) {
|
|
184
184
|
a.value = y.filter(
|
|
185
|
-
(
|
|
185
|
+
(d) => !Be(d, e)
|
|
186
186
|
);
|
|
187
187
|
return;
|
|
188
188
|
} else {
|
|
@@ -190,16 +190,16 @@ const ll = (l, S, A) => {
|
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
}, xe = (e) => f.value[e]?.disabled, c = {
|
|
193
|
-
activeIndex:
|
|
193
|
+
activeIndex: v,
|
|
194
194
|
options: f,
|
|
195
|
-
selectedOption:
|
|
195
|
+
selectedOption: u,
|
|
196
196
|
labelRef: U,
|
|
197
197
|
activeOption: E,
|
|
198
198
|
listRef: w,
|
|
199
199
|
clearable: l.clearable,
|
|
200
200
|
type: ce.input ? _.Search : _.Dropdown,
|
|
201
201
|
mode: l.multi ? T.Multi : T.Single,
|
|
202
|
-
query:
|
|
202
|
+
query: S,
|
|
203
203
|
selectedValue: J,
|
|
204
204
|
toggle: m,
|
|
205
205
|
disabled: l.disabled,
|
|
@@ -207,34 +207,34 @@ const ll = (l, S, A) => {
|
|
|
207
207
|
mandatory: l.mandatory,
|
|
208
208
|
size: l.size,
|
|
209
209
|
placeholder: l.placeholder,
|
|
210
|
-
select:
|
|
210
|
+
select: V,
|
|
211
211
|
clearSelection: () => {
|
|
212
|
-
M(""),
|
|
212
|
+
M(""), u.value = c.mode === T.Single ? null : [], s.value = c.mode === T.Single ? null : [], O.value && (O.value.value = "");
|
|
213
213
|
},
|
|
214
214
|
search: M,
|
|
215
215
|
goToOption: async (e) => {
|
|
216
216
|
if (!g.value)
|
|
217
217
|
return;
|
|
218
|
-
let t =
|
|
219
|
-
const
|
|
220
|
-
(
|
|
221
|
-
).length, y = o.value.length -
|
|
218
|
+
let t = v.value + e;
|
|
219
|
+
const n = f.value.filter(
|
|
220
|
+
(d) => d.disabled
|
|
221
|
+
).length, y = o.value.length - n;
|
|
222
222
|
for (t > y && (t = y + 1); ; ) {
|
|
223
223
|
if (!f.value[t]?.disabled) {
|
|
224
|
-
E.value = o.value[t],
|
|
224
|
+
E.value = o.value[t], v.value = t;
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
|
-
if ((e === 1 || e === 10) && (t = t + 1), (e === -1 || e === -10) && (t = t + -1), !!xe(
|
|
228
|
-
E.value = o.value[t],
|
|
227
|
+
if ((e === 1 || e === 10) && (t = t + 1), (e === -1 || e === -10) && (t = t + -1), !!xe(v.value)) {
|
|
228
|
+
E.value = o.value[t], v.value = t;
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
},
|
|
233
233
|
registerInput: (e) => {
|
|
234
|
-
|
|
234
|
+
O.value = e.value;
|
|
235
235
|
},
|
|
236
|
-
registerOption: (e, t,
|
|
237
|
-
f.value = [...f.value, { id: e, disabled: t, hasSubtitle:
|
|
236
|
+
registerOption: (e, t, n) => {
|
|
237
|
+
f.value = [...f.value, { id: e, disabled: t, hasSubtitle: n }];
|
|
238
238
|
},
|
|
239
239
|
unRegisterOption(e) {
|
|
240
240
|
f.value = f.value.filter((t) => t.id !== e);
|
|
@@ -251,24 +251,24 @@ const ll = (l, S, A) => {
|
|
|
251
251
|
q,
|
|
252
252
|
$,
|
|
253
253
|
j,
|
|
254
|
-
|
|
254
|
+
O,
|
|
255
255
|
F.ref
|
|
256
256
|
]
|
|
257
257
|
}
|
|
258
258
|
);
|
|
259
259
|
const De = () => {
|
|
260
|
-
|
|
260
|
+
O.value && (O.value.value = c.query.value = "");
|
|
261
261
|
};
|
|
262
262
|
He(async () => {
|
|
263
|
-
l.autoFocus && (await
|
|
263
|
+
l.autoFocus && (await C(), setTimeout(() => {
|
|
264
264
|
L.value.focus();
|
|
265
265
|
})), c.goToOption(0);
|
|
266
266
|
});
|
|
267
|
-
const
|
|
268
|
-
X.value = K.value,
|
|
267
|
+
const Ne = () => {
|
|
268
|
+
X.value = K.value, u.value = a.value, Array.isArray(u.value) && (s.value = P(u.value).slice()), b("apply", u.value), m(!1), De();
|
|
269
269
|
}, p = () => {
|
|
270
|
-
Q.value && Array.isArray(s.value) && (
|
|
271
|
-
},
|
|
270
|
+
Q.value && Array.isArray(s.value) && (u.value = P(s.value).slice()), S.value = "", m(!1);
|
|
271
|
+
}, Ce = (e) => {
|
|
272
272
|
if (!l.disableKeyboardEvents)
|
|
273
273
|
switch (e.key) {
|
|
274
274
|
case "Space":
|
|
@@ -317,49 +317,49 @@ const ll = (l, S, A) => {
|
|
|
317
317
|
m(!0);
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
V(o.value[v.value], v.value), c.mode === T.Single && !l.keepOpen && m(!1), e.preventDefault();
|
|
321
321
|
break;
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
}, Ee = r(() => {
|
|
325
325
|
if (l.loading)
|
|
326
326
|
return 8.5;
|
|
327
|
-
const e = l.customNumberOfDisplayedOptions || Z.value.reduce((
|
|
327
|
+
const e = l.customNumberOfDisplayedOptions || Z.value.reduce((k, Ke) => {
|
|
328
328
|
const Me = l.overrideOptionCountCalculation ? l.overrideOptionCountCalculation(Ke.data) : 1;
|
|
329
|
-
return
|
|
330
|
-
}, 0), t = l.multi && l.showSelectAll && !
|
|
331
|
-
let
|
|
332
|
-
return l.noResultsText &&
|
|
333
|
-
|
|
329
|
+
return k + Me;
|
|
330
|
+
}, 0), t = l.multi && l.showSelectAll && !S.value ? 1 : 0, n = e > h.MAX_NUMBER_OF_OPTIONS, y = e + t;
|
|
331
|
+
let d = n ? h.MAX_NUMBER_OF_OPTIONS + 0.1 : y;
|
|
332
|
+
return l.noResultsText && d === 0 && (d = d + 1), $e(
|
|
333
|
+
d * Y.value + h.PADDING_PX
|
|
334
334
|
);
|
|
335
335
|
});
|
|
336
336
|
return {
|
|
337
337
|
onKeydown: Re,
|
|
338
|
-
location:
|
|
338
|
+
location: ve,
|
|
339
339
|
open: g,
|
|
340
340
|
toggleMenu: m,
|
|
341
|
-
onButtonKeydown:
|
|
342
|
-
displayedValue:
|
|
341
|
+
onButtonKeydown: Ce,
|
|
342
|
+
displayedValue: Se,
|
|
343
343
|
labelRef: U,
|
|
344
|
-
query:
|
|
344
|
+
query: S,
|
|
345
345
|
containerProps: F,
|
|
346
346
|
calculateTableHeight: Ee,
|
|
347
347
|
wrapperProps: Pe,
|
|
348
348
|
filteredOptions: o,
|
|
349
349
|
allSelected: K,
|
|
350
350
|
allSelectedApplied: X,
|
|
351
|
-
isIndeterminate:
|
|
351
|
+
isIndeterminate: me,
|
|
352
352
|
onSelectAll: we,
|
|
353
353
|
virtualOptions: Z,
|
|
354
354
|
isSelected: oe,
|
|
355
|
-
selectedOption:
|
|
355
|
+
selectedOption: u,
|
|
356
356
|
selectedOptionPrevious: s,
|
|
357
357
|
selectedValue: J,
|
|
358
|
-
onSelect:
|
|
359
|
-
activeIndex:
|
|
358
|
+
onSelect: V,
|
|
359
|
+
activeIndex: v,
|
|
360
360
|
onCancel: p,
|
|
361
|
-
onApply:
|
|
362
|
-
scrollTo:
|
|
361
|
+
onApply: Ne,
|
|
362
|
+
scrollTo: N,
|
|
363
363
|
onClickOutside: le,
|
|
364
364
|
listRef: w,
|
|
365
365
|
buttonRef: I,
|