@ironsource/shared-ui 2.1.11-rc.0 → 2.1.11-rc.2
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 N, 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,8 +7,8 @@ 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,
|
|
@@ -25,25 +25,25 @@ const ll = (l, S, A) => {
|
|
|
25
25
|
})(B || (B = {}));
|
|
26
26
|
const a = i(
|
|
27
27
|
l.selected
|
|
28
|
-
),
|
|
28
|
+
), C = je(), n = r({
|
|
29
29
|
get() {
|
|
30
|
-
return
|
|
30
|
+
return C?.value?.value ?? a.value;
|
|
31
31
|
},
|
|
32
32
|
set(e) {
|
|
33
|
-
|
|
33
|
+
C.onChange?.(e), C.onClose?.(), b("update:selected", e);
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
|
|
36
|
+
A(
|
|
37
37
|
() => l.selected,
|
|
38
38
|
() => {
|
|
39
|
-
a.value = l.selected,
|
|
39
|
+
a.value = l.selected, d.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), R = 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), m = i(""), d = 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,9 +56,9 @@ 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(() => n.value ? l.displayValue(n.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 ?? ""}`;
|
|
@@ -68,18 +68,18 @@ const ll = (l, S, A) => {
|
|
|
68
68
|
return n.value ? l.displayValue(n.value) : l.placeholder;
|
|
69
69
|
if (Array.isArray(a.value))
|
|
70
70
|
return Oe(a);
|
|
71
|
-
}),
|
|
71
|
+
}), E = r(() => {
|
|
72
72
|
if (Array.isArray(a.value))
|
|
73
73
|
return l.groupedOptions ? ie(o, a) : a.value.length === o.value.length;
|
|
74
74
|
}), Se = r(() => !l.multi || !Array.isArray(a.value) ? !1 : l.groupedOptions ? ue(
|
|
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
|
+
m.value = e;
|
|
79
|
+
}, D = r(() => l.groupedOptions ? ae(l.options) : l.options), be = r(() => {
|
|
80
80
|
if (re(
|
|
81
81
|
D,
|
|
82
|
-
|
|
82
|
+
d
|
|
83
83
|
))
|
|
84
84
|
return D.value;
|
|
85
85
|
const e = {
|
|
@@ -87,64 +87,64 @@ const ll = (l, S, A) => {
|
|
|
87
87
|
notSelected: []
|
|
88
88
|
};
|
|
89
89
|
P(D).value.forEach((u) => {
|
|
90
|
-
const
|
|
91
|
-
(
|
|
92
|
-
) > -1 :
|
|
93
|
-
e[
|
|
90
|
+
const s = (l.comparingKey ? d.value.findIndex(
|
|
91
|
+
(k) => k[l.comparingKey] === u[l.comparingKey]
|
|
92
|
+
) > -1 : d.value.includes(u)) ? "selected" : "notSelected";
|
|
93
|
+
e[s].push(u);
|
|
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(
|
|
98
|
+
const e = Array.isArray(d.value) && l.multi && h.VERSION === 4 && !te ? be.value : D.value;
|
|
99
99
|
if (l.onSearch) {
|
|
100
|
-
const t = e.filter((u) => l.groupedOptions && H(u) ? u : l.onSearch(u,
|
|
100
|
+
const t = e.filter((u) => l.groupedOptions && H(u) ? u : l.onSearch(u, m.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: K
|
|
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
|
-
),
|
|
120
|
+
), A([x], async () => {
|
|
121
121
|
await N();
|
|
122
|
-
}),
|
|
123
|
-
[g,
|
|
122
|
+
}), A(
|
|
123
|
+
[g, v, x],
|
|
124
124
|
async ([e], [t]) => {
|
|
125
125
|
g.value && (await N(), x.value !== -1 && e !== t && setTimeout(() => {
|
|
126
|
-
l.multi &&
|
|
127
|
-
}),
|
|
128
|
-
|
|
126
|
+
l.multi && h.VERSION === 4 || K(x.value);
|
|
127
|
+
}), v.value && setTimeout(() => {
|
|
128
|
+
K(v.value);
|
|
129
129
|
}));
|
|
130
130
|
}
|
|
131
|
-
),
|
|
132
|
-
|
|
131
|
+
), A(m, () => {
|
|
132
|
+
b("onsearch", m.value), K(0);
|
|
133
133
|
});
|
|
134
|
-
const
|
|
134
|
+
const S = (e, t = !1) => {
|
|
135
135
|
l.disabled || (W(e), N(() => {
|
|
136
|
-
g.value &&
|
|
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
|
+
m.value = "", Q.value && Array.isArray(n.value) && (d.value = P(n.value).slice());
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
z();
|
|
145
145
|
});
|
|
146
146
|
const Te = () => {
|
|
147
|
-
if (
|
|
147
|
+
if (E.value) {
|
|
148
148
|
a.value = [];
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
@@ -158,80 +158,78 @@ 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 && (n.value = a.value);
|
|
165
165
|
}, Ie = (e = !0) => {
|
|
166
|
-
a.value = [], e && (n.value = [],
|
|
167
|
-
},
|
|
168
|
-
if (e = P(e), f.value[t]?.disabled)
|
|
166
|
+
a.value = [], e && (n.value = [], d.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
|
-
l.keepOpen ||
|
|
171
|
+
l.keepOpen || S(!1), c.goToOption(
|
|
172
172
|
0
|
|
173
173
|
/* None */
|
|
174
|
-
), n.value = e, M(""), z(), c.type === _.Search &&
|
|
174
|
+
), n.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
|
+
(s) => s[l.comparingKey] === e[l.comparingKey]
|
|
183
183
|
) > -1) {
|
|
184
|
-
a.value = y.filter(
|
|
185
|
-
(v) => !Be(v, e)
|
|
186
|
-
);
|
|
184
|
+
a.value = y.filter((s) => l.comparingKey ? s[l.comparingKey] !== e[l.comparingKey] : !Be(s, e));
|
|
187
185
|
return;
|
|
188
186
|
} else {
|
|
189
187
|
a.value = [...y, e];
|
|
190
188
|
return;
|
|
191
189
|
}
|
|
192
190
|
}, xe = (e) => f.value[e]?.disabled, c = {
|
|
193
|
-
activeIndex:
|
|
191
|
+
activeIndex: v,
|
|
194
192
|
options: f,
|
|
195
193
|
selectedOption: n,
|
|
196
194
|
labelRef: U,
|
|
197
|
-
activeOption:
|
|
195
|
+
activeOption: R,
|
|
198
196
|
listRef: w,
|
|
199
197
|
clearable: l.clearable,
|
|
200
198
|
type: ce.input ? _.Search : _.Dropdown,
|
|
201
199
|
mode: l.multi ? T.Multi : T.Single,
|
|
202
|
-
query:
|
|
200
|
+
query: m,
|
|
203
201
|
selectedValue: J,
|
|
204
|
-
toggle:
|
|
202
|
+
toggle: S,
|
|
205
203
|
disabled: l.disabled,
|
|
206
204
|
open: g,
|
|
207
205
|
mandatory: l.mandatory,
|
|
208
206
|
size: l.size,
|
|
209
207
|
placeholder: l.placeholder,
|
|
210
|
-
select:
|
|
208
|
+
select: V,
|
|
211
209
|
clearSelection: () => {
|
|
212
|
-
M(""), n.value = c.mode === T.Single ? null : [],
|
|
210
|
+
M(""), n.value = c.mode === T.Single ? null : [], d.value = c.mode === T.Single ? null : [], O.value && (O.value.value = "");
|
|
213
211
|
},
|
|
214
212
|
search: M,
|
|
215
213
|
goToOption: async (e) => {
|
|
216
214
|
if (!g.value)
|
|
217
215
|
return;
|
|
218
|
-
let t =
|
|
216
|
+
let t = v.value + e;
|
|
219
217
|
const u = f.value.filter(
|
|
220
|
-
(
|
|
218
|
+
(s) => s.disabled
|
|
221
219
|
).length, y = o.value.length - u;
|
|
222
220
|
for (t > y && (t = y + 1); ; ) {
|
|
223
221
|
if (!f.value[t]?.disabled) {
|
|
224
|
-
|
|
222
|
+
R.value = o.value[t], v.value = t;
|
|
225
223
|
return;
|
|
226
224
|
}
|
|
227
|
-
if ((e === 1 || e === 10) && (t = t + 1), (e === -1 || e === -10) && (t = t + -1), !!xe(
|
|
228
|
-
|
|
225
|
+
if ((e === 1 || e === 10) && (t = t + 1), (e === -1 || e === -10) && (t = t + -1), !!xe(v.value)) {
|
|
226
|
+
R.value = o.value[t], v.value = t;
|
|
229
227
|
return;
|
|
230
228
|
}
|
|
231
229
|
}
|
|
232
230
|
},
|
|
233
231
|
registerInput: (e) => {
|
|
234
|
-
|
|
232
|
+
O.value = e.value;
|
|
235
233
|
},
|
|
236
234
|
registerOption: (e, t, u) => {
|
|
237
235
|
f.value = [...f.value, { id: e, disabled: t, hasSubtitle: u }];
|
|
@@ -251,23 +249,23 @@ const ll = (l, S, A) => {
|
|
|
251
249
|
q,
|
|
252
250
|
$,
|
|
253
251
|
j,
|
|
254
|
-
|
|
252
|
+
O,
|
|
255
253
|
F.ref
|
|
256
254
|
]
|
|
257
255
|
}
|
|
258
256
|
);
|
|
259
257
|
const De = () => {
|
|
260
|
-
|
|
258
|
+
O.value && (O.value.value = c.query.value = "");
|
|
261
259
|
};
|
|
262
260
|
He(async () => {
|
|
263
261
|
l.autoFocus && (await N(), setTimeout(() => {
|
|
264
262
|
L.value.focus();
|
|
265
263
|
})), c.goToOption(0);
|
|
266
264
|
});
|
|
267
|
-
const
|
|
268
|
-
X.value =
|
|
265
|
+
const Ke = () => {
|
|
266
|
+
X.value = E.value, n.value = a.value, Array.isArray(n.value) && (d.value = P(n.value).slice()), b("apply", n.value), S(!1), De();
|
|
269
267
|
}, p = () => {
|
|
270
|
-
Q.value && Array.isArray(
|
|
268
|
+
Q.value && Array.isArray(d.value) && (n.value = P(d.value).slice()), m.value = "", S(!1);
|
|
271
269
|
}, Ne = (e) => {
|
|
272
270
|
if (!l.disableKeyboardEvents)
|
|
273
271
|
switch (e.key) {
|
|
@@ -275,9 +273,9 @@ const ll = (l, S, A) => {
|
|
|
275
273
|
case "Enter":
|
|
276
274
|
case "ArrowUp":
|
|
277
275
|
case "ArrowDown":
|
|
278
|
-
|
|
276
|
+
S(!0), e.preventDefault();
|
|
279
277
|
}
|
|
280
|
-
},
|
|
278
|
+
}, Ce = (e) => {
|
|
281
279
|
if (!l.disableKeyboardEvents)
|
|
282
280
|
switch (e.key) {
|
|
283
281
|
case "ArrowUp": {
|
|
@@ -295,7 +293,7 @@ const ll = (l, S, A) => {
|
|
|
295
293
|
break;
|
|
296
294
|
}
|
|
297
295
|
case "Escape": {
|
|
298
|
-
|
|
296
|
+
S(!1), e.preventDefault();
|
|
299
297
|
break;
|
|
300
298
|
}
|
|
301
299
|
case "PageUp": {
|
|
@@ -314,52 +312,52 @@ const ll = (l, S, A) => {
|
|
|
314
312
|
}
|
|
315
313
|
case "Enter": {
|
|
316
314
|
if (!g.value) {
|
|
317
|
-
|
|
315
|
+
S(!0);
|
|
318
316
|
return;
|
|
319
317
|
}
|
|
320
|
-
|
|
318
|
+
V(o.value[v.value], v.value), c.mode === T.Single && !l.keepOpen && S(!1), e.preventDefault();
|
|
321
319
|
break;
|
|
322
320
|
}
|
|
323
321
|
}
|
|
324
|
-
},
|
|
322
|
+
}, Re = r(() => {
|
|
325
323
|
if (l.loading)
|
|
326
324
|
return 8.5;
|
|
327
|
-
const e = l.customNumberOfDisplayedOptions || Z.value.reduce((
|
|
328
|
-
const Me = l.overrideOptionCountCalculation ? l.overrideOptionCountCalculation(
|
|
329
|
-
return
|
|
330
|
-
}, 0), t = l.multi && l.showSelectAll && !
|
|
331
|
-
let
|
|
332
|
-
return l.noResultsText &&
|
|
333
|
-
|
|
325
|
+
const e = l.customNumberOfDisplayedOptions || Z.value.reduce((k, Ee) => {
|
|
326
|
+
const Me = l.overrideOptionCountCalculation ? l.overrideOptionCountCalculation(Ee.data) : 1;
|
|
327
|
+
return k + Me;
|
|
328
|
+
}, 0), t = l.multi && l.showSelectAll && !m.value ? 1 : 0, u = e > h.MAX_NUMBER_OF_OPTIONS, y = e + t;
|
|
329
|
+
let s = u ? h.MAX_NUMBER_OF_OPTIONS + 0.1 : y;
|
|
330
|
+
return l.noResultsText && s === 0 && (s = s + 1), $e(
|
|
331
|
+
s * Y.value + h.PADDING_PX
|
|
334
332
|
);
|
|
335
333
|
});
|
|
336
334
|
return {
|
|
337
|
-
onKeydown:
|
|
338
|
-
location:
|
|
335
|
+
onKeydown: Ce,
|
|
336
|
+
location: ve,
|
|
339
337
|
open: g,
|
|
340
|
-
toggleMenu:
|
|
338
|
+
toggleMenu: S,
|
|
341
339
|
onButtonKeydown: Ne,
|
|
342
340
|
displayedValue: me,
|
|
343
341
|
labelRef: U,
|
|
344
|
-
query:
|
|
342
|
+
query: m,
|
|
345
343
|
containerProps: F,
|
|
346
|
-
calculateTableHeight:
|
|
344
|
+
calculateTableHeight: Re,
|
|
347
345
|
wrapperProps: Pe,
|
|
348
346
|
filteredOptions: o,
|
|
349
|
-
allSelected:
|
|
347
|
+
allSelected: E,
|
|
350
348
|
allSelectedApplied: X,
|
|
351
349
|
isIndeterminate: Se,
|
|
352
350
|
onSelectAll: we,
|
|
353
351
|
virtualOptions: Z,
|
|
354
352
|
isSelected: oe,
|
|
355
353
|
selectedOption: n,
|
|
356
|
-
selectedOptionPrevious:
|
|
354
|
+
selectedOptionPrevious: d,
|
|
357
355
|
selectedValue: J,
|
|
358
|
-
onSelect:
|
|
359
|
-
activeIndex:
|
|
356
|
+
onSelect: V,
|
|
357
|
+
activeIndex: v,
|
|
360
358
|
onCancel: p,
|
|
361
|
-
onApply:
|
|
362
|
-
scrollTo:
|
|
359
|
+
onApply: Ke,
|
|
360
|
+
scrollTo: K,
|
|
363
361
|
onClickOutside: le,
|
|
364
362
|
listRef: w,
|
|
365
363
|
buttonRef: I,
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './AppIcon.vue_vue_type_style_index_0_scoped_56ba337c_lang.css';
|
|
2
2
|
import { AppTriggerTypes as ro } from "./components/appTrigger/index.js";
|
|
3
3
|
import { AutocompleteDropdownTypes as mo } from "./components/autocompleteDropdown/index.js";
|
|
4
4
|
import { MenuItemTypes as po } from "./components/menuItem/index.js";
|