@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.
@@ -0,0 +1,3 @@
1
+ import { buildXpath as e, parseXpath as t, validateXpath as n } from "./xpath-input.js";
2
+ import r from "./xpath-input2.js";
3
+ export { r as XpathInput, e as buildXpath, t as parseXpath, n as validateXpath };
@@ -0,0 +1,28 @@
1
+ //#region lib/xpath-input/xpath-input.ts
2
+ var e = "[\\w.-]+", t = RegExp(`^${e}$`), n = `ancestor::\\*\\[local-name\\(\\)='(${e})'\\]\\[1\\]`, r = `local-name\\(\\)='${e}'`, i = RegExp(`^(?:${n})?//\\*(?:\\[(${r}(?: or ${r})*)\\])?$`);
3
+ function a({ anchor: e, targets: t }) {
4
+ return c(e, { optional: !0 }), t.forEach((e) => c(e)), !e && t.length === 0 ? "" : `${e ? `ancestor::*[local-name()='${e}'][1]` : ""}//*${t.length > 0 ? `[${t.map((e) => `local-name()='${e}'`).join(" or ")}]` : ""}`;
5
+ }
6
+ function o(e) {
7
+ let t = i.exec(e);
8
+ if (!t || !t[1] && !t[2]) return;
9
+ let n = [...(t[2] ?? "").matchAll(/local-name\(\)='([^']+)'/g)].map((e) => e[1]);
10
+ return {
11
+ anchor: t[1] ?? "",
12
+ targets: n
13
+ };
14
+ }
15
+ function s(e) {
16
+ if (e.trim() !== "") try {
17
+ let t = document.implementation.createDocument(null, "root");
18
+ t.evaluate(e, t, null, XPathResult.ANY_TYPE, null);
19
+ return;
20
+ } catch (e) {
21
+ return e instanceof Error && e.message || "Invalid XPath";
22
+ }
23
+ }
24
+ function c(e, { optional: n = !1 } = {}) {
25
+ if (!(n && e === "") && !t.test(e)) throw Error(`Invalid element name "${e}"`);
26
+ }
27
+ //#endregion
28
+ export { a as buildXpath, o as parseXpath, s as validateXpath };
@@ -0,0 +1,97 @@
1
+ import { buildXpath as e, parseXpath as t, validateXpath as n } from "./xpath-input.js";
2
+ import { Fragment as r, computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, defineComponent as c, mergeModels as l, normalizeClass as u, openBlock as d, ref as f, renderList as p, renderSlot as m, toDisplayString as h, useModel as g, vModelText as _, watch as v, withDirectives as y } from "vue";
3
+ //#region lib/xpath-input/xpath-input.vue?vue&type=script&setup=true&lang.ts
4
+ var b = {
5
+ class: "flex flex-col gap-2",
6
+ "data-testid": "xpath-input"
7
+ }, x = { class: "tabs tabs-box w-fit tabs-sm" }, S = ["disabled", "title"], C = { class: "fieldset" }, w = { class: "flex flex-wrap gap-2" }, T = [
8
+ "aria-pressed",
9
+ "data-testid",
10
+ "onClick"
11
+ ], E = { class: "fieldset" }, D = { class: "flex flex-wrap gap-2" }, O = [
12
+ "aria-pressed",
13
+ "data-testid",
14
+ "onClick"
15
+ ], k = {
16
+ key: 1,
17
+ class: "fieldset"
18
+ }, A = {
19
+ key: 0,
20
+ class: "label text-error",
21
+ role: "alert",
22
+ "data-testid": "xpath-input-error"
23
+ }, j = /*@__PURE__*/ c({
24
+ __name: "xpath-input",
25
+ props: /*@__PURE__*/ l({
26
+ anchors: {},
27
+ targets: {},
28
+ anywhereLabel: { default: "Anywhere" }
29
+ }, {
30
+ modelValue: { default: "" },
31
+ modelModifiers: {}
32
+ }),
33
+ emits: ["update:modelValue"],
34
+ setup(c) {
35
+ let l = c, j = g(c, "modelValue"), M = i(() => t(j.value)), N = f(M.value?.anchor ?? ""), P = f(M.value?.targets ?? []), F = f(M.value || j.value === "" ? "builder" : "xpath"), I = i(() => j.value === "" || M.value !== void 0), L = i(() => n(j.value)), R = i(() => [{
36
+ value: "",
37
+ label: l.anywhereLabel
38
+ }, ...l.anchors]);
39
+ v(M, (e) => {
40
+ e && (N.value = e.anchor, P.value = e.targets);
41
+ });
42
+ function z(e) {
43
+ N.value = e, V();
44
+ }
45
+ function B(e) {
46
+ P.value = P.value.includes(e) ? P.value.filter((t) => t !== e) : [...P.value, e], V();
47
+ }
48
+ function V() {
49
+ j.value = e({
50
+ anchor: N.value,
51
+ targets: P.value
52
+ });
53
+ }
54
+ return (e, t) => (d(), o("div", b, [
55
+ s("div", x, [s("button", {
56
+ type: "button",
57
+ class: u(["tab", { "tab-active": F.value === "builder" }]),
58
+ disabled: !I.value,
59
+ title: I.value ? void 0 : "This XPath cannot be shown in the builder",
60
+ "data-testid": "xpath-input-mode-builder",
61
+ onClick: t[0] ||= (e) => F.value = "builder"
62
+ }, " Builder ", 10, S), s("button", {
63
+ type: "button",
64
+ class: u(["tab", { "tab-active": F.value === "xpath" }]),
65
+ "data-testid": "xpath-input-mode-xpath",
66
+ onClick: t[1] ||= (e) => F.value = "xpath"
67
+ }, " XPath ", 2)]),
68
+ F.value === "builder" ? (d(), o(r, { key: 0 }, [s("fieldset", C, [t[3] ||= s("legend", { class: "fieldset-legend text-sm font-medium" }, "Scope", -1), s("div", w, [(d(!0), o(r, null, p(R.value, (e) => (d(), o("button", {
69
+ key: e.value,
70
+ type: "button",
71
+ class: u(["badge badge-sm cursor-pointer", N.value === e.value ? "badge-primary" : "badge-soft"]),
72
+ "aria-pressed": N.value === e.value,
73
+ "data-testid": `xpath-input-anchor-${e.value || "none"}`,
74
+ onClick: (t) => z(e.value)
75
+ }, h(e.label), 11, T))), 128))])]), s("fieldset", E, [t[4] ||= s("legend", { class: "fieldset-legend text-sm font-medium" }, "Select", -1), s("div", D, [(d(!0), o(r, null, p(l.targets, (e) => (d(), o("button", {
76
+ key: e.value,
77
+ type: "button",
78
+ class: u(["badge badge-sm cursor-pointer", P.value.includes(e.value) ? "badge-primary" : "badge-soft"]),
79
+ "aria-pressed": P.value.includes(e.value),
80
+ "data-testid": `xpath-input-target-${e.value}`,
81
+ onClick: (t) => B(e.value)
82
+ }, h(e.label), 11, O))), 128))])])], 64)) : (d(), o("fieldset", k, [
83
+ t[5] ||= s("legend", { class: "fieldset-legend" }, "XPath", -1),
84
+ y(s("input", {
85
+ "onUpdate:modelValue": t[2] ||= (e) => j.value = e,
86
+ type: "text",
87
+ class: u(["input w-full font-mono", { "input-error": L.value }]),
88
+ "data-testid": "xpath-input-raw"
89
+ }, null, 2), [[_, j.value]]),
90
+ L.value ? (d(), o("p", A, h(L.value), 1)) : a("", !0)
91
+ ])),
92
+ m(e.$slots, "footer")
93
+ ]));
94
+ }
95
+ });
96
+ //#endregion
97
+ export { j as default };
@@ -0,0 +1,5 @@
1
+ import e from "./xpath-input.vue_vue_type_script_setup_true_lang.js";
2
+ //#region lib/xpath-input/xpath-input.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@septkit/ui",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
4
4
  "type": "module",
5
5
  "source": "lib/index.ts",
6
6
  "files": [