@milaboratories/uikit 2.15.43 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +27 -22
- package/.turbo/turbo-formatter$colon$check.log +2 -2
- package/.turbo/turbo-linter$colon$check.log +2 -2
- package/.turbo/turbo-types$colon$check.log +1 -1
- package/CHANGELOG.md +16 -0
- package/dist/components/DropdownListItem.js.map +1 -1
- package/dist/components/DropdownListItem.vue.d.ts.map +1 -1
- package/dist/components/DropdownListItem.vue2.js +22 -20
- package/dist/components/DropdownListItem.vue2.js.map +1 -1
- package/dist/components/PlAlert/PlAlert.vue.d.ts +1 -1
- package/dist/components/PlAlert/PlAlert.vue.d.ts.map +1 -1
- package/dist/components/PlAutocomplete/PlAutocomplete.vue2.js +27 -27
- package/dist/components/PlAutocomplete/PlAutocomplete.vue2.js.map +1 -1
- package/dist/components/PlAutocompleteMulti/PlAutocompleteMulti.vue2.js +17 -17
- package/dist/components/PlBtnSplit/PlBtnSplit.vue2.js +11 -11
- package/dist/components/PlColumnLabel/PlColumnLabel.js +8 -0
- package/dist/components/PlColumnLabel/PlColumnLabel.js.map +1 -0
- package/dist/components/PlColumnLabel/PlColumnLabel.style.js +8 -0
- package/dist/components/PlColumnLabel/PlColumnLabel.style.js.map +1 -0
- package/dist/components/PlColumnLabel/PlColumnLabel.vue.css +1 -0
- package/dist/components/PlColumnLabel/PlColumnLabel.vue.d.ts +23 -0
- package/dist/components/PlColumnLabel/PlColumnLabel.vue.d.ts.map +1 -0
- package/dist/components/PlColumnLabel/PlColumnLabel.vue2.js +28 -0
- package/dist/components/PlColumnLabel/PlColumnLabel.vue2.js.map +1 -0
- package/dist/components/PlColumnLabel/index.d.ts +2 -0
- package/dist/components/PlColumnLabel/index.d.ts.map +1 -0
- package/dist/components/PlColumnLabel/index.js +1 -0
- package/dist/components/PlDropdown/PlDropdown.js.map +1 -1
- package/dist/components/PlDropdown/PlDropdown.vue.d.ts.map +1 -1
- package/dist/components/PlDropdown/PlDropdown.vue2.js +124 -112
- package/dist/components/PlDropdown/PlDropdown.vue2.js.map +1 -1
- package/dist/components/PlDropdownLegacy/PlDropdownLegacy.vue2.js +32 -32
- package/dist/components/PlDropdownLegacy/PlDropdownLegacy.vue2.js.map +1 -1
- package/dist/components/PlDropdownLine/PlDropdownLine.vue2.js +30 -30
- package/dist/components/PlDropdownMulti/PlDropdownMulti.vue2.js +12 -12
- package/dist/components/PlDropdownMultiRef/PlDropdownMultiRef.vue.d.ts +1 -1
- package/dist/components/PlDropdownMultiRef/PlDropdownMultiRef.vue.d.ts.map +1 -1
- package/dist/components/PlElementList/PlElementListItem.vue2.js +7 -7
- package/dist/components/PlFileDialog/Remote.vue2.js +1 -1
- package/dist/components/PlFileInput/PlFileInput.vue2.js +10 -10
- package/dist/components/PlFileInput/PlFileInput.vue2.js.map +1 -1
- package/dist/components/PlNumberField/PlNumberField.vue2.js +5 -5
- package/dist/components/PlSearchField/PlSearchField.vue2.js +7 -7
- package/dist/components/PlTextArea/PlTextArea.vue2.js +11 -11
- package/dist/components/PlTextField/PlTextField.vue2.js +16 -16
- package/dist/components/Slider.vue2.js +7 -7
- package/dist/components/SliderRange.vue2.js +11 -11
- package/dist/components/SliderRangeTriple.vue2.js +9 -9
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +2 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +103 -101
- package/dist/index.js.map +1 -1
- package/dist/utils/useLabelNotch.js +6 -6
- package/package.json +8 -3
- package/src/components/DropdownListItem.vue +2 -1
- package/src/components/PlColumnLabel/PlColumnLabel.vue +46 -0
- package/src/components/PlColumnLabel/index.ts +1 -0
- package/src/components/PlDropdown/PlDropdown.vue +13 -10
- package/src/helpers/utils.ts +1 -0
- package/src/index.ts +1 -0
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { normalizeListOptions as t } from "../../helpers/utils.js";
|
|
3
|
-
import n from "../PlTooltip/PlTooltip.js";
|
|
4
|
-
import "../PlTooltip/index.js";
|
|
5
|
-
import { getErrorMessage as r } from "../../helpers/error.js";
|
|
6
|
-
import i from "../LongText.js";
|
|
7
|
-
import a from "../PlSvg/PlSvg.js";
|
|
1
|
+
import e from "../PlSvg/PlSvg.js";
|
|
8
2
|
import "../PlSvg/index.js";
|
|
9
|
-
import
|
|
10
|
-
import "../PlIcon24/index.js";
|
|
11
|
-
import s from "../PlIcon16/PlIcon16.js";
|
|
12
|
-
import ee from "../../utils/DoubleContour.js";
|
|
13
|
-
import { useLabelNotch as c } from "../../utils/useLabelNotch.js";
|
|
14
|
-
import { deepEqual as l } from "../../helpers/objects.js";
|
|
3
|
+
import t from "../PlIcon16/PlIcon16.js";
|
|
15
4
|
import "../PlIcon16/index.js";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
5
|
+
import { normalizeListOptions as n } from "../../helpers/utils.js";
|
|
6
|
+
import { tap as r } from "../../helpers/functions.js";
|
|
7
|
+
import i from "../PlTooltip/PlTooltip.js";
|
|
8
|
+
import "../PlTooltip/index.js";
|
|
9
|
+
import a from "../PlColumnLabel/PlColumnLabel.js";
|
|
10
|
+
import "../PlColumnLabel/index.js";
|
|
11
|
+
import { getErrorMessage as o } from "../../helpers/error.js";
|
|
12
|
+
import s from "../LongText.js";
|
|
13
|
+
import c from "../PlIcon24/PlIcon24.js";
|
|
14
|
+
import "../PlIcon24/index.js";
|
|
15
|
+
import l from "../../utils/DoubleContour.js";
|
|
16
|
+
import { useLabelNotch as u } from "../../utils/useLabelNotch.js";
|
|
17
|
+
import { deepEqual as d } from "../../helpers/objects.js";
|
|
18
|
+
import f from "../../assets/images/required.js";
|
|
19
|
+
import ee from "./OptionList.js";
|
|
18
20
|
import './pl-dropdown.css';/* empty css */
|
|
19
|
-
import { useGroupBy as
|
|
20
|
-
import { computed as
|
|
21
|
+
import { useGroupBy as p } from "./useGroupBy.js";
|
|
22
|
+
import { computed as m, createBlock as h, createCommentVNode as g, createElementBlock as _, createElementVNode as v, createTextVNode as y, createVNode as b, defineComponent as x, normalizeClass as S, openBlock as C, reactive as te, ref as w, renderSlot as T, toDisplayString as E, unref as D, useTemplateRef as O, vModelText as k, watch as A, watchPostEffect as ne, withCtx as j, withDirectives as re, withModifiers as M } from "vue";
|
|
21
23
|
//#region src/components/PlDropdown/PlDropdown.vue?vue&type=script&setup=true&lang.ts
|
|
22
24
|
var ie = ["tabindex"], ae = { class: "pl-dropdown__container" }, oe = ["title"], se = ["disabled", "placeholder"], ce = {
|
|
23
25
|
key: 0,
|
|
@@ -30,15 +32,15 @@ var ie = ["tabindex"], ae = { class: "pl-dropdown__container" }, oe = ["title"],
|
|
|
30
32
|
key: 0,
|
|
31
33
|
class: "pl-dropdown__error",
|
|
32
34
|
"data-testid": "pl-dropdown-error"
|
|
33
|
-
},
|
|
35
|
+
}, fe = {
|
|
34
36
|
key: 1,
|
|
35
37
|
class: "pl-dropdown__helper",
|
|
36
38
|
"data-testid": "pl-dropdown-helper"
|
|
37
|
-
},
|
|
39
|
+
}, pe = {
|
|
38
40
|
key: 2,
|
|
39
41
|
class: "pl-dropdown__helper",
|
|
40
42
|
"data-testid": "pl-dropdown-helper"
|
|
41
|
-
},
|
|
43
|
+
}, N = /* @__PURE__ */ x({
|
|
42
44
|
name: "PlDropdown",
|
|
43
45
|
props: {
|
|
44
46
|
modelValue: {},
|
|
@@ -68,37 +70,41 @@ var ie = ["tabindex"], ae = { class: "pl-dropdown__container" }, oe = ["title"],
|
|
|
68
70
|
groupPosition: { default: void 0 }
|
|
69
71
|
},
|
|
70
72
|
emits: ["update:modelValue"],
|
|
71
|
-
setup(
|
|
72
|
-
let
|
|
73
|
+
setup(x, { emit: N }) {
|
|
74
|
+
let P = N, F = x, I = w(), L = w(), R = O("optionListRef"), z = te({
|
|
73
75
|
search: "",
|
|
74
76
|
activeIndex: -1,
|
|
75
77
|
open: !1,
|
|
76
78
|
optionsHeight: 0
|
|
77
|
-
}),
|
|
78
|
-
if (!
|
|
79
|
-
}),
|
|
79
|
+
}), B = () => r(Z.value.findIndex((e) => d(e.value, F.modelValue)), (e) => e < 0 ? 0 : e), me = () => z.activeIndex = B(), V = m(() => F.options === void 0), H = m(() => !F.disabled && V.value), U = m(() => V.value ? !0 : F.disabled), W = m(() => (F.options ?? []).findIndex((e) => d(e.value, F.modelValue))), G = m(() => F.modelValue !== void 0 && F.modelValue !== null), K = m(() => G.value && W.value === -1 && !V.value), q = m(() => {
|
|
80
|
+
if (!V.value && F.error) return o(F.error);
|
|
81
|
+
}), J = m(() => n(F.options ?? []).map((e, t) => ({
|
|
80
82
|
...e,
|
|
81
83
|
index: t,
|
|
82
|
-
isSelected: t ===
|
|
83
|
-
isActive: t ===
|
|
84
|
-
}))),
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
isSelected: t === W.value,
|
|
85
|
+
isActive: t === z.activeIndex
|
|
86
|
+
}))), Y = m(() => D(J).find((e) => d(e.value, F.modelValue))), X = m(() => Y.value?.label), he = m(() => {
|
|
87
|
+
if (z.open) return;
|
|
88
|
+
if (K.value) return F.missingValueLabel;
|
|
89
|
+
if (X.value === void 0) return;
|
|
90
|
+
let e = Y.value?.linkHint;
|
|
91
|
+
return e ? `${X.value}\n${e}` : String(X.value);
|
|
92
|
+
}), ge = m(() => !z.open && G.value ? "" : X.value ? String(X.value) : F.placeholder), { orderedRef: Z, groupsRef: _e, restRef: ve } = p(m(() => {
|
|
93
|
+
let e = J.value;
|
|
94
|
+
return z.search ? e.filter((e) => {
|
|
95
|
+
let t = z.search.toLowerCase();
|
|
96
|
+
return e.label.toLowerCase().includes(t) || e.description && e.description.toLowerCase().includes(t) ? !0 : typeof e.value == "string" ? e.value.toLowerCase().includes(t) : e.value === z.search;
|
|
91
97
|
}) : e;
|
|
92
|
-
}), "group"),
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
},
|
|
98
|
+
}), "group"), ye = m(() => U.value ? void 0 : "0"), Q = (e) => {
|
|
99
|
+
P("update:modelValue", e), z.search = "", z.open = !1, I?.value?.focus();
|
|
100
|
+
}, be = (e) => {
|
|
101
|
+
Q(e);
|
|
102
|
+
}, $ = () => P("update:modelValue", void 0), xe = () => L.value?.focus(), Se = () => {
|
|
103
|
+
z.open = !z.open, z.open || (z.search = "");
|
|
104
|
+
}, Ce = () => z.open = !0, we = (e) => {
|
|
99
105
|
let t = e.relatedTarget;
|
|
100
|
-
!
|
|
101
|
-
},
|
|
106
|
+
!I.value?.contains(t) && !R.value?.listRef?.contains(t) && (z.search = "", z.open = !1);
|
|
107
|
+
}, Te = (e) => {
|
|
102
108
|
if ([
|
|
103
109
|
"ArrowDown",
|
|
104
110
|
"ArrowUp",
|
|
@@ -106,138 +112,144 @@ var ie = ["tabindex"], ae = { class: "pl-dropdown__container" }, oe = ["title"],
|
|
|
106
112
|
"Escape"
|
|
107
113
|
].includes(e.code)) e.preventDefault();
|
|
108
114
|
else return;
|
|
109
|
-
let { open: t, activeIndex: n } =
|
|
115
|
+
let { open: t, activeIndex: n } = z;
|
|
110
116
|
if (!t) {
|
|
111
|
-
e.code === "Enter" && (
|
|
117
|
+
e.code === "Enter" && (z.open = !0);
|
|
112
118
|
return;
|
|
113
119
|
}
|
|
114
|
-
e.code === "Escape" && (
|
|
115
|
-
let r =
|
|
120
|
+
e.code === "Escape" && (z.open = !1, I.value?.focus());
|
|
121
|
+
let r = Z.value, { length: i } = r;
|
|
116
122
|
if (!i) return;
|
|
117
|
-
e.code === "Enter" &&
|
|
123
|
+
e.code === "Enter" && Q(r.find((e) => e.index === n)?.value);
|
|
118
124
|
let a = r.findIndex((e) => e.index === n) ?? -1, o = e.code === "ArrowDown" ? 1 : e.code === "ArrowUp" ? -1 : 0;
|
|
119
|
-
|
|
125
|
+
z.activeIndex = r[Math.abs(a + o + i) % i].index ?? -1;
|
|
120
126
|
};
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
}), (
|
|
127
|
+
return u(I), A(() => F.modelValue, me, { immediate: !0 }), A(() => z.open, (e) => e ? L.value?.focus() : ""), ne(() => {
|
|
128
|
+
z.search, z.activeIndex >= 0 && z.open && R.value?.scrollIntoActive();
|
|
129
|
+
}), (n, r) => (C(), _("div", {
|
|
124
130
|
class: "pl-dropdown__envelope",
|
|
125
|
-
onClick:
|
|
131
|
+
onClick: xe,
|
|
126
132
|
"data-testid": "pl-dropdown"
|
|
127
|
-
}, [
|
|
133
|
+
}, [v("div", {
|
|
128
134
|
ref_key: "rootRef",
|
|
129
|
-
ref:
|
|
130
|
-
tabindex:
|
|
131
|
-
class:
|
|
132
|
-
open:
|
|
133
|
-
error:
|
|
134
|
-
disabled:
|
|
135
|
+
ref: I,
|
|
136
|
+
tabindex: ye.value,
|
|
137
|
+
class: S(["pl-dropdown", {
|
|
138
|
+
open: z.open,
|
|
139
|
+
error: x.error || x.errorStatus,
|
|
140
|
+
disabled: U.value
|
|
135
141
|
}]),
|
|
136
142
|
"data-testid": "pl-dropdown-control",
|
|
137
|
-
onKeydown:
|
|
138
|
-
onFocusout:
|
|
139
|
-
}, [
|
|
140
|
-
|
|
143
|
+
onKeydown: Te,
|
|
144
|
+
onFocusout: we
|
|
145
|
+
}, [v("div", ae, [
|
|
146
|
+
v("div", {
|
|
141
147
|
class: "pl-dropdown__field",
|
|
142
|
-
title:
|
|
148
|
+
title: he.value
|
|
143
149
|
}, [
|
|
144
|
-
|
|
150
|
+
re(v("input", {
|
|
145
151
|
ref_key: "input",
|
|
146
|
-
ref:
|
|
147
|
-
"onUpdate:modelValue":
|
|
152
|
+
ref: L,
|
|
153
|
+
"onUpdate:modelValue": r[0] ||= (e) => z.search = e,
|
|
148
154
|
type: "text",
|
|
149
155
|
tabindex: "-1",
|
|
150
|
-
disabled:
|
|
151
|
-
placeholder:
|
|
156
|
+
disabled: U.value,
|
|
157
|
+
placeholder: ge.value,
|
|
152
158
|
spellcheck: "false",
|
|
153
159
|
autocomplete: "chrome-off",
|
|
154
160
|
"data-testid": "pl-dropdown-input",
|
|
155
|
-
onFocus:
|
|
156
|
-
}, null, 40, se), [[
|
|
157
|
-
|
|
161
|
+
onFocus: Ce
|
|
162
|
+
}, null, 40, se), [[k, z.search]]),
|
|
163
|
+
z.open ? g("", !0) : (C(), _("div", ce, [K.value ? (C(), h(s, {
|
|
158
164
|
key: 0,
|
|
159
165
|
class: "input-value--missing",
|
|
160
166
|
"data-testid": "pl-dropdown-value-missing"
|
|
161
167
|
}, {
|
|
162
|
-
default:
|
|
168
|
+
default: j(() => [y(E(x.missingValueLabel), 1)]),
|
|
163
169
|
_: 1
|
|
164
|
-
})) :
|
|
165
|
-
|
|
170
|
+
})) : X.value === void 0 ? g("", !0) : (C(), h(D(a), {
|
|
171
|
+
key: 1,
|
|
172
|
+
option: Y.value
|
|
173
|
+
}, {
|
|
174
|
+
default: j(() => [b(s, null, {
|
|
175
|
+
default: j(() => [y(E(X.value), 1)]),
|
|
176
|
+
_: 1
|
|
177
|
+
})]),
|
|
166
178
|
_: 1
|
|
167
|
-
}))])),
|
|
168
|
-
|
|
169
|
-
|
|
179
|
+
}, 8, ["option"]))])),
|
|
180
|
+
v("div", le, [
|
|
181
|
+
H.value ? (C(), h(D(c), {
|
|
170
182
|
key: 0,
|
|
171
183
|
name: "loading",
|
|
172
184
|
"data-testid": "pl-dropdown-loading"
|
|
173
|
-
})) :
|
|
174
|
-
|
|
185
|
+
})) : g("", !0),
|
|
186
|
+
x.clearable && G.value ? (C(), h(D(t), {
|
|
175
187
|
key: 1,
|
|
176
188
|
class: "clear",
|
|
177
189
|
"data-testid": "pl-dropdown-clear",
|
|
178
190
|
name: "delete-clear",
|
|
179
|
-
onClick:
|
|
180
|
-
})) :
|
|
181
|
-
|
|
182
|
-
|
|
191
|
+
onClick: M($, ["stop"])
|
|
192
|
+
})) : g("", !0),
|
|
193
|
+
T(n.$slots, "append"),
|
|
194
|
+
v("div", {
|
|
183
195
|
class: "pl-dropdown__arrow-wrapper",
|
|
184
196
|
"data-testid": "pl-dropdown-arrow",
|
|
185
|
-
onClick:
|
|
186
|
-
}, [
|
|
197
|
+
onClick: M(Se, ["stop"])
|
|
198
|
+
}, [x.arrowIconLarge ? (C(), h(D(c), {
|
|
187
199
|
key: 0,
|
|
188
|
-
name:
|
|
200
|
+
name: x.arrowIconLarge,
|
|
189
201
|
class: "arrow-icon"
|
|
190
|
-
}, null, 8, ["name"])) :
|
|
202
|
+
}, null, 8, ["name"])) : x.arrowIcon ? (C(), h(D(t), {
|
|
191
203
|
key: 1,
|
|
192
|
-
name:
|
|
204
|
+
name: x.arrowIcon,
|
|
193
205
|
class: "arrow-icon"
|
|
194
|
-
}, null, 8, ["name"])) : (
|
|
206
|
+
}, null, 8, ["name"])) : (C(), h(D(t), {
|
|
195
207
|
key: 2,
|
|
196
208
|
name: "chevron-down",
|
|
197
209
|
class: "arrow-icon arrow-icon-default"
|
|
198
210
|
}))])
|
|
199
211
|
])
|
|
200
212
|
], 8, oe),
|
|
201
|
-
|
|
202
|
-
|
|
213
|
+
x.label ? (C(), _("label", ue, [
|
|
214
|
+
x.required ? (C(), h(D(e), {
|
|
203
215
|
key: 0,
|
|
204
|
-
uri:
|
|
216
|
+
uri: D(f),
|
|
205
217
|
"data-testid": "pl-dropdown-required"
|
|
206
|
-
}, null, 8, ["uri"])) :
|
|
207
|
-
|
|
208
|
-
|
|
218
|
+
}, null, 8, ["uri"])) : g("", !0),
|
|
219
|
+
v("span", null, E(x.label), 1),
|
|
220
|
+
n.$slots.tooltip ? (C(), h(D(i), {
|
|
209
221
|
key: 1,
|
|
210
222
|
class: "info",
|
|
211
223
|
position: "top",
|
|
212
224
|
"data-testid": "pl-dropdown-tooltip"
|
|
213
225
|
}, {
|
|
214
|
-
tooltip:
|
|
226
|
+
tooltip: j(() => [T(n.$slots, "tooltip")]),
|
|
215
227
|
_: 3
|
|
216
|
-
})) :
|
|
217
|
-
])) :
|
|
218
|
-
|
|
228
|
+
})) : g("", !0)
|
|
229
|
+
])) : g("", !0),
|
|
230
|
+
z.open ? (C(), h(ee, {
|
|
219
231
|
key: 1,
|
|
220
232
|
ref_key: "optionListRef",
|
|
221
|
-
ref:
|
|
222
|
-
"root-ref":
|
|
223
|
-
groups:
|
|
224
|
-
rest:
|
|
225
|
-
"option-size":
|
|
226
|
-
"select-option":
|
|
233
|
+
ref: R,
|
|
234
|
+
"root-ref": I.value,
|
|
235
|
+
groups: D(_e),
|
|
236
|
+
rest: D(ve),
|
|
237
|
+
"option-size": x.optionSize,
|
|
238
|
+
"select-option": be
|
|
227
239
|
}, null, 8, [
|
|
228
240
|
"root-ref",
|
|
229
241
|
"groups",
|
|
230
242
|
"rest",
|
|
231
243
|
"option-size"
|
|
232
|
-
])) :
|
|
233
|
-
|
|
244
|
+
])) : g("", !0),
|
|
245
|
+
b(l, {
|
|
234
246
|
class: "pl-dropdown__contour",
|
|
235
|
-
"group-position":
|
|
247
|
+
"group-position": x.groupPosition
|
|
236
248
|
}, null, 8, ["group-position"])
|
|
237
|
-
])], 42, ie),
|
|
249
|
+
])], 42, ie), q.value ? (C(), _("div", de, E(q.value), 1)) : H.value && x.loadingOptionsHelper ? (C(), _("div", fe, E(x.loadingOptionsHelper), 1)) : x.helper ? (C(), _("div", pe, E(x.helper), 1)) : g("", !0)]));
|
|
238
250
|
}
|
|
239
251
|
});
|
|
240
252
|
//#endregion
|
|
241
|
-
export {
|
|
253
|
+
export { N as default };
|
|
242
254
|
|
|
243
255
|
//# sourceMappingURL=PlDropdown.vue2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlDropdown.vue_vue_type_script_setup_true_lang.js","names":["$slots"],"sources":["../../../src/components/PlDropdown/PlDropdown.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * A component for selecting one value from a list of options\n */\nexport default {\n name: \"PlDropdown\",\n};\n</script>\n\n<script lang=\"ts\" setup generic=\"M = unknown\">\nimport { computed, reactive, ref, unref, useTemplateRef, watch, watchPostEffect } from \"vue\";\nimport SvgRequired from \"../../assets/images/required.svg?raw\";\nimport { getErrorMessage } from \"../../helpers/error.ts\";\nimport { tap } from \"../../helpers/functions\";\nimport { deepEqual } from \"../../helpers/objects\";\nimport { normalizeListOptions } from \"../../helpers/utils\";\nimport type { ListOption, ListOptionNormalized, MaskIconName16, MaskIconName24 } from \"../../types\";\nimport DoubleContour from \"../../utils/DoubleContour.vue\";\nimport { useLabelNotch } from \"../../utils/useLabelNotch\";\nimport LongText from \"../LongText.vue\";\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { PlSvg } from \"../PlSvg\";\nimport { PlTooltip } from \"../PlTooltip\";\nimport OptionList from \"./OptionList.vue\";\nimport \"./pl-dropdown.scss\";\nimport type { LOption } from \"./types\";\nimport { useGroupBy } from \"./useGroupBy\";\n\nconst emit = defineEmits<{\n /**\n * Emitted when the model value is updated.\n */\n (e: \"update:modelValue\", value: M | undefined): void;\n}>();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current selected value of the dropdown.\n */\n modelValue: M;\n /**\n * The label text for the dropdown field (optional)\n */\n label?: string;\n /**\n * List of available options for the dropdown\n */\n options?: Readonly<ListOption<M>[]>;\n /**\n * A helper text displayed below the dropdown when there are no errors (optional).\n */\n helper?: string;\n /**\n * A helper text displayed below the dropdown when there are no options yet or options is undefined (optional).\n */\n loadingOptionsHelper?: string;\n /**\n * Error message displayed below the dropdown (optional)\n */\n error?: unknown;\n /**\n * Shows red border even without an error message\n */\n errorStatus?: boolean;\n /**\n * Placeholder text shown when no value is selected.\n */\n placeholder?: string;\n /**\n * Text shown in the field when `modelValue` has no matching option — e.g. its\n * upstream block was deleted. Rendered italic in error color.\n */\n missingValueLabel?: string;\n /**\n * Enables a button to clear the selected value (default: false)\n */\n clearable?: boolean;\n /**\n * If `true`, the dropdown component is marked as required.\n */\n required?: boolean;\n /**\n * If `true`, the dropdown component is disabled and cannot be interacted with.\n */\n disabled?: boolean;\n /**\n * Custom icon (16px) class for the dropdown arrow (optional)\n */\n arrowIcon?: MaskIconName16;\n /**\n * Custom icon (24px) class for the dropdown arrow (optional)\n */\n arrowIconLarge?: MaskIconName24;\n /**\n * Option list item size\n */\n optionSize?: \"small\" | \"medium\";\n /**\n * Makes some of corners not rounded\n * */\n groupPosition?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"middle\";\n }>(),\n {\n label: \"\",\n helper: undefined,\n loadingOptionsHelper: undefined,\n error: undefined,\n showErrorMessage: true,\n placeholder: \"...\",\n missingValueLabel: \"Value not available\",\n clearable: false,\n required: false,\n disabled: false,\n arrowIcon: undefined,\n arrowIconLarge: undefined,\n optionSize: \"small\",\n options: undefined,\n groupPosition: undefined,\n },\n);\n\nconst rootRef = ref<HTMLElement | undefined>();\nconst input = ref<HTMLInputElement | undefined>();\n\nconst optionListRef = useTemplateRef<InstanceType<typeof OptionList>>(\"optionListRef\");\n\nconst data = reactive({\n search: \"\",\n activeIndex: -1,\n open: false,\n optionsHeight: 0,\n});\n\nconst findActiveIndex = () =>\n tap(\n orderedRef.value.findIndex((o) => deepEqual(o.value, props.modelValue)),\n (v) => (v < 0 ? 0 : v),\n );\n\nconst updateActive = () => (data.activeIndex = findActiveIndex());\n\nconst isLoadingOptions = computed(() => {\n return props.options === undefined;\n});\n\n/**\n * Loading spinner should not be shown when the dropdown is explicitly disabled,\n * even if options are undefined. The disabled state takes precedence.\n */\nconst showLoadingSpinner = computed(() => {\n return !props.disabled && isLoadingOptions.value;\n});\n\nconst isDisabled = computed(() => {\n if (isLoadingOptions.value) {\n return true;\n }\n\n return props.disabled;\n});\n\nconst selectedIndex = computed(() => {\n return (props.options ?? []).findIndex((o) => deepEqual(o.value, props.modelValue));\n});\n\nconst hasValue = computed(() => {\n return props.modelValue !== undefined && props.modelValue !== null;\n});\n\nconst isMissing = computed(() => {\n return hasValue.value && selectedIndex.value === -1 && !isLoadingOptions.value;\n});\n\nconst computedError = computed(() => {\n if (isLoadingOptions.value) {\n return undefined;\n }\n\n if (props.error) {\n return getErrorMessage(props.error);\n }\n\n // The field renders the missing state via `missingValueLabel`; no need to\n // duplicate it as a helper error.\n return undefined;\n});\n\nconst optionsRef = computed<LOption<M>[]>(() =>\n normalizeListOptions(props.options ?? []).map((opt, index) => ({\n ...opt,\n index,\n isSelected: index === selectedIndex.value,\n isActive: index === data.activeIndex,\n })),\n);\n\nconst textValue = computed(() => {\n const options = unref(optionsRef);\n const item: ListOption | undefined = options.find((o) => deepEqual(o.value, props.modelValue));\n return item?.label;\n});\n\n// Native tooltip with the full selected value. The `.input-value` layer has\n// `pointer-events: none`, so the title must sit on the field wrapper, which is\n// what actually receives the hover.\nconst fieldTitle = computed(() => {\n if (data.open) return undefined;\n if (isMissing.value) return props.missingValueLabel;\n return textValue.value !== undefined ? String(textValue.value) : undefined;\n});\n\nconst computedPlaceholder = computed(() => {\n if (!data.open && hasValue.value) {\n return \"\";\n }\n\n return textValue.value ? String(textValue.value) : props.placeholder;\n});\n\nconst filteredRef = computed(() => {\n const options = optionsRef.value;\n\n if (data.search) {\n return options.filter((o: ListOptionNormalized) => {\n const search = data.search.toLowerCase();\n\n if (o.label.toLowerCase().includes(search)) {\n return true;\n }\n\n if (o.description && o.description.toLowerCase().includes(search)) {\n return true;\n }\n\n if (typeof o.value === \"string\") {\n return o.value.toLowerCase().includes(search);\n }\n\n return o.value === data.search;\n });\n }\n\n return options;\n});\n\nconst { orderedRef, groupsRef, restRef } = useGroupBy(filteredRef, \"group\");\n\nconst tabindex = computed(() => (isDisabled.value ? undefined : \"0\"));\n\nconst selectOption = (v: M | undefined) => {\n emit(\"update:modelValue\", v);\n data.search = \"\";\n data.open = false;\n rootRef?.value?.focus();\n};\n\nconst selectOptionWrapper = (v: unknown) => {\n selectOption(v as M | undefined);\n};\n\nconst clear = () => emit(\"update:modelValue\", undefined);\n\nconst setFocusOnInput = () => input.value?.focus();\n\nconst toggleOpen = () => {\n data.open = !data.open;\n if (!data.open) {\n data.search = \"\";\n }\n};\n\nconst onInputFocus = () => (data.open = true);\n\nconst onFocusOut = (event: FocusEvent) => {\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (\n !rootRef.value?.contains(relatedTarget) &&\n !optionListRef.value?.listRef?.contains(relatedTarget)\n ) {\n data.search = \"\";\n data.open = false;\n }\n};\n\nconst handleKeydown = (e: { code: string; preventDefault(): void }) => {\n if (![\"ArrowDown\", \"ArrowUp\", \"Enter\", \"Escape\"].includes(e.code)) {\n return;\n } else {\n e.preventDefault();\n }\n\n const { open, activeIndex } = data;\n\n if (!open) {\n if (e.code === \"Enter\") {\n data.open = true;\n }\n return;\n }\n\n if (e.code === \"Escape\") {\n data.open = false;\n rootRef.value?.focus();\n }\n\n const ordered = orderedRef.value;\n\n const { length } = ordered;\n\n if (!length) {\n return;\n }\n\n if (e.code === \"Enter\") {\n selectOption(ordered.find((it) => it.index === activeIndex)?.value);\n }\n\n const localIndex = ordered.findIndex((it) => it.index === activeIndex) ?? -1;\n\n const delta = e.code === \"ArrowDown\" ? 1 : e.code === \"ArrowUp\" ? -1 : 0;\n\n const newIndex = Math.abs(localIndex + delta + length) % length;\n\n data.activeIndex = ordered[newIndex].index ?? -1;\n};\n\nuseLabelNotch(rootRef);\n\nwatch(() => props.modelValue, updateActive, { immediate: true });\n\nwatch(\n () => data.open,\n (open) => (open ? input.value?.focus() : \"\"),\n);\n\nwatchPostEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n data.search; // to watch\n\n if (data.activeIndex >= 0 && data.open) {\n optionListRef.value?.scrollIntoActive();\n }\n});\n</script>\n\n<template>\n <div class=\"pl-dropdown__envelope\" @click=\"setFocusOnInput\" data-testid=\"pl-dropdown\">\n <div\n ref=\"rootRef\"\n :tabindex=\"tabindex\"\n class=\"pl-dropdown\"\n data-testid=\"pl-dropdown-control\"\n :class=\"{ open: data.open, error: error || errorStatus, disabled: isDisabled }\"\n @keydown=\"handleKeydown\"\n @focusout=\"onFocusOut\"\n >\n <div class=\"pl-dropdown__container\">\n <div class=\"pl-dropdown__field\" :title=\"fieldTitle\">\n <input\n ref=\"input\"\n v-model=\"data.search\"\n type=\"text\"\n tabindex=\"-1\"\n :disabled=\"isDisabled\"\n :placeholder=\"computedPlaceholder\"\n spellcheck=\"false\"\n autocomplete=\"chrome-off\"\n data-testid=\"pl-dropdown-input\"\n @focus=\"onInputFocus\"\n />\n\n <div v-if=\"!data.open\" class=\"input-value\" data-testid=\"pl-dropdown-value\">\n <LongText\n v-if=\"isMissing\"\n class=\"input-value--missing\"\n data-testid=\"pl-dropdown-value-missing\"\n >\n {{ missingValueLabel }}\n </LongText>\n <LongText v-else-if=\"textValue !== undefined\">\n {{ textValue }}\n </LongText>\n </div>\n\n <div class=\"pl-dropdown__controls\">\n <PlIcon24 v-if=\"showLoadingSpinner\" name=\"loading\" data-testid=\"pl-dropdown-loading\" />\n <PlIcon16\n v-if=\"clearable && hasValue\"\n class=\"clear\"\n data-testid=\"pl-dropdown-clear\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n <slot name=\"append\" />\n <div\n class=\"pl-dropdown__arrow-wrapper\"\n data-testid=\"pl-dropdown-arrow\"\n @click.stop=\"toggleOpen\"\n >\n <PlIcon24 v-if=\"arrowIconLarge\" :name=\"arrowIconLarge\" class=\"arrow-icon\" />\n <PlIcon16 v-else-if=\"arrowIcon\" :name=\"arrowIcon\" class=\"arrow-icon\" />\n <PlIcon16 v-else name=\"chevron-down\" class=\"arrow-icon arrow-icon-default\" />\n </div>\n </div>\n </div>\n <label v-if=\"label\" data-testid=\"pl-dropdown-label\">\n <PlSvg v-if=\"required\" :uri=\"SvgRequired\" data-testid=\"pl-dropdown-required\" />\n <span>{{ label }}</span>\n <PlTooltip\n v-if=\"$slots.tooltip\"\n class=\"info\"\n position=\"top\"\n data-testid=\"pl-dropdown-tooltip\"\n >\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <OptionList\n v-if=\"data.open\"\n ref=\"optionListRef\"\n :root-ref=\"rootRef!\"\n :groups=\"groupsRef\"\n :rest=\"restRef\"\n :option-size=\"optionSize\"\n :select-option=\"selectOptionWrapper\"\n />\n <DoubleContour class=\"pl-dropdown__contour\" :group-position=\"groupPosition\" />\n </div>\n </div>\n <div v-if=\"computedError\" class=\"pl-dropdown__error\" data-testid=\"pl-dropdown-error\">\n {{ computedError }}\n </div>\n <div\n v-else-if=\"showLoadingSpinner && loadingOptionsHelper\"\n class=\"pl-dropdown__helper\"\n data-testid=\"pl-dropdown-helper\"\n >\n {{ loadingOptionsHelper }}\n </div>\n <div v-else-if=\"helper\" class=\"pl-dropdown__helper\" data-testid=\"pl-dropdown-helper\">\n {{ helper }}\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBR,IAAM,IAAO,GAOP,IAAQ,GAgGR,IAAU,GAA8B,EACxC,IAAQ,GAAmC,EAE3C,IAAgB,GAAgD,gBAAgB,EAEhF,IAAO,GAAS;GACpB,QAAQ;GACR,aAAa;GACb,MAAM;GACN,eAAe;GAChB,CAAC,EAEI,UACJ,EACE,EAAW,MAAM,WAAW,MAAM,EAAU,EAAE,OAAO,EAAM,WAAW,CAAC,GACtE,MAAO,IAAI,IAAI,IAAI,EACrB,EAEG,UAAsB,EAAK,cAAc,GAAiB,EAE1D,IAAmB,QAChB,EAAM,YAAY,KAAA,EACzB,EAMI,IAAqB,QAClB,CAAC,EAAM,YAAY,EAAiB,MAC3C,EAEI,IAAa,QACb,EAAiB,QACZ,KAGF,EAAM,SACb,EAEI,IAAgB,SACZ,EAAM,WAAW,EAAE,EAAE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down.vue_vue_type_script_setup_true_lang.js","names":["$slots"],"sources":["../../../src/components/PlDropdown/PlDropdown.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * A component for selecting one value from a list of options\n */\nexport default {\n name: \"PlDropdown\",\n};\n</script>\n\n<script lang=\"ts\" setup generic=\"M = unknown\">\nimport { computed, reactive, ref, unref, useTemplateRef, watch, watchPostEffect } from \"vue\";\nimport SvgRequired from \"../../assets/images/required.svg?raw\";\nimport { getErrorMessage } from \"../../helpers/error.ts\";\nimport { tap } from \"../../helpers/functions\";\nimport { deepEqual } from \"../../helpers/objects\";\nimport { normalizeListOptions } from \"../../helpers/utils\";\nimport type { ListOption, ListOptionNormalized, MaskIconName16, MaskIconName24 } from \"../../types\";\nimport DoubleContour from \"../../utils/DoubleContour.vue\";\nimport { useLabelNotch } from \"../../utils/useLabelNotch\";\nimport LongText from \"../LongText.vue\";\nimport { PlColumnLabel } from \"../PlColumnLabel\";\nimport { PlIcon16 } from \"../PlIcon16\";\nimport { PlIcon24 } from \"../PlIcon24\";\nimport { PlSvg } from \"../PlSvg\";\nimport { PlTooltip } from \"../PlTooltip\";\nimport OptionList from \"./OptionList.vue\";\nimport \"./pl-dropdown.scss\";\nimport type { LOption } from \"./types\";\nimport { useGroupBy } from \"./useGroupBy\";\n\nconst emit = defineEmits<{\n /**\n * Emitted when the model value is updated.\n */\n (e: \"update:modelValue\", value: M | undefined): void;\n}>();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current selected value of the dropdown.\n */\n modelValue: M;\n /**\n * The label text for the dropdown field (optional)\n */\n label?: string;\n /**\n * List of available options for the dropdown\n */\n options?: Readonly<ListOption<M>[]>;\n /**\n * A helper text displayed below the dropdown when there are no errors (optional).\n */\n helper?: string;\n /**\n * A helper text displayed below the dropdown when there are no options yet or options is undefined (optional).\n */\n loadingOptionsHelper?: string;\n /**\n * Error message displayed below the dropdown (optional)\n */\n error?: unknown;\n /**\n * Shows red border even without an error message\n */\n errorStatus?: boolean;\n /**\n * Placeholder text shown when no value is selected.\n */\n placeholder?: string;\n /**\n * Text shown in the field when `modelValue` has no matching option — e.g. its\n * upstream block was deleted. Rendered italic in error color.\n */\n missingValueLabel?: string;\n /**\n * Enables a button to clear the selected value (default: false)\n */\n clearable?: boolean;\n /**\n * If `true`, the dropdown component is marked as required.\n */\n required?: boolean;\n /**\n * If `true`, the dropdown component is disabled and cannot be interacted with.\n */\n disabled?: boolean;\n /**\n * Custom icon (16px) class for the dropdown arrow (optional)\n */\n arrowIcon?: MaskIconName16;\n /**\n * Custom icon (24px) class for the dropdown arrow (optional)\n */\n arrowIconLarge?: MaskIconName24;\n /**\n * Option list item size\n */\n optionSize?: \"small\" | \"medium\";\n /**\n * Makes some of corners not rounded\n * */\n groupPosition?:\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"middle\";\n }>(),\n {\n label: \"\",\n helper: undefined,\n loadingOptionsHelper: undefined,\n error: undefined,\n showErrorMessage: true,\n placeholder: \"...\",\n missingValueLabel: \"Value not available\",\n clearable: false,\n required: false,\n disabled: false,\n arrowIcon: undefined,\n arrowIconLarge: undefined,\n optionSize: \"small\",\n options: undefined,\n groupPosition: undefined,\n },\n);\n\nconst rootRef = ref<HTMLElement | undefined>();\nconst input = ref<HTMLInputElement | undefined>();\n\nconst optionListRef = useTemplateRef<InstanceType<typeof OptionList>>(\"optionListRef\");\n\nconst data = reactive({\n search: \"\",\n activeIndex: -1,\n open: false,\n optionsHeight: 0,\n});\n\nconst findActiveIndex = () =>\n tap(\n orderedRef.value.findIndex((o) => deepEqual(o.value, props.modelValue)),\n (v) => (v < 0 ? 0 : v),\n );\n\nconst updateActive = () => (data.activeIndex = findActiveIndex());\n\nconst isLoadingOptions = computed(() => {\n return props.options === undefined;\n});\n\n/**\n * Loading spinner should not be shown when the dropdown is explicitly disabled,\n * even if options are undefined. The disabled state takes precedence.\n */\nconst showLoadingSpinner = computed(() => {\n return !props.disabled && isLoadingOptions.value;\n});\n\nconst isDisabled = computed(() => {\n if (isLoadingOptions.value) {\n return true;\n }\n\n return props.disabled;\n});\n\nconst selectedIndex = computed(() => {\n return (props.options ?? []).findIndex((o) => deepEqual(o.value, props.modelValue));\n});\n\nconst hasValue = computed(() => {\n return props.modelValue !== undefined && props.modelValue !== null;\n});\n\nconst isMissing = computed(() => {\n return hasValue.value && selectedIndex.value === -1 && !isLoadingOptions.value;\n});\n\nconst computedError = computed(() => {\n if (isLoadingOptions.value) {\n return undefined;\n }\n\n if (props.error) {\n return getErrorMessage(props.error);\n }\n\n // The field renders the missing state via `missingValueLabel`; no need to\n // duplicate it as a helper error.\n return undefined;\n});\n\nconst optionsRef = computed<LOption<M>[]>(() =>\n normalizeListOptions(props.options ?? []).map((opt, index) => ({\n ...opt,\n index,\n isSelected: index === selectedIndex.value,\n isActive: index === data.activeIndex,\n })),\n);\n\nconst selectedOption = computed(() =>\n unref(optionsRef).find((o) => deepEqual(o.value, props.modelValue)),\n);\n\nconst textValue = computed(() => selectedOption.value?.label);\n\n// Native tooltip with the full selected value and its link hint. The `.input-value` layer has\n// `pointer-events: none`, so the title must sit on the field wrapper, which is\n// what actually receives the hover.\nconst fieldTitle = computed(() => {\n if (data.open) return undefined;\n if (isMissing.value) return props.missingValueLabel;\n if (textValue.value === undefined) return undefined;\n const hint = selectedOption.value?.linkHint;\n return hint ? `${textValue.value}\\n${hint}` : String(textValue.value);\n});\n\nconst computedPlaceholder = computed(() => {\n if (!data.open && hasValue.value) {\n return \"\";\n }\n\n return textValue.value ? String(textValue.value) : props.placeholder;\n});\n\nconst filteredRef = computed(() => {\n const options = optionsRef.value;\n\n if (data.search) {\n return options.filter((o: ListOptionNormalized) => {\n const search = data.search.toLowerCase();\n\n if (o.label.toLowerCase().includes(search)) {\n return true;\n }\n\n if (o.description && o.description.toLowerCase().includes(search)) {\n return true;\n }\n\n if (typeof o.value === \"string\") {\n return o.value.toLowerCase().includes(search);\n }\n\n return o.value === data.search;\n });\n }\n\n return options;\n});\n\nconst { orderedRef, groupsRef, restRef } = useGroupBy(filteredRef, \"group\");\n\nconst tabindex = computed(() => (isDisabled.value ? undefined : \"0\"));\n\nconst selectOption = (v: M | undefined) => {\n emit(\"update:modelValue\", v);\n data.search = \"\";\n data.open = false;\n rootRef?.value?.focus();\n};\n\nconst selectOptionWrapper = (v: unknown) => {\n selectOption(v as M | undefined);\n};\n\nconst clear = () => emit(\"update:modelValue\", undefined);\n\nconst setFocusOnInput = () => input.value?.focus();\n\nconst toggleOpen = () => {\n data.open = !data.open;\n if (!data.open) {\n data.search = \"\";\n }\n};\n\nconst onInputFocus = () => (data.open = true);\n\nconst onFocusOut = (event: FocusEvent) => {\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (\n !rootRef.value?.contains(relatedTarget) &&\n !optionListRef.value?.listRef?.contains(relatedTarget)\n ) {\n data.search = \"\";\n data.open = false;\n }\n};\n\nconst handleKeydown = (e: { code: string; preventDefault(): void }) => {\n if (![\"ArrowDown\", \"ArrowUp\", \"Enter\", \"Escape\"].includes(e.code)) {\n return;\n } else {\n e.preventDefault();\n }\n\n const { open, activeIndex } = data;\n\n if (!open) {\n if (e.code === \"Enter\") {\n data.open = true;\n }\n return;\n }\n\n if (e.code === \"Escape\") {\n data.open = false;\n rootRef.value?.focus();\n }\n\n const ordered = orderedRef.value;\n\n const { length } = ordered;\n\n if (!length) {\n return;\n }\n\n if (e.code === \"Enter\") {\n selectOption(ordered.find((it) => it.index === activeIndex)?.value);\n }\n\n const localIndex = ordered.findIndex((it) => it.index === activeIndex) ?? -1;\n\n const delta = e.code === \"ArrowDown\" ? 1 : e.code === \"ArrowUp\" ? -1 : 0;\n\n const newIndex = Math.abs(localIndex + delta + length) % length;\n\n data.activeIndex = ordered[newIndex].index ?? -1;\n};\n\nuseLabelNotch(rootRef);\n\nwatch(() => props.modelValue, updateActive, { immediate: true });\n\nwatch(\n () => data.open,\n (open) => (open ? input.value?.focus() : \"\"),\n);\n\nwatchPostEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n data.search; // to watch\n\n if (data.activeIndex >= 0 && data.open) {\n optionListRef.value?.scrollIntoActive();\n }\n});\n</script>\n\n<template>\n <div class=\"pl-dropdown__envelope\" @click=\"setFocusOnInput\" data-testid=\"pl-dropdown\">\n <div\n ref=\"rootRef\"\n :tabindex=\"tabindex\"\n class=\"pl-dropdown\"\n data-testid=\"pl-dropdown-control\"\n :class=\"{ open: data.open, error: error || errorStatus, disabled: isDisabled }\"\n @keydown=\"handleKeydown\"\n @focusout=\"onFocusOut\"\n >\n <div class=\"pl-dropdown__container\">\n <div class=\"pl-dropdown__field\" :title=\"fieldTitle\">\n <input\n ref=\"input\"\n v-model=\"data.search\"\n type=\"text\"\n tabindex=\"-1\"\n :disabled=\"isDisabled\"\n :placeholder=\"computedPlaceholder\"\n spellcheck=\"false\"\n autocomplete=\"chrome-off\"\n data-testid=\"pl-dropdown-input\"\n @focus=\"onInputFocus\"\n />\n\n <div v-if=\"!data.open\" class=\"input-value\" data-testid=\"pl-dropdown-value\">\n <LongText\n v-if=\"isMissing\"\n class=\"input-value--missing\"\n data-testid=\"pl-dropdown-value-missing\"\n >\n {{ missingValueLabel }}\n </LongText>\n <PlColumnLabel v-else-if=\"textValue !== undefined\" :option=\"selectedOption\">\n <LongText>{{ textValue }}</LongText>\n </PlColumnLabel>\n </div>\n\n <div class=\"pl-dropdown__controls\">\n <PlIcon24 v-if=\"showLoadingSpinner\" name=\"loading\" data-testid=\"pl-dropdown-loading\" />\n <PlIcon16\n v-if=\"clearable && hasValue\"\n class=\"clear\"\n data-testid=\"pl-dropdown-clear\"\n name=\"delete-clear\"\n @click.stop=\"clear\"\n />\n <slot name=\"append\" />\n <div\n class=\"pl-dropdown__arrow-wrapper\"\n data-testid=\"pl-dropdown-arrow\"\n @click.stop=\"toggleOpen\"\n >\n <PlIcon24 v-if=\"arrowIconLarge\" :name=\"arrowIconLarge\" class=\"arrow-icon\" />\n <PlIcon16 v-else-if=\"arrowIcon\" :name=\"arrowIcon\" class=\"arrow-icon\" />\n <PlIcon16 v-else name=\"chevron-down\" class=\"arrow-icon arrow-icon-default\" />\n </div>\n </div>\n </div>\n <label v-if=\"label\" data-testid=\"pl-dropdown-label\">\n <PlSvg v-if=\"required\" :uri=\"SvgRequired\" data-testid=\"pl-dropdown-required\" />\n <span>{{ label }}</span>\n <PlTooltip\n v-if=\"$slots.tooltip\"\n class=\"info\"\n position=\"top\"\n data-testid=\"pl-dropdown-tooltip\"\n >\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <OptionList\n v-if=\"data.open\"\n ref=\"optionListRef\"\n :root-ref=\"rootRef!\"\n :groups=\"groupsRef\"\n :rest=\"restRef\"\n :option-size=\"optionSize\"\n :select-option=\"selectOptionWrapper\"\n />\n <DoubleContour class=\"pl-dropdown__contour\" :group-position=\"groupPosition\" />\n </div>\n </div>\n <div v-if=\"computedError\" class=\"pl-dropdown__error\" data-testid=\"pl-dropdown-error\">\n {{ computedError }}\n </div>\n <div\n v-else-if=\"showLoadingSpinner && loadingOptionsHelper\"\n class=\"pl-dropdown__helper\"\n data-testid=\"pl-dropdown-helper\"\n >\n {{ loadingOptionsHelper }}\n </div>\n <div v-else-if=\"helper\" class=\"pl-dropdown__helper\" data-testid=\"pl-dropdown-helper\">\n {{ helper }}\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBR,IAAM,IAAO,GAOP,IAAQ,GAgGR,IAAU,GAA8B,EACxC,IAAQ,GAAmC,EAE3C,IAAgB,EAAgD,gBAAgB,EAEhF,IAAO,GAAS;GACpB,QAAQ;GACR,aAAa;GACb,MAAM;GACN,eAAe;GAChB,CAAC,EAEI,UACJ,EACE,EAAW,MAAM,WAAW,MAAM,EAAU,EAAE,O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,EAAA,GAAS;IACjB,MAAM,EAAA,GAAO;IACb,eAAa,EAAA;IACb,iBAAe;;;;;;;GAElB,EAA8E,GAAA;IAA/D,OAAM;IAAwB,kBAAgB,EAAA;;gBAGtD,EAAA,SAAA,GAAA,EAAX,EAEM,OAFN,IAEM,EADD,EAAA,MAAa,EAAA,EAAA,IAGL,EAAA,SAAsB,EAAA,wBAAA,GAAA,EADnC,EAMM,OANN,IAMM,EADD,EAAA,qBAAoB,EAAA,EAAA,IAET,EAAA,UAAA,GAAA,EAAhB,EAEM,OAFN,IAEM,EADD,EAAA,OAAM,EAAA,EAAA,IAAA,EAAA,IAAA,GAAA,CAAA,CAAA"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import e from "../
|
|
2
|
-
import { tap as t, tapIf as n } from "../../helpers/functions.js";
|
|
3
|
-
import { normalizeListOptions as r } from "../../helpers/utils.js";
|
|
4
|
-
import i from "../PlTooltip/PlTooltip.js";
|
|
5
|
-
import "../PlTooltip/index.js";
|
|
6
|
-
import { getErrorMessage as a } from "../../helpers/error.js";
|
|
7
|
-
import o from "../LongText.js";
|
|
8
|
-
import { scrollIntoView as s } from "../../helpers/dom.js";
|
|
9
|
-
import ee from "../PlSvg/PlSvg.js";
|
|
1
|
+
import e from "../PlSvg/PlSvg.js";
|
|
10
2
|
import "../PlSvg/index.js";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
3
|
+
import t from "../PlIcon16/PlIcon16.js";
|
|
4
|
+
import "../PlIcon16/index.js";
|
|
5
|
+
import { normalizeListOptions as n } from "../../helpers/utils.js";
|
|
6
|
+
import { tap as r, tapIf as i } from "../../helpers/functions.js";
|
|
7
|
+
import a from "../PlTooltip/PlTooltip.js";
|
|
8
|
+
import "../PlTooltip/index.js";
|
|
9
|
+
import o from "../DropdownListItem.js";
|
|
10
|
+
import { getErrorMessage as s } from "../../helpers/error.js";
|
|
11
|
+
import ee from "../LongText.js";
|
|
12
|
+
import { scrollIntoView as te } from "../../helpers/dom.js";
|
|
13
|
+
import c from "../PlIcon24/PlIcon24.js";
|
|
13
14
|
import l from "../../utils/DoubleContour.js";
|
|
14
15
|
import { useLabelNotch as ne } from "../../utils/useLabelNotch.js";
|
|
15
16
|
import { deepEqual as u } from "../../helpers/objects.js";
|
|
16
|
-
import "../PlIcon16/index.js";
|
|
17
17
|
import "../PlMaskIcon24/index.js";
|
|
18
18
|
import re from "../../assets/images/required.js";
|
|
19
19
|
/* empty css */
|
|
@@ -73,12 +73,12 @@ var ue = {
|
|
|
73
73
|
search: "",
|
|
74
74
|
activeIndex: -1,
|
|
75
75
|
open: !1
|
|
76
|
-
}), me = () =>
|
|
76
|
+
}), me = () => r(X.value.findIndex((e) => u(e.value, R.modelValue)), (e) => e < 0 ? 0 : e), he = () => U.activeIndex = me(), W = d(() => R.options === void 0), G = d(() => W.value ? !0 : R.disabled), K = d(() => (R.options ?? []).findIndex((e) => u(e.value, R.modelValue))), q = d(() => {
|
|
77
77
|
if (!W.value) {
|
|
78
|
-
if (R.error) return
|
|
78
|
+
if (R.error) return s(R.error);
|
|
79
79
|
if (R.modelValue !== void 0 && K.value === -1) return "The selected value is not one of the options";
|
|
80
80
|
}
|
|
81
|
-
}), J = d(() =>
|
|
81
|
+
}), J = d(() => n(R.options ?? []).map((e, t) => ({
|
|
82
82
|
...e,
|
|
83
83
|
index: t,
|
|
84
84
|
isSelected: t === K.value,
|
|
@@ -99,8 +99,8 @@ var ue = {
|
|
|
99
99
|
B?.value?.contains(e.relatedTarget) || (U.search = "", U.open = !1);
|
|
100
100
|
}, Ce = () => {
|
|
101
101
|
let e = V.value;
|
|
102
|
-
e &&
|
|
103
|
-
|
|
102
|
+
e && i(e.querySelector(".hovered-item"), (t) => {
|
|
103
|
+
te(e, t);
|
|
104
104
|
});
|
|
105
105
|
}, we = (e) => {
|
|
106
106
|
if ([
|
|
@@ -124,7 +124,7 @@ var ue = {
|
|
|
124
124
|
};
|
|
125
125
|
return ne(B), E(() => R.modelValue, he, { immediate: !0 }), E(() => U.open, (e) => e ? H.value?.focus() : ""), ce(() => {
|
|
126
126
|
U.search, U.activeIndex >= 0 && U.open && Ce();
|
|
127
|
-
}), (
|
|
127
|
+
}), (n, r) => (y(), m("div", ue, [h("div", {
|
|
128
128
|
ref_key: "root",
|
|
129
129
|
ref: B,
|
|
130
130
|
tabindex: Z.value,
|
|
@@ -144,7 +144,7 @@ var ue = {
|
|
|
144
144
|
le(h("input", {
|
|
145
145
|
ref_key: "input",
|
|
146
146
|
ref: H,
|
|
147
|
-
"onUpdate:modelValue":
|
|
147
|
+
"onUpdate:modelValue": r[0] ||= (e) => U.search = e,
|
|
148
148
|
type: "text",
|
|
149
149
|
tabindex: "-1",
|
|
150
150
|
disabled: G.value,
|
|
@@ -158,24 +158,24 @@ var ue = {
|
|
|
158
158
|
key: 0,
|
|
159
159
|
"data-testid": "pl-dropdown-legacy-value",
|
|
160
160
|
onClick: be
|
|
161
|
-
}, [g(
|
|
161
|
+
}, [g(ee, { class: "input-value" }, {
|
|
162
162
|
default: D(() => [ae(w(Y.value), 1)]),
|
|
163
163
|
_: 1
|
|
164
164
|
})])),
|
|
165
165
|
h("div", A, [
|
|
166
|
-
W.value ? (y(), f(T(
|
|
166
|
+
W.value ? (y(), f(T(c), {
|
|
167
167
|
key: 0,
|
|
168
168
|
name: "loading",
|
|
169
169
|
"data-testid": "pl-dropdown-legacy-loading"
|
|
170
170
|
})) : p("", !0),
|
|
171
|
-
_.clearable && ve.value ? (y(), f(T(
|
|
171
|
+
_.clearable && ve.value ? (y(), f(T(t), {
|
|
172
172
|
key: 1,
|
|
173
173
|
class: "clear",
|
|
174
174
|
"data-testid": "pl-dropdown-legacy-clear",
|
|
175
175
|
name: "delete-clear",
|
|
176
176
|
onClick: O(ye, ["stop"])
|
|
177
177
|
})) : p("", !0),
|
|
178
|
-
C(
|
|
178
|
+
C(n.$slots, "append"),
|
|
179
179
|
_.arrowIconLarge ? (y(), m("div", {
|
|
180
180
|
key: 2,
|
|
181
181
|
class: v(["arrow-icon", [`icon-24 ${_.arrowIconLarge}`]]),
|
|
@@ -195,19 +195,19 @@ var ue = {
|
|
|
195
195
|
])
|
|
196
196
|
], 8, pe),
|
|
197
197
|
_.label ? (y(), m("label", j, [
|
|
198
|
-
_.required ? (y(), f(T(
|
|
198
|
+
_.required ? (y(), f(T(e), {
|
|
199
199
|
key: 0,
|
|
200
200
|
uri: T(re),
|
|
201
201
|
"data-testid": "pl-dropdown-legacy-required"
|
|
202
202
|
}, null, 8, ["uri"])) : p("", !0),
|
|
203
203
|
h("span", null, w(_.label), 1),
|
|
204
|
-
T(z).tooltip ? (y(), f(T(
|
|
204
|
+
T(z).tooltip ? (y(), f(T(a), {
|
|
205
205
|
key: 1,
|
|
206
206
|
class: "info",
|
|
207
207
|
position: "top",
|
|
208
208
|
"data-testid": "pl-dropdown-legacy-tooltip"
|
|
209
209
|
}, {
|
|
210
|
-
tooltip: D(() => [C(
|
|
210
|
+
tooltip: D(() => [C(n.$slots, "tooltip")]),
|
|
211
211
|
_: 3
|
|
212
212
|
})) : p("", !0)
|
|
213
213
|
])) : p("", !0),
|
|
@@ -217,14 +217,14 @@ var ue = {
|
|
|
217
217
|
ref: V,
|
|
218
218
|
class: "ui-dropdown__options",
|
|
219
219
|
"data-testid": "pl-dropdown-legacy-options"
|
|
220
|
-
}, [(y(!0), m(ie, null, S(X.value, (
|
|
221
|
-
key:
|
|
222
|
-
option:
|
|
223
|
-
"is-selected":
|
|
224
|
-
"is-hovered":
|
|
220
|
+
}, [(y(!0), m(ie, null, S(X.value, (e, t) => (y(), f(o, {
|
|
221
|
+
key: t,
|
|
222
|
+
option: e,
|
|
223
|
+
"is-selected": e.isSelected,
|
|
224
|
+
"is-hovered": e.isActive,
|
|
225
225
|
size: _.optionSize,
|
|
226
226
|
"data-testid": "pl-dropdown-legacy-option",
|
|
227
|
-
onClick: O((
|
|
227
|
+
onClick: O((t) => Q(e.value), ["stop"])
|
|
228
228
|
}, null, 8, [
|
|
229
229
|
"option",
|
|
230
230
|
"is-selected",
|