@ironsource/shared-ui 2.1.6-rc.21 → 2.1.6-rc.22
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,9 +1,9 @@
|
|
|
1
1
|
import { useToggle as me } from "../../../composables/useToggle.js";
|
|
2
|
-
import { ref as n, computed as r, watch as
|
|
2
|
+
import { ref as n, computed as r, watch as m, useSlots as Pe, toRaw as A, nextTick as N, provide as Te, onMounted as we } from "vue";
|
|
3
3
|
import { isObjectInArray as W } from "../../../utils/array.js";
|
|
4
4
|
import { objectsEqual as xe } from "../../../utils/object.js";
|
|
5
5
|
import { useClamp as Ie, useVirtualList as De, onClickOutside as Y } from "@vueuse/core";
|
|
6
|
-
import { Mode as
|
|
6
|
+
import { Mode as P, Type as _, DropdownContext as Ne } from "./DropdownContext.js";
|
|
7
7
|
import { pxToRem as Re } from "../../../utils/style.js";
|
|
8
8
|
import { useEditableContext as Ee } from "../../table-cells/common/EditableContext.js";
|
|
9
9
|
const Ue = (l, O, b) => {
|
|
@@ -14,25 +14,25 @@ const Ue = (l, O, b) => {
|
|
|
14
14
|
})(k || (k = {}));
|
|
15
15
|
const a = n(
|
|
16
16
|
l.selected
|
|
17
|
-
),
|
|
17
|
+
), R = Ee(), u = r({
|
|
18
18
|
get() {
|
|
19
|
-
return
|
|
19
|
+
return R?.value?.value ?? a.value;
|
|
20
20
|
},
|
|
21
21
|
set(e) {
|
|
22
|
-
|
|
22
|
+
R.onChange?.(e), R.onClose?.(), O("update:selected", e);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
m(
|
|
26
26
|
() => l.selected,
|
|
27
27
|
() => {
|
|
28
28
|
a.value = l.selected, v.value = l.selected;
|
|
29
29
|
}
|
|
30
30
|
);
|
|
31
|
-
const p = Pe(),
|
|
31
|
+
const p = Pe(), w = n(null), g = n(null), V = n(null), E = n(null), H = n(null), x = n(null), F = n(), B = n(null), L = n(null), U = n(null), ee = 8, le = r(() => x.value ? x.value.getBoundingClientRect().height + ee + l.distance : 0), c = n([]), I = n(-1), T = n(""), v = n(l.selected || []), q = () => x.value?.focus(), [d, te, ae] = me({
|
|
32
32
|
disabled: l.disabled,
|
|
33
33
|
initialValue: l.defaultOpen
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
m(
|
|
36
36
|
() => l.disabled,
|
|
37
37
|
(e) => {
|
|
38
38
|
e !== void 0 && ae(e);
|
|
@@ -60,8 +60,8 @@ const Ue = (l, O, b) => {
|
|
|
60
60
|
}), $ = r(() => {
|
|
61
61
|
if (Array.isArray(a.value))
|
|
62
62
|
return a.value.length === s.value.length;
|
|
63
|
-
}), oe = r(() => !l.multi || !Array.isArray(a.value) ? !1 : a.value.length > 0 && a.value.length < s.value.length),
|
|
64
|
-
|
|
63
|
+
}), oe = r(() => !l.multi || !Array.isArray(a.value) ? !1 : a.value.length > 0 && a.value.length < s.value.length), M = (e) => {
|
|
64
|
+
T.value = e;
|
|
65
65
|
}, se = r(() => {
|
|
66
66
|
const e = A(v.value), t = {
|
|
67
67
|
selected: [],
|
|
@@ -73,41 +73,43 @@ const Ue = (l, O, b) => {
|
|
|
73
73
|
}), [].concat(t.selected, t.notSelected);
|
|
74
74
|
}), s = r(() => {
|
|
75
75
|
const e = Array.isArray(v.value) && l.multi && b.VERSION === 4 ? se.value : l.options;
|
|
76
|
-
return l.onSearch ? e.filter((t) => l.onSearch(t,
|
|
77
|
-
}), ce = r(() => c.value[0]?.hasSubtitle), X = r(() => i.mode ===
|
|
76
|
+
return l.onSearch ? e.filter((t) => l.onSearch(t, T.value)) : e;
|
|
77
|
+
}), ce = r(() => c.value[0]?.hasSubtitle), X = r(() => i.mode === P.Multi), j = r(
|
|
78
78
|
() => ce.value ? b.MULTILINE_LIST_HEIGHT : b.LIST_HEIGHT
|
|
79
79
|
), {
|
|
80
80
|
list: z,
|
|
81
81
|
containerProps: J,
|
|
82
82
|
wrapperProps: ve,
|
|
83
|
-
scrollTo:
|
|
83
|
+
scrollTo: D
|
|
84
84
|
} = De(s, {
|
|
85
85
|
itemHeight: j.value,
|
|
86
86
|
overscan: 2
|
|
87
87
|
});
|
|
88
|
-
|
|
88
|
+
m(
|
|
89
89
|
() => l.isOpen,
|
|
90
90
|
(e) => {
|
|
91
91
|
G(e);
|
|
92
92
|
}
|
|
93
|
-
),
|
|
94
|
-
await
|
|
95
|
-
}),
|
|
96
|
-
[d, o,
|
|
93
|
+
), m([I], async () => {
|
|
94
|
+
await N();
|
|
95
|
+
}), m(
|
|
96
|
+
[d, o, I],
|
|
97
97
|
async ([e], [t]) => {
|
|
98
|
-
d.value && (await
|
|
99
|
-
l.multi && b.VERSION === 4 ||
|
|
98
|
+
d.value && (await N(), I.value !== -1 && e !== t && setTimeout(() => {
|
|
99
|
+
l.multi && b.VERSION === 4 || D(I.value);
|
|
100
100
|
}), o.value && setTimeout(() => {
|
|
101
|
-
|
|
101
|
+
D(o.value);
|
|
102
102
|
}));
|
|
103
103
|
}
|
|
104
|
-
)
|
|
104
|
+
), m(T, () => {
|
|
105
|
+
D(0);
|
|
106
|
+
});
|
|
105
107
|
const h = (e, t = !1) => {
|
|
106
|
-
l.disabled || (G(e),
|
|
107
|
-
d.value && O("opened"), d.value || O("closed"),
|
|
108
|
+
l.disabled || (G(e), N(() => {
|
|
109
|
+
d.value && O("opened"), d.value || O("closed"), w.value && t && w.value.focus();
|
|
108
110
|
}));
|
|
109
111
|
};
|
|
110
|
-
|
|
112
|
+
m(d, (e) => {
|
|
111
113
|
if (e) {
|
|
112
114
|
X.value && Array.isArray(u.value) && (v.value = A(u.value).slice());
|
|
113
115
|
return;
|
|
@@ -133,11 +135,11 @@ const Ue = (l, O, b) => {
|
|
|
133
135
|
}, C = (e, t) => {
|
|
134
136
|
if (e = A(e), c.value[t]?.disabled)
|
|
135
137
|
return;
|
|
136
|
-
if (
|
|
138
|
+
if (I.value = t, i.mode !== P.Multi) {
|
|
137
139
|
l.keepOpen || h(!1), i.goToOption(
|
|
138
140
|
0
|
|
139
141
|
/* None */
|
|
140
|
-
), u.value = e,
|
|
142
|
+
), u.value = e, M(""), q(), i.type === _.Search && g.value && (g.value.value = l.displayValue(e));
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
143
145
|
if (!Array.isArray(a.value))
|
|
@@ -158,12 +160,12 @@ const Ue = (l, O, b) => {
|
|
|
158
160
|
options: c,
|
|
159
161
|
selectedOption: u,
|
|
160
162
|
labelRef: H,
|
|
161
|
-
activeOption:
|
|
162
|
-
listRef:
|
|
163
|
+
activeOption: E,
|
|
164
|
+
listRef: w,
|
|
163
165
|
clearable: l.clearable,
|
|
164
166
|
type: p.input ? _.Search : _.Dropdown,
|
|
165
|
-
mode: l.multi ?
|
|
166
|
-
query:
|
|
167
|
+
mode: l.multi ? P.Multi : P.Single,
|
|
168
|
+
query: T,
|
|
167
169
|
selectedValue: K,
|
|
168
170
|
toggle: h,
|
|
169
171
|
disabled: l.disabled,
|
|
@@ -173,9 +175,9 @@ const Ue = (l, O, b) => {
|
|
|
173
175
|
placeholder: l.placeholder,
|
|
174
176
|
select: C,
|
|
175
177
|
clearSelection: () => {
|
|
176
|
-
|
|
178
|
+
M(""), u.value = i.mode === P.Single ? null : [], v.value = i.mode === P.Single ? null : [], g.value && (g.value.value = "");
|
|
177
179
|
},
|
|
178
|
-
search:
|
|
180
|
+
search: M,
|
|
179
181
|
goToOption: async (e) => {
|
|
180
182
|
if (!d.value)
|
|
181
183
|
return;
|
|
@@ -185,11 +187,11 @@ const Ue = (l, O, b) => {
|
|
|
185
187
|
).length, S = s.value.length - y;
|
|
186
188
|
for (t > S && (t = S + 1); ; ) {
|
|
187
189
|
if (!c.value[t]?.disabled) {
|
|
188
|
-
|
|
190
|
+
E.value = s.value[t], o.value = t;
|
|
189
191
|
return;
|
|
190
192
|
}
|
|
191
193
|
if ((e === 1 || e === 10) && (t = t + 1), (e === -1 || e === -10) && (t = t + -1), !!he(o.value)) {
|
|
192
|
-
|
|
194
|
+
E.value = s.value[t], o.value = t;
|
|
193
195
|
return;
|
|
194
196
|
}
|
|
195
197
|
}
|
|
@@ -205,13 +207,13 @@ const Ue = (l, O, b) => {
|
|
|
205
207
|
}
|
|
206
208
|
};
|
|
207
209
|
Te(Ne, i), Y(
|
|
208
|
-
|
|
210
|
+
w,
|
|
209
211
|
() => {
|
|
210
212
|
d.value && Q();
|
|
211
213
|
},
|
|
212
214
|
{
|
|
213
215
|
ignore: [
|
|
214
|
-
|
|
216
|
+
x,
|
|
215
217
|
B,
|
|
216
218
|
L,
|
|
217
219
|
U,
|
|
@@ -224,14 +226,14 @@ const Ue = (l, O, b) => {
|
|
|
224
226
|
g.value && (g.value.value = i.query.value = "");
|
|
225
227
|
};
|
|
226
228
|
we(async () => {
|
|
227
|
-
l.autoFocus && (await
|
|
229
|
+
l.autoFocus && (await N(), setTimeout(() => {
|
|
228
230
|
V.value.focus();
|
|
229
231
|
})), i.goToOption(0);
|
|
230
232
|
});
|
|
231
233
|
const Se = () => {
|
|
232
234
|
u.value = a.value, Array.isArray(u.value) && (v.value = A(u.value).slice()), O("apply", u.value), h(!1), ye();
|
|
233
235
|
}, Q = () => {
|
|
234
|
-
X.value && Array.isArray(v.value) && (u.value = A(v.value).slice()),
|
|
236
|
+
X.value && Array.isArray(v.value) && (u.value = A(v.value).slice()), T.value = "", h(!1);
|
|
235
237
|
}, be = (e) => {
|
|
236
238
|
if (!l.disableKeyboardEvents)
|
|
237
239
|
switch (e.key) {
|
|
@@ -281,7 +283,7 @@ const Ue = (l, O, b) => {
|
|
|
281
283
|
h(!0);
|
|
282
284
|
return;
|
|
283
285
|
}
|
|
284
|
-
C(s.value[o.value], o.value), i.mode ===
|
|
286
|
+
C(s.value[o.value], o.value), i.mode === P.Single && !l.keepOpen && h(!1), e.preventDefault();
|
|
285
287
|
break;
|
|
286
288
|
}
|
|
287
289
|
}
|
|
@@ -300,7 +302,7 @@ const Ue = (l, O, b) => {
|
|
|
300
302
|
onButtonKeydown: be,
|
|
301
303
|
displayedValue: re,
|
|
302
304
|
labelRef: H,
|
|
303
|
-
query:
|
|
305
|
+
query: T,
|
|
304
306
|
containerProps: J,
|
|
305
307
|
calculateTableHeight: Oe,
|
|
306
308
|
wrapperProps: ve,
|
|
@@ -317,10 +319,10 @@ const Ue = (l, O, b) => {
|
|
|
317
319
|
activeIndex: o,
|
|
318
320
|
onCancel: Q,
|
|
319
321
|
onApply: Se,
|
|
320
|
-
scrollTo:
|
|
322
|
+
scrollTo: D,
|
|
321
323
|
onClickOutside: Y,
|
|
322
|
-
listRef:
|
|
323
|
-
buttonRef:
|
|
324
|
+
listRef: w,
|
|
325
|
+
buttonRef: x,
|
|
324
326
|
apply: B,
|
|
325
327
|
cancel: L,
|
|
326
328
|
el: V,
|