@septkit/ui 0.0.72 → 0.0.74
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/autocomplete/index.js +2 -0
- package/dist/autocomplete/text-input-autocomplete.js +5 -0
- package/dist/autocomplete/text-input-autocomplete.vue_vue_type_script_setup_true_lang.js +92 -0
- package/dist/index.d.ts +183 -107
- package/dist/index.js +48 -43
- package/dist/ui.css +1 -1
- package/dist/xpath-input/index.js +3 -0
- package/dist/xpath-input/xpath-input.js +28 -0
- package/dist/xpath-input/xpath-input.vue_vue_type_script_setup_true_lang.js +97 -0
- package/dist/xpath-input/xpath-input2.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, defineComponent as o, mergeModels as s, normalizeClass as c, normalizeStyle as l, openBlock as u, ref as d, renderList as f, toDisplayString as p, useModel as m, watch as h, withModifiers as g } from "vue";
|
|
2
|
+
//#region lib/autocomplete/text-input-autocomplete.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var _ = { class: "relative w-full" }, v = ["value", "placeholder"], y = ["aria-selected", "onMousedown"], b = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "font-bold"
|
|
6
|
+
}, x = /*@__PURE__*/ o({
|
|
7
|
+
__name: "text-input-autocomplete",
|
|
8
|
+
props: /*@__PURE__*/ s({
|
|
9
|
+
suggestions: { default: () => [] },
|
|
10
|
+
placeholder: { default: "" },
|
|
11
|
+
suggestionsMaxHeight: { default: "13rem" }
|
|
12
|
+
}, {
|
|
13
|
+
modelValue: { default: "" },
|
|
14
|
+
modelModifiers: {}
|
|
15
|
+
}),
|
|
16
|
+
emits: ["update:modelValue"],
|
|
17
|
+
setup(o) {
|
|
18
|
+
let s = o, x = m(o, "modelValue"), S = d(!1), C = d(-1), w = d(null), T = t(() => x.value.toLowerCase().split(/\s+/).filter(Boolean)), E = t(() => T.value.length === 0 ? s.suggestions : s.suggestions.filter((e) => {
|
|
19
|
+
let t = e.toLowerCase();
|
|
20
|
+
return T.value.every((e) => t.includes(e));
|
|
21
|
+
}));
|
|
22
|
+
h(C, (e) => {
|
|
23
|
+
e < 0 || w.value?.children[e]?.scrollIntoView({
|
|
24
|
+
block: "nearest",
|
|
25
|
+
inline: "nearest"
|
|
26
|
+
});
|
|
27
|
+
}, { flush: "post" });
|
|
28
|
+
function D(e) {
|
|
29
|
+
let t = e.toLowerCase(), n = Array(e.length).fill(!1);
|
|
30
|
+
for (let e of T.value) {
|
|
31
|
+
let r = t.indexOf(e);
|
|
32
|
+
for (; r !== -1;) n.fill(!0, r, r + e.length), r = t.indexOf(e, r + 1);
|
|
33
|
+
}
|
|
34
|
+
let r = [];
|
|
35
|
+
for (let t = 0; t < e.length; t++) {
|
|
36
|
+
let i = n[t], a = r[r.length - 1];
|
|
37
|
+
a && a.matched === i ? a.text += e[t] : r.push({
|
|
38
|
+
text: e[t],
|
|
39
|
+
matched: i
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return r;
|
|
43
|
+
}
|
|
44
|
+
function O(e) {
|
|
45
|
+
x.value = e.target.value, C.value = -1, S.value = E.value.length > 0;
|
|
46
|
+
}
|
|
47
|
+
function k() {
|
|
48
|
+
E.value.length > 0 && (S.value = !0);
|
|
49
|
+
}
|
|
50
|
+
function A() {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
S.value = !1, C.value = -1;
|
|
53
|
+
}, 150);
|
|
54
|
+
}
|
|
55
|
+
function j(e) {
|
|
56
|
+
x.value = e, S.value = !1, C.value = -1;
|
|
57
|
+
}
|
|
58
|
+
function M(e) {
|
|
59
|
+
if (!S.value) {
|
|
60
|
+
e.key === "ArrowDown" && E.value.length > 0 && (S.value = !0);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
e.key === "ArrowDown" ? (e.preventDefault(), C.value = Math.min(C.value + 1, E.value.length - 1)) : e.key === "ArrowUp" ? (e.preventDefault(), C.value = Math.max(C.value - 1, -1)) : e.key === "Enter" && C.value >= 0 ? (e.preventDefault(), j(E.value[C.value])) : e.key === "Tab" && E.value.length > 0 ? (e.preventDefault(), j(C.value >= 0 ? E.value[C.value] : E.value[0])) : e.key === "Escape" && (S.value = !1, C.value = -1);
|
|
64
|
+
}
|
|
65
|
+
return (t, s) => (u(), r("div", _, [i("input", {
|
|
66
|
+
type: "text",
|
|
67
|
+
value: x.value,
|
|
68
|
+
placeholder: o.placeholder,
|
|
69
|
+
class: "input input-bordered w-full",
|
|
70
|
+
autocomplete: "off",
|
|
71
|
+
onInput: O,
|
|
72
|
+
onFocus: k,
|
|
73
|
+
onBlur: A,
|
|
74
|
+
onKeydown: M
|
|
75
|
+
}, null, 40, v), S.value ? (u(), r("ul", {
|
|
76
|
+
key: 0,
|
|
77
|
+
ref_key: "listbox",
|
|
78
|
+
ref: w,
|
|
79
|
+
class: "absolute z-50 mt-1 w-full bg-base-100 border border-base-300 rounded-box shadow-md overflow-y-auto p-1",
|
|
80
|
+
style: l({ maxHeight: o.suggestionsMaxHeight }),
|
|
81
|
+
role: "listbox"
|
|
82
|
+
}, [(u(!0), r(e, null, f(E.value, (t, n) => (u(), r("li", {
|
|
83
|
+
key: t,
|
|
84
|
+
class: c(["cursor-pointer text-sm px-3 py-1.5 rounded select-none", n === C.value ? "bg-primary text-primary-content" : "hover:bg-base-200"]),
|
|
85
|
+
"aria-selected": n === C.value,
|
|
86
|
+
role: "option",
|
|
87
|
+
onMousedown: g((e) => j(t), ["prevent"])
|
|
88
|
+
}, [(u(!0), r(e, null, f(D(t), (t, n) => (u(), r(e, { key: n }, [t.matched ? (u(), r("strong", b, p(t.text), 1)) : (u(), r(e, { key: 1 }, [a(p(t.text), 1)], 64))], 64))), 128))], 42, y))), 128))], 4)) : n("", !0)]));
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
//#endregion
|
|
92
|
+
export { x as default };
|