admins-components 9.0.70 → 9.0.72
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/dist/admins-components26.js +108 -97
- package/dist/admins-components26.js.map +1 -1
- package/dist/admins-components28.js.map +1 -1
- package/dist/admins-components83.js +12 -2
- package/dist/admins-components83.js.map +1 -1
- package/dist/admins-components85.js.map +1 -1
- package/dist/admins-components86.js +18 -18
- package/dist/admins-components86.js.map +1 -1
- package/dist/admins-components87.js +63 -19
- package/dist/admins-components87.js.map +1 -1
- package/dist/admins-components91.js.map +1 -1
- package/dist/admins-components93.js.map +1 -1
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/src/components/DropdownSelect.vue.d.ts +4 -4
- package/package.json +1 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import e from "./admins-components6.js";
|
|
2
2
|
import t from "./admins-components25.js";
|
|
3
|
-
import { Fragment as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createVNode as ee, defineComponent as c, nextTick as l, normalizeClass as u, onBeforeUnmount as
|
|
3
|
+
import { Fragment as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createVNode as ee, defineComponent as c, nextTick as l, normalizeClass as u, onBeforeUnmount as te, onMounted as d, openBlock as f, ref as p, renderList as m, toDisplayString as h, watch as g, withModifiers as _ } from "vue";
|
|
4
4
|
//#region src/components/DropdownSelect.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var
|
|
5
|
+
var v = { class: "ac-component" }, ne = ["aria-disabled"], re = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "c-truncate ds-value"
|
|
8
|
-
},
|
|
8
|
+
}, ie = {
|
|
9
9
|
key: 1,
|
|
10
10
|
class: "c-placeholder"
|
|
11
|
-
},
|
|
11
|
+
}, y = {
|
|
12
12
|
key: 0,
|
|
13
13
|
class: "ds-filter"
|
|
14
|
-
},
|
|
14
|
+
}, b = ["title"], x = ["value", "placeholder"], S = { class: "ds-options c-scroll" }, C = {
|
|
15
15
|
key: 0,
|
|
16
16
|
class: "ds-option ds-option--loading"
|
|
17
|
-
},
|
|
17
|
+
}, w = ["onClick", "onKeydown"], T = ["innerHTML"], E = {
|
|
18
18
|
key: 0,
|
|
19
19
|
class: "ds-option ds-option--empty"
|
|
20
|
-
},
|
|
20
|
+
}, D = {
|
|
21
21
|
key: 1,
|
|
22
22
|
class: "c-footer"
|
|
23
|
-
},
|
|
23
|
+
}, O = {
|
|
24
24
|
placeholder: "Válassz...",
|
|
25
25
|
filterable: !0,
|
|
26
26
|
filterPlaceholder: "Kezdj el gépelni...",
|
|
@@ -32,35 +32,45 @@ var y = { class: "ac-component" }, b = ["aria-disabled"], te = {
|
|
|
32
32
|
size: "normal",
|
|
33
33
|
highlight: !0,
|
|
34
34
|
disabled: !1
|
|
35
|
-
},
|
|
35
|
+
}, k = /* @__PURE__ */ c({
|
|
36
36
|
__name: "DropdownSelect",
|
|
37
37
|
props: {
|
|
38
38
|
modelValue: { default: null },
|
|
39
39
|
options: {},
|
|
40
|
-
config: { default: () => ({ ...
|
|
40
|
+
config: { default: () => ({ ...O }) }
|
|
41
41
|
},
|
|
42
42
|
emits: ["update:modelValue", "filter-input"],
|
|
43
|
-
setup(c, { expose:
|
|
44
|
-
let
|
|
45
|
-
...
|
|
46
|
-
...
|
|
47
|
-
})),
|
|
48
|
-
function
|
|
49
|
-
return e == null ? [] : Array.isArray(e) ? [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
43
|
+
setup(c, { expose: k, emit: A }) {
|
|
44
|
+
let j = c, M = r(() => ({
|
|
45
|
+
...O,
|
|
46
|
+
...j.config
|
|
47
|
+
})), N = A, P = p(!1), F = p(""), I = p(null), L = p(null), R = p([]), z = p(B(j.modelValue, j.options));
|
|
48
|
+
function B(e, t) {
|
|
49
|
+
return e == null ? [] : (Array.isArray(e) ? e : [e]).map((e) => e == null ? null : typeof e == "object" && "label" in e ? e : typeof e == "string" ? t.find((t) => t.value === e) ?? {
|
|
50
|
+
value: e,
|
|
51
|
+
label: e
|
|
52
|
+
} : null).filter((e) => e !== null);
|
|
53
|
+
}
|
|
54
|
+
g(() => [j.modelValue, j.options], ([e]) => {
|
|
55
|
+
z.value = B(e, j.options);
|
|
56
|
+
}), g(P, (e) => {
|
|
57
|
+
e && (F.value = "", M.value.filterable && l(() => L.value?.focus()), M.value.lazy && (R.value = [...z.value]));
|
|
55
58
|
});
|
|
56
|
-
function
|
|
57
|
-
|
|
59
|
+
function V(e) {
|
|
60
|
+
F.value = e, N("filter-input", e);
|
|
58
61
|
}
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
let H = r(() => {
|
|
63
|
+
if (z.value.length === 0) return null;
|
|
64
|
+
if (!M.value.multiple) {
|
|
65
|
+
let e = z.value[0];
|
|
66
|
+
return j.options.find((t) => t.value === e.value)?.label ?? e.label ?? null;
|
|
67
|
+
}
|
|
68
|
+
return z.value.length > 2 ? `${z.value.length} kiválasztva` : z.value.map((e) => j.options.find((t) => t.value === e.value)?.label ?? e.label ?? e.value).join(", ");
|
|
69
|
+
}), U = r(() => {
|
|
70
|
+
let e = F.value.toLowerCase();
|
|
71
|
+
return e ? j.options.filter((t) => t.label.toLowerCase().includes(e)) : j.options;
|
|
62
72
|
});
|
|
63
|
-
function
|
|
73
|
+
function W(e) {
|
|
64
74
|
return e.replace(/[&<>"']/g, (e) => ({
|
|
65
75
|
"&": "&",
|
|
66
76
|
"<": "<",
|
|
@@ -69,151 +79,152 @@ var y = { class: "ac-component" }, b = ["aria-disabled"], te = {
|
|
|
69
79
|
"'": "'"
|
|
70
80
|
})[e]);
|
|
71
81
|
}
|
|
72
|
-
function
|
|
73
|
-
let t =
|
|
74
|
-
if (!t || !
|
|
75
|
-
let n =
|
|
82
|
+
function G(e) {
|
|
83
|
+
let t = F.value.trim();
|
|
84
|
+
if (!t || !M.value.highlight) return W(e);
|
|
85
|
+
let n = W(e), r = W(t), i = new RegExp(r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "ig");
|
|
76
86
|
return n.replace(i, (e) => `<mark class="ds-option__highlight">${e}</mark>`);
|
|
77
87
|
}
|
|
78
|
-
let
|
|
79
|
-
if (
|
|
80
|
-
let e =
|
|
81
|
-
return
|
|
88
|
+
let K = r(() => U.value.filter((e) => e.value)), q = r(() => {
|
|
89
|
+
if (K.value.length === 0) return !1;
|
|
90
|
+
let e = M.value.lazy && P.value ? R.value : z.value;
|
|
91
|
+
return K.value.every((t) => t.value && e.some((e) => e.value === t.value));
|
|
82
92
|
});
|
|
83
|
-
function
|
|
84
|
-
return (
|
|
85
|
-
}
|
|
86
|
-
function
|
|
87
|
-
let e =
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
function J(e) {
|
|
94
|
+
return (M.value.lazy && P.value ? R : z).value.some((t) => t.value === e);
|
|
95
|
+
}
|
|
96
|
+
function Y() {
|
|
97
|
+
let e = M.value.lazy && P.value ? R : z, t = K.value.filter((e) => e.value);
|
|
98
|
+
if (q.value) {
|
|
99
|
+
let n = new Set(t.map((e) => e.value));
|
|
100
|
+
e.value = e.value.filter((e) => !n.has(e.value));
|
|
101
|
+
} else {
|
|
102
|
+
let n = new Set(e.value.map((e) => e.value)), r = t.filter((e) => !n.has(e.value));
|
|
103
|
+
e.value = [...e.value, ...r];
|
|
92
104
|
}
|
|
93
|
-
|
|
105
|
+
M.value.lazy || N("update:modelValue", z.value.length > 0 ? [...z.value] : null);
|
|
94
106
|
}
|
|
95
107
|
function X(e, t) {
|
|
96
|
-
let n = e.
|
|
108
|
+
let n = e.findIndex((e) => e.value === t.value);
|
|
97
109
|
return n >= 0 ? e.filter((e, t) => t !== n) : [...e, t];
|
|
98
110
|
}
|
|
99
111
|
function Z(e) {
|
|
100
112
|
if (e.callback) {
|
|
101
|
-
e.callback(),
|
|
113
|
+
e.callback(), P.value = !1;
|
|
102
114
|
return;
|
|
103
115
|
}
|
|
104
|
-
|
|
105
|
-
t && (N.value.multiple ? N.value.lazy ? z.value = X(z.value, t) : (B.value = X(B.value, t), P("update:modelValue", B.value.length > 0 ? [...B.value] : null)) : (B.value = [t], P("update:modelValue", t), F.value = !1));
|
|
116
|
+
e.value && (M.value.multiple ? M.value.lazy ? R.value = X(R.value, e) : (z.value = X(z.value, e), N("update:modelValue", z.value.length > 0 ? [...z.value] : null)) : (z.value = [e], N("update:modelValue", e), P.value = !1));
|
|
106
117
|
}
|
|
107
118
|
function Q() {
|
|
108
|
-
|
|
119
|
+
M.value.lazy && (z.value = [...R.value], N("update:modelValue", R.value.length > 0 ? [...R.value] : null)), P.value = !1;
|
|
109
120
|
}
|
|
110
121
|
function ae() {
|
|
111
|
-
|
|
122
|
+
M.value.lazy ? R.value = [] : (z.value = [], N("update:modelValue", null));
|
|
112
123
|
}
|
|
113
124
|
function oe(e, t) {
|
|
114
125
|
e.key === " " ? (e.preventDefault(), Z(t)) : e.key === "Enter" && (e.preventDefault(), Q());
|
|
115
126
|
}
|
|
116
127
|
function $(e) {
|
|
117
|
-
|
|
128
|
+
I.value && !I.value.contains(e.target) && (P.value = !1);
|
|
118
129
|
}
|
|
119
|
-
|
|
130
|
+
d(() => document.addEventListener("mousedown", $)), te(() => {
|
|
120
131
|
document.removeEventListener("mousedown", $);
|
|
121
132
|
});
|
|
122
133
|
function se() {
|
|
123
|
-
|
|
134
|
+
M.value.disabled || (P.value = !P.value, P.value && M.value.filterable && (F.value = "", N("filter-input", "")));
|
|
124
135
|
}
|
|
125
136
|
function ce() {
|
|
126
|
-
|
|
137
|
+
M.value.disabled || (z.value = [], N("update:modelValue", null), P.value = !1);
|
|
127
138
|
}
|
|
128
139
|
function le() {
|
|
129
|
-
|
|
140
|
+
M.value.disabled || (P.value = !0, M.value.filterable && l(() => L.value?.focus()));
|
|
130
141
|
}
|
|
131
142
|
function ue() {
|
|
132
|
-
|
|
143
|
+
F.value = "", N("filter-input", "");
|
|
133
144
|
}
|
|
134
|
-
return
|
|
145
|
+
return k({ focusAndOpen: le }), (r, c) => (f(), o("div", v, [s("div", {
|
|
135
146
|
ref_key: "wrapperRef",
|
|
136
|
-
ref:
|
|
147
|
+
ref: I,
|
|
137
148
|
class: "c-wrapper ds-wrapper"
|
|
138
149
|
}, [s("div", {
|
|
139
150
|
class: u(["c-input-row pointer", {
|
|
140
|
-
"c-input-row--sm":
|
|
141
|
-
"c-input-row--lg":
|
|
142
|
-
"c-input-row--disabled":
|
|
151
|
+
"c-input-row--sm": M.value.size === "small",
|
|
152
|
+
"c-input-row--lg": M.value.size === "large",
|
|
153
|
+
"c-input-row--disabled": M.value.disabled
|
|
143
154
|
}]),
|
|
144
|
-
"aria-disabled":
|
|
155
|
+
"aria-disabled": M.value.disabled || void 0,
|
|
145
156
|
onClick: c[1] ||= (e) => se()
|
|
146
157
|
}, [
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
H.value ? (f(), o("span", re, h(H.value), 1)) : (f(), o("span", ie, h(M.value.placeholder), 1)),
|
|
159
|
+
M.value.clearable && z.value.length > 0 ? (f(), o("button", {
|
|
149
160
|
key: 2,
|
|
150
161
|
type: "button",
|
|
151
162
|
class: "c-icon-btn c-icon-btn--clear ds-clear-btn",
|
|
152
|
-
onClick: c[0] ||=
|
|
163
|
+
onClick: c[0] ||= _((e) => ce(), ["stop"]),
|
|
153
164
|
"aria-label": "Törlés"
|
|
154
165
|
}, [...c[6] ||= [s("i", { class: "fa-solid fa-fw fa-xmark" }, null, -1)]])) : a("", !0),
|
|
155
|
-
s("span", { class: u(["c-icon-btn c-icon-btn--chevron mr-2", { "c-icon-btn--chevron-open":
|
|
156
|
-
], 10,
|
|
166
|
+
s("span", { class: u(["c-icon-btn c-icon-btn--chevron mr-2", { "c-icon-btn--chevron-open": P.value }]) }, [...c[7] ||= [s("i", { class: "fa-solid fa-fw fa-chevron-down" }, null, -1)]], 2)
|
|
167
|
+
], 10, ne), P.value ? (f(), o("div", {
|
|
157
168
|
key: 0,
|
|
158
|
-
class: u(["c-dropdown ds-dropdown ac-component", { "ds-dropdown--multiple":
|
|
169
|
+
class: u(["c-dropdown ds-dropdown ac-component", { "ds-dropdown--multiple": M.value.multiple }])
|
|
159
170
|
}, [
|
|
160
|
-
|
|
161
|
-
|
|
171
|
+
M.value.filterable ? (f(), o("div", y, [
|
|
172
|
+
M.value.multiple ? (f(), o("span", {
|
|
162
173
|
key: 0,
|
|
163
|
-
class: u(["c-checkbox ds-select-all-checkbox", { "c-checkbox--checked":
|
|
164
|
-
onClick: c[2] ||=
|
|
165
|
-
title:
|
|
166
|
-
}, null, 10,
|
|
174
|
+
class: u(["c-checkbox ds-select-all-checkbox", { "c-checkbox--checked": q.value }]),
|
|
175
|
+
onClick: c[2] ||= _((e) => Y(), ["stop"]),
|
|
176
|
+
title: q.value ? "Összes kijelölés törlése" : "Összes kijelölése"
|
|
177
|
+
}, null, 10, b)) : a("", !0),
|
|
167
178
|
s("input", {
|
|
168
179
|
ref_key: "filterInputRef",
|
|
169
|
-
ref:
|
|
180
|
+
ref: L,
|
|
170
181
|
type: "text",
|
|
171
182
|
id: "ds-filter-input",
|
|
172
183
|
class: "c-focus ds-filter-input",
|
|
173
|
-
value:
|
|
174
|
-
onInput: c[3] ||= (e) =>
|
|
184
|
+
value: F.value,
|
|
185
|
+
onInput: c[3] ||= (e) => V(e.target.value),
|
|
175
186
|
autocomplete: "off",
|
|
176
|
-
placeholder:
|
|
177
|
-
onClick: c[4] ||=
|
|
178
|
-
}, null, 40,
|
|
179
|
-
|
|
187
|
+
placeholder: M.value.filterPlaceholder,
|
|
188
|
+
onClick: c[4] ||= _(() => {}, ["stop"])
|
|
189
|
+
}, null, 40, x),
|
|
190
|
+
F.value ? (f(), o("button", {
|
|
180
191
|
key: 1,
|
|
181
192
|
type: "button",
|
|
182
193
|
class: "c-icon-btn c-icon-btn--clear ds-filter-clear",
|
|
183
|
-
onClick: c[5] ||=
|
|
194
|
+
onClick: c[5] ||= _((e) => ue(), ["stop"]),
|
|
184
195
|
"aria-label": "Szűrők törlése"
|
|
185
196
|
}, [...c[8] ||= [s("i", { class: "fa-solid fa-xmark" }, null, -1)]])) : a("", !0)
|
|
186
197
|
])) : a("", !0),
|
|
187
|
-
s("ul",
|
|
198
|
+
s("ul", S, [M.value.loading ? (f(), o("li", C, [ee(t, {
|
|
188
199
|
size: "2rem",
|
|
189
200
|
color: "var(--neutral-300)",
|
|
190
201
|
class: "m-auto p-3"
|
|
191
|
-
})])) : (
|
|
202
|
+
})])) : (f(), o(n, { key: 1 }, [(f(!0), o(n, null, m(U.value, (e, t) => (f(), o("li", {
|
|
192
203
|
key: e.value ?? `cb-${t}`,
|
|
193
|
-
class: u(["d-option ds-option", { "ds-option--selected": e.value &&
|
|
204
|
+
class: u(["d-option ds-option", { "ds-option--selected": e.value && J(e.value) }]),
|
|
194
205
|
tabindex: "0",
|
|
195
206
|
onClick: (t) => Z(e),
|
|
196
207
|
onKeydown: (t) => oe(t, e)
|
|
197
208
|
}, [
|
|
198
|
-
|
|
209
|
+
M.value.multiple && e.value ? (f(), o("span", {
|
|
199
210
|
key: 0,
|
|
200
|
-
class: u(["c-checkbox", { "c-checkbox--checked":
|
|
211
|
+
class: u(["c-checkbox", { "c-checkbox--checked": J(e.value) }])
|
|
201
212
|
}, null, 2)) : a("", !0),
|
|
202
|
-
e.icon ? (
|
|
213
|
+
e.icon ? (f(), o("i", {
|
|
203
214
|
key: 1,
|
|
204
215
|
class: u(["fa-fw", e.icon])
|
|
205
216
|
}, null, 2)) : a("", !0),
|
|
206
217
|
s("span", {
|
|
207
|
-
class: u(["d-option__label", { "c-truncate":
|
|
208
|
-
innerHTML:
|
|
209
|
-
}, null, 10,
|
|
210
|
-
], 42,
|
|
211
|
-
|
|
218
|
+
class: u(["d-option__label", { "c-truncate": M.value.textEllipsis }]),
|
|
219
|
+
innerHTML: G(e.label)
|
|
220
|
+
}, null, 10, T)
|
|
221
|
+
], 42, w))), 128)), U.value.length === 0 ? (f(), o("li", E, " Nincs találat ")) : a("", !0)], 64))]),
|
|
222
|
+
M.value.multiple || M.value.clearable && z.value.length > 0 ? (f(), o("div", D, [M.value.clearable ? (f(), i(e, {
|
|
212
223
|
key: 0,
|
|
213
224
|
label: "Törlés",
|
|
214
225
|
outline: "",
|
|
215
226
|
onClick: ae
|
|
216
|
-
})) : a("", !0),
|
|
227
|
+
})) : a("", !0), M.value.multiple ? (f(), i(e, {
|
|
217
228
|
key: 1,
|
|
218
229
|
label: "OK",
|
|
219
230
|
type: "success",
|
|
@@ -223,4 +234,4 @@ var y = { class: "ac-component" }, b = ["aria-disabled"], te = {
|
|
|
223
234
|
}
|
|
224
235
|
});
|
|
225
236
|
//#endregion
|
|
226
|
-
export {
|
|
237
|
+
export { k as default, O as dropdownSelectConfigDefaults };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admins-components26.js","names":[],"sources":["../src/components/DropdownSelect.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface DropdownSelectConfig {\n placeholder?: string\n filterable?: boolean\n filterPlaceholder?: string\n clearable?: boolean\n textEllipsis?: boolean\n multiple?: boolean\n lazy?: boolean\n size?: ControlSize\n loading?: boolean\n highlight?: boolean\n disabled?: boolean\n}\n\nexport const dropdownSelectConfigDefaults: DropdownSelectConfig = {\n placeholder: 'Válassz...',\n filterable: true,\n filterPlaceholder: 'Kezdj el gépelni...',\n clearable: true,\n textEllipsis: true,\n multiple: false,\n lazy: false,\n loading: false,\n size: 'normal' as ControlSize,\n highlight: true,\n disabled: false,\n}\n\nexport interface DropdownOption {\n icon?: string\n value?: string\n label: string\n callback?: () => void\n}\n\nexport interface DropdownSelectProps {\n modelValue?: string | string[] | null\n options: DropdownOption[]\n config?: DropdownSelectConfig\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'\nimport Button from '@/components/Button.vue'\nimport type { ControlSize } from '@/types/types'\nimport Loader from '@/components/Loader.vue'\n\nconst props = withDefaults(defineProps<DropdownSelectProps>(), {\n modelValue: null,\n config: () => ({ ...dropdownSelectConfigDefaults }),\n})\n\nconst cfg = computed(() => ({ ...dropdownSelectConfigDefaults, ...props.config }))\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: string | string[] | null]\n 'filter-input': [filterText: string]\n}>()\n\nconst isOpen = ref(false)\nconst filterText = ref('')\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst filterInputRef = ref<HTMLInputElement | null>(null)\nconst buffer = ref<string[]>([])\nconst selection = ref<string[]>(toArray(props.modelValue))\n\nfunction toArray(val: string | string[] | null | undefined): string[] {\n if (val == null) return []\n return Array.isArray(val) ? [...val] : [val]\n}\n\nwatch(\n () => props.modelValue,\n (v) => {\n selection.value = toArray(v)\n },\n)\n\nwatch(isOpen, (open) => {\n if (open) {\n filterText.value = ''\n if (cfg.value.filterable) nextTick(() => filterInputRef.value?.focus())\n if (cfg.value.lazy) buffer.value = [...selection.value]\n }\n})\n\nfunction onFilterInput(text: string) {\n filterText.value = text\n emit('filter-input', text)\n //debouncedEmit(text)\n}\n\n/* const debouncedEmit = debounce((raw: string) => {\n emit('filter-input', raw)\n}) */\n\n// Display\nconst selectedLabel = computed(() => {\n if (selection.value.length === 0) return null\n if (!cfg.value.multiple)\n return props.options.find((o) => o.value === selection.value[0])?.label ?? null\n if (selection.value.length > 2) return `${selection.value.length} kiválasztva`\n return selection.value.map((v) => props.options.find((o) => o.value === v)?.label ?? v).join(', ')\n})\n\nconst filteredOptions = computed(() => {\n const q = filterText.value.toLowerCase()\n return q ? props.options.filter((o) => o.label.toLowerCase().includes(q)) : props.options\n})\n\nfunction escapeHtml(str: string) {\n return str.replace(\n /[&<>\"']/g,\n (m) => ({ '&': '&', '<': '<', '>': '>', '\"': '"', \"'\": ''' })[m]!,\n )\n}\n\nfunction highlight(label: string) {\n const q = filterText.value.trim()\n if (!q || !cfg.value.highlight) return escapeHtml(label)\n\n const safeLabel = escapeHtml(label)\n const safeQ = escapeHtml(q)\n\n const re = new RegExp(safeQ.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'ig')\n return safeLabel.replace(re, (m) => `<mark class=\"ds-option__highlight\">${m}</mark>`)\n}\n\nconst selectableOptions = computed(() => {\n return filteredOptions.value.filter((o) => o.value)\n})\n\nconst allOptionsSelected = computed(() => {\n if (selectableOptions.value.length === 0) return false\n const currentList = cfg.value.lazy && isOpen.value ? buffer.value : selection.value\n return selectableOptions.value.every((o) => o.value && currentList.includes(o.value))\n})\n\nfunction isSelected(value: string): boolean {\n return (cfg.value.lazy && isOpen.value ? buffer : selection).value.includes(value)\n}\n\nfunction toggleAllOptions() {\n const currentList = cfg.value.lazy && isOpen.value ? buffer : selection\n const selectableValues = selectableOptions.value.map((o) => o.value as string)\n\n if (allOptionsSelected.value) {\n currentList.value = currentList.value.filter((v) => !selectableValues.includes(v))\n } else {\n const toAdd = selectableValues.filter((v) => !currentList.value.includes(v))\n currentList.value = [...currentList.value, ...toAdd]\n }\n\n if (!cfg.value.lazy) {\n emit('update:modelValue', selection.value.length > 0 ? [...selection.value] : null)\n }\n}\n\n// Actions\nfunction toggleList(list: string[], value: string): string[] {\n const idx = list.indexOf(value)\n return idx >= 0 ? list.filter((_, i) => i !== idx) : [...list, value]\n}\n\nfunction selectOption(opt: DropdownOption) {\n if (opt.callback) {\n opt.callback()\n isOpen.value = false\n return\n }\n\n const value = opt.value\n if (!value) return\n\n if (cfg.value.multiple) {\n if (cfg.value.lazy) {\n buffer.value = toggleList(buffer.value, value)\n } else {\n selection.value = toggleList(selection.value, value)\n emit('update:modelValue', selection.value.length > 0 ? [...selection.value] : null)\n }\n } else {\n selection.value = [value]\n emit('update:modelValue', value)\n isOpen.value = false\n }\n}\n\nfunction confirm() {\n if (cfg.value.lazy) {\n selection.value = [...buffer.value]\n emit('update:modelValue', buffer.value.length > 0 ? [...buffer.value] : null)\n }\n isOpen.value = false\n}\n\nfunction clear() {\n if (cfg.value.lazy) {\n buffer.value = []\n } else {\n selection.value = []\n emit('update:modelValue', null)\n }\n}\n\nfunction onOptionKeydown(e: KeyboardEvent, opt: DropdownOption) {\n if (e.key === ' ') {\n e.preventDefault()\n selectOption(opt)\n } else if (e.key === 'Enter') {\n e.preventDefault()\n confirm()\n }\n}\n\nfunction onClickOutside(e: MouseEvent) {\n if (wrapperRef.value && !wrapperRef.value.contains(e.target as Node)) isOpen.value = false\n}\n\nonMounted(() => document.addEventListener('mousedown', onClickOutside))\nonBeforeUnmount(() => {\n document.removeEventListener('mousedown', onClickOutside)\n})\n\nfunction toggleOpen() {\n if (cfg.value.disabled) return\n isOpen.value = !isOpen.value\n if (isOpen.value) {\n if (cfg.value.filterable) {\n filterText.value = ''\n emit('filter-input', '')\n }\n }\n}\n\nfunction clearInput() {\n if (cfg.value.disabled) return\n selection.value = []\n emit('update:modelValue', null)\n isOpen.value = false\n}\n\nfunction focusAndOpen() {\n if (cfg.value.disabled) return\n isOpen.value = true\n if (cfg.value.filterable) nextTick(() => filterInputRef.value?.focus())\n}\n\nfunction handleFilterClear() {\n filterText.value = ''\n emit('filter-input', '')\n}\n\ndefineExpose({ focusAndOpen })\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"c-wrapper ds-wrapper\">\n <div\n class=\"c-input-row pointer\"\n :class=\"{\n 'c-input-row--sm': cfg.size === 'small',\n 'c-input-row--lg': cfg.size === 'large',\n 'c-input-row--disabled': cfg.disabled,\n }\"\n :aria-disabled=\"cfg.disabled || undefined\"\n @click=\"toggleOpen()\"\n >\n <span v-if=\"selectedLabel\" class=\"c-truncate ds-value\">{{ selectedLabel }}</span>\n <span v-else class=\"c-placeholder\">{{ cfg.placeholder }}</span>\n <button\n v-if=\"cfg.clearable && selection.length > 0\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-clear-btn\"\n @click.stop=\"clearInput()\"\n aria-label=\"Törlés\"\n >\n <i class=\"fa-solid fa-fw fa-xmark\"></i>\n </button>\n <span\n class=\"c-icon-btn c-icon-btn--chevron mr-2\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </div>\n\n <div\n v-if=\"isOpen\"\n class=\"c-dropdown ds-dropdown ac-component\"\n :class=\"{ 'ds-dropdown--multiple': cfg.multiple }\"\n >\n <div v-if=\"cfg.filterable\" class=\"ds-filter\">\n <span\n v-if=\"cfg.multiple\"\n class=\"c-checkbox ds-select-all-checkbox\"\n :class=\"{ 'c-checkbox--checked': allOptionsSelected }\"\n @click.stop=\"toggleAllOptions()\"\n :title=\"allOptionsSelected ? 'Összes kijelölés törlése' : 'Összes kijelölése'\"\n ></span>\n <input\n ref=\"filterInputRef\"\n type=\"text\"\n id=\"ds-filter-input\"\n class=\"c-focus ds-filter-input\"\n :value=\"filterText\"\n @input=\"onFilterInput(($event.target as HTMLInputElement).value)\"\n autocomplete=\"off\"\n :placeholder=\"cfg.filterPlaceholder\"\n @click.stop\n />\n <button\n v-if=\"filterText\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-filter-clear\"\n @click.stop=\"handleFilterClear()\"\n aria-label=\"Szűrők törlése\"\n >\n <i class=\"fa-solid fa-xmark\"></i>\n </button>\n </div>\n\n <ul class=\"ds-options c-scroll\">\n <li v-if=\"cfg.loading\" class=\"ds-option ds-option--loading\">\n <Loader size=\"2rem\" color=\"var(--neutral-300)\" class=\"m-auto p-3\" />\n </li>\n <template v-else>\n <li\n v-for=\"(opt, idx) in filteredOptions\"\n :key=\"opt.value ?? `cb-${idx}`\"\n class=\"d-option ds-option\"\n :class=\"{ 'ds-option--selected': opt.value && isSelected(opt.value) }\"\n tabindex=\"0\"\n @click=\"selectOption(opt)\"\n @keydown=\"onOptionKeydown($event, opt)\"\n >\n <span\n v-if=\"cfg.multiple && opt.value\"\n class=\"c-checkbox\"\n :class=\"{ 'c-checkbox--checked': isSelected(opt.value) }\"\n ></span>\n <i v-if=\"opt.icon\" class=\"fa-fw\" :class=\"opt.icon\"></i>\n <span\n class=\"d-option__label\"\n :class=\"{ 'c-truncate': cfg.textEllipsis }\"\n v-html=\"highlight(opt.label)\"\n ></span>\n </li>\n <li v-if=\"filteredOptions.length === 0\" class=\"ds-option ds-option--empty\">\n Nincs találat\n </li>\n </template>\n </ul>\n\n <div v-if=\"cfg.multiple || (cfg.clearable && selection.length > 0)\" class=\"c-footer\">\n <Button v-if=\"cfg.clearable\" label=\"Törlés\" outline @click=\"clear\" />\n <Button v-if=\"cfg.multiple\" label=\"OK\" type=\"success\" @click=\"confirm\" />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\" src=\"@/styles/components/dropdown-select.scss\"></style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;GAea,IAAqD;CAChE,aAAa;CACb,YAAY;CACZ,mBAAmB;CACnB,WAAW;CACX,cAAc;CACd,UAAU;CACV,MAAM;CACN,SAAS;CACT,MAAM;CACN,WAAW;CACX,UAAU;AACZ;;;;;;;;;EAsBA,IAAM,IAAQ,GAKR,IAAM,SAAgB;GAAE,GAAG;GAA8B,GAAG,EAAM;EAAO,EAAE,GAE3E,IAAO,IAKP,IAAS,EAAI,EAAK,GAClB,IAAa,EAAI,EAAE,GACnB,IAAa,EAAwB,IAAI,GACzC,IAAiB,EAA6B,IAAI,GAClD,IAAS,EAAc,CAAC,CAAC,GACzB,IAAY,EAAc,EAAQ,EAAM,UAAU,CAAC;EAEzD,SAAS,EAAQ,GAAqD;GAEpE,OADI,KAAO,OAAa,CAAC,IAClB,MAAM,QAAQ,CAAG,IAAI,CAAC,GAAG,CAAG,IAAI,CAAC,CAAG;EAC7C;EASA,AAPA,QACQ,EAAM,aACX,MAAM;GACL,EAAU,QAAQ,EAAQ,CAAC;EAC7B,CACF,GAEA,EAAM,IAAS,MAAS;GACtB,AAAI,MACF,EAAW,QAAQ,IACf,EAAI,MAAM,cAA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AA,GAD5B,EAIQ,QAAA;;KAFN,OAAK,EAAA,CAAC,cAAY,EAAA,uBACe,EAAW,EAAI,KAAK,EAAA,CAAA,CAAA;;IAE9C,EAAI,QAAA,EAAA,GAAb,EAAuD,KAAA;;KAApC,OAAK,EAAA,CAAC,SAAgB,EAAI,IAAI,CAAA;;IACjD,EAIQ,QAAA;KAHN,OAAK,EAAA,CAAC,mBAAiB,EAAA,cACC,EAAA,MAAI,aAAY,CAAA,CAAA;KACxC,WAAQ,EAAU,EAAI,KAAK;;uBAGrB,EAAA,MAAgB,WAAM,KAAA,EAAA,GAAhC,EAEK,MAFL,GAA2E,iBAE3E,KAAA,EAAA,IAAA,EAAA,CAAA,GAAA,EAAA,EAAA,CAAA;GAIO,EAAA,MAAI,YAAa,EAAA,MAAI,aAAa,EAAA,MAAU,SAAM,KAAA,EAAA,GAA7D,EAGM,OAHN,GAGM,CAFU,EAAA,MAAI,aAAA,EAAA,GAAlB,EAAqE,GAAA;;IAAxC,OAAM;IAAS,SAAA;IAAS,SAAO;oBAC9C,EAAA,MAAI,YAAA,EAAA,GAAlB,EAAyE,GAAA;;IAA7C,OAAM;IAAK,MAAK;IAAW,SAAO"}
|
|
1
|
+
{"version":3,"file":"admins-components26.js","names":[],"sources":["../src/components/DropdownSelect.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface DropdownSelectConfig {\n placeholder?: string\n filterable?: boolean\n filterPlaceholder?: string\n clearable?: boolean\n textEllipsis?: boolean\n multiple?: boolean\n lazy?: boolean\n size?: ControlSize\n loading?: boolean\n highlight?: boolean\n disabled?: boolean\n}\n\nexport const dropdownSelectConfigDefaults: DropdownSelectConfig = {\n placeholder: 'Válassz...',\n filterable: true,\n filterPlaceholder: 'Kezdj el gépelni...',\n clearable: true,\n textEllipsis: true,\n multiple: false,\n lazy: false,\n loading: false,\n size: 'normal' as ControlSize,\n highlight: true,\n disabled: false,\n}\n\nexport interface DropdownOption {\n icon?: string\n value?: string\n label: string\n callback?: () => void\n}\n\nexport interface DropdownSelectProps {\n modelValue?: DropdownOption | DropdownOption[] | string | string[] | null\n options: DropdownOption[]\n config?: DropdownSelectConfig\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'\nimport Button from '@/components/Button.vue'\nimport type { ControlSize } from '@/types/types'\nimport Loader from '@/components/Loader.vue'\n\nconst props = withDefaults(defineProps<DropdownSelectProps>(), {\n modelValue: null,\n config: () => ({ ...dropdownSelectConfigDefaults }),\n})\n\nconst cfg = computed(() => ({ ...dropdownSelectConfigDefaults, ...props.config }))\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: DropdownOption | DropdownOption[] | null]\n 'filter-input': [filterText: string]\n}>()\n\nconst isOpen = ref(false)\nconst filterText = ref('')\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst filterInputRef = ref<HTMLInputElement | null>(null)\nconst buffer = ref<DropdownOption[]>([])\nconst selection = ref<DropdownOption[]>(normalizeToOptions(props.modelValue, props.options))\n\n\nfunction normalizeToOptions(\n val: DropdownOption | DropdownOption[] | string | string[] | null | undefined,\n options: DropdownOption[],\n): DropdownOption[] {\n if (val == null) return []\n const arr = Array.isArray(val) ? val : [val]\n return arr\n .map((entry): DropdownOption | null => {\n if (entry == null) return null\n if (typeof entry === 'object' && 'label' in entry) {\n return entry as DropdownOption\n }\n if (typeof entry === 'string') {\n const found = options.find((o) => o.value === entry)\n return found ?? { value: entry, label: entry }\n }\n return null\n })\n .filter((o): o is DropdownOption => o !== null)\n}\n\nwatch(\n () => [props.modelValue, props.options],\n ([v]) => {\n selection.value = normalizeToOptions(v as typeof props.modelValue, props.options)\n },\n)\n\nwatch(isOpen, (open) => {\n if (open) {\n filterText.value = ''\n if (cfg.value.filterable) nextTick(() => filterInputRef.value?.focus())\n if (cfg.value.lazy) buffer.value = [...selection.value]\n }\n})\n\nfunction onFilterInput(text: string) {\n filterText.value = text\n emit('filter-input', text)\n //debouncedEmit(text)\n}\n\n/* const debouncedEmit = debounce((raw: string) => {\n emit('filter-input', raw)\n}) */\n\n// Display\nconst selectedLabel = computed(() => {\n if (selection.value.length === 0) return null\n if (!cfg.value.multiple) {\n const sel = selection.value[0]\n // Prefer the label from the live options list, fall back to the stored label\n return props.options.find((o) => o.value === sel.value)?.label ?? sel.label ?? null\n }\n if (selection.value.length > 2) return `${selection.value.length} kiválasztva`\n return selection.value\n .map((sel) => props.options.find((o) => o.value === sel.value)?.label ?? sel.label ?? sel.value)\n .join(', ')\n})\n\nconst filteredOptions = computed(() => {\n const q = filterText.value.toLowerCase()\n return q ? props.options.filter((o) => o.label.toLowerCase().includes(q)) : props.options\n})\n\nfunction escapeHtml(str: string) {\n return str.replace(\n /[&<>\"']/g,\n (m) => ({ '&': '&', '<': '<', '>': '>', '\"': '"', \"'\": ''' })[m]!,\n )\n}\n\nfunction highlight(label: string) {\n const q = filterText.value.trim()\n if (!q || !cfg.value.highlight) return escapeHtml(label)\n\n const safeLabel = escapeHtml(label)\n const safeQ = escapeHtml(q)\n\n const re = new RegExp(safeQ.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'ig')\n return safeLabel.replace(re, (m) => `<mark class=\"ds-option__highlight\">${m}</mark>`)\n}\n\nconst selectableOptions = computed(() => {\n return filteredOptions.value.filter((o) => o.value)\n})\n\nconst allOptionsSelected = computed(() => {\n if (selectableOptions.value.length === 0) return false\n const currentList = cfg.value.lazy && isOpen.value ? buffer.value : selection.value\n return selectableOptions.value.every((o) => o.value && currentList.some((s) => s.value === o.value))\n})\n\nfunction isSelected(value: string): boolean {\n const list = cfg.value.lazy && isOpen.value ? buffer : selection\n return list.value.some((s) => s.value === value)\n}\n\nfunction toggleAllOptions() {\n const currentList = cfg.value.lazy && isOpen.value ? buffer : selection\n const selectableOpts = selectableOptions.value.filter((o) => o.value)\n\n if (allOptionsSelected.value) {\n const selectableValues = new Set(selectableOpts.map((o) => o.value as string))\n currentList.value = currentList.value.filter((s) => !selectableValues.has(s.value))\n } else {\n const existingValues = new Set(currentList.value.map((s) => s.value))\n const toAdd = selectableOpts.filter((o) => !existingValues.has(o.value as string))\n currentList.value = [...currentList.value, ...toAdd]\n }\n\n if (!cfg.value.lazy) {\n emit('update:modelValue', selection.value.length > 0 ? [...selection.value] : null)\n }\n}\n\n// Actions\nfunction toggleList(list: DropdownOption[], opt: DropdownOption): DropdownOption[] {\n const idx = list.findIndex((s) => s.value === opt.value)\n return idx >= 0 ? list.filter((_, i) => i !== idx) : [...list, opt]\n}\n\nfunction selectOption(opt: DropdownOption) {\n if (opt.callback) {\n opt.callback()\n isOpen.value = false\n return\n }\n\n const value = opt.value\n if (!value) return\n\n if (cfg.value.multiple) {\n if (cfg.value.lazy) {\n buffer.value = toggleList(buffer.value, opt)\n } else {\n selection.value = toggleList(selection.value, opt)\n emit('update:modelValue', selection.value.length > 0 ? [...selection.value] : null)\n }\n } else {\n selection.value = [opt]\n emit('update:modelValue', opt)\n isOpen.value = false\n }\n}\n\nfunction confirm() {\n if (cfg.value.lazy) {\n selection.value = [...buffer.value]\n emit('update:modelValue', buffer.value.length > 0 ? [...buffer.value] : null)\n }\n isOpen.value = false\n}\n\nfunction clear() {\n if (cfg.value.lazy) {\n buffer.value = []\n } else {\n selection.value = []\n emit('update:modelValue', null)\n }\n}\n\nfunction onOptionKeydown(e: KeyboardEvent, opt: DropdownOption) {\n if (e.key === ' ') {\n e.preventDefault()\n selectOption(opt)\n } else if (e.key === 'Enter') {\n e.preventDefault()\n confirm()\n }\n}\n\nfunction onClickOutside(e: MouseEvent) {\n if (wrapperRef.value && !wrapperRef.value.contains(e.target as Node)) isOpen.value = false\n}\n\nonMounted(() => document.addEventListener('mousedown', onClickOutside))\nonBeforeUnmount(() => {\n document.removeEventListener('mousedown', onClickOutside)\n})\n\nfunction toggleOpen() {\n if (cfg.value.disabled) return\n isOpen.value = !isOpen.value\n if (isOpen.value) {\n if (cfg.value.filterable) {\n filterText.value = ''\n emit('filter-input', '')\n }\n }\n}\n\nfunction clearInput() {\n if (cfg.value.disabled) return\n selection.value = []\n emit('update:modelValue', null)\n isOpen.value = false\n}\n\nfunction focusAndOpen() {\n if (cfg.value.disabled) return\n isOpen.value = true\n if (cfg.value.filterable) nextTick(() => filterInputRef.value?.focus())\n}\n\nfunction handleFilterClear() {\n filterText.value = ''\n emit('filter-input', '')\n}\n\ndefineExpose({ focusAndOpen })\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"c-wrapper ds-wrapper\">\n <div\n class=\"c-input-row pointer\"\n :class=\"{\n 'c-input-row--sm': cfg.size === 'small',\n 'c-input-row--lg': cfg.size === 'large',\n 'c-input-row--disabled': cfg.disabled,\n }\"\n :aria-disabled=\"cfg.disabled || undefined\"\n @click=\"toggleOpen()\"\n >\n <span v-if=\"selectedLabel\" class=\"c-truncate ds-value\">{{ selectedLabel }}</span>\n <span v-else class=\"c-placeholder\">{{ cfg.placeholder }}</span>\n <button\n v-if=\"cfg.clearable && selection.length > 0\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-clear-btn\"\n @click.stop=\"clearInput()\"\n aria-label=\"Törlés\"\n >\n <i class=\"fa-solid fa-fw fa-xmark\"></i>\n </button>\n <span\n class=\"c-icon-btn c-icon-btn--chevron mr-2\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </div>\n\n <div\n v-if=\"isOpen\"\n class=\"c-dropdown ds-dropdown ac-component\"\n :class=\"{ 'ds-dropdown--multiple': cfg.multiple }\"\n >\n <div v-if=\"cfg.filterable\" class=\"ds-filter\">\n <span\n v-if=\"cfg.multiple\"\n class=\"c-checkbox ds-select-all-checkbox\"\n :class=\"{ 'c-checkbox--checked': allOptionsSelected }\"\n @click.stop=\"toggleAllOptions()\"\n :title=\"allOptionsSelected ? 'Összes kijelölés törlése' : 'Összes kijelölése'\"\n ></span>\n <input\n ref=\"filterInputRef\"\n type=\"text\"\n id=\"ds-filter-input\"\n class=\"c-focus ds-filter-input\"\n :value=\"filterText\"\n @input=\"onFilterInput(($event.target as HTMLInputElement).value)\"\n autocomplete=\"off\"\n :placeholder=\"cfg.filterPlaceholder\"\n @click.stop\n />\n <button\n v-if=\"filterText\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-filter-clear\"\n @click.stop=\"handleFilterClear()\"\n aria-label=\"Szűrők törlése\"\n >\n <i class=\"fa-solid fa-xmark\"></i>\n </button>\n </div>\n\n <ul class=\"ds-options c-scroll\">\n <li v-if=\"cfg.loading\" class=\"ds-option ds-option--loading\">\n <Loader size=\"2rem\" color=\"var(--neutral-300)\" class=\"m-auto p-3\" />\n </li>\n <template v-else>\n <li\n v-for=\"(opt, idx) in filteredOptions\"\n :key=\"opt.value ?? `cb-${idx}`\"\n class=\"d-option ds-option\"\n :class=\"{ 'ds-option--selected': opt.value && isSelected(opt.value) }\"\n tabindex=\"0\"\n @click=\"selectOption(opt)\"\n @keydown=\"onOptionKeydown($event, opt)\"\n >\n <span\n v-if=\"cfg.multiple && opt.value\"\n class=\"c-checkbox\"\n :class=\"{ 'c-checkbox--checked': isSelected(opt.value) }\"\n ></span>\n <i v-if=\"opt.icon\" class=\"fa-fw\" :class=\"opt.icon\"></i>\n <span\n class=\"d-option__label\"\n :class=\"{ 'c-truncate': cfg.textEllipsis }\"\n v-html=\"highlight(opt.label)\"\n ></span>\n </li>\n <li v-if=\"filteredOptions.length === 0\" class=\"ds-option ds-option--empty\">\n Nincs találat\n </li>\n </template>\n </ul>\n\n <div v-if=\"cfg.multiple || (cfg.clearable && selection.length > 0)\" class=\"c-footer\">\n <Button v-if=\"cfg.clearable\" label=\"Törlés\" outline @click=\"clear\" />\n <Button v-if=\"cfg.multiple\" label=\"OK\" type=\"success\" @click=\"confirm\" />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\" src=\"@/styles/components/dropdown-select.scss\"></style>\n"],"mappings":";;;;;;;;;;;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;IAG7B,EAAA,MAAI,YAAY,EAAI,SAAA,EAAA,GAD5B,EAIQ,QAAA;;KAFN,OAAK,EAAA,CAAC,cAAY,EAAA,uBACe,EAAW,EAAI,KAAK,EAAA,CAAA,CAAA;;IAE9C,EAAI,QAAA,EAAA,GAAb,EAAuD,KAAA;;KAApC,OAAK,EAAA,CAAC,SAAgB,EAAI,IAAI,CAAA;;IACjD,EAIQ,QAAA;KAHN,OAAK,EAAA,CAAC,mBAAiB,EAAA,cACC,EAAA,MAAI,aAAY,CAAA,CAAA;KACxC,WAAQ,EAAU,EAAI,KAAK;;uBAGrB,EAAA,MAAgB,WAAM,KAAA,EAAA,GAAhC,EAEK,MAFL,GAA2E,iBAE3E,KAAA,EAAA,IAAA,EAAA,CAAA,GAAA,EAAA,EAAA,CAAA;GAIO,EAAA,MAAI,YAAa,EAAA,MAAI,aAAa,EAAA,MAAU,SAAM,KAAA,EAAA,GAA7D,EAGM,OAHN,GAGM,CAFU,EAAA,MAAI,aAAA,EAAA,GAAlB,EAAqE,GAAA;;IAAxC,OAAM;IAAS,SAAA;IAAS,SAAO;oBAC9C,EAAA,MAAI,YAAA,EAAA,GAAlB,EAAyE,GAAA;;IAA7C,OAAM;IAAK,MAAK;IAAW,SAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admins-components28.js","names":[],"sources":["../src/components/DropdownSelect.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface DropdownSelectConfig {\n placeholder?: string\n filterable?: boolean\n filterPlaceholder?: string\n clearable?: boolean\n textEllipsis?: boolean\n multiple?: boolean\n lazy?: boolean\n size?: ControlSize\n loading?: boolean\n highlight?: boolean\n disabled?: boolean\n}\n\nexport const dropdownSelectConfigDefaults: DropdownSelectConfig = {\n placeholder: 'Válassz...',\n filterable: true,\n filterPlaceholder: 'Kezdj el gépelni...',\n clearable: true,\n textEllipsis: true,\n multiple: false,\n lazy: false,\n loading: false,\n size: 'normal' as ControlSize,\n highlight: true,\n disabled: false,\n}\n\nexport interface DropdownOption {\n icon?: string\n value?: string\n label: string\n callback?: () => void\n}\n\nexport interface DropdownSelectProps {\n modelValue?: string | string[] | null\n options: DropdownOption[]\n config?: DropdownSelectConfig\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'\nimport Button from '@/components/Button.vue'\nimport type { ControlSize } from '@/types/types'\nimport Loader from '@/components/Loader.vue'\n\nconst props = withDefaults(defineProps<DropdownSelectProps>(), {\n modelValue: null,\n config: () => ({ ...dropdownSelectConfigDefaults }),\n})\n\nconst cfg = computed(() => ({ ...dropdownSelectConfigDefaults, ...props.config }))\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: string | string[] | null]\n 'filter-input': [filterText: string]\n}>()\n\nconst isOpen = ref(false)\nconst filterText = ref('')\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst filterInputRef = ref<HTMLInputElement | null>(null)\nconst buffer = ref<string[]>([])\nconst selection = ref<string[]>(toArray(props.modelValue))\n\nfunction toArray(val: string | string[] | null | undefined): string[] {\n if (val == null) return []\n return Array.isArray(val) ? [...val] : [val]\n}\n\nwatch(\n () => props.modelValue,\n (v) => {\n selection.value = toArray(v)\n },\n)\n\nwatch(isOpen, (open) => {\n if (open) {\n filterText.value = ''\n if (cfg.value.filterable) nextTick(() => filterInputRef.value?.focus())\n if (cfg.value.lazy) buffer.value = [...selection.value]\n }\n})\n\nfunction onFilterInput(text: string) {\n filterText.value = text\n emit('filter-input', text)\n //debouncedEmit(text)\n}\n\n/* const debouncedEmit = debounce((raw: string) => {\n emit('filter-input', raw)\n}) */\n\n// Display\nconst selectedLabel = computed(() => {\n if (selection.value.length === 0) return null\n if (!cfg.value.multiple)\n return props.options.find((o) => o.value === selection.value[0])?.label ?? null\n if (selection.value.length > 2) return `${selection.value.length} kiválasztva`\n return selection.value.map((v) => props.options.find((o) => o.value === v)?.label ?? v).join(', ')\n})\n\nconst filteredOptions = computed(() => {\n const q = filterText.value.toLowerCase()\n return q ? props.options.filter((o) => o.label.toLowerCase().includes(q)) : props.options\n})\n\nfunction escapeHtml(str: string) {\n return str.replace(\n /[&<>\"']/g,\n (m) => ({ '&': '&', '<': '<', '>': '>', '\"': '"', \"'\": ''' })[m]!,\n )\n}\n\nfunction highlight(label: string) {\n const q = filterText.value.trim()\n if (!q || !cfg.value.highlight) return escapeHtml(label)\n\n const safeLabel = escapeHtml(label)\n const safeQ = escapeHtml(q)\n\n const re = new RegExp(safeQ.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'ig')\n return safeLabel.replace(re, (m) => `<mark class=\"ds-option__highlight\">${m}</mark>`)\n}\n\nconst selectableOptions = computed(() => {\n return filteredOptions.value.filter((o) => o.value)\n})\n\nconst allOptionsSelected = computed(() => {\n if (selectableOptions.value.length === 0) return false\n const currentList = cfg.value.lazy && isOpen.value ? buffer.value : selection.value\n return selectableOptions.value.every((o) => o.value && currentList.includes(o.value))\n})\n\nfunction isSelected(value: string): boolean {\n return (cfg.value.lazy && isOpen.value ? buffer : selection).value.includes(value)\n}\n\nfunction toggleAllOptions() {\n const currentList = cfg.value.lazy && isOpen.value ? buffer : selection\n const selectableValues = selectableOptions.value.map((o) => o.value as string)\n\n if (allOptionsSelected.value) {\n currentList.value = currentList.value.filter((v) => !selectableValues.includes(v))\n } else {\n const toAdd = selectableValues.filter((v) => !currentList.value.includes(v))\n currentList.value = [...currentList.value, ...toAdd]\n }\n\n if (!cfg.value.lazy) {\n emit('update:modelValue', selection.value.length > 0 ? [...selection.value] : null)\n }\n}\n\n// Actions\nfunction toggleList(list: string[], value: string): string[] {\n const idx = list.indexOf(value)\n return idx >= 0 ? list.filter((_, i) => i !== idx) : [...list, value]\n}\n\nfunction selectOption(opt: DropdownOption) {\n if (opt.callback) {\n opt.callback()\n isOpen.value = false\n return\n }\n\n const value = opt.value\n if (!value) return\n\n if (cfg.value.multiple) {\n if (cfg.value.lazy) {\n buffer.value = toggleList(buffer.value, value)\n } else {\n selection.value = toggleList(selection.value, value)\n emit('update:modelValue', selection.value.length > 0 ? [...selection.value] : null)\n }\n } else {\n selection.value = [value]\n emit('update:modelValue', value)\n isOpen.value = false\n }\n}\n\nfunction confirm() {\n if (cfg.value.lazy) {\n selection.value = [...buffer.value]\n emit('update:modelValue', buffer.value.length > 0 ? [...buffer.value] : null)\n }\n isOpen.value = false\n}\n\nfunction clear() {\n if (cfg.value.lazy) {\n buffer.value = []\n } else {\n selection.value = []\n emit('update:modelValue', null)\n }\n}\n\nfunction onOptionKeydown(e: KeyboardEvent, opt: DropdownOption) {\n if (e.key === ' ') {\n e.preventDefault()\n selectOption(opt)\n } else if (e.key === 'Enter') {\n e.preventDefault()\n confirm()\n }\n}\n\nfunction onClickOutside(e: MouseEvent) {\n if (wrapperRef.value && !wrapperRef.value.contains(e.target as Node)) isOpen.value = false\n}\n\nonMounted(() => document.addEventListener('mousedown', onClickOutside))\nonBeforeUnmount(() => {\n document.removeEventListener('mousedown', onClickOutside)\n})\n\nfunction toggleOpen() {\n if (cfg.value.disabled) return\n isOpen.value = !isOpen.value\n if (isOpen.value) {\n if (cfg.value.filterable) {\n filterText.value = ''\n emit('filter-input', '')\n }\n }\n}\n\nfunction clearInput() {\n if (cfg.value.disabled) return\n selection.value = []\n emit('update:modelValue', null)\n isOpen.value = false\n}\n\nfunction focusAndOpen() {\n if (cfg.value.disabled) return\n isOpen.value = true\n if (cfg.value.filterable) nextTick(() => filterInputRef.value?.focus())\n}\n\nfunction handleFilterClear() {\n filterText.value = ''\n emit('filter-input', '')\n}\n\ndefineExpose({ focusAndOpen })\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"c-wrapper ds-wrapper\">\n <div\n class=\"c-input-row pointer\"\n :class=\"{\n 'c-input-row--sm': cfg.size === 'small',\n 'c-input-row--lg': cfg.size === 'large',\n 'c-input-row--disabled': cfg.disabled,\n }\"\n :aria-disabled=\"cfg.disabled || undefined\"\n @click=\"toggleOpen()\"\n >\n <span v-if=\"selectedLabel\" class=\"c-truncate ds-value\">{{ selectedLabel }}</span>\n <span v-else class=\"c-placeholder\">{{ cfg.placeholder }}</span>\n <button\n v-if=\"cfg.clearable && selection.length > 0\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-clear-btn\"\n @click.stop=\"clearInput()\"\n aria-label=\"Törlés\"\n >\n <i class=\"fa-solid fa-fw fa-xmark\"></i>\n </button>\n <span\n class=\"c-icon-btn c-icon-btn--chevron mr-2\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </div>\n\n <div\n v-if=\"isOpen\"\n class=\"c-dropdown ds-dropdown ac-component\"\n :class=\"{ 'ds-dropdown--multiple': cfg.multiple }\"\n >\n <div v-if=\"cfg.filterable\" class=\"ds-filter\">\n <span\n v-if=\"cfg.multiple\"\n class=\"c-checkbox ds-select-all-checkbox\"\n :class=\"{ 'c-checkbox--checked': allOptionsSelected }\"\n @click.stop=\"toggleAllOptions()\"\n :title=\"allOptionsSelected ? 'Összes kijelölés törlése' : 'Összes kijelölése'\"\n ></span>\n <input\n ref=\"filterInputRef\"\n type=\"text\"\n id=\"ds-filter-input\"\n class=\"c-focus ds-filter-input\"\n :value=\"filterText\"\n @input=\"onFilterInput(($event.target as HTMLInputElement).value)\"\n autocomplete=\"off\"\n :placeholder=\"cfg.filterPlaceholder\"\n @click.stop\n />\n <button\n v-if=\"filterText\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-filter-clear\"\n @click.stop=\"handleFilterClear()\"\n aria-label=\"Szűrők törlése\"\n >\n <i class=\"fa-solid fa-xmark\"></i>\n </button>\n </div>\n\n <ul class=\"ds-options c-scroll\">\n <li v-if=\"cfg.loading\" class=\"ds-option ds-option--loading\">\n <Loader size=\"2rem\" color=\"var(--neutral-300)\" class=\"m-auto p-3\" />\n </li>\n <template v-else>\n <li\n v-for=\"(opt, idx) in filteredOptions\"\n :key=\"opt.value ?? `cb-${idx}`\"\n class=\"d-option ds-option\"\n :class=\"{ 'ds-option--selected': opt.value && isSelected(opt.value) }\"\n tabindex=\"0\"\n @click=\"selectOption(opt)\"\n @keydown=\"onOptionKeydown($event, opt)\"\n >\n <span\n v-if=\"cfg.multiple && opt.value\"\n class=\"c-checkbox\"\n :class=\"{ 'c-checkbox--checked': isSelected(opt.value) }\"\n ></span>\n <i v-if=\"opt.icon\" class=\"fa-fw\" :class=\"opt.icon\"></i>\n <span\n class=\"d-option__label\"\n :class=\"{ 'c-truncate': cfg.textEllipsis }\"\n v-html=\"highlight(opt.label)\"\n ></span>\n </li>\n <li v-if=\"filteredOptions.length === 0\" class=\"ds-option ds-option--empty\">\n Nincs találat\n </li>\n </template>\n </ul>\n\n <div v-if=\"cfg.multiple || (cfg.clearable && selection.length > 0)\" class=\"c-footer\">\n <Button v-if=\"cfg.clearable\" label=\"Törlés\" outline @click=\"clear\" />\n <Button v-if=\"cfg.multiple\" label=\"OK\" type=\"success\" @click=\"confirm\" />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\" src=\"@/styles/components/dropdown-select.scss\"></style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"admins-components28.js","names":[],"sources":["../src/components/DropdownSelect.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface DropdownSelectConfig {\n placeholder?: string\n filterable?: boolean\n filterPlaceholder?: string\n clearable?: boolean\n textEllipsis?: boolean\n multiple?: boolean\n lazy?: boolean\n size?: ControlSize\n loading?: boolean\n highlight?: boolean\n disabled?: boolean\n}\n\nexport const dropdownSelectConfigDefaults: DropdownSelectConfig = {\n placeholder: 'Válassz...',\n filterable: true,\n filterPlaceholder: 'Kezdj el gépelni...',\n clearable: true,\n textEllipsis: true,\n multiple: false,\n lazy: false,\n loading: false,\n size: 'normal' as ControlSize,\n highlight: true,\n disabled: false,\n}\n\nexport interface DropdownOption {\n icon?: string\n value?: string\n label: string\n callback?: () => void\n}\n\nexport interface DropdownSelectProps {\n modelValue?: DropdownOption | DropdownOption[] | string | string[] | null\n options: DropdownOption[]\n config?: DropdownSelectConfig\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'\nimport Button from '@/components/Button.vue'\nimport type { ControlSize } from '@/types/types'\nimport Loader from '@/components/Loader.vue'\n\nconst props = withDefaults(defineProps<DropdownSelectProps>(), {\n modelValue: null,\n config: () => ({ ...dropdownSelectConfigDefaults }),\n})\n\nconst cfg = computed(() => ({ ...dropdownSelectConfigDefaults, ...props.config }))\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: DropdownOption | DropdownOption[] | null]\n 'filter-input': [filterText: string]\n}>()\n\nconst isOpen = ref(false)\nconst filterText = ref('')\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst filterInputRef = ref<HTMLInputElement | null>(null)\nconst buffer = ref<DropdownOption[]>([])\nconst selection = ref<DropdownOption[]>(normalizeToOptions(props.modelValue, props.options))\n\n\nfunction normalizeToOptions(\n val: DropdownOption | DropdownOption[] | string | string[] | null | undefined,\n options: DropdownOption[],\n): DropdownOption[] {\n if (val == null) return []\n const arr = Array.isArray(val) ? val : [val]\n return arr\n .map((entry): DropdownOption | null => {\n if (entry == null) return null\n if (typeof entry === 'object' && 'label' in entry) {\n return entry as DropdownOption\n }\n if (typeof entry === 'string') {\n const found = options.find((o) => o.value === entry)\n return found ?? { value: entry, label: entry }\n }\n return null\n })\n .filter((o): o is DropdownOption => o !== null)\n}\n\nwatch(\n () => [props.modelValue, props.options],\n ([v]) => {\n selection.value = normalizeToOptions(v as typeof props.modelValue, props.options)\n },\n)\n\nwatch(isOpen, (open) => {\n if (open) {\n filterText.value = ''\n if (cfg.value.filterable) nextTick(() => filterInputRef.value?.focus())\n if (cfg.value.lazy) buffer.value = [...selection.value]\n }\n})\n\nfunction onFilterInput(text: string) {\n filterText.value = text\n emit('filter-input', text)\n //debouncedEmit(text)\n}\n\n/* const debouncedEmit = debounce((raw: string) => {\n emit('filter-input', raw)\n}) */\n\n// Display\nconst selectedLabel = computed(() => {\n if (selection.value.length === 0) return null\n if (!cfg.value.multiple) {\n const sel = selection.value[0]\n // Prefer the label from the live options list, fall back to the stored label\n return props.options.find((o) => o.value === sel.value)?.label ?? sel.label ?? null\n }\n if (selection.value.length > 2) return `${selection.value.length} kiválasztva`\n return selection.value\n .map((sel) => props.options.find((o) => o.value === sel.value)?.label ?? sel.label ?? sel.value)\n .join(', ')\n})\n\nconst filteredOptions = computed(() => {\n const q = filterText.value.toLowerCase()\n return q ? props.options.filter((o) => o.label.toLowerCase().includes(q)) : props.options\n})\n\nfunction escapeHtml(str: string) {\n return str.replace(\n /[&<>\"']/g,\n (m) => ({ '&': '&', '<': '<', '>': '>', '\"': '"', \"'\": ''' })[m]!,\n )\n}\n\nfunction highlight(label: string) {\n const q = filterText.value.trim()\n if (!q || !cfg.value.highlight) return escapeHtml(label)\n\n const safeLabel = escapeHtml(label)\n const safeQ = escapeHtml(q)\n\n const re = new RegExp(safeQ.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'ig')\n return safeLabel.replace(re, (m) => `<mark class=\"ds-option__highlight\">${m}</mark>`)\n}\n\nconst selectableOptions = computed(() => {\n return filteredOptions.value.filter((o) => o.value)\n})\n\nconst allOptionsSelected = computed(() => {\n if (selectableOptions.value.length === 0) return false\n const currentList = cfg.value.lazy && isOpen.value ? buffer.value : selection.value\n return selectableOptions.value.every((o) => o.value && currentList.some((s) => s.value === o.value))\n})\n\nfunction isSelected(value: string): boolean {\n const list = cfg.value.lazy && isOpen.value ? buffer : selection\n return list.value.some((s) => s.value === value)\n}\n\nfunction toggleAllOptions() {\n const currentList = cfg.value.lazy && isOpen.value ? buffer : selection\n const selectableOpts = selectableOptions.value.filter((o) => o.value)\n\n if (allOptionsSelected.value) {\n const selectableValues = new Set(selectableOpts.map((o) => o.value as string))\n currentList.value = currentList.value.filter((s) => !selectableValues.has(s.value))\n } else {\n const existingValues = new Set(currentList.value.map((s) => s.value))\n const toAdd = selectableOpts.filter((o) => !existingValues.has(o.value as string))\n currentList.value = [...currentList.value, ...toAdd]\n }\n\n if (!cfg.value.lazy) {\n emit('update:modelValue', selection.value.length > 0 ? [...selection.value] : null)\n }\n}\n\n// Actions\nfunction toggleList(list: DropdownOption[], opt: DropdownOption): DropdownOption[] {\n const idx = list.findIndex((s) => s.value === opt.value)\n return idx >= 0 ? list.filter((_, i) => i !== idx) : [...list, opt]\n}\n\nfunction selectOption(opt: DropdownOption) {\n if (opt.callback) {\n opt.callback()\n isOpen.value = false\n return\n }\n\n const value = opt.value\n if (!value) return\n\n if (cfg.value.multiple) {\n if (cfg.value.lazy) {\n buffer.value = toggleList(buffer.value, opt)\n } else {\n selection.value = toggleList(selection.value, opt)\n emit('update:modelValue', selection.value.length > 0 ? [...selection.value] : null)\n }\n } else {\n selection.value = [opt]\n emit('update:modelValue', opt)\n isOpen.value = false\n }\n}\n\nfunction confirm() {\n if (cfg.value.lazy) {\n selection.value = [...buffer.value]\n emit('update:modelValue', buffer.value.length > 0 ? [...buffer.value] : null)\n }\n isOpen.value = false\n}\n\nfunction clear() {\n if (cfg.value.lazy) {\n buffer.value = []\n } else {\n selection.value = []\n emit('update:modelValue', null)\n }\n}\n\nfunction onOptionKeydown(e: KeyboardEvent, opt: DropdownOption) {\n if (e.key === ' ') {\n e.preventDefault()\n selectOption(opt)\n } else if (e.key === 'Enter') {\n e.preventDefault()\n confirm()\n }\n}\n\nfunction onClickOutside(e: MouseEvent) {\n if (wrapperRef.value && !wrapperRef.value.contains(e.target as Node)) isOpen.value = false\n}\n\nonMounted(() => document.addEventListener('mousedown', onClickOutside))\nonBeforeUnmount(() => {\n document.removeEventListener('mousedown', onClickOutside)\n})\n\nfunction toggleOpen() {\n if (cfg.value.disabled) return\n isOpen.value = !isOpen.value\n if (isOpen.value) {\n if (cfg.value.filterable) {\n filterText.value = ''\n emit('filter-input', '')\n }\n }\n}\n\nfunction clearInput() {\n if (cfg.value.disabled) return\n selection.value = []\n emit('update:modelValue', null)\n isOpen.value = false\n}\n\nfunction focusAndOpen() {\n if (cfg.value.disabled) return\n isOpen.value = true\n if (cfg.value.filterable) nextTick(() => filterInputRef.value?.focus())\n}\n\nfunction handleFilterClear() {\n filterText.value = ''\n emit('filter-input', '')\n}\n\ndefineExpose({ focusAndOpen })\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"c-wrapper ds-wrapper\">\n <div\n class=\"c-input-row pointer\"\n :class=\"{\n 'c-input-row--sm': cfg.size === 'small',\n 'c-input-row--lg': cfg.size === 'large',\n 'c-input-row--disabled': cfg.disabled,\n }\"\n :aria-disabled=\"cfg.disabled || undefined\"\n @click=\"toggleOpen()\"\n >\n <span v-if=\"selectedLabel\" class=\"c-truncate ds-value\">{{ selectedLabel }}</span>\n <span v-else class=\"c-placeholder\">{{ cfg.placeholder }}</span>\n <button\n v-if=\"cfg.clearable && selection.length > 0\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-clear-btn\"\n @click.stop=\"clearInput()\"\n aria-label=\"Törlés\"\n >\n <i class=\"fa-solid fa-fw fa-xmark\"></i>\n </button>\n <span\n class=\"c-icon-btn c-icon-btn--chevron mr-2\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </div>\n\n <div\n v-if=\"isOpen\"\n class=\"c-dropdown ds-dropdown ac-component\"\n :class=\"{ 'ds-dropdown--multiple': cfg.multiple }\"\n >\n <div v-if=\"cfg.filterable\" class=\"ds-filter\">\n <span\n v-if=\"cfg.multiple\"\n class=\"c-checkbox ds-select-all-checkbox\"\n :class=\"{ 'c-checkbox--checked': allOptionsSelected }\"\n @click.stop=\"toggleAllOptions()\"\n :title=\"allOptionsSelected ? 'Összes kijelölés törlése' : 'Összes kijelölése'\"\n ></span>\n <input\n ref=\"filterInputRef\"\n type=\"text\"\n id=\"ds-filter-input\"\n class=\"c-focus ds-filter-input\"\n :value=\"filterText\"\n @input=\"onFilterInput(($event.target as HTMLInputElement).value)\"\n autocomplete=\"off\"\n :placeholder=\"cfg.filterPlaceholder\"\n @click.stop\n />\n <button\n v-if=\"filterText\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-filter-clear\"\n @click.stop=\"handleFilterClear()\"\n aria-label=\"Szűrők törlése\"\n >\n <i class=\"fa-solid fa-xmark\"></i>\n </button>\n </div>\n\n <ul class=\"ds-options c-scroll\">\n <li v-if=\"cfg.loading\" class=\"ds-option ds-option--loading\">\n <Loader size=\"2rem\" color=\"var(--neutral-300)\" class=\"m-auto p-3\" />\n </li>\n <template v-else>\n <li\n v-for=\"(opt, idx) in filteredOptions\"\n :key=\"opt.value ?? `cb-${idx}`\"\n class=\"d-option ds-option\"\n :class=\"{ 'ds-option--selected': opt.value && isSelected(opt.value) }\"\n tabindex=\"0\"\n @click=\"selectOption(opt)\"\n @keydown=\"onOptionKeydown($event, opt)\"\n >\n <span\n v-if=\"cfg.multiple && opt.value\"\n class=\"c-checkbox\"\n :class=\"{ 'c-checkbox--checked': isSelected(opt.value) }\"\n ></span>\n <i v-if=\"opt.icon\" class=\"fa-fw\" :class=\"opt.icon\"></i>\n <span\n class=\"d-option__label\"\n :class=\"{ 'c-truncate': cfg.textEllipsis }\"\n v-html=\"highlight(opt.label)\"\n ></span>\n </li>\n <li v-if=\"filteredOptions.length === 0\" class=\"ds-option ds-option--empty\">\n Nincs találat\n </li>\n </template>\n </ul>\n\n <div v-if=\"cfg.multiple || (cfg.clearable && selection.length > 0)\" class=\"c-footer\">\n <Button v-if=\"cfg.clearable\" label=\"Törlés\" outline @click=\"clear\" />\n <Button v-if=\"cfg.multiple\" label=\"OK\" type=\"success\" @click=\"confirm\" />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\" src=\"@/styles/components/dropdown-select.scss\"></style>\n"],"mappings":""}
|
|
@@ -38,9 +38,19 @@ var j = /* @__PURE__ */ d({
|
|
|
38
38
|
extraStyle: (e) => ({ minWidth: `${Math.max(e.width, 240)}px` }),
|
|
39
39
|
closeOnScroll: !0
|
|
40
40
|
}), R = a({
|
|
41
|
-
get: () =>
|
|
41
|
+
get: () => {
|
|
42
|
+
let e = M.modelValue?.key;
|
|
43
|
+
return e ? M.options.find((t) => t.value === e) ?? {
|
|
44
|
+
value: e,
|
|
45
|
+
label: e
|
|
46
|
+
} : null;
|
|
47
|
+
},
|
|
42
48
|
set: (e) => {
|
|
43
|
-
|
|
49
|
+
if (e == null) {
|
|
50
|
+
V(null, M.modelValue?.direction ?? "asc");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
Array.isArray(e) || V(e.value ?? null, M.modelValue?.direction ?? "asc");
|
|
44
54
|
}
|
|
45
55
|
}), z = a({
|
|
46
56
|
get: () => M.modelValue?.direction ?? "asc",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admins-components83.js","names":[],"sources":["../src/components/data-table/DataSort.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type SortDirection = 'asc' | 'desc'\n\nexport interface DataSortOption {\n value: string\n label: string\n icon?: string\n}\n\nexport interface DataSortProps {\n modelValue: { key: string; direction: SortDirection } | null\n options: DataSortOption[]\n placeholder?: string\n handleUrl?: boolean\n disabled?: boolean\n}\n\nexport function getDefaultSort(): { key: string; direction: SortDirection } | null {\n if (typeof window === 'undefined') return null\n const params = new URLSearchParams(window.location.search)\n const key = params.get('sortBy')\n const dir = params.get('sortDir')\n if (key && (dir === 'asc' || dir === 'desc')) {\n return { key, direction: dir }\n }\n return null\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, ref, watch } from 'vue'\nimport DropdownSelect from '@/components/DropdownSelect.vue'\nimport { useDropdownAnchor } from '@/composables/useDropdownAnchor'\nimport { writeUrlOrRemove } from '@/utils/url'\nimport Button from '../Button.vue'\n\nconst props = withDefaults(defineProps<DataSortProps>(), {\n placeholder: 'Rendezés...',\n handleUrl: false,\n disabled: false\n})\n\nconst emit = defineEmits<{\n 'update:modelValue': [sort: { key: string; direction: SortDirection } | null]\n 'sort-change': [sort: { key: string; direction: SortDirection } | null]\n}>()\n\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst dropdownRef = ref<HTMLElement | null>(null)\nconst { isOpen, dropdownStyle } = useDropdownAnchor(wrapperRef, dropdownRef, {\n extraStyle: (rect) => ({ minWidth: `${Math.max(rect.width, 240)}px` }),\n closeOnScroll: true,\n})\n\nconst sortBy = computed<string | string[] | null>({\n get: () => props.modelValue?.key ?? null,\n set: (v) => {\n if (Array.isArray(v)) return\n emitChange(v, props.modelValue?.direction ?? 'asc')\n },\n})\n\nconst direction = computed<SortDirection>({\n get: () => props.modelValue?.direction ?? 'asc',\n set: (d) => emitChange(props.modelValue?.key ?? null, d),\n})\n\nconst activeLabel = computed(() => {\n if (!props.modelValue) return props.placeholder\n const opt = props.options.find((o) => o.value === props.modelValue!.key)\n const label = opt?.label ?? props.modelValue.key\n return `${label} (${props.modelValue.direction === 'asc' ? 'növekvő' : 'csökkenő'})`\n})\n\nfunction emitChange(key: string | null, dir: SortDirection) {\n if (key == null) {\n if (props.handleUrl) {\n writeUrlOrRemove('sortBy', null, { handleUrl: true })\n writeUrlOrRemove('sortDir', null, { handleUrl: true })\n }\n emit('update:modelValue', null)\n emit('sort-change', null)\n return\n }\n if (props.handleUrl) {\n writeUrlOrRemove('sortBy', key, { handleUrl: true })\n writeUrlOrRemove('sortDir', dir, { handleUrl: true, default: 'asc' })\n }\n const next = { key, direction: dir }\n emit('update:modelValue', next)\n emit('sort-change', next)\n}\n\nfunction clear() {\n emitChange(null, 'asc')\n isOpen.value = false\n}\n\n// Read initial state from URL on mount when handleUrl is true and modelValue is empty.\nwatch(\n isOpen,\n (open) => {\n if (!open || !props.handleUrl || props.modelValue) return\n const sort = getDefaultSort()\n if (sort) emitChange(sort.key, sort.direction)\n },\n { immediate: true },\n)\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"ds-sort-wrapper\">\n <button\n type=\"button\"\n class=\"c-btn ds-sort-trigger lh-1\"\n :class=\"[modelValue && 'is-active', disabled && 'is-disabled', isOpen && 'is-open']\"\n :disabled=\"disabled\"\n :aria-label=\"`Rendezés: ${activeLabel}`\"\n @click=\"isOpen = !isOpen\"\n >\n <i\n class=\"fa-solid fa-fw\"\n :class=\"\n !modelValue || modelValue.direction === 'asc'\n ? 'fa-arrow-up-wide-short'\n : 'fa-arrow-down-wide-short'\n \"\n ></i>\n <span class=\"ds-sort-label c-truncate\">{{ activeLabel }}</span>\n <button\n v-if=\"modelValue\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-sort-clear\"\n aria-label=\"Rendezés törlése\"\n title=\"Rendezés törlése\"\n @click.stop=\"clear\"\n >\n <i class=\"fa-solid fa-fw fa-xmark\"></i>\n </button>\n <span\n class=\"c-icon-btn c-icon-btn--chevron\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </button>\n\n <Teleport to=\"body\">\n <div class=\"ac-component\">\n <div v-if=\"isOpen\" ref=\"dropdownRef\" class=\"ds-sort-panel\" :style=\"dropdownStyle\">\n\n <div class=\"ds-sort-panel__row\">\n <label class=\"ds-sort-panel__label\">Oszlop</label>\n <DropdownSelect\n :model-value=\"sortBy\"\n :options=\"options\"\n :config=\"{\n clearable: false,\n placeholder: 'Válassz oszlopot...',\n filterable: false,\n }\"\n @update:model-value=\"(v) => (sortBy = v)\"\n />\n </div>\n\n <div class=\"ds-sort-panel__row\">\n <span class=\"ds-sort-panel__label\">Irány</span>\n <div class=\"ds-sort-direction\" role=\"group\" aria-label=\"Rendezés iránya\">\n <button\n type=\"button\"\n class=\"ds-sort-direction__btn\"\n :class=\"{ 'is-active': direction === 'asc' }\"\n :aria-pressed=\"direction === 'asc'\"\n aria-label=\"Növekvő\"\n @click=\"direction = 'asc'\"\n >\n <i class=\"fa-solid fa-fw fa-arrow-up-wide-short\"></i>\n <span>Növekvő</span>\n </button>\n <button\n type=\"button\"\n class=\"ds-sort-direction__btn dir-desc\"\n :class=\"{ 'is-active': direction === 'desc' }\"\n :aria-pressed=\"direction === 'desc'\"\n aria-label=\"Csökkenő\"\n @click=\"direction = 'desc'\"\n >\n <i class=\"fa-solid fa-fw fa-arrow-down-wide-short\"></i>\n <span>Csökkenő</span>\n </button>\n </div>\n </div>\n\n <div class=\"ds-sort-panel__footer\">\n <Button label=\"Rendben\" outline size=\"small\" @click=\"isOpen = false\" />\n </div>\n </div>\n </div>\n </Teleport>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\" src=\"@/styles/components/data-table/data-sort.scss\"></style>\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,IAAmE;CACjF,IAAI,OAAO,SAAW,KAAa,OAAO;CAC1C,IAAM,IAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM,GACnD,IAAM,EAAO,IAAI,QAAQ,GACzB,IAAM,EAAO,IAAI,SAAS;CAIhC,OAHI,MAAQ,MAAQ,SAAS,MAAQ,UAC5B;EAAE;EAAK,WAAW;CAAI,IAExB;AACT;;;;;;;;;;;;;;;;;;EAUA,IAAM,IAAQ,GAMR,IAAO,GAKP,IAAa,EAAwB,IAAI,GACzC,IAAc,EAAwB,IAAI,GAC1C,EAAE,WAAQ,qBAAkB,EAAkB,GAAY,GAAa;GAC3E,aAAa,OAAU,EAAE,UAAU,GAAG,KAAK,IAAI,EAAK,OAAO,GAAG,EAAE,IAAI;GACpE,eAAe;EACjB,CAAC,GAEK,IAAS,EAAmC;GAChD,WAAW,EAAM,YAAY,OAAO;GACpC,MAAM,MAAM;IACN,MAAM,QAAQ,CAAC,KACnB,EAAW,GAAG,EAAM,YAAY,aAAa,KAAK;GACpD;EACF,CAAC,GAEK,IAAY,EAAwB;GACxC,WAAW,EAAM,YAAY,aAAa;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M,uBAAsB,GAAC,SAAK,EAAA,GACxC,EAuBM,OAvBN,GAuBM,CAtBJ,EAUS,UAAA;IATP,MAAK;IACL,OAAK,EAAA,CAAC,0BAAwB,EAAA,aACP,EAAA,UAAS,MAAA,CAAA,CAAA;IAC/B,gBAAc,EAAA,UAAS;IACxB,cAAW;IACV,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,QAAS;oBAEjB,EAAqD,KAAA,EAAlD,OAAM,wCAAuC,GAAA,MAAA,EAAA,GAChD,EAAoB,QAAA,MAAd,WAAO,EAAA,CAAA,CAAA,GAAA,IAAA,CAAA,GAEf,EAUS,UAAA;IATP,MAAK;IACL,OAAK,EAAA,CAAC,mCAAiC,EAAA,aAChB,EAAA,UAAS,OAAA,CAAA,CAAA;IAC/B,gBAAc,EAAA,UAAS;IACxB,cAAW;IACV,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,QAAS;oBAEjB,EAAuD,KAAA,EAApD,OAAM,0CAAyC,GAAA,MAAA,EAAA,GAClD,EAAqB,QAAA,MAAf,YAAQ,EAAA,CAAA,CAAA,GAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA;GAKpB,EAEM,OAFN,GAEM,CADJ,EAAuE,GAAA;IAA/D,OAAM;IAAU,SAAA;IAAQ,MAAK;IAAS,SAAK,AAAA,EAAA,QAAA,MAAE,EAAA,QAAM"}
|
|
1
|
+
{"version":3,"file":"admins-components83.js","names":[],"sources":["../src/components/data-table/DataSort.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type SortDirection = 'asc' | 'desc'\n\nexport interface DataSortOption {\n value: string\n label: string\n icon?: string\n}\n\nexport interface DataSortProps {\n modelValue: { key: string; direction: SortDirection } | null\n options: DataSortOption[]\n placeholder?: string\n handleUrl?: boolean\n disabled?: boolean\n}\n\nexport function getDefaultSort(): { key: string; direction: SortDirection } | null {\n if (typeof window === 'undefined') return null\n const params = new URLSearchParams(window.location.search)\n const key = params.get('sortBy')\n const dir = params.get('sortDir')\n if (key && (dir === 'asc' || dir === 'desc')) {\n return { key, direction: dir }\n }\n return null\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, ref, watch } from 'vue'\nimport DropdownSelect, { type DropdownOption } from '@/components/DropdownSelect.vue'\nimport { useDropdownAnchor } from '@/composables/useDropdownAnchor'\nimport { writeUrlOrRemove } from '@/utils/url'\nimport Button from '../Button.vue'\n\nconst props = withDefaults(defineProps<DataSortProps>(), {\n placeholder: 'Rendezés...',\n handleUrl: false,\n disabled: false\n})\n\nconst emit = defineEmits<{\n 'update:modelValue': [sort: { key: string; direction: SortDirection } | null]\n 'sort-change': [sort: { key: string; direction: SortDirection } | null]\n}>()\n\nconst wrapperRef = ref<HTMLElement | null>(null)\nconst dropdownRef = ref<HTMLElement | null>(null)\nconst { isOpen, dropdownStyle } = useDropdownAnchor(wrapperRef, dropdownRef, {\n extraStyle: (rect) => ({ minWidth: `${Math.max(rect.width, 240)}px` }),\n closeOnScroll: true,\n})\n\nconst sortBy = computed<DropdownOption | DropdownOption[] | null>({\n get: () => {\n const key = props.modelValue?.key\n if (!key) return null\n const opt = props.options.find((o) => o.value === key)\n return opt ?? { value: key, label: key }\n },\n set: (v) => {\n if (v == null) {\n emitChange(null, props.modelValue?.direction ?? 'asc')\n return\n }\n if (Array.isArray(v)) return\n emitChange(v.value ?? null, props.modelValue?.direction ?? 'asc')\n },\n})\n\nconst direction = computed<SortDirection>({\n get: () => props.modelValue?.direction ?? 'asc',\n set: (d) => emitChange(props.modelValue?.key ?? null, d),\n})\n\nconst activeLabel = computed(() => {\n if (!props.modelValue) return props.placeholder\n const opt = props.options.find((o) => o.value === props.modelValue!.key)\n const label = opt?.label ?? props.modelValue.key\n return `${label} (${props.modelValue.direction === 'asc' ? 'növekvő' : 'csökkenő'})`\n})\n\nfunction emitChange(key: string | null, dir: SortDirection) {\n if (key == null) {\n if (props.handleUrl) {\n writeUrlOrRemove('sortBy', null, { handleUrl: true })\n writeUrlOrRemove('sortDir', null, { handleUrl: true })\n }\n emit('update:modelValue', null)\n emit('sort-change', null)\n return\n }\n if (props.handleUrl) {\n writeUrlOrRemove('sortBy', key, { handleUrl: true })\n writeUrlOrRemove('sortDir', dir, { handleUrl: true, default: 'asc' })\n }\n const next = { key, direction: dir }\n emit('update:modelValue', next)\n emit('sort-change', next)\n}\n\nfunction clear() {\n emitChange(null, 'asc')\n isOpen.value = false\n}\n\n// Read initial state from URL on mount when handleUrl is true and modelValue is empty.\nwatch(\n isOpen,\n (open) => {\n if (!open || !props.handleUrl || props.modelValue) return\n const sort = getDefaultSort()\n if (sort) emitChange(sort.key, sort.direction)\n },\n { immediate: true },\n)\n</script>\n\n<template>\n <div class=\"ac-component\">\n <div ref=\"wrapperRef\" class=\"ds-sort-wrapper\">\n <button\n type=\"button\"\n class=\"c-btn ds-sort-trigger lh-1\"\n :class=\"[modelValue && 'is-active', disabled && 'is-disabled', isOpen && 'is-open']\"\n :disabled=\"disabled\"\n :aria-label=\"`Rendezés: ${activeLabel}`\"\n @click=\"isOpen = !isOpen\"\n >\n <i\n class=\"fa-solid fa-fw\"\n :class=\"\n !modelValue || modelValue.direction === 'asc'\n ? 'fa-arrow-up-wide-short'\n : 'fa-arrow-down-wide-short'\n \"\n ></i>\n <span class=\"ds-sort-label c-truncate\">{{ activeLabel }}</span>\n <button\n v-if=\"modelValue\"\n type=\"button\"\n class=\"c-icon-btn c-icon-btn--clear ds-sort-clear\"\n aria-label=\"Rendezés törlése\"\n title=\"Rendezés törlése\"\n @click.stop=\"clear\"\n >\n <i class=\"fa-solid fa-fw fa-xmark\"></i>\n </button>\n <span\n class=\"c-icon-btn c-icon-btn--chevron\"\n :class=\"{ 'c-icon-btn--chevron-open': isOpen }\"\n >\n <i class=\"fa-solid fa-fw fa-chevron-down\"></i>\n </span>\n </button>\n\n <Teleport to=\"body\">\n <div class=\"ac-component\">\n <div v-if=\"isOpen\" ref=\"dropdownRef\" class=\"ds-sort-panel\" :style=\"dropdownStyle\">\n\n <div class=\"ds-sort-panel__row\">\n <label class=\"ds-sort-panel__label\">Oszlop</label>\n <DropdownSelect\n :model-value=\"sortBy\"\n :options=\"options\"\n :config=\"{\n clearable: false,\n placeholder: 'Válassz oszlopot...',\n filterable: false,\n }\"\n @update:model-value=\"(v) => (sortBy = v)\"\n />\n </div>\n\n <div class=\"ds-sort-panel__row\">\n <span class=\"ds-sort-panel__label\">Irány</span>\n <div class=\"ds-sort-direction\" role=\"group\" aria-label=\"Rendezés iránya\">\n <button\n type=\"button\"\n class=\"ds-sort-direction__btn\"\n :class=\"{ 'is-active': direction === 'asc' }\"\n :aria-pressed=\"direction === 'asc'\"\n aria-label=\"Növekvő\"\n @click=\"direction = 'asc'\"\n >\n <i class=\"fa-solid fa-fw fa-arrow-up-wide-short\"></i>\n <span>Növekvő</span>\n </button>\n <button\n type=\"button\"\n class=\"ds-sort-direction__btn dir-desc\"\n :class=\"{ 'is-active': direction === 'desc' }\"\n :aria-pressed=\"direction === 'desc'\"\n aria-label=\"Csökkenő\"\n @click=\"direction = 'desc'\"\n >\n <i class=\"fa-solid fa-fw fa-arrow-down-wide-short\"></i>\n <span>Csökkenő</span>\n </button>\n </div>\n </div>\n\n <div class=\"ds-sort-panel__footer\">\n <Button label=\"Rendben\" outline size=\"small\" @click=\"isOpen = false\" />\n </div>\n </div>\n </div>\n </Teleport>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\" src=\"@/styles/components/data-table/data-sort.scss\"></style>\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,IAAmE;CACjF,IAAI,OAAO,SAAW,KAAa,OAAO;CAC1C,IAAM,IAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM,GACnD,IAAM,EAAO,IAAI,QAAQ,GACzB,IAAM,EAAO,IAAI,SAAS;CAIhC,OAHI,MAAQ,MAAQ,SAAS,MAAQ,UAC5B;EAAE;EAAK,WAAW;CAAI,IAExB;AACT;;;;;;;;;;;;;;;;;;EAUA,IAAM,IAAQ,GAMR,IAAO,GAKP,IAAa,EAA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