@kong-ui-public/forms 4.17.10 → 4.17.11-pr.2517.181da427a.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/forms.es.js +211 -211
- package/dist/forms.umd.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/fields/AutoSuggest.vue.d.ts +2 -2
- package/dist/types/components/fields/FieldArray.vue.d.ts +65 -65
- package/dist/types/components/fields/FieldAutoSuggest.vue.d.ts +173 -8
- package/dist/types/components/fields/{FieldAutoSuggestV2.vue.d.ts → FieldAutoSuggestLegacy.vue.d.ts} +9 -174
- package/dist/types/components/fields/FieldAutoSuggestLegacy.vue.d.ts.map +1 -0
- package/dist/types/components/fields/__tests__/FieldAutoSuggestLegacy.spec.d.ts +2 -0
- package/dist/types/components/fields/__tests__/FieldAutoSuggestLegacy.spec.d.ts.map +1 -0
- package/dist/types/utils/fieldsLoader.d.ts +1 -1
- package/dist/types/utils/fieldsLoader.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/types/components/fields/FieldAutoSuggestV2.vue.d.ts.map +0 -1
- package/dist/types/components/fields/__tests__/FieldAutoSuggest.spec.d.ts +0 -2
- package/dist/types/components/fields/__tests__/FieldAutoSuggest.spec.d.ts.map +0 -1
package/dist/forms.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElementBlock as _, openBlock as c, createElementVNode as m, toDisplayString as L, normalizeClass as ee, createVNode as O, defineComponent as he, provide as zt, resolveComponent as D, withCtx as M, renderSlot as Oe, unref as I, createTextVNode as ce,
|
|
1
|
+
import { createElementBlock as _, openBlock as c, createElementVNode as m, toDisplayString as L, normalizeClass as ee, createVNode as O, defineComponent as he, provide as zt, resolveComponent as D, withCtx as M, renderSlot as Oe, unref as I, createTextVNode as ce, mergeModels as Oi, useModel as Po, createBlock as U, createSlots as cn, ref as ae, onMounted as Xn, watch as mn, resolveDynamicComponent as me, Fragment as Y, renderList as oe, computed as z, toRefs as ut, inject as an, onBeforeMount as Jn, mergeProps as et, Transition as Do, createCommentVNode as B, resolveDirective as Aa, withDirectives as Ee, vModelText as $t, vModelCheckbox as $o, vModelSelect as Vo, vModelDynamic as Ia, isRef as Et, toRef as jo, vModelRadio as qo, vShow as Ko, normalizeProps as Bo, guardReactiveProps as zo, useSlots as fn, nextTick as Fi } from "vue";
|
|
2
2
|
import { createI18n as ke } from "@kong-ui-public/i18n";
|
|
3
3
|
import { TrashIcon as xt, SearchIcon as xo, AddIcon as Qn, RemoveIcon as Ho } from "@kong/icons";
|
|
4
4
|
import { isAxiosError as Yo } from "axios";
|
|
@@ -2383,193 +2383,12 @@ const $e = {
|
|
|
2383
2383
|
]);
|
|
2384
2384
|
};
|
|
2385
2385
|
}
|
|
2386
|
-
}), yo = /* @__PURE__ */ W(Dc, [["__scopeId", "data-v-b4fcf731"]]), $c = "
|
|
2387
|
-
|
|
2388
|
-
label: e.name,
|
|
2389
|
-
value: e.id
|
|
2390
|
-
});
|
|
2391
|
-
function vo(e, t, n) {
|
|
2392
|
-
return n ? je.SET_REFERRAL_VALUE : e && !t || !e && t ? je.UPDATE_ENTITY : e && t ? je.CREATE_FROM_ENTITY : je.CREATE_NOT_FROM_ENTITY;
|
|
2393
|
-
}
|
|
2394
|
-
const Bn = 50, jc = {
|
|
2395
|
-
mixins: [$e],
|
|
2396
|
-
inject: [Se],
|
|
2397
|
-
emits: ["model-updated"],
|
|
2398
|
-
setup() {
|
|
2399
|
-
const { t: e } = ke("en-us", Re);
|
|
2400
|
-
return {
|
|
2401
|
-
t: e
|
|
2402
|
-
};
|
|
2403
|
-
},
|
|
2404
|
-
data() {
|
|
2405
|
-
return {
|
|
2406
|
-
suggestions: [],
|
|
2407
|
-
idValue: "",
|
|
2408
|
-
message: "Type something to search",
|
|
2409
|
-
items: [],
|
|
2410
|
-
initialItems: [],
|
|
2411
|
-
loading: !1
|
|
2412
|
-
};
|
|
2413
|
-
},
|
|
2414
|
-
computed: {
|
|
2415
|
-
fieldState() {
|
|
2416
|
-
return vo(this.model[this.schema.model], this.associatedEntity || this.entityId, this.bypassSearch);
|
|
2417
|
-
},
|
|
2418
|
-
associatedEntity() {
|
|
2419
|
-
return this.$route && this.$route.params[this.entity];
|
|
2420
|
-
},
|
|
2421
|
-
entity() {
|
|
2422
|
-
return this.schema.entity;
|
|
2423
|
-
},
|
|
2424
|
-
scope() {
|
|
2425
|
-
return this.schema.label.toLowerCase();
|
|
2426
|
-
},
|
|
2427
|
-
bypassSearch() {
|
|
2428
|
-
return this.$route && this.$route.query && this.$route.query.no_search;
|
|
2429
|
-
}
|
|
2430
|
-
},
|
|
2431
|
-
async created() {
|
|
2432
|
-
await this.$nextTick();
|
|
2433
|
-
let e, t;
|
|
2434
|
-
switch (this.fieldState) {
|
|
2435
|
-
case je.UPDATE_ENTITY:
|
|
2436
|
-
if (!this[Se]) {
|
|
2437
|
-
console.warn("[@kong-ui-public/forms] No API service provided");
|
|
2438
|
-
break;
|
|
2439
|
-
}
|
|
2440
|
-
t = (await this[Se].getOne(this.entity, this.model[this.schema.model])).data, e = this.getItem(this.schema.entityDataKey ? t[this.schema.entityDataKey] : t), this.idValue = e.id;
|
|
2441
|
-
break;
|
|
2442
|
-
case je.CREATE_FROM_ENTITY:
|
|
2443
|
-
this.idValue = this.associatedEntity.id;
|
|
2444
|
-
break;
|
|
2445
|
-
case je.SET_REFERRAL_VALUE:
|
|
2446
|
-
this.idValue = this.value;
|
|
2447
|
-
}
|
|
2448
|
-
try {
|
|
2449
|
-
e && (this.initialItems = [{ ...e, label: this.getSuggestionLabel(e), value: e.id }]), this.items = this.initialItems;
|
|
2450
|
-
} catch (n) {
|
|
2451
|
-
this.message = `There was an error loading ${this.schema.entity}`, console.error("err!", n);
|
|
2452
|
-
}
|
|
2453
|
-
},
|
|
2454
|
-
methods: {
|
|
2455
|
-
onQueryChange(e) {
|
|
2456
|
-
e.trim().length === 0 && (this.items = [], this.message = "Type something to search"), typeof this.performSearch != "function" && (this.performSearch = wt(
|
|
2457
|
-
this.search,
|
|
2458
|
-
500
|
|
2459
|
-
)), this.performSearch(e);
|
|
2460
|
-
},
|
|
2461
|
-
async search(e) {
|
|
2462
|
-
if (e.trim().length === 0)
|
|
2463
|
-
return;
|
|
2464
|
-
this.loading = !0;
|
|
2465
|
-
const t = [], n = [], i = this.getInputFields(), a = /* @__PURE__ */ new Set();
|
|
2466
|
-
Zn(e) && i.includes("id") ? n.push((async () => {
|
|
2467
|
-
const o = await this.fetchExact(e);
|
|
2468
|
-
t.push({ ...o, label: this.getSuggestionLabel(o), value: o.id });
|
|
2469
|
-
})()) : n.push(...i.filter((o) => o !== "id").map(async (o) => {
|
|
2470
|
-
(await this.fetchSuggestions(e, o)).forEach((r) => {
|
|
2471
|
-
a.has(r.id) || (a.add(r.id), t.push({ ...r, label: this.getSuggestionLabel(r), value: r.id }));
|
|
2472
|
-
});
|
|
2473
|
-
})), await Promise.all(n), this.items = t, this.items.length === 0 && (this.message = "No results"), this.loading = !1;
|
|
2474
|
-
},
|
|
2475
|
-
getItem(e) {
|
|
2476
|
-
return e.data ? e.data.length > 0 ? e.data[0] : [] : e;
|
|
2477
|
-
},
|
|
2478
|
-
async fetchUntilLimit(e) {
|
|
2479
|
-
const t = [];
|
|
2480
|
-
let n = null;
|
|
2481
|
-
if (!this[Se])
|
|
2482
|
-
return console.warn("[@kong-ui-public/forms] No API service provided"), [];
|
|
2483
|
-
for (; t.length < Bn; ) {
|
|
2484
|
-
const i = await this[Se].getAll(this.entity, {
|
|
2485
|
-
size: Bn,
|
|
2486
|
-
offset: n,
|
|
2487
|
-
...e
|
|
2488
|
-
});
|
|
2489
|
-
if (t.push(...i.data.data), n = i.data.offset, !n) break;
|
|
2490
|
-
}
|
|
2491
|
-
return t.slice(0, Bn);
|
|
2492
|
-
},
|
|
2493
|
-
async fetchSuggestions(e, t) {
|
|
2494
|
-
return this.fetchUntilLimit({ [t]: e });
|
|
2495
|
-
},
|
|
2496
|
-
async fetchExact(e) {
|
|
2497
|
-
return this[Se] ? (await this[Se].getOne(this.entity, e)).data : (console.warn("[@kong-ui-public/forms] No API service provided"), {});
|
|
2498
|
-
},
|
|
2499
|
-
getInputFields() {
|
|
2500
|
-
var e, t;
|
|
2501
|
-
return ((t = (e = this.schema) == null ? void 0 : e.inputValues) == null ? void 0 : t.fields) || [];
|
|
2502
|
-
},
|
|
2503
|
-
getSuggestionLabel(e) {
|
|
2504
|
-
const t = this.getInputFields();
|
|
2505
|
-
return t.length && e ? t.map((n) => e[n]).filter(Boolean).join(" - ") : "";
|
|
2506
|
-
},
|
|
2507
|
-
updateModel(e) {
|
|
2508
|
-
this.$emit("model-updated", e != null && e.length ? e : null, this.schema.model);
|
|
2509
|
-
},
|
|
2510
|
-
onSelected(e) {
|
|
2511
|
-
this.idValue = e && e.id, this.updateModel(this.getReturnValue(e || {}));
|
|
2512
|
-
},
|
|
2513
|
-
getReturnValue(e) {
|
|
2514
|
-
var n;
|
|
2515
|
-
const t = (n = this.schema) == null ? void 0 : n.returnKey;
|
|
2516
|
-
return t ? e[t] : e.id;
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
}, qc = ["data-testid", "data-testlabel"], Kc = ["data-testid"], Bc = { class: "autosuggest__results_message" };
|
|
2520
|
-
function zc(e, t, n, i, a, o) {
|
|
2521
|
-
const s = D("KSelect");
|
|
2522
|
-
return c(), U(me(e.schema.disabled ? "k-tooltip" : "div"), {
|
|
2523
|
-
class: "field-wrap autosuggest",
|
|
2524
|
-
"max-width": "300",
|
|
2525
|
-
text: i.t("general.disable_source_scope_change", { scope: o.scope })
|
|
2526
|
-
}, {
|
|
2527
|
-
default: M(() => [
|
|
2528
|
-
O(s, {
|
|
2529
|
-
id: e.schema.model,
|
|
2530
|
-
ref: "suggestion",
|
|
2531
|
-
modelValue: a.idValue,
|
|
2532
|
-
"onUpdate:modelValue": t[0] || (t[0] = (r) => a.idValue = r),
|
|
2533
|
-
clearable: "",
|
|
2534
|
-
disabled: e.schema.disabled,
|
|
2535
|
-
"enable-filtering": "",
|
|
2536
|
-
"filter-function": () => !0,
|
|
2537
|
-
items: a.items,
|
|
2538
|
-
loading: a.loading,
|
|
2539
|
-
placeholder: e.schema.placeholder,
|
|
2540
|
-
width: "100%",
|
|
2541
|
-
onChange: o.onSelected,
|
|
2542
|
-
onQueryChange: o.onQueryChange
|
|
2543
|
-
}, {
|
|
2544
|
-
"item-template": M(({ item: r }) => [
|
|
2545
|
-
m("span", {
|
|
2546
|
-
class: "first-part",
|
|
2547
|
-
"data-testid": r.id && `${r.id}-0`,
|
|
2548
|
-
"data-testlabel": r.label
|
|
2549
|
-
}, L(o.getSuggestionLabel(r).split(" - ")[0]), 9, qc),
|
|
2550
|
-
(c(!0), _(Y, null, oe(o.getSuggestionLabel(r).split(" - ").slice(1), (d, u) => (c(), _("span", {
|
|
2551
|
-
key: u,
|
|
2552
|
-
class: "field-span",
|
|
2553
|
-
"data-testid": r.id && `${r.id}-${u + 1}` || u + 1
|
|
2554
|
-
}, L(d), 9, Kc))), 128))
|
|
2555
|
-
]),
|
|
2556
|
-
empty: M(() => [
|
|
2557
|
-
m("div", Bc, [
|
|
2558
|
-
m("span", null, L(a.message), 1)
|
|
2559
|
-
])
|
|
2560
|
-
]),
|
|
2561
|
-
_: 1
|
|
2562
|
-
}, 8, ["id", "modelValue", "disabled", "items", "loading", "placeholder", "onChange", "onQueryChange"])
|
|
2563
|
-
]),
|
|
2564
|
-
_: 1
|
|
2565
|
-
}, 8, ["text"]);
|
|
2566
|
-
}
|
|
2567
|
-
const bo = /* @__PURE__ */ W(jc, [["render", zc], ["__scopeId", "data-v-9b7636bc"]]), xc = "#6c7489", Hc = "12px", Yc = "20px";
|
|
2568
|
-
var Gc = 4;
|
|
2386
|
+
}), yo = /* @__PURE__ */ W(Dc, [["__scopeId", "data-v-b4fcf731"]]), $c = "#6c7489", Vc = "12px", jc = "20px";
|
|
2387
|
+
var qc = 4;
|
|
2569
2388
|
function Ta(e) {
|
|
2570
|
-
return jt(e,
|
|
2389
|
+
return jt(e, qc);
|
|
2571
2390
|
}
|
|
2572
|
-
const
|
|
2391
|
+
const Kc = ["data-testid", "data-testlabel"], Bc = { class: "item-label" }, zc = { class: "autosuggest__results_message" }, xc = /* @__PURE__ */ he({
|
|
2573
2392
|
__name: "AutoSuggest",
|
|
2574
2393
|
props: /* @__PURE__ */ Oi({
|
|
2575
2394
|
placeholder: { default: "" },
|
|
@@ -2609,16 +2428,16 @@ const Wc = ["data-testid", "data-testlabel"], Zc = { class: "item-label" }, Xc =
|
|
|
2609
2428
|
class: "item-label",
|
|
2610
2429
|
"data-testid": s.id && `${s.id}-0`,
|
|
2611
2430
|
"data-testlabel": s.label
|
|
2612
|
-
}, L(s.label), 9,
|
|
2431
|
+
}, L(s.label), 9, Kc)
|
|
2613
2432
|
], !0)
|
|
2614
2433
|
]),
|
|
2615
2434
|
"selected-item-template": M(({ item: s }) => [
|
|
2616
2435
|
Oe(i.$slots, "selected-item", { item: s }, () => [
|
|
2617
|
-
m("span",
|
|
2436
|
+
m("span", Bc, L(s.label), 1)
|
|
2618
2437
|
], !0)
|
|
2619
2438
|
]),
|
|
2620
2439
|
empty: M(() => [
|
|
2621
|
-
m("div",
|
|
2440
|
+
m("div", zc, [
|
|
2622
2441
|
m("span", null, L(i.emptyMessage || I(t)("fields.auto_suggest.no_results")), 1)
|
|
2623
2442
|
])
|
|
2624
2443
|
]),
|
|
@@ -2634,10 +2453,18 @@ const Wc = ["data-testid", "data-testlabel"], Zc = { class: "item-label" }, Xc =
|
|
|
2634
2453
|
]), 1032, ["id", "modelValue", "disabled", "items", "loading", "placeholder"]);
|
|
2635
2454
|
};
|
|
2636
2455
|
}
|
|
2637
|
-
}),
|
|
2456
|
+
}), Hc = /* @__PURE__ */ W(xc, [["__scopeId", "data-v-baeb3bb0"]]), Yc = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", Zn = (e) => e ? e.length === 36 && new RegExp(`^${Yc}$`).test(e) : !1, Gc = (e) => ({
|
|
2457
|
+
...e,
|
|
2458
|
+
label: e.name,
|
|
2459
|
+
value: e.id
|
|
2460
|
+
});
|
|
2461
|
+
function vo(e, t, n) {
|
|
2462
|
+
return n ? je.SET_REFERRAL_VALUE : e && !t || !e && t ? je.UPDATE_ENTITY : e && t ? je.CREATE_FROM_ENTITY : je.CREATE_NOT_FROM_ENTITY;
|
|
2463
|
+
}
|
|
2464
|
+
const Wc = 500, Zc = 50, Xc = /* @__PURE__ */ he({
|
|
2638
2465
|
__name: "FieldScopedEntitySelect",
|
|
2639
2466
|
props: {
|
|
2640
|
-
transformItem: { type: Function, default:
|
|
2467
|
+
transformItem: { type: Function, default: Gc },
|
|
2641
2468
|
allowUuidSearch: { type: Boolean, default: !1 },
|
|
2642
2469
|
placeholder: {},
|
|
2643
2470
|
fields: { default: () => [] },
|
|
@@ -2689,8 +2516,8 @@ const Wc = ["data-testid", "data-testlabel"], Zc = { class: "item-label" }, Xc =
|
|
|
2689
2516
|
return;
|
|
2690
2517
|
}
|
|
2691
2518
|
A(y, v);
|
|
2692
|
-
},
|
|
2693
|
-
const { data: { data: y, next: v, offset: g } } = await e.getPartial(
|
|
2519
|
+
}, Wc, { leading: !0 }), k = async (y, v) => await e.getAll(y, v), q = async () => {
|
|
2520
|
+
const { data: { data: y, next: v, offset: g } } = await e.getPartial(Zc);
|
|
2694
2521
|
return (!v || !g) && (i.value = !0), s.value = y, r.value = y.map((V) => ({
|
|
2695
2522
|
...e.transformItem(V),
|
|
2696
2523
|
group: d("fields.auto_suggest.recently_created", { entity: e.entity })
|
|
@@ -2711,7 +2538,7 @@ const Wc = ["data-testid", "data-testlabel"], Zc = { class: "item-label" }, Xc =
|
|
|
2711
2538
|
v && (o.value = N(r.value)), y();
|
|
2712
2539
|
});
|
|
2713
2540
|
o.value = N(r.value);
|
|
2714
|
-
}), (y, v) => (c(), U(
|
|
2541
|
+
}), (y, v) => (c(), U(Hc, {
|
|
2715
2542
|
id: y.id,
|
|
2716
2543
|
disabled: y.fieldDisabled,
|
|
2717
2544
|
"dom-id": y.domId,
|
|
@@ -2740,9 +2567,9 @@ const Wc = ["data-testid", "data-testlabel"], Zc = { class: "item-label" }, Xc =
|
|
|
2740
2567
|
} : void 0
|
|
2741
2568
|
]), 1032, ["id", "disabled", "dom-id", "empty-message", "loading", "placeholder", "readonly", "suggestions", "onQueryChange"]));
|
|
2742
2569
|
}
|
|
2743
|
-
}),
|
|
2570
|
+
}), Jc = 1e3, Qc = {
|
|
2744
2571
|
components: {
|
|
2745
|
-
FieldScopedEntitySelect:
|
|
2572
|
+
FieldScopedEntitySelect: Xc,
|
|
2746
2573
|
SearchIcon: xo
|
|
2747
2574
|
},
|
|
2748
2575
|
mixins: [$e],
|
|
@@ -2752,8 +2579,8 @@ const Wc = ["data-testid", "data-testlabel"], Zc = { class: "item-label" }, Xc =
|
|
|
2752
2579
|
const { t: e } = ke("en-us", Re);
|
|
2753
2580
|
return {
|
|
2754
2581
|
t: e,
|
|
2755
|
-
KUI_ICON_SIZE_40:
|
|
2756
|
-
KUI_COLOR_TEXT_NEUTRAL:
|
|
2582
|
+
KUI_ICON_SIZE_40: jc,
|
|
2583
|
+
KUI_COLOR_TEXT_NEUTRAL: $c,
|
|
2757
2584
|
EMPTY_VALUE_PLACEHOLDER: rl
|
|
2758
2585
|
};
|
|
2759
2586
|
},
|
|
@@ -2848,7 +2675,7 @@ const Wc = ["data-testid", "data-testlabel"], Zc = { class: "item-label" }, Xc =
|
|
|
2848
2675
|
if (!this[Se])
|
|
2849
2676
|
return console.warn("[@kong-ui-public/forms] No API service provided"), [];
|
|
2850
2677
|
const n = this[Se].getAllV2, { data: i } = await n(this.entity, {
|
|
2851
|
-
size:
|
|
2678
|
+
size: Jc,
|
|
2852
2679
|
...e
|
|
2853
2680
|
}, t);
|
|
2854
2681
|
return i.data;
|
|
@@ -2873,8 +2700,8 @@ const Wc = ["data-testid", "data-testlabel"], Zc = { class: "item-label" }, Xc =
|
|
|
2873
2700
|
return t ? e[t] : e.id;
|
|
2874
2701
|
}
|
|
2875
2702
|
}
|
|
2876
|
-
},
|
|
2877
|
-
function
|
|
2703
|
+
}, em = { class: "entity-suggestion-item" }, tm = { class: "entity-label" }, nm = { class: "entity-id" }, im = { class: "selected-entity-item" }, am = { class: "selected-entity-label" };
|
|
2704
|
+
function om(e, t, n, i, a, o) {
|
|
2878
2705
|
const s = D("SearchIcon"), r = D("FieldScopedEntitySelect");
|
|
2879
2706
|
return c(), U(me(e.schema.disabled ? "k-tooltip" : "div"), {
|
|
2880
2707
|
class: "field-wrap autosuggest",
|
|
@@ -2907,14 +2734,14 @@ function um(e, t, n, i, a, o) {
|
|
|
2907
2734
|
}, null, 8, ["color", "size"])
|
|
2908
2735
|
]),
|
|
2909
2736
|
item: M(({ item: d }) => [
|
|
2910
|
-
m("div",
|
|
2911
|
-
m("span",
|
|
2912
|
-
m("span",
|
|
2737
|
+
m("div", em, [
|
|
2738
|
+
m("span", tm, L(d.label ?? i.EMPTY_VALUE_PLACEHOLDER), 1),
|
|
2739
|
+
m("span", nm, L(d.id), 1)
|
|
2913
2740
|
])
|
|
2914
2741
|
]),
|
|
2915
2742
|
"selected-item": M(({ item: d }) => [
|
|
2916
|
-
m("span",
|
|
2917
|
-
m("span",
|
|
2743
|
+
m("span", im, [
|
|
2744
|
+
m("span", am, L(d.label ?? d.id), 1)
|
|
2918
2745
|
])
|
|
2919
2746
|
]),
|
|
2920
2747
|
_: 1
|
|
@@ -2923,7 +2750,180 @@ function um(e, t, n, i, a, o) {
|
|
|
2923
2750
|
_: 1
|
|
2924
2751
|
}, 8, ["text"]);
|
|
2925
2752
|
}
|
|
2926
|
-
const
|
|
2753
|
+
const bo = /* @__PURE__ */ W(Qc, [["render", om], ["__scopeId", "data-v-94561d0b"]]), Bn = 50, rm = {
|
|
2754
|
+
mixins: [$e],
|
|
2755
|
+
inject: [Se],
|
|
2756
|
+
emits: ["model-updated"],
|
|
2757
|
+
setup() {
|
|
2758
|
+
const { t: e } = ke("en-us", Re);
|
|
2759
|
+
return {
|
|
2760
|
+
t: e
|
|
2761
|
+
};
|
|
2762
|
+
},
|
|
2763
|
+
data() {
|
|
2764
|
+
return {
|
|
2765
|
+
suggestions: [],
|
|
2766
|
+
idValue: "",
|
|
2767
|
+
message: "Type something to search",
|
|
2768
|
+
items: [],
|
|
2769
|
+
initialItems: [],
|
|
2770
|
+
loading: !1
|
|
2771
|
+
};
|
|
2772
|
+
},
|
|
2773
|
+
computed: {
|
|
2774
|
+
fieldState() {
|
|
2775
|
+
return vo(this.model[this.schema.model], this.associatedEntity || this.entityId, this.bypassSearch);
|
|
2776
|
+
},
|
|
2777
|
+
associatedEntity() {
|
|
2778
|
+
return this.$route && this.$route.params[this.entity];
|
|
2779
|
+
},
|
|
2780
|
+
entity() {
|
|
2781
|
+
return this.schema.entity;
|
|
2782
|
+
},
|
|
2783
|
+
scope() {
|
|
2784
|
+
return this.schema.label.toLowerCase();
|
|
2785
|
+
},
|
|
2786
|
+
bypassSearch() {
|
|
2787
|
+
return this.$route && this.$route.query && this.$route.query.no_search;
|
|
2788
|
+
}
|
|
2789
|
+
},
|
|
2790
|
+
async created() {
|
|
2791
|
+
await this.$nextTick();
|
|
2792
|
+
let e, t;
|
|
2793
|
+
switch (this.fieldState) {
|
|
2794
|
+
case je.UPDATE_ENTITY:
|
|
2795
|
+
if (!this[Se]) {
|
|
2796
|
+
console.warn("[@kong-ui-public/forms] No API service provided");
|
|
2797
|
+
break;
|
|
2798
|
+
}
|
|
2799
|
+
t = (await this[Se].getOne(this.entity, this.model[this.schema.model])).data, e = this.getItem(this.schema.entityDataKey ? t[this.schema.entityDataKey] : t), this.idValue = e.id;
|
|
2800
|
+
break;
|
|
2801
|
+
case je.CREATE_FROM_ENTITY:
|
|
2802
|
+
this.idValue = this.associatedEntity.id;
|
|
2803
|
+
break;
|
|
2804
|
+
case je.SET_REFERRAL_VALUE:
|
|
2805
|
+
this.idValue = this.value;
|
|
2806
|
+
}
|
|
2807
|
+
try {
|
|
2808
|
+
e && (this.initialItems = [{ ...e, label: this.getSuggestionLabel(e), value: e.id }]), this.items = this.initialItems;
|
|
2809
|
+
} catch (n) {
|
|
2810
|
+
this.message = `There was an error loading ${this.schema.entity}`, console.error("err!", n);
|
|
2811
|
+
}
|
|
2812
|
+
},
|
|
2813
|
+
methods: {
|
|
2814
|
+
onQueryChange(e) {
|
|
2815
|
+
e.trim().length === 0 && (this.items = [], this.message = "Type something to search"), typeof this.performSearch != "function" && (this.performSearch = wt(
|
|
2816
|
+
this.search,
|
|
2817
|
+
500
|
|
2818
|
+
)), this.performSearch(e);
|
|
2819
|
+
},
|
|
2820
|
+
async search(e) {
|
|
2821
|
+
if (e.trim().length === 0)
|
|
2822
|
+
return;
|
|
2823
|
+
this.loading = !0;
|
|
2824
|
+
const t = [], n = [], i = this.getInputFields(), a = /* @__PURE__ */ new Set();
|
|
2825
|
+
Zn(e) && i.includes("id") ? n.push((async () => {
|
|
2826
|
+
const o = await this.fetchExact(e);
|
|
2827
|
+
t.push({ ...o, label: this.getSuggestionLabel(o), value: o.id });
|
|
2828
|
+
})()) : n.push(...i.filter((o) => o !== "id").map(async (o) => {
|
|
2829
|
+
(await this.fetchSuggestions(e, o)).forEach((r) => {
|
|
2830
|
+
a.has(r.id) || (a.add(r.id), t.push({ ...r, label: this.getSuggestionLabel(r), value: r.id }));
|
|
2831
|
+
});
|
|
2832
|
+
})), await Promise.all(n), this.items = t, this.items.length === 0 && (this.message = "No results"), this.loading = !1;
|
|
2833
|
+
},
|
|
2834
|
+
getItem(e) {
|
|
2835
|
+
return e.data ? e.data.length > 0 ? e.data[0] : [] : e;
|
|
2836
|
+
},
|
|
2837
|
+
async fetchUntilLimit(e) {
|
|
2838
|
+
const t = [];
|
|
2839
|
+
let n = null;
|
|
2840
|
+
if (!this[Se])
|
|
2841
|
+
return console.warn("[@kong-ui-public/forms] No API service provided"), [];
|
|
2842
|
+
for (; t.length < Bn; ) {
|
|
2843
|
+
const i = await this[Se].getAll(this.entity, {
|
|
2844
|
+
size: Bn,
|
|
2845
|
+
offset: n,
|
|
2846
|
+
...e
|
|
2847
|
+
});
|
|
2848
|
+
if (t.push(...i.data.data), n = i.data.offset, !n) break;
|
|
2849
|
+
}
|
|
2850
|
+
return t.slice(0, Bn);
|
|
2851
|
+
},
|
|
2852
|
+
async fetchSuggestions(e, t) {
|
|
2853
|
+
return this.fetchUntilLimit({ [t]: e });
|
|
2854
|
+
},
|
|
2855
|
+
async fetchExact(e) {
|
|
2856
|
+
return this[Se] ? (await this[Se].getOne(this.entity, e)).data : (console.warn("[@kong-ui-public/forms] No API service provided"), {});
|
|
2857
|
+
},
|
|
2858
|
+
getInputFields() {
|
|
2859
|
+
var e, t;
|
|
2860
|
+
return ((t = (e = this.schema) == null ? void 0 : e.inputValues) == null ? void 0 : t.fields) || [];
|
|
2861
|
+
},
|
|
2862
|
+
getSuggestionLabel(e) {
|
|
2863
|
+
const t = this.getInputFields();
|
|
2864
|
+
return t.length && e ? t.map((n) => e[n]).filter(Boolean).join(" - ") : "";
|
|
2865
|
+
},
|
|
2866
|
+
updateModel(e) {
|
|
2867
|
+
this.$emit("model-updated", e != null && e.length ? e : null, this.schema.model);
|
|
2868
|
+
},
|
|
2869
|
+
onSelected(e) {
|
|
2870
|
+
this.idValue = e && e.id, this.updateModel(this.getReturnValue(e || {}));
|
|
2871
|
+
},
|
|
2872
|
+
getReturnValue(e) {
|
|
2873
|
+
var n;
|
|
2874
|
+
const t = (n = this.schema) == null ? void 0 : n.returnKey;
|
|
2875
|
+
return t ? e[t] : e.id;
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
}, sm = ["data-testid", "data-testlabel"], lm = ["data-testid"], dm = { class: "autosuggest__results_message" };
|
|
2879
|
+
function um(e, t, n, i, a, o) {
|
|
2880
|
+
const s = D("KSelect");
|
|
2881
|
+
return c(), U(me(e.schema.disabled ? "k-tooltip" : "div"), {
|
|
2882
|
+
class: "field-wrap autosuggest",
|
|
2883
|
+
"max-width": "300",
|
|
2884
|
+
text: i.t("general.disable_source_scope_change", { scope: o.scope })
|
|
2885
|
+
}, {
|
|
2886
|
+
default: M(() => [
|
|
2887
|
+
O(s, {
|
|
2888
|
+
id: e.schema.model,
|
|
2889
|
+
ref: "suggestion",
|
|
2890
|
+
modelValue: a.idValue,
|
|
2891
|
+
"onUpdate:modelValue": t[0] || (t[0] = (r) => a.idValue = r),
|
|
2892
|
+
clearable: "",
|
|
2893
|
+
disabled: e.schema.disabled,
|
|
2894
|
+
"enable-filtering": "",
|
|
2895
|
+
"filter-function": () => !0,
|
|
2896
|
+
items: a.items,
|
|
2897
|
+
loading: a.loading,
|
|
2898
|
+
placeholder: e.schema.placeholder,
|
|
2899
|
+
width: "100%",
|
|
2900
|
+
onChange: o.onSelected,
|
|
2901
|
+
onQueryChange: o.onQueryChange
|
|
2902
|
+
}, {
|
|
2903
|
+
"item-template": M(({ item: r }) => [
|
|
2904
|
+
m("span", {
|
|
2905
|
+
class: "first-part",
|
|
2906
|
+
"data-testid": r.id && `${r.id}-0`,
|
|
2907
|
+
"data-testlabel": r.label
|
|
2908
|
+
}, L(o.getSuggestionLabel(r).split(" - ")[0]), 9, sm),
|
|
2909
|
+
(c(!0), _(Y, null, oe(o.getSuggestionLabel(r).split(" - ").slice(1), (d, u) => (c(), _("span", {
|
|
2910
|
+
key: u,
|
|
2911
|
+
class: "field-span",
|
|
2912
|
+
"data-testid": r.id && `${r.id}-${u + 1}` || u + 1
|
|
2913
|
+
}, L(d), 9, lm))), 128))
|
|
2914
|
+
]),
|
|
2915
|
+
empty: M(() => [
|
|
2916
|
+
m("div", dm, [
|
|
2917
|
+
m("span", null, L(a.message), 1)
|
|
2918
|
+
])
|
|
2919
|
+
]),
|
|
2920
|
+
_: 1
|
|
2921
|
+
}, 8, ["id", "modelValue", "disabled", "items", "loading", "placeholder", "onChange", "onQueryChange"])
|
|
2922
|
+
]),
|
|
2923
|
+
_: 1
|
|
2924
|
+
}, 8, ["text"]);
|
|
2925
|
+
}
|
|
2926
|
+
const _o = /* @__PURE__ */ W(rm, [["render", um], ["__scopeId", "data-v-8cfdc7f6"]]);
|
|
2927
2927
|
function cm(e) {
|
|
2928
2928
|
const t = ae([]), n = ae(null), i = (h) => st(h) ? dt[h] != null ? dt[h] : (console.warn(`'${h}' is not a validator function!`), null) : h, a = z({
|
|
2929
2929
|
get() {
|
|
@@ -3747,7 +3747,7 @@ const So = /* @__PURE__ */ W(gm, [["render", vm]]), bm = { class: "field-object-
|
|
|
3747
3747
|
FieldObject: wo,
|
|
3748
3748
|
FieldObjectAdvanced: Eo,
|
|
3749
3749
|
FieldAutoSuggest: bo,
|
|
3750
|
-
|
|
3750
|
+
FieldAutoSuggestLegacy: _o,
|
|
3751
3751
|
FieldRadio: Mo,
|
|
3752
3752
|
FieldArrayCardContainer: po,
|
|
3753
3753
|
FieldInput: To
|
|
@@ -3924,7 +3924,7 @@ function Xm(e, t, n, i, a, o) {
|
|
|
3924
3924
|
}, 8, ["class", "data-testid", "onClick"])
|
|
3925
3925
|
], 10, Ym)) : B("", !0);
|
|
3926
3926
|
}
|
|
3927
|
-
const Jm = /* @__PURE__ */ W(Hm, [["render", Xm], ["__scopeId", "data-v-
|
|
3927
|
+
const Jm = /* @__PURE__ */ W(Hm, [["render", Xm], ["__scopeId", "data-v-d6740b2b"]]), Qm = { class: "form-field-wrapper field-checkbox" }, ef = /* @__PURE__ */ he({
|
|
3928
3928
|
__name: "FieldCheckbox",
|
|
3929
3929
|
props: {
|
|
3930
3930
|
disabled: {
|
|
@@ -4622,7 +4622,7 @@ const _f = /* @__PURE__ */ W(ff, [["render", bf], ["__scopeId", "data-v-9a9650ac
|
|
|
4622
4622
|
FieldArrayItem: go,
|
|
4623
4623
|
FieldArrayMultiItem: yo,
|
|
4624
4624
|
FieldAutoSuggest: bo,
|
|
4625
|
-
|
|
4625
|
+
FieldAutoSuggestLegacy: _o,
|
|
4626
4626
|
FieldCheckbox: tf,
|
|
4627
4627
|
FieldChecklist: mf,
|
|
4628
4628
|
FieldInput: To,
|
|
@@ -5081,7 +5081,7 @@ const Zf = (e) => {
|
|
|
5081
5081
|
"data-testid": "new-redis-config-area",
|
|
5082
5082
|
onClick: T[0] || (T[0] = (g) => N.$emit("showNewPartialModal"))
|
|
5083
5083
|
}, [
|
|
5084
|
-
O(I(Qn), { size: I(
|
|
5084
|
+
O(I(Qn), { size: I(Vc) }, null, 8, ["size"]),
|
|
5085
5085
|
m("span", null, L(I(t)("redis.shared_configuration.create_new_configuration", { type: I(Sa)(e.redisType) })), 1)
|
|
5086
5086
|
])
|
|
5087
5087
|
]),
|