@oneb/ui-vue 0.3.27 → 0.3.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,68 +1,735 @@
1
- import { defineComponent as ge, computed as f, ref as g, onMounted as me, onUnmounted as pe, watch as te, openBlock as l, createElementBlock as a, Fragment as le, createElementVNode as s, normalizeClass as u, renderSlot as m, unref as V, toDisplayString as d, createCommentVNode as c, createBlock as $, resolveDynamicComponent as ne, createTextVNode as z, withModifiers as ae, withCtx as ke, withDirectives as be, vModelText as Ce, renderList as we, createVNode as Se, nextTick as Ee } from "vue";
2
- import { u as Ve, O as Le } from "../useModal-85f57682.js";
3
- import { _ as se } from "../OneAvatar.vue_vue_type_script_setup_true_lang-08ab80dd.js";
1
+ import { defineComponent as M, openBlock as a, createBlock as F, unref as d, withCtx as E, createElementBlock as o, renderSlot as f, createCommentVNode as C, computed as S, normalizeClass as v, toDisplayString as x, createElementVNode as r, normalizeStyle as X, resolveDynamicComponent as H, withModifiers as Q, createTextVNode as G, ref as I, onMounted as ne, onUnmounted as ae, watch as Y, nextTick as ie, createVNode as q, Fragment as Z, renderList as se, createSlots as R, normalizeProps as oe, guardReactiveProps as re, isRef as de } from "vue";
2
+ import { O as ue, u as ce } from "../useModal-85f57682.js";
3
+ import { _ as D } from "../OneAvatar.vue_vue_type_script_setup_true_lang-08ab80dd.js";
4
4
  import "vue-markdown-render";
5
5
  import "../OneMarkdown.vue_vue_type_style_index_0_lang-4ed993c7.js";
6
6
  import "../SpinnerIcon.vue_vue_type_style_index_0_lang-4ed993c7.js";
7
- import { useOnebI18n as Be } from "../i18n/index.js";
7
+ import { useOnebI18n as ye } from "../i18n/index.js";
8
8
  import "../_plugin-vue_export-helper-dad06003.js";
9
- const Me = { key: 0 }, Ae = { class: "" }, qe = {
10
- key: 0,
11
- class: "space-y-1 flex flex-col"
12
- }, je = {
13
- key: 0,
14
- class: "text-gray-400 text-xs font-light"
15
- }, $e = {
16
- key: 0,
17
- class: "text-[10px] text-gray-500 ml-1 py-0.5 rounded-full font-semibold hover:text-info-base"
18
- }, ze = {
9
+ const fe = {
19
10
  key: 0,
20
11
  class: "overflow-auto max-h-[85dvh] h-full"
21
- }, Oe = {
12
+ }, ve = {
22
13
  key: 1,
23
14
  class: "overflow-auto max-h-[85dvh] h-full"
24
- }, Ie = {
15
+ }, me = {
25
16
  key: 2,
26
17
  class: "pb-6"
27
- }, Ne = {
18
+ }, ge = {
28
19
  key: 0,
29
20
  class: "px-2 pt-3"
30
- }, Te = {
31
- key: 1,
32
- class: "relative px-3 py-3"
33
- }, Ke = { class: "relative" }, Pe = ["placeholder"], Ue = {
34
- key: 2,
35
- class: "px-2 py-3 h-[62px]"
36
- }, Fe = {
21
+ }, be = /* @__PURE__ */ M({
22
+ __name: "EntityPickerModal",
23
+ props: {
24
+ useModal: {
25
+ type: Object,
26
+ required: !0
27
+ },
28
+ title: { type: String, default: "" },
29
+ titleCenter: { type: Boolean, default: !1 },
30
+ size: {
31
+ type: String,
32
+ default: "sm"
33
+ },
34
+ mobileView: { type: Boolean, default: !1 },
35
+ view: {
36
+ type: String,
37
+ default: "browse"
38
+ }
39
+ },
40
+ setup(e) {
41
+ return (l, t) => e.useModal.isOpened.value ? (a(), F(d(ue), {
42
+ key: 0,
43
+ useModal: e.useModal,
44
+ title: e.title,
45
+ size: e.size,
46
+ classModal: e.mobileView,
47
+ titleCenter: e.titleCenter
48
+ }, {
49
+ default: E(() => [
50
+ e.view === "create" ? (a(), o("div", fe, [
51
+ f(l.$slots, "create")
52
+ ])) : e.view === "edit" ? (a(), o("div", ve, [
53
+ f(l.$slots, "edit")
54
+ ])) : (a(), o("div", me, [
55
+ l.$slots.header ? (a(), o("div", ge, [
56
+ f(l.$slots, "header")
57
+ ])) : C("", !0),
58
+ f(l.$slots, "search"),
59
+ f(l.$slots, "prepend"),
60
+ f(l.$slots, "createButton"),
61
+ f(l.$slots, "list")
62
+ ]))
63
+ ]),
64
+ _: 3
65
+ }, 8, ["useModal", "title", "size", "classModal", "titleCenter"])) : C("", !0);
66
+ }
67
+ }), he = {
37
68
  key: 0,
38
- class: "flex items-center justify-center py-8"
39
- }, Ge = {
40
- key: 1,
41
- class: "relative px-5 py-10 text-center"
42
- }, He = { class: "mb-4 text-sm text-gray-500" }, We = {
43
- key: 2,
44
- class: "p-3 text-center mt-6"
45
- }, Je = { class: "text-xs" }, Re = ["onClick"], Xe = { class: "mr-2" }, Ye = { class: "w-full" }, Ze = { class: "font-bold truncate overflow-hidden sm:max-w-[400px] max-w-[280px] text-xs" }, Qe = {
69
+ class: "relative select-none inline-flex items-center gap-3"
70
+ }, ke = { class: "text-sm font-medium truncate text-inherit" }, Se = ["aria-label"], Ce = {
46
71
  key: 0,
47
- class: "text-xs text-gray-600 divide-x font-thin"
48
- }, De = { class: "px-2 first:pl-0" }, _e = ["onClick"], et = {
72
+ class: "w-4 h-4",
73
+ fill: "none",
74
+ viewBox: "0 0 24 24",
75
+ stroke: "currentColor",
76
+ "stroke-width": "2"
77
+ }, xe = {
49
78
  key: 1,
50
- class: "w-5 h-5 text-green-500 flex-shrink-0",
79
+ class: "w-4 h-4",
51
80
  fill: "none",
52
81
  viewBox: "0 0 24 24",
53
82
  stroke: "currentColor",
54
83
  "stroke-width": "2"
55
- }, tt = {
56
- key: 2,
57
- class: "w-5 h-5 text-gray-400 flex-shrink-0",
84
+ }, Ee = { key: 0 }, Le = { class: "" }, we = {
85
+ key: 0,
86
+ class: "space-y-1 flex flex-col"
87
+ }, $e = {
88
+ key: 0,
89
+ class: "text-gray-400 text-xs font-light"
90
+ }, Ve = {
91
+ key: 0,
92
+ class: "text-[10px] text-gray-500 ml-1 py-0.5 rounded-full font-semibold hover:text-info-base"
93
+ }, Ae = /* @__PURE__ */ M({
94
+ __name: "EntityPickerTrigger",
95
+ props: {
96
+ variant: {
97
+ type: String,
98
+ default: "default"
99
+ },
100
+ modelValue: { type: [Object, null], default: null },
101
+ icon: { type: [Object, Function, null], default: null },
102
+ title: { type: String, default: "" },
103
+ labelSelect: { type: String, default: "" },
104
+ labelSelectNote: { type: String, default: "" },
105
+ labelClass: { type: String, default: "" },
106
+ iconClass: { type: String, default: "" },
107
+ iconClassBlock: { type: String, default: "" },
108
+ noIcon: { type: Boolean, default: !1 },
109
+ readonly: { type: Boolean, default: !1 },
110
+ tagColor: { type: String, default: "#525B66" },
111
+ changeLabel: { type: String, default: "" },
112
+ resolvers: { type: Object, required: !0 }
113
+ },
114
+ emits: ["open", "clear"],
115
+ setup(e, { emit: l }) {
116
+ const t = e, n = l, m = () => n("open"), i = S(() => t.variant === "compact" || t.variant === "minimal"), g = S(() => t.variant === "compact"), c = S(() => t.variant === "pill"), y = S(() => t.modelValue == null ? {} : { backgroundColor: `${t.tagColor}1A` }), L = S(
117
+ () => t.modelValue != null ? t.tagColor : "#979CA9"
118
+ );
119
+ return (s, h) => e.variant === "tag" ? (a(), o("div", he, [
120
+ f(s.$slots, "button", {
121
+ title: e.title,
122
+ modelValue: e.modelValue,
123
+ openModal: m
124
+ }, () => [
125
+ e.title ? (a(), o("p", {
126
+ key: 0,
127
+ class: v(["font-semibold text-black", e.labelClass])
128
+ }, x(e.title), 3)) : C("", !0),
129
+ r("div", {
130
+ class: v([
131
+ "flex items-center gap-2 h-10 px-3 rounded-xl transition-colors",
132
+ e.readonly ? "" : "cursor-pointer",
133
+ e.modelValue == null ? "bg-[#FAFAFA] hover:bg-gray-100 text-[#979CA9]" : "hover:opacity-90 text-black"
134
+ ]),
135
+ style: X(y.value),
136
+ onClick: m
137
+ }, [
138
+ e.icon ? (a(), F(H(e.icon), {
139
+ key: 0,
140
+ class: v(["w-5 h-5 flex-shrink-0", e.iconClass]),
141
+ style: X({ color: L.value })
142
+ }, null, 8, ["style", "class"])) : C("", !0),
143
+ r("span", ke, x(e.modelValue != null ? e.resolvers.getEntityLabel(e.modelValue) : e.labelSelect), 1),
144
+ e.readonly ? C("", !0) : (a(), o("button", {
145
+ key: 1,
146
+ type: "button",
147
+ class: "text-[#979CA9] hover:text-gray-700 flex-shrink-0 -mr-1",
148
+ "aria-label": e.changeLabel,
149
+ onClick: h[0] || (h[0] = Q((w) => e.modelValue != null ? s.$emit("clear") : m(), ["stop"]))
150
+ }, [
151
+ e.modelValue != null ? (a(), o("svg", Ce, [...h[2] || (h[2] = [
152
+ r("path", {
153
+ "stroke-linecap": "round",
154
+ "stroke-linejoin": "round",
155
+ d: "M6 18L18 6M6 6l12 12"
156
+ }, null, -1)
157
+ ])])) : (a(), o("svg", xe, [...h[3] || (h[3] = [
158
+ r("path", {
159
+ "stroke-linecap": "round",
160
+ "stroke-linejoin": "round",
161
+ d: "M19.5 8.25l-7.5 7.5-7.5-7.5"
162
+ }, null, -1)
163
+ ])]))
164
+ ], 8, Se))
165
+ ], 6)
166
+ ])
167
+ ])) : (a(), o("div", {
168
+ key: 1,
169
+ class: v(["relative select-none", i.value ? "space-y-1.5" : "space-y-3"])
170
+ }, [
171
+ f(s.$slots, "button", {
172
+ title: e.title,
173
+ modelValue: e.modelValue,
174
+ openModal: m
175
+ }, () => [
176
+ e.title ? (a(), o("p", {
177
+ key: 0,
178
+ class: v(["font-semibold pb-0", e.labelClass])
179
+ }, x(e.title), 3)) : C("", !0),
180
+ r("div", {
181
+ class: v(["flex justify-between z-10 items-center", [
182
+ e.readonly ? "" : "cursor-pointer hover:bg-gray-50",
183
+ i.value ? ["rounded-full", g.value ? "bg-[#4089E01A]" : ""] : "border px-3 pr-3 py-3 rounded-lg h-[72px]",
184
+ c.value ? "border-none !py-0 h-max !rounded-full" : "",
185
+ c.value && e.modelValue !== null ? "bg-[#4089E01A]" : ""
186
+ ]])
187
+ }, [
188
+ r("div", {
189
+ class: v(["flex items-center w-full gap-x-3", [i.value ? "!gap-x-1 px-0.5 py-0.5" : "", c.value ? "h-9 p-0" : ""]]),
190
+ onClick: m
191
+ }, [
192
+ !e.noIcon && (c.value || i.value || e.icon || e.modelValue) ? (a(), o("div", {
193
+ key: 0,
194
+ class: v(["w-10 h-10 flex items-center justify-center", e.iconClassBlock])
195
+ }, [
196
+ c.value ? (a(), o("div", Ee, [
197
+ e.modelValue == null ? (a(), o("svg", {
198
+ key: 0,
199
+ class: v(["w-3 text-blue-600", e.iconClass]),
200
+ fill: "none",
201
+ viewBox: "0 0 24 24",
202
+ stroke: "currentColor",
203
+ "stroke-width": "2"
204
+ }, [...h[4] || (h[4] = [
205
+ r("path", {
206
+ "stroke-linecap": "round",
207
+ "stroke-linejoin": "round",
208
+ d: "M12 4.5v15m7.5-7.5h-15"
209
+ }, null, -1)
210
+ ])], 2)) : (a(), F(H(e.icon), {
211
+ key: 1,
212
+ class: v(["w-5", e.iconClass])
213
+ }, null, 8, ["class"]))
214
+ ])) : e.icon != null && e.modelValue == null || i.value ? (a(), o("div", {
215
+ key: 1,
216
+ class: v(i.value ? "" : "bg-gray-50 p-2.5 rounded-lg")
217
+ }, [
218
+ (a(), F(H(e.icon), {
219
+ class: v([["w-5", e.iconClass], "text-gray-600"])
220
+ }, null, 8, ["class"]))
221
+ ], 2)) : e.modelValue ? (a(), F(d(D), {
222
+ key: 2,
223
+ text: e.resolvers.getEntityLabel(e.modelValue),
224
+ src: e.resolvers.getEntityAvatar(e.modelValue),
225
+ rounded: !1,
226
+ size: "40",
227
+ class: "!rounded-lg"
228
+ }, null, 8, ["text", "src"])) : C("", !0)
229
+ ], 2)) : C("", !0),
230
+ r("div", Le, [
231
+ e.modelValue == null ? (a(), o("div", we, [
232
+ r("div", {
233
+ class: v(["font-medium text-gray-600 truncate overflow-hidden whitespace-nowrap", [
234
+ i.value ? "text-xs truncate max-w-[120px] text-[#525B66]" : "text-sm",
235
+ c.value ? "!text-xs truncate max-w-[120px] text-[#4089E0]" : ""
236
+ ]])
237
+ }, x(e.labelSelect), 3),
238
+ e.labelSelectNote && !i.value && !c.value ? (a(), o("span", $e, x(e.labelSelectNote), 1)) : C("", !0)
239
+ ])) : (a(), o("div", {
240
+ key: 1,
241
+ class: v(["grid items-center pr-2", i.value ? "" : "py-1"])
242
+ }, [
243
+ r("div", {
244
+ class: v(["break-all leading-4 truncate !text-sm", {
245
+ "text-sm font-medium": e.resolvers.getEntityLabel(e.modelValue).length < 20,
246
+ "text-xs font-semibold": e.resolvers.getEntityLabel(e.modelValue).length > 20,
247
+ "truncate text-[#525B66] text-xs": i.value,
248
+ "truncate text-xs": c.value
249
+ }])
250
+ }, [
251
+ G(x(e.resolvers.getEntityLabel(e.modelValue)) + " ", 1),
252
+ !e.readonly && !i.value && !c.value ? (a(), o("span", Ve, x(e.changeLabel), 1)) : C("", !0)
253
+ ], 2),
254
+ e.resolvers.getEntityAdditional(e.modelValue) ? (a(), o("div", {
255
+ key: 0,
256
+ class: v(["font-thin leading-3 break-all line-clamp-2 pt-1 truncate !text-xs", {
257
+ "text-xs": e.resolvers.getEntityAdditional(e.modelValue).length < 20,
258
+ "text-[10px]": e.resolvers.getEntityAdditional(e.modelValue).length > 20 && e.resolvers.getEntityAdditional(e.modelValue).length < 35,
259
+ "text-[9px]": e.resolvers.getEntityAdditional(e.modelValue).length > 35
260
+ }])
261
+ }, [
262
+ f(s.$slots, "entityAdditional", { item: e.modelValue }, () => [
263
+ G(x(e.resolvers.getEntityAdditional(e.modelValue)), 1)
264
+ ])
265
+ ], 2)) : C("", !0)
266
+ ], 2))
267
+ ])
268
+ ], 2),
269
+ e.modelValue != null && !e.readonly ? (a(), o("button", {
270
+ key: 0,
271
+ type: "button",
272
+ class: v(["rounded-full hover:text-gray-900 text-gray-500", { "mr-2 text-[#525B66] p-0.5": i.value }]),
273
+ onClick: h[1] || (h[1] = Q((w) => s.$emit("clear"), ["stop"]))
274
+ }, [...h[5] || (h[5] = [
275
+ r("svg", {
276
+ class: "w-4 h-4",
277
+ fill: "none",
278
+ viewBox: "0 0 24 24",
279
+ stroke: "currentColor",
280
+ "stroke-width": "2"
281
+ }, [
282
+ r("path", {
283
+ "stroke-linecap": "round",
284
+ "stroke-linejoin": "round",
285
+ d: "M6 18L18 6M6 6l12 12"
286
+ })
287
+ ], -1)
288
+ ])], 2)) : !e.readonly && !i.value && !c.value ? (a(), o("button", {
289
+ key: 1,
290
+ type: "button",
291
+ class: "py-2.5 text-gray-500",
292
+ onClick: m
293
+ }, [...h[6] || (h[6] = [
294
+ r("svg", {
295
+ class: "w-5 h-5",
296
+ fill: "none",
297
+ viewBox: "0 0 24 24",
298
+ stroke: "currentColor",
299
+ "stroke-width": "2"
300
+ }, [
301
+ r("path", {
302
+ "stroke-linecap": "round",
303
+ "stroke-linejoin": "round",
304
+ d: "M8.25 4.5l7.5 7.5-7.5 7.5"
305
+ })
306
+ ], -1)
307
+ ])])) : C("", !0)
308
+ ], 2)
309
+ ])
310
+ ], 2));
311
+ }
312
+ });
313
+ function Ie(e) {
314
+ const l = (s) => s ? String(s[e.entityLabel] || "") : "", t = (s) => !s || !e.entityAvatar ? "" : String(s[e.entityAvatar] || ""), n = (s) => !s || !e.entityAdditional ? "" : String(s[e.entityAdditional] || ""), m = (s) => s ? s[e.entityKey] : "", i = (s) => s[e.entityListKey];
315
+ return {
316
+ getEntityLabel: l,
317
+ getEntityAvatar: t,
318
+ getEntityAdditional: n,
319
+ getEntityKey: m,
320
+ getEntityListKey: i,
321
+ getEntityListLabel: (s) => String(s[e.entityListLabel] || ""),
322
+ getEntityListAvatar: (s) => e.entityListAvatar ? String(s[e.entityListAvatar] || "") : "",
323
+ getEntityListAdditional: (s) => e.entityListAdditional ? String(s[e.entityListAdditional] || "") : "",
324
+ isSelected: (s) => m(e.modelValue) === i(s)
325
+ };
326
+ }
327
+ function Be(e, l) {
328
+ const t = e.listEntityUse ? e.listEntityUse() : null, n = t == null ? void 0 : t.nodes, m = t == null ? void 0 : t.load, i = t == null ? void 0 : t.searchTerm, g = t == null ? void 0 : t.isLoading, c = t == null ? void 0 : t.isLoad, y = t == null ? void 0 : t.group, L = I(null), s = S(() => (y == null ? void 0 : y.value) ?? L.value), h = (k) => {
329
+ y ? y.value = k : L.value = k;
330
+ }, w = I(""), T = S({
331
+ get: () => (i == null ? void 0 : i.value) ?? w.value,
332
+ set: (k) => {
333
+ i ? i.value = k : w.value = k;
334
+ }
335
+ }), O = () => {
336
+ w.value = "", i && (i.value = "");
337
+ }, P = S(() => (g == null ? void 0 : g.value) ?? e.isLoading), z = S(() => (n == null ? void 0 : n.value) ?? e.items), u = S(() => {
338
+ const k = z.value;
339
+ if (e.modelValue == null)
340
+ return k;
341
+ const B = l.getEntityKey(e.modelValue);
342
+ return k.some(
343
+ ($) => l.getEntityListKey($) === B
344
+ ) ? k : [e.modelValue, ...k];
345
+ }), j = S(() => {
346
+ if (!T.value)
347
+ return u.value;
348
+ const k = T.value.toLowerCase(), B = e.modelValue != null ? l.getEntityKey(e.modelValue) : null;
349
+ return u.value.filter((V) => {
350
+ if (B != null && l.getEntityListKey(V) === B)
351
+ return !0;
352
+ const $ = l.getEntityListLabel(V).toLowerCase(), K = l.getEntityListAdditional(V).toLowerCase();
353
+ return $.includes(k) || K.includes(k);
354
+ });
355
+ }), W = S(() => {
356
+ const k = j.value;
357
+ if (e.modelValue == null)
358
+ return k;
359
+ const B = l.getEntityKey(e.modelValue), V = k.findIndex(
360
+ (N) => l.getEntityListKey(N) === B
361
+ );
362
+ if (V <= 0)
363
+ return k;
364
+ const $ = k.slice(), [K] = $.splice(V, 1);
365
+ return $.unshift(K), $;
366
+ });
367
+ return {
368
+ // dynamic data hooks (exposed for modal lifecycle watchers)
369
+ load: m,
370
+ dynamicIsLoad: c,
371
+ nodes: n,
372
+ // search
373
+ searchTerm: T,
374
+ clearSearchTerm: O,
375
+ // group selection (for prepend slot)
376
+ selectedGroup: s,
377
+ setSelectedGroup: h,
378
+ // items pipeline
379
+ rawItems: z,
380
+ availableItems: u,
381
+ filteredItems: j,
382
+ sortedItems: W,
383
+ // state
384
+ loading: P
385
+ };
386
+ }
387
+ function Me(e, l, t) {
388
+ const n = ce(), m = I(null), i = I(!1), g = I(null), c = I(!1), y = I(e.modalSize), L = I(!1);
389
+ let s = null;
390
+ ne(() => {
391
+ s = window.matchMedia("(max-width: 767px)"), L.value = s.matches;
392
+ const u = (j) => {
393
+ L.value = j.matches;
394
+ };
395
+ s.addEventListener("change", u), ae(() => {
396
+ s == null || s.removeEventListener("change", u);
397
+ });
398
+ });
399
+ const h = () => {
400
+ e.readonly || (l.clearSearchTerm(), i.value = !1, g.value = null, c.value = !1, y.value = e.modalSize, n.open(), ie(() => {
401
+ var u;
402
+ (u = m.value) == null || u.focus();
403
+ }));
404
+ }, w = (u) => {
405
+ t("update:modelValue", u), n.close();
406
+ }, T = () => {
407
+ t("update:modelValue", null);
408
+ }, O = () => {
409
+ i.value = !0, y.value = e.sizeModalCreateEntity;
410
+ }, P = (u) => {
411
+ g.value = u, y.value = e.sizeModalCreateEntity;
412
+ }, z = (u) => {
413
+ i.value = !1, g.value = null, c.value = !1, y.value = e.modalSize, u ? (n.close(), t("update:modelValue", u)) : !l.loading.value && l.availableItems.value.length === 0 && !l.searchTerm.value && n.close();
414
+ };
415
+ return Y(n.isOpened, (u) => {
416
+ u && l.load && l.load(), u || (i.value = !1, y.value = e.modalSize);
417
+ }), Y(
418
+ () => {
419
+ var u;
420
+ return (u = l.dynamicIsLoad) == null ? void 0 : u.value;
421
+ },
422
+ () => {
423
+ var u;
424
+ l.dynamicIsLoad && !l.loading.value && l.dynamicIsLoad.value && !l.searchTerm.value && ((u = l.nodes) == null ? void 0 : u.value.length) === 0 && (c.value = !0, y.value = e.sizeModalCreateEntity);
425
+ }
426
+ ), {
427
+ modal: n,
428
+ searchInput: m,
429
+ creatingEntity: i,
430
+ editEntity: g,
431
+ startCreate: c,
432
+ currentModalSize: y,
433
+ isMobileView: L,
434
+ openPicker: h,
435
+ selectItem: w,
436
+ onClear: T,
437
+ onCreateEntity: O,
438
+ onEditEntity: P,
439
+ onCloseCreateEntity: z
440
+ };
441
+ }
442
+ const Te = { class: "relative px-4 pt-3 pb-2" }, ze = { class: "relative" }, qe = ["value", "placeholder"], je = /* @__PURE__ */ M({
443
+ __name: "EntityPickerSearch",
444
+ props: {
445
+ modelValue: {
446
+ type: String,
447
+ default: ""
448
+ },
449
+ placeholder: {
450
+ type: String,
451
+ default: ""
452
+ }
453
+ },
454
+ emits: ["update:modelValue"],
455
+ setup(e, { expose: l, emit: t }) {
456
+ const n = t, m = I(null), i = (g) => {
457
+ n("update:modelValue", g.target.value);
458
+ };
459
+ return l({
460
+ focus: () => {
461
+ var g;
462
+ return (g = m.value) == null ? void 0 : g.focus();
463
+ }
464
+ }), (g, c) => (a(), o("div", Te, [
465
+ r("div", ze, [
466
+ c[0] || (c[0] = r("svg", {
467
+ class: "absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-[#979CA9]",
468
+ fill: "none",
469
+ viewBox: "0 0 24 24",
470
+ stroke: "currentColor",
471
+ "stroke-width": "2"
472
+ }, [
473
+ r("path", {
474
+ "stroke-linecap": "round",
475
+ "stroke-linejoin": "round",
476
+ d: "M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
477
+ })
478
+ ], -1)),
479
+ r("input", {
480
+ ref_key: "inputRef",
481
+ ref: m,
482
+ value: e.modelValue,
483
+ type: "text",
484
+ class: "w-full h-10 pl-11 pr-3 border border-[#E2E7EF] rounded-[10px] text-sm placeholder:text-[#979CA9] focus:outline-none focus:ring-2 focus:ring-primary-base focus:border-transparent",
485
+ placeholder: e.placeholder,
486
+ onInput: i
487
+ }, null, 40, qe)
488
+ ])
489
+ ]));
490
+ }
491
+ }), Fe = { class: "px-3 pb-2" }, Oe = { class: "text-xs font-semibold tracking-[0.4px]" }, Pe = /* @__PURE__ */ M({
492
+ __name: "EntityPickerCreateButton",
493
+ props: {
494
+ label: { type: String, required: !0 }
495
+ },
496
+ emits: ["click"],
497
+ setup(e) {
498
+ return (l, t) => (a(), o("div", Fe, [
499
+ r("button", {
500
+ type: "button",
501
+ class: "w-full h-10 flex items-center justify-center gap-2 bg-[#FAFAFA] border border-[#E3ECF2] rounded-[10px] text-[#4089E0] hover:bg-[#F2F4F8] hover:border-[#D6DDE7] transition-colors",
502
+ onClick: t[0] || (t[0] = (n) => l.$emit("click"))
503
+ }, [
504
+ t[1] || (t[1] = r("svg", {
505
+ class: "w-4 h-4",
506
+ fill: "none",
507
+ viewBox: "0 0 24 24",
508
+ stroke: "currentColor",
509
+ "stroke-width": "2"
510
+ }, [
511
+ r("path", {
512
+ "stroke-linecap": "round",
513
+ "stroke-linejoin": "round",
514
+ d: "M12 4.5v15m7.5-7.5h-15"
515
+ })
516
+ ], -1)),
517
+ r("span", Oe, x(e.label), 1)
518
+ ])
519
+ ]));
520
+ }
521
+ }), Ke = {
522
+ key: 0,
523
+ class: "flex items-center justify-center w-8 h-8 flex-shrink-0"
524
+ }, Ne = {
525
+ key: 0,
526
+ class: "w-5 h-5 rounded-full bg-[#4089E0] flex items-center justify-center"
527
+ }, Ue = {
528
+ key: 1,
529
+ class: "w-4 h-4 text-[#525B66]",
58
530
  fill: "none",
59
531
  viewBox: "0 0 24 24",
60
532
  stroke: "currentColor",
61
533
  "stroke-width": "2"
62
- }, lt = {
534
+ }, Re = /* @__PURE__ */ M({
535
+ __name: "EntityPickerIndicator",
536
+ props: {
537
+ variant: {
538
+ type: String,
539
+ default: "check"
540
+ },
541
+ selected: {
542
+ type: Boolean,
543
+ default: !1
544
+ }
545
+ },
546
+ setup(e) {
547
+ return (l, t) => e.variant !== "none" ? (a(), o("div", Ke, [
548
+ e.selected ? (a(), o("span", Ne, [...t[0] || (t[0] = [
549
+ r("svg", {
550
+ class: "w-3 h-3 text-white",
551
+ fill: "none",
552
+ viewBox: "0 0 24 24",
553
+ stroke: "currentColor",
554
+ "stroke-width": "3"
555
+ }, [
556
+ r("path", {
557
+ "stroke-linecap": "round",
558
+ "stroke-linejoin": "round",
559
+ d: "M4.5 12.75l6 6 9-13.5"
560
+ })
561
+ ], -1)
562
+ ])])) : e.variant === "navigation" ? (a(), o("svg", Ue, [...t[1] || (t[1] = [
563
+ r("path", {
564
+ "stroke-linecap": "round",
565
+ "stroke-linejoin": "round",
566
+ d: "M8.25 4.5l7.5 7.5-7.5 7.5"
567
+ }, null, -1)
568
+ ])])) : C("", !0)
569
+ ])) : C("", !0);
570
+ }
571
+ }), Ge = { class: "flex-1 min-w-0" }, We = /* @__PURE__ */ M({
572
+ __name: "EntityPickerListItem",
573
+ props: {
574
+ selected: { type: Boolean, default: !1 },
575
+ title: { type: String, default: "" },
576
+ subtitle: { type: String, default: "" },
577
+ avatarText: { type: String, default: "" },
578
+ avatarSrc: { type: String, default: "" },
579
+ avatarSize: { type: [String, Number], default: 40 },
580
+ iconWrapperClass: { type: String, default: "" },
581
+ itemClass: { type: String, default: "" },
582
+ titleClass: { type: String, default: "" },
583
+ subtitleClass: { type: String, default: "" },
584
+ indicator: {
585
+ type: String,
586
+ default: "check"
587
+ },
588
+ showEdit: { type: Boolean, default: !1 },
589
+ editLabel: { type: String, default: "" }
590
+ },
591
+ emits: ["select", "edit"],
592
+ setup(e) {
593
+ return (l, t) => (a(), o("div", {
594
+ class: v(["flex items-center gap-3 py-3 px-4 hover:bg-secondary-body-hover cursor-pointer", [{ "bg-gray-50": e.selected }, e.itemClass]]),
595
+ onClick: t[1] || (t[1] = (n) => l.$emit("select"))
596
+ }, [
597
+ r("div", {
598
+ class: v(["flex-shrink-0", e.iconWrapperClass])
599
+ }, [
600
+ f(l.$slots, "icon", {}, () => [
601
+ q(d(D), {
602
+ text: e.avatarText,
603
+ src: e.avatarSrc,
604
+ rounded: !1,
605
+ size: String(e.avatarSize),
606
+ class: "!rounded-[10px]"
607
+ }, null, 8, ["text", "src", "size"])
608
+ ])
609
+ ], 2),
610
+ r("div", Ge, [
611
+ r("p", {
612
+ class: v(e.titleClass)
613
+ }, x(e.title), 3),
614
+ e.subtitle ? (a(), o("div", {
615
+ key: 0,
616
+ class: v(e.subtitleClass)
617
+ }, [
618
+ f(l.$slots, "additional", {}, () => [
619
+ G(x(e.subtitle), 1)
620
+ ])
621
+ ], 2)) : C("", !0)
622
+ ]),
623
+ e.showEdit ? (a(), o("button", {
624
+ key: 0,
625
+ type: "button",
626
+ class: "text-xs font-semibold text-[#4089E0] hover:text-primary-active flex-shrink-0 tracking-[0.4px]",
627
+ onClick: t[0] || (t[0] = Q((n) => l.$emit("edit"), ["stop"]))
628
+ }, x(e.editLabel), 1)) : C("", !0),
629
+ q(Re, {
630
+ variant: e.indicator,
631
+ selected: e.selected
632
+ }, null, 8, ["variant", "selected"])
633
+ ], 2));
634
+ }
635
+ }), He = {
636
+ key: 0,
637
+ class: "flex items-center justify-center py-8"
638
+ }, Qe = {
63
639
  key: 1,
640
+ class: "relative px-5 py-10 text-center"
641
+ }, Je = { class: "mb-4 text-sm text-gray-500" }, Xe = {
642
+ key: 2,
643
+ class: "p-3 text-center mt-6"
644
+ }, Ye = { class: "text-xs" }, Ze = /* @__PURE__ */ M({
645
+ __name: "EntityPickerList",
646
+ props: {
647
+ loading: { type: Boolean, default: !1 },
648
+ items: { type: Array, default: () => [] },
649
+ searchTerm: { type: String, default: "" },
650
+ // scroll container height — applied as Tailwind class(es)
651
+ scrollHeightClass: {
652
+ type: [String, Object],
653
+ default: ""
654
+ },
655
+ resolvers: { type: Object, required: !0 },
656
+ // copy
657
+ emptyMessage: { type: String, default: "" },
658
+ notFoundLabel: { type: String, default: "" },
659
+ createWithQueryLabel: { type: String, default: "" },
660
+ canCreate: { type: Boolean, default: !1 },
661
+ // per-item appearance
662
+ itemSize: { type: [String, Number], default: 40 },
663
+ itemIconClass: { type: String, default: "" },
664
+ itemTitleClass: { type: String, default: "" },
665
+ itemSubtitleClass: { type: String, default: "" },
666
+ itemIndicator: {
667
+ type: String,
668
+ default: "check"
669
+ },
670
+ canEdit: { type: Boolean, default: !1 },
671
+ editLabel: { type: String, default: "" }
672
+ },
673
+ emits: ["select", "edit", "create"],
674
+ setup(e) {
675
+ return (l, t) => (a(), o("div", {
676
+ class: v(["divide-y divide-[#E3ECF2] overflow-auto", e.scrollHeightClass])
677
+ }, [
678
+ e.loading ? (a(), o("div", He, [...t[1] || (t[1] = [
679
+ r("div", { class: "animate-spin w-6 h-6 border-2 border-primary-base border-t-transparent rounded-full" }, null, -1)
680
+ ])])) : e.items.length === 0 && !e.searchTerm ? (a(), o("div", Qe, [
681
+ f(l.$slots, "empty", {}, () => [
682
+ r("p", Je, x(e.emptyMessage), 1)
683
+ ])
684
+ ])) : e.items.length === 0 && e.searchTerm ? (a(), o("div", Xe, [
685
+ r("p", Ye, [
686
+ G(x(e.notFoundLabel) + " ", 1),
687
+ r("b", null, x(e.searchTerm), 1)
688
+ ]),
689
+ e.canCreate ? (a(), o("button", {
690
+ key: 0,
691
+ type: "button",
692
+ class: "w-full text-xs text-blue-400 hover:text-blue-300 mt-2",
693
+ onClick: t[0] || (t[0] = (n) => l.$emit("create"))
694
+ }, x(e.createWithQueryLabel), 1)) : C("", !0)
695
+ ])) : (a(!0), o(Z, { key: 3 }, se(e.items, (n) => (a(), F(We, {
696
+ key: e.resolvers.getEntityListKey(n),
697
+ selected: e.resolvers.isSelected(n),
698
+ title: e.resolvers.getEntityListLabel(n),
699
+ subtitle: e.resolvers.getEntityListAdditional(n),
700
+ "avatar-text": e.resolvers.getEntityListLabel(n),
701
+ "avatar-src": e.resolvers.getEntityListAvatar(n),
702
+ "avatar-size": e.itemSize,
703
+ "icon-wrapper-class": e.itemIconClass,
704
+ "title-class": e.itemTitleClass,
705
+ "subtitle-class": e.itemSubtitleClass,
706
+ indicator: e.itemIndicator,
707
+ "show-edit": e.resolvers.isSelected(n) && e.canEdit,
708
+ "edit-label": e.editLabel,
709
+ onSelect: (m) => l.$emit("select", n),
710
+ onEdit: (m) => l.$emit("edit", e.resolvers.getEntityKey(n))
711
+ }, R({ _: 2 }, [
712
+ l.$slots.itemIcon ? {
713
+ name: "icon",
714
+ fn: E(() => [
715
+ f(l.$slots, "itemIcon", { item: n })
716
+ ]),
717
+ key: "0"
718
+ } : void 0,
719
+ l.$slots.itemAdditional ? {
720
+ name: "additional",
721
+ fn: E(() => [
722
+ f(l.$slots, "itemAdditional", { item: n })
723
+ ]),
724
+ key: "1"
725
+ } : void 0
726
+ ]), 1032, ["selected", "title", "subtitle", "avatar-text", "avatar-src", "avatar-size", "icon-wrapper-class", "title-class", "subtitle-class", "indicator", "show-edit", "edit-label", "onSelect", "onEdit"]))), 128))
727
+ ], 2));
728
+ }
729
+ }), De = {
730
+ key: 0,
64
731
  class: "text-xs px-2 py-1 text-red-600"
65
- }, ct = /* @__PURE__ */ ge({
732
+ }, pe = "text-sm font-semibold text-black truncate leading-5 tracking-[0.4px]", _e = "text-xs text-[#979CA9] font-normal leading-5 truncate tracking-[0.4px]", rt = /* @__PURE__ */ M({
66
733
  __name: "OneEntityPicker",
67
734
  props: {
68
735
  t: {
@@ -189,13 +856,66 @@ const Me = { key: 0 }, Ae = { class: "" }, qe = {
189
856
  type: Boolean,
190
857
  default: !1
191
858
  },
192
- // Variant
859
+ // Trigger variant
193
860
  variant: {
194
861
  type: String,
195
862
  default: "default",
196
- validator: (t) => ["default", "compact", "minimal", "pill"].includes(t)
863
+ validator: (e) => ["default", "compact", "minimal", "pill", "tag"].includes(e)
864
+ },
865
+ tagColor: {
866
+ type: String,
867
+ default: "#525B66"
868
+ },
869
+ // ───── Modal customization ─────
870
+ modalTitle: {
871
+ required: !1,
872
+ type: String,
873
+ default: ""
874
+ },
875
+ modalTitlePosition: {
876
+ required: !1,
877
+ type: String,
878
+ default: "left",
879
+ validator: (e) => ["left", "center"].includes(e)
197
880
  },
198
- // Options
881
+ modalSize: {
882
+ required: !1,
883
+ type: String,
884
+ default: "sm"
885
+ },
886
+ searchPlaceholder: {
887
+ required: !1,
888
+ type: String,
889
+ default: ""
890
+ },
891
+ // ───── List item appearance ─────
892
+ listItemIndicator: {
893
+ required: !1,
894
+ type: String,
895
+ default: "check",
896
+ validator: (e) => ["check", "navigation", "none"].includes(e)
897
+ },
898
+ listItemSize: {
899
+ required: !1,
900
+ type: [String, Number],
901
+ default: 40
902
+ },
903
+ listItemIconClass: {
904
+ required: !1,
905
+ type: String,
906
+ default: ""
907
+ },
908
+ listItemTitleClass: {
909
+ required: !1,
910
+ type: String,
911
+ default: ""
912
+ },
913
+ listItemSubtitleClass: {
914
+ required: !1,
915
+ type: String,
916
+ default: ""
917
+ },
918
+ // ───── Misc ─────
199
919
  noCreate: {
200
920
  type: Boolean,
201
921
  default: !1
@@ -215,361 +935,191 @@ const Me = { key: 0 }, Ae = { class: "" }, qe = {
215
935
  listEmptyMessage: {
216
936
  type: String,
217
937
  default: ""
938
+ },
939
+ editButtonLabel: {
940
+ type: String,
941
+ default: ""
218
942
  }
219
943
  },
220
944
  emits: ["update:modelValue", "onSetEntity"],
221
- setup(t, { emit: oe }) {
222
- const ie = Be(), n = t, O = oe, b = f(() => n.t ?? ie), h = Ve(), Y = g(null), L = g(!1), B = g(null), q = g(!1), p = g("sm"), I = g(!1);
223
- let C = null;
224
- me(() => {
225
- C = window.matchMedia("(max-width: 767px)"), I.value = C.matches;
226
- const e = (o) => {
227
- I.value = o.matches;
228
- };
229
- C.addEventListener("change", e), pe(() => {
230
- C == null || C.removeEventListener("change", e);
231
- });
945
+ setup(e, { emit: l }) {
946
+ const t = ye(), n = e, m = l, i = S(() => n.t ?? t), g = Ie(n), c = Be(n, g), { searchTerm: y, selectedGroup: L, setSelectedGroup: s, sortedItems: h, loading: w } = c, {
947
+ modal: T,
948
+ searchInput: O,
949
+ creatingEntity: P,
950
+ editEntity: z,
951
+ startCreate: u,
952
+ currentModalSize: j,
953
+ isMobileView: W,
954
+ openPicker: k,
955
+ selectItem: B,
956
+ onClear: V,
957
+ onCreateEntity: $,
958
+ onEditEntity: K,
959
+ onCloseCreateEntity: N
960
+ } = Me(n, c, m), p = S(
961
+ () => n.modalTitle || i.value("ui.entity_picker.Select")
962
+ ), _ = S(
963
+ () => n.listItemTitleClass || pe
964
+ ), ee = S(
965
+ () => n.listItemSubtitleClass || _e
966
+ ), te = S(
967
+ () => n.noSearch ? "sm:h-[52vh] h-[86dvh] min-h-[300px]" : "sm:h-[40vh] h-[60dvh]"
968
+ ), le = S(() => P.value || u.value ? "create" : z.value ? "edit" : "browse"), J = S(() => {
969
+ const b = [];
970
+ return n.validation == null || n.validationIndex == null || Object.keys(n.validation).forEach((U) => {
971
+ U.startsWith(n.validationIndex) && b.push(...n.validation[U]);
972
+ }), b;
232
973
  });
233
- const i = n.listEntityUse ? n.listEntityUse() : null, w = i == null ? void 0 : i.nodes, Z = i == null ? void 0 : i.load, k = i == null ? void 0 : i.searchTerm, S = i == null ? void 0 : i.isLoading, M = i == null ? void 0 : i.isLoad, A = i == null ? void 0 : i.group, Q = g(null), re = f(() => (A == null ? void 0 : A.value) ?? Q.value), ue = (e) => {
234
- A ? A.value = e : Q.value = e;
235
- }, N = g(""), v = f({
236
- get: () => (k == null ? void 0 : k.value) ?? N.value,
237
- set: (e) => {
238
- k ? k.value = e : N.value = e;
239
- }
240
- }), T = f(() => (S == null ? void 0 : S.value) ?? n.isLoading), K = f(() => (w == null ? void 0 : w.value) ?? n.items), P = f(() => n.icon), y = f(() => n.variant === "compact" || n.variant === "minimal"), de = f(() => n.variant === "compact"), x = f(() => n.variant === "pill"), D = f(() => {
241
- const e = [];
242
- return n.validation == null || n.validationIndex == null || Object.keys(n.validation).forEach((o) => {
243
- o.startsWith(n.validationIndex) && e.push(...n.validation[o]);
244
- }), e;
245
- }), U = f(() => {
246
- if (!v.value)
247
- return K.value;
248
- const e = v.value.toLowerCase();
249
- return K.value.filter((o) => {
250
- const r = H(o).toLowerCase(), X = W(o).toLowerCase();
251
- return r.includes(e) || X.includes(e);
252
- });
253
- }), ce = f(() => [...U.value].sort((e) => G(e) === F(n.modelValue) ? -1 : 0)), j = (e) => e ? String(e[n.entityLabel] || "") : "", ve = (e) => !e || !n.entityAvatar ? "" : String(e[n.entityAvatar] || ""), E = (e) => !e || !n.entityAdditional ? "" : String(e[n.entityAdditional] || ""), F = (e) => e ? e[n.entityKey] : "", G = (e) => e[n.entityListKey], H = (e) => String(e[n.entityListLabel] || ""), ye = (e) => n.entityListAvatar ? String(e[n.entityListAvatar] || "") : "", W = (e) => n.entityListAdditional ? String(e[n.entityListAdditional] || "") : "", J = (e) => F(n.modelValue) === G(e), _ = () => {
254
- n.readonly || (N.value = "", k && (k.value = ""), L.value = !1, B.value = null, q.value = !1, p.value = "sm", h.open(), Ee(() => {
255
- var e;
256
- (e = Y.value) == null || e.focus();
257
- }));
258
- }, fe = (e) => {
259
- O("update:modelValue", e), h.close();
260
- }, xe = () => {
261
- O("update:modelValue", null);
262
- }, ee = () => {
263
- L.value = !0, p.value = n.sizeModalCreateEntity;
264
- }, he = (e) => {
265
- B.value = e, p.value = n.sizeModalCreateEntity;
266
- }, R = (e) => {
267
- L.value = !1, B.value = null, q.value = !1, p.value = "sm", e ? (h.close(), O("update:modelValue", e)) : !T.value && K.value.length === 0 && !v.value && h.close();
268
- };
269
- return te(h.isOpened, (e) => {
270
- e && Z && Z(), e || (L.value = !1, p.value = "sm");
271
- }), te(
272
- () => M == null ? void 0 : M.value,
273
- () => {
274
- M && !(S != null && S.value) && M.value && !v.value && (w == null ? void 0 : w.value.length) === 0 && (q.value = !0, p.value = n.sizeModalCreateEntity);
275
- }
276
- ), (e, o) => (l(), a(le, null, [
277
- s("div", {
278
- class: u(["relative select-none", y.value ? "space-y-1.5" : "space-y-3"])
279
- }, [
280
- m(e.$slots, "button", {
281
- title: t.title,
282
- modelValue: t.modelValue,
283
- openModal: () => V(h).open()
284
- }, () => [
285
- t.title ? (l(), a("p", {
286
- key: 0,
287
- class: u(["font-semibold pb-0", t.labelClass])
288
- }, d(t.title), 3)) : c("", !0),
289
- s("div", {
290
- class: u(["flex justify-between z-10 items-center", [
291
- t.readonly ? "" : "cursor-pointer hover:bg-gray-50",
292
- y.value ? ["rounded-full", de.value ? "bg-[#4089E01A]" : ""] : "border px-3 pr-3 py-3 rounded-lg h-[72px]",
293
- x.value ? "border-none !py-0 h-max !rounded-full" : "",
294
- x.value && t.modelValue !== null ? "bg-[#4089E01A]" : ""
295
- ]])
296
- }, [
297
- s("div", {
298
- class: u(["flex items-center w-full gap-x-3", [y.value ? "!gap-x-1 px-0.5 py-0.5" : "", x.value ? "h-9 p-0" : ""]]),
299
- onClick: _
300
- }, [
301
- t.noIcon ? c("", !0) : (l(), a("div", {
302
- key: 0,
303
- class: u(["w-10 h-10 flex items-center justify-center", t.iconClassBlock])
304
- }, [
305
- x.value ? (l(), a("div", Me, [
306
- t.modelValue == null ? (l(), a("svg", {
307
- key: 0,
308
- class: u(["w-3 text-blue-600", t.iconClass]),
309
- fill: "none",
310
- viewBox: "0 0 24 24",
311
- stroke: "currentColor",
312
- "stroke-width": "2"
313
- }, [...o[1] || (o[1] = [
314
- s("path", {
315
- "stroke-linecap": "round",
316
- "stroke-linejoin": "round",
317
- d: "M12 4.5v15m7.5-7.5h-15"
318
- }, null, -1)
319
- ])], 2)) : (l(), $(ne(P.value), {
320
- key: 1,
321
- class: u(["w-5", t.iconClass])
322
- }, null, 8, ["class"]))
323
- ])) : P.value != null && t.modelValue == null || y.value ? (l(), a("div", {
324
- key: 1,
325
- class: u(y.value ? "" : "bg-gray-50 p-2.5 rounded-lg")
326
- }, [
327
- (l(), $(ne(P.value), {
328
- class: u([["w-5", t.iconClass], "text-gray-600"])
329
- }, null, 8, ["class"]))
330
- ], 2)) : t.modelValue ? (l(), $(V(se), {
331
- key: 2,
332
- text: j(t.modelValue),
333
- src: ve(t.modelValue),
334
- rounded: !1,
335
- size: "40",
336
- class: "!rounded-lg"
337
- }, null, 8, ["text", "src"])) : c("", !0)
338
- ], 2)),
339
- s("div", Ae, [
340
- t.modelValue == null ? (l(), a("div", qe, [
341
- s("div", {
342
- class: u(["font-medium text-gray-600 truncate overflow-hidden whitespace-nowrap", [
343
- y.value ? "text-xs truncate max-w-[120px] text-[#525B66]" : "text-sm",
344
- x.value ? "!text-xs truncate max-w-[120px] text-[#4089E0]" : ""
345
- ]])
346
- }, d(t.labelSelect), 3),
347
- t.labelSelectNote && !y.value && !x.value ? (l(), a("span", je, d(t.labelSelectNote), 1)) : c("", !0)
348
- ])) : (l(), a("div", {
349
- key: 1,
350
- class: u(["grid items-center pr-2", y.value ? "" : "py-1"])
351
- }, [
352
- s("div", {
353
- class: u(["break-all leading-4 truncate !text-sm", {
354
- "text-sm font-medium": j(t.modelValue).length < 20,
355
- "text-xs font-semibold": j(t.modelValue).length > 20,
356
- "truncate text-[#525B66] text-xs": y.value,
357
- "truncate text-xs": x.value
358
- }])
359
- }, [
360
- z(d(j(t.modelValue)) + " ", 1),
361
- !t.readonly && !y.value && !x.value ? (l(), a("span", $e, d(b.value("ui.entity_picker.Change")), 1)) : c("", !0)
362
- ], 2),
363
- E(t.modelValue) ? (l(), a("div", {
364
- key: 0,
365
- class: u(["font-thin leading-3 break-all line-clamp-2 pt-1 truncate !text-xs", {
366
- "text-xs": E(t.modelValue).length < 20,
367
- "text-[10px]": E(t.modelValue).length > 20 && E(t.modelValue).length < 35,
368
- "text-[9px]": E(t.modelValue).length > 35
369
- }])
370
- }, [
371
- m(e.$slots, "entityAdditional", { item: t.modelValue }, () => [
372
- z(d(E(t.modelValue)), 1)
373
- ])
374
- ], 2)) : c("", !0)
375
- ], 2))
376
- ])
377
- ], 2),
378
- t.modelValue != null && !t.readonly ? (l(), a("button", {
379
- key: 0,
380
- type: "button",
381
- onClick: ae(xe, ["stop"]),
382
- class: u(["rounded-full hover:text-gray-900 text-gray-500", { "mr-2 text-[#525B66] p-0.5": y.value }])
383
- }, [...o[2] || (o[2] = [
384
- s("svg", {
385
- class: "w-4 h-4",
386
- fill: "none",
387
- viewBox: "0 0 24 24",
388
- stroke: "currentColor",
389
- "stroke-width": "2"
390
- }, [
391
- s("path", {
392
- "stroke-linecap": "round",
393
- "stroke-linejoin": "round",
394
- d: "M6 18L18 6M6 6l12 12"
395
- })
396
- ], -1)
397
- ])], 2)) : !t.readonly && !y.value && !x.value ? (l(), a("button", {
398
- key: 1,
399
- type: "button",
400
- class: "py-2.5 text-gray-500",
401
- onClick: _
402
- }, [...o[3] || (o[3] = [
403
- s("svg", {
404
- class: "w-5 h-5",
405
- fill: "none",
406
- viewBox: "0 0 24 24",
407
- stroke: "currentColor",
408
- "stroke-width": "2"
409
- }, [
410
- s("path", {
411
- "stroke-linecap": "round",
412
- "stroke-linejoin": "round",
413
- d: "M8.25 4.5l7.5 7.5-7.5 7.5"
974
+ return (b, U) => (a(), o(Z, null, [
975
+ q(Ae, {
976
+ variant: e.variant,
977
+ "model-value": e.modelValue,
978
+ icon: e.icon,
979
+ title: e.title,
980
+ "label-select": e.labelSelect,
981
+ "label-select-note": e.labelSelectNote,
982
+ "label-class": e.labelClass,
983
+ "icon-class": e.iconClass,
984
+ "icon-class-block": e.iconClassBlock,
985
+ "no-icon": e.noIcon,
986
+ readonly: e.readonly,
987
+ "tag-color": e.tagColor,
988
+ "change-label": i.value("ui.entity_picker.Change"),
989
+ resolvers: d(g),
990
+ onOpen: d(k),
991
+ onClear: d(V)
992
+ }, R({ _: 2 }, [
993
+ b.$slots.button ? {
994
+ name: "button",
995
+ fn: E((A) => [
996
+ f(b.$slots, "button", oe(re(A)))
997
+ ]),
998
+ key: "0"
999
+ } : void 0,
1000
+ b.$slots.entityAdditional ? {
1001
+ name: "entityAdditional",
1002
+ fn: E(({ item: A }) => [
1003
+ f(b.$slots, "entityAdditional", { item: A })
1004
+ ]),
1005
+ key: "1"
1006
+ } : void 0
1007
+ ]), 1032, ["variant", "model-value", "icon", "title", "label-select", "label-select-note", "label-class", "icon-class", "icon-class-block", "no-icon", "readonly", "tag-color", "change-label", "resolvers", "onOpen", "onClear"]),
1008
+ q(be, {
1009
+ useModal: d(T),
1010
+ title: p.value,
1011
+ "title-center": e.modalTitlePosition === "center",
1012
+ size: d(j),
1013
+ "mobile-view": d(W),
1014
+ view: le.value
1015
+ }, R({
1016
+ create: E(() => [
1017
+ f(b.$slots, "creating", {
1018
+ onCloseCreateEntity: d(N),
1019
+ find: d(y)
1020
+ })
1021
+ ]),
1022
+ edit: E(() => [
1023
+ f(b.$slots, "edit", {
1024
+ onCloseCreateEntity: d(N),
1025
+ editId: d(z)
1026
+ })
1027
+ ]),
1028
+ list: E(() => [
1029
+ q(Ze, {
1030
+ loading: d(w),
1031
+ items: d(h),
1032
+ "search-term": d(y),
1033
+ "scroll-height-class": te.value,
1034
+ resolvers: d(g),
1035
+ "empty-message": e.listEmptyMessage || i.value("ui.entity_picker.List empty"),
1036
+ "not-found-label": i.value("ui.entity_picker.Nothing found for"),
1037
+ "create-with-query-label": `${e.labelCreateButton} «${d(y)}»`,
1038
+ "can-create": !e.noCreate && !!e.labelCreateButton,
1039
+ "item-size": e.listItemSize,
1040
+ "item-icon-class": e.listItemIconClass,
1041
+ "item-title-class": _.value,
1042
+ "item-subtitle-class": ee.value,
1043
+ "item-indicator": e.listItemIndicator,
1044
+ "can-edit": !!b.$slots.edit && !e.noEdit,
1045
+ "edit-label": e.editButtonLabel || i.value("ui.entity_picker.Edit"),
1046
+ onSelect: d(B),
1047
+ onEdit: d(K),
1048
+ onCreate: d($)
1049
+ }, R({ _: 2 }, [
1050
+ b.$slots.creating ? {
1051
+ name: "empty",
1052
+ fn: E(() => [
1053
+ f(b.$slots, "creating", {
1054
+ onCloseCreateEntity: d(N),
1055
+ find: d(y)
414
1056
  })
415
- ], -1)
416
- ])])) : c("", !0)
417
- ], 2)
418
- ])
419
- ], 2),
420
- V(h).isOpened.value ? (l(), $(V(Le), {
421
- key: 0,
422
- useModal: V(h),
423
- title: b.value("ui.entity_picker.Select"),
424
- size: p.value,
425
- classModal: I.value,
426
- titleCenter: !0
427
- }, {
428
- default: ke(() => [
429
- L.value || q.value ? (l(), a("div", ze, [
430
- m(e.$slots, "creating", {
431
- onCloseCreateEntity: R,
432
- find: v.value
433
- })
434
- ])) : B.value ? (l(), a("div", Oe, [
435
- m(e.$slots, "edit", {
436
- onCloseCreateEntity: R,
437
- editId: B.value
438
- })
439
- ])) : (l(), a("div", Ie, [
440
- e.$slots.modalHeader ? (l(), a("div", Ne, [
441
- m(e.$slots, "modalHeader")
442
- ])) : c("", !0),
443
- t.noSearch ? c("", !0) : (l(), a("div", Te, [
444
- s("div", Ke, [
445
- o[4] || (o[4] = s("svg", {
446
- class: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400",
447
- fill: "none",
448
- viewBox: "0 0 24 24",
449
- stroke: "currentColor",
450
- "stroke-width": "2"
451
- }, [
452
- s("path", {
453
- "stroke-linecap": "round",
454
- "stroke-linejoin": "round",
455
- d: "M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
456
- })
457
- ], -1)),
458
- be(s("input", {
459
- "onUpdate:modelValue": o[0] || (o[0] = (r) => v.value = r),
460
- type: "text",
461
- class: "w-full pl-9 pr-3 py-2 border rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-base focus:border-transparent",
462
- placeholder: b.value("ui.entity_picker.Search"),
463
- ref_key: "searchInput",
464
- ref: Y
465
- }, null, 8, Pe), [
466
- [Ce, v.value]
467
- ])
468
- ])
469
- ])),
470
- m(e.$slots, "prepend", {
471
- selectedGroup: re.value,
472
- setSelectedGroup: ue
473
- }),
474
- !T.value && !t.noCreate && t.labelCreateButton ? (l(), a("div", Ue, [
475
- s("button", {
476
- type: "button",
477
- onClick: ee,
478
- class: "w-full flex items-center justify-center gap-2 py-2 text-blue-400 hover:text-blue-300 text-sm"
479
- }, [
480
- o[5] || (o[5] = s("svg", {
481
- class: "w-4 h-4",
482
- fill: "none",
483
- viewBox: "0 0 24 24",
484
- stroke: "currentColor",
485
- "stroke-width": "2"
486
- }, [
487
- s("path", {
488
- "stroke-linecap": "round",
489
- "stroke-linejoin": "round",
490
- d: "M12 4.5v15m7.5-7.5h-15"
491
- })
492
- ], -1)),
493
- z(" " + d(t.labelCreateButton), 1)
494
- ])
495
- ])) : c("", !0),
496
- s("div", {
497
- class: u(["divide-y overflow-auto", {
498
- "sm:h-[40vh] h-[60dvh]": !t.noSearch,
499
- "sm:h-[52vh] h-[86dvh] min-h-[300px]": t.noSearch
500
- }])
501
- }, [
502
- T.value ? (l(), a("div", Fe, [...o[6] || (o[6] = [
503
- s("div", { class: "animate-spin w-6 h-6 border-2 border-primary-base border-t-transparent rounded-full" }, null, -1)
504
- ])])) : U.value.length === 0 && !v.value ? (l(), a("div", Ge, [
505
- m(e.$slots, "creating", {
506
- onCloseCreateEntity: R,
507
- find: v.value
508
- }, () => [
509
- s("p", He, d(t.listEmptyMessage || b.value("ui.entity_picker.List empty")), 1)
510
- ])
511
- ])) : U.value.length === 0 && v.value ? (l(), a("div", We, [
512
- s("p", Je, [
513
- z(d(b.value("ui.entity_picker.Nothing found for")) + " ", 1),
514
- s("b", null, d(v.value), 1)
515
- ]),
516
- !t.noCreate && t.labelCreateButton ? (l(), a("button", {
517
- key: 0,
518
- type: "button",
519
- onClick: ee,
520
- class: "w-full text-xs text-blue-400 hover:text-blue-300 mt-2"
521
- }, d(t.labelCreateButton) + " «" + d(v.value) + "» ", 1)) : c("", !0)
522
- ])) : (l(!0), a(le, { key: 3 }, we(ce.value, (r) => (l(), a("div", {
523
- key: G(r),
524
- class: u(["flex items-center py-3 hover:bg-secondary-body-hover px-3 cursor-pointer", { "bg-gray-50 text-blue-900": J(r) }]),
525
- onClick: (X) => fe(r)
526
- }, [
527
- s("div", Xe, [
528
- Se(V(se), {
529
- text: H(r),
530
- src: ye(r),
531
- rounded: !1,
532
- size: "30",
533
- class: "!rounded-lg"
534
- }, null, 8, ["text", "src"])
535
- ]),
536
- s("div", Ye, [
537
- s("p", Ze, d(H(r)), 1),
538
- W(r) ? (l(), a("div", Qe, [
539
- m(e.$slots, "entityAdditional", { item: r }, () => [
540
- s("span", De, d(W(r)), 1)
541
- ])
542
- ])) : c("", !0)
543
- ]),
544
- J(r) && e.$slots.edit && !t.noEdit ? (l(), a("button", {
545
- key: 0,
546
- type: "button",
547
- onClick: ae((X) => he(F(r)), ["stop"]),
548
- class: "text-xs text-blue-400 hover:text-blue-300 mr-2"
549
- }, d(b.value("ui.entity_picker.Edit")), 9, _e)) : c("", !0),
550
- J(r) ? (l(), a("svg", et, [...o[7] || (o[7] = [
551
- s("path", {
552
- "stroke-linecap": "round",
553
- "stroke-linejoin": "round",
554
- d: "M4.5 12.75l6 6 9-13.5"
555
- }, null, -1)
556
- ])])) : (l(), a("svg", tt, [...o[8] || (o[8] = [
557
- s("path", {
558
- "stroke-linecap": "round",
559
- "stroke-linejoin": "round",
560
- d: "M8.25 4.5l7.5 7.5-7.5 7.5"
561
- }, null, -1)
562
- ])]))
563
- ], 10, Re))), 128))
564
- ], 2)
565
- ]))
1057
+ ]),
1058
+ key: "0"
1059
+ } : void 0,
1060
+ b.$slots.entityListIcon ? {
1061
+ name: "itemIcon",
1062
+ fn: E(({ item: A }) => [
1063
+ f(b.$slots, "entityListIcon", { item: A })
1064
+ ]),
1065
+ key: "1"
1066
+ } : void 0,
1067
+ b.$slots.entityAdditional ? {
1068
+ name: "itemAdditional",
1069
+ fn: E(({ item: A }) => [
1070
+ f(b.$slots, "entityAdditional", { item: A })
1071
+ ]),
1072
+ key: "2"
1073
+ } : void 0
1074
+ ]), 1032, ["loading", "items", "search-term", "scroll-height-class", "resolvers", "empty-message", "not-found-label", "create-with-query-label", "can-create", "item-size", "item-icon-class", "item-title-class", "item-subtitle-class", "item-indicator", "can-edit", "edit-label", "onSelect", "onEdit", "onCreate"])
566
1075
  ]),
567
- _: 3
568
- }, 8, ["useModal", "title", "size", "classModal"])) : c("", !0),
569
- D.value.length > 0 ? (l(), a("div", lt, d(D.value.join(" ")), 1)) : c("", !0)
1076
+ _: 2
1077
+ }, [
1078
+ b.$slots.modalHeader ? {
1079
+ name: "header",
1080
+ fn: E(() => [
1081
+ f(b.$slots, "modalHeader")
1082
+ ]),
1083
+ key: "0"
1084
+ } : void 0,
1085
+ e.noSearch ? void 0 : {
1086
+ name: "search",
1087
+ fn: E(() => [
1088
+ q(je, {
1089
+ ref_key: "searchInput",
1090
+ ref: O,
1091
+ modelValue: d(y),
1092
+ "onUpdate:modelValue": U[0] || (U[0] = (A) => de(y) ? y.value = A : null),
1093
+ placeholder: e.searchPlaceholder || i.value("ui.entity_picker.Search")
1094
+ }, null, 8, ["modelValue", "placeholder"])
1095
+ ]),
1096
+ key: "1"
1097
+ },
1098
+ b.$slots.prepend ? {
1099
+ name: "prepend",
1100
+ fn: E(() => [
1101
+ f(b.$slots, "prepend", {
1102
+ selectedGroup: d(L),
1103
+ setSelectedGroup: d(s)
1104
+ })
1105
+ ]),
1106
+ key: "2"
1107
+ } : void 0,
1108
+ !d(w) && !e.noCreate && e.labelCreateButton ? {
1109
+ name: "createButton",
1110
+ fn: E(() => [
1111
+ q(Pe, {
1112
+ label: e.labelCreateButton,
1113
+ onClick: d($)
1114
+ }, null, 8, ["label", "onClick"])
1115
+ ]),
1116
+ key: "3"
1117
+ } : void 0
1118
+ ]), 1032, ["useModal", "title", "title-center", "size", "mobile-view", "view"]),
1119
+ J.value.length > 0 ? (a(), o("div", De, x(J.value.join(" ")), 1)) : C("", !0)
570
1120
  ], 64));
571
1121
  }
572
- }), vt = {
1122
+ }), dt = {
573
1123
  "entity_picker.Loading": "Завантаження...",
574
1124
  "entity_picker.Select": "Вибір",
575
1125
  "entity_picker.Search": "Пошук...",
@@ -579,6 +1129,6 @@ const Me = { key: 0 }, Ae = { class: "" }, qe = {
579
1129
  "entity_picker.Nothing found for": "За запитом нічого не знайдено:"
580
1130
  };
581
1131
  export {
582
- ct as OneEntityPicker,
583
- vt as defaultEntityPickerTranslations
1132
+ rt as OneEntityPicker,
1133
+ dt as defaultEntityPickerTranslations
584
1134
  };