@septkit/ui 0.0.81 → 0.0.82

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/index.d.ts CHANGED
@@ -336,8 +336,9 @@ declare const __VLS_component_8: DefineComponent<__VLS_PublicProps_7, {}, {}, {}
336
336
  "onUpdate:invalid"?: ((value: boolean) => any) | undefined;
337
337
  }>, {
338
338
  targets: string[];
339
- nameOwners: string[];
339
+ nameParent: boolean;
340
340
  anywhereLabel: string;
341
+ nameLabel: string;
341
342
  searchable: boolean;
342
343
  allowXpath: boolean;
343
344
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
@@ -494,10 +495,11 @@ declare type __VLS_Props_23 = {
494
495
  };
495
496
 
496
497
  declare type __VLS_Props_24 = {
497
- anchors: Option_2[];
498
+ anchors: AnchorOption[];
498
499
  anywhereLabel?: string;
499
500
  targets?: string[];
500
- nameOwners?: string[];
501
+ nameParent?: boolean;
502
+ nameLabel?: string;
501
503
  searchable?: boolean;
502
504
  allowXpath?: boolean;
503
505
  };
@@ -1110,6 +1112,11 @@ export declare type AffixMaskResolver = (params: {
1110
1112
  attr: string;
1111
1113
  }) => AttributeAffix | undefined;
1112
1114
 
1115
+ export declare type AnchorOption = {
1116
+ value: string;
1117
+ label: string;
1118
+ };
1119
+
1113
1120
  /**
1114
1121
  * Seed `visibleChildIds` from the initial expand/collapse options: BFS from the
1115
1122
  * roots, expanding a node when it is explicitly expanded or within
@@ -1149,7 +1156,7 @@ export declare function buildRecordCache<TRecord extends LayoutTreeRecord>(recor
1149
1156
 
1150
1157
  export declare function buildTreeOptions<T>(rows: readonly T[], getPath: (row: T) => string[]): FilterTreeNode[];
1151
1158
 
1152
- export declare function buildXpath({ anchor, targets, nameFilter, nameOwners, }: XpathBuilderState): string;
1159
+ export declare function buildXpath({ anchor, targets, nameFilter, nameParent, }: XpathBuilderState): string;
1153
1160
 
1154
1161
  export declare const Button: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
1155
1162
 
@@ -3608,18 +3615,12 @@ export declare interface NoteData {
3608
3615
 
3609
3616
  export declare type NoteStatus = (typeof NOTE_STATUSES)[number];
3610
3617
 
3611
- declare type Option_2 = {
3612
- value: string;
3613
- label: string;
3614
- };
3615
-
3616
3618
  /**
3617
3619
  * Parse note data from the JSON value of a `<Text>` element.
3618
3620
  * Returns undefined if the value is not a valid note JSON.
3619
3621
  */
3620
3622
  export declare function parseNoteData(value: string | undefined): NoteData | undefined;
3621
3623
 
3622
- /** Returns undefined for any XPath the builder could not have produced. */
3623
3624
  export declare function parseXpath(xpath: string): XpathBuilderState | undefined;
3624
3625
 
3625
3626
  /** Presentation progress: a held monotonic fraction in `[0, 1]` and its caption. */
@@ -3964,6 +3965,8 @@ export declare interface UseRowSortConfig<TRow, TColId extends string> {
3964
3965
  sortAccessors: Partial<Record<TColId, (row: TRow) => string>>;
3965
3966
  }
3966
3967
 
3968
+ export declare function validateSearchText(value: string): string | undefined;
3969
+
3967
3970
  export declare function validateXpath(xpath: string): string | undefined;
3968
3971
 
3969
3972
  /** Options that drive which nodes are initially visible. */
@@ -3985,7 +3988,7 @@ export declare type XpathBuilderState = {
3985
3988
  anchor: string;
3986
3989
  targets: string[];
3987
3990
  nameFilter?: NameFilter;
3988
- nameOwners?: string[];
3991
+ nameParent?: boolean;
3989
3992
  };
3990
3993
 
3991
3994
  export { }
package/dist/index.js CHANGED
@@ -55,18 +55,18 @@ import oe from "./table/filterable-column-header.js";
55
55
  import "./table/index.js";
56
56
  import se from "./context-menu/context-menu.js";
57
57
  import "./context-menu/index.js";
58
- import { buildXpath as ce, matchName as le, parseXpath as ue, validateXpath as de } from "./selector-input/selector-input.js";
59
- import fe from "./selector-input/selector-input2.js";
58
+ import { buildXpath as ce, matchName as le, parseXpath as ue, validateSearchText as de, validateXpath as fe } from "./selector-input/selector-xpath.js";
59
+ import pe from "./selector-input/selector-input.js";
60
60
  import "./selector-input/index.js";
61
- import pe from "./split-layout/split-layout.js";
61
+ import me from "./split-layout/split-layout.js";
62
62
  import "./split-layout/index.js";
63
- import { applyInitialVisibility as me, buildRecordCache as he, collectVisibleIds as ge, hideDescendants as _e } from "./diagram-layout/visibility-model.js";
64
- import { groupStackMetrics as ve } from "./diagram-layout/group-stack.js";
65
- import { GROUP_COLLAPSED_MEMBERS_HEIGHT as ye, GROUP_HEADER_HEIGHT as be, GROUP_MEMBER_GAP as xe, GROUP_MEMBER_HEIGHT as Se, GROUP_MEMBER_HEIGHT_COMPACT as Ce, memberCardHeight as we } from "./diagram-layout/group-geometry.js";
66
- import { computeGroups as Te, isGroupId as Ee, makeGroupId as De } from "./diagram-layout/grouping.js";
67
- import { createElkLayoutEngine as Oe } from "./diagram-layout/elk-layout-engine.js";
68
- import { useDiagramLayout as ke } from "./diagram-layout/use-diagram-layout.js";
69
- import Ae from "./diagram-layout/diagram-node-card.js";
70
- import je from "./diagram-layout/diagram-node-group.js";
63
+ import { applyInitialVisibility as he, buildRecordCache as ge, collectVisibleIds as _e, hideDescendants as ve } from "./diagram-layout/visibility-model.js";
64
+ import { groupStackMetrics as ye } from "./diagram-layout/group-stack.js";
65
+ import { GROUP_COLLAPSED_MEMBERS_HEIGHT as be, GROUP_HEADER_HEIGHT as xe, GROUP_MEMBER_GAP as Se, GROUP_MEMBER_HEIGHT as Ce, GROUP_MEMBER_HEIGHT_COMPACT as we, memberCardHeight as Te } from "./diagram-layout/group-geometry.js";
66
+ import { computeGroups as Ee, isGroupId as De, makeGroupId as Oe } from "./diagram-layout/grouping.js";
67
+ import { createElkLayoutEngine as ke } from "./diagram-layout/elk-layout-engine.js";
68
+ import { useDiagramLayout as Ae } from "./diagram-layout/use-diagram-layout.js";
69
+ import je from "./diagram-layout/diagram-node-card.js";
70
+ import Me from "./diagram-layout/diagram-node-group.js";
71
71
  import "./diagram-layout/index.js";
72
- export { s as Button, x as CATEGORY_ELEMENTS, k as CodeBlock, l as Combobox, se as ContextMenu, z as DecisionToggle, Ae as DiagramNodeCard, je as DiagramNodeGroup, p as Dialog, y as DialogHost, b as DocumentProgressBar, c as Dropdown, S as ELEMENT_TO_COLOR, C as ELEMENT_TO_ICON, w as ElementBadge, B as ElementDetail, m as FeedbackDialog, oe as FilterableColumnHeader, u as FloatingTooltip, ye as GROUP_COLLAPSED_MEMBERS_HEIGHT, be as GROUP_HEADER_HEIGHT, xe as GROUP_MEMBER_GAP, Se as GROUP_MEMBER_HEIGHT, Ce as GROUP_MEMBER_HEIGHT_COMPACT, K as KEY_SEPARATOR, D as LibraryBrowser, V as MergeMap, G as MergeReview, H as MergeTree, d as MultiSelect, M as NOTE_CATEGORIES, N as NOTE_CATEGORY_LABELS, P as NOTE_STATUSES, q as NO_VALUE_KEY, R as NoteCategoryPicker, L as NoteCategoryTag, E as SclExplorer, fe as SelectorInput, pe as SplitLayout, f as TextInputAutocomplete, U as TypeNameAuthority, j as XmlDiff, me as applyInitialVisibility, J as buildFlatOptions, Y as buildMultiValueOptions, he as buildRecordCache, X as buildTreeOptions, ce as buildXpath, T as collectExpandableNodeIds, Z as collectLeafKeys, Q as collectParentKeys, ge as collectVisibleIds, Te as computeGroups, h as createDialogHost, e as createDocumentStore, Oe as createElkLayoutEngine, g as dialogHostKey, A as diffLines, $ as filterTree, ve as groupStackMetrics, _e as hideDescendants, O as highlightCode, Ee as isGroupId, De as makeGroupId, le as matchName, we as memberCardHeight, F as parseNoteData, ue as parseXpath, ne as provideColumnFilterHeader, _ as provideDialogHost, ie as provideRowSortHeader, I as serializeNoteData, i as useActiveDocument, re as useColumnFilterHeaderContext, ee as useColumnFilters, ke as useDiagramLayout, t as useDialecteChannel, v as useDialog, a as useDocumentProgress, o as useDocumentState, n as useLiveData, W as useMergeSession, ae as useOptionalRowSortContext, r as useProjectLiveData, te as useRowSort, de as validateXpath };
72
+ export { s as Button, x as CATEGORY_ELEMENTS, k as CodeBlock, l as Combobox, se as ContextMenu, z as DecisionToggle, je as DiagramNodeCard, Me as DiagramNodeGroup, p as Dialog, y as DialogHost, b as DocumentProgressBar, c as Dropdown, S as ELEMENT_TO_COLOR, C as ELEMENT_TO_ICON, w as ElementBadge, B as ElementDetail, m as FeedbackDialog, oe as FilterableColumnHeader, u as FloatingTooltip, be as GROUP_COLLAPSED_MEMBERS_HEIGHT, xe as GROUP_HEADER_HEIGHT, Se as GROUP_MEMBER_GAP, Ce as GROUP_MEMBER_HEIGHT, we as GROUP_MEMBER_HEIGHT_COMPACT, K as KEY_SEPARATOR, D as LibraryBrowser, V as MergeMap, G as MergeReview, H as MergeTree, d as MultiSelect, M as NOTE_CATEGORIES, N as NOTE_CATEGORY_LABELS, P as NOTE_STATUSES, q as NO_VALUE_KEY, R as NoteCategoryPicker, L as NoteCategoryTag, E as SclExplorer, pe as SelectorInput, me as SplitLayout, f as TextInputAutocomplete, U as TypeNameAuthority, j as XmlDiff, he as applyInitialVisibility, J as buildFlatOptions, Y as buildMultiValueOptions, ge as buildRecordCache, X as buildTreeOptions, ce as buildXpath, T as collectExpandableNodeIds, Z as collectLeafKeys, Q as collectParentKeys, _e as collectVisibleIds, Ee as computeGroups, h as createDialogHost, e as createDocumentStore, ke as createElkLayoutEngine, g as dialogHostKey, A as diffLines, $ as filterTree, ye as groupStackMetrics, ve as hideDescendants, O as highlightCode, De as isGroupId, Oe as makeGroupId, le as matchName, Te as memberCardHeight, F as parseNoteData, ue as parseXpath, ne as provideColumnFilterHeader, _ as provideDialogHost, ie as provideRowSortHeader, I as serializeNoteData, i as useActiveDocument, re as useColumnFilterHeaderContext, ee as useColumnFilters, Ae as useDiagramLayout, t as useDialecteChannel, v as useDialog, a as useDocumentProgress, o as useDocumentState, n as useLiveData, W as useMergeSession, ae as useOptionalRowSortContext, r as useProjectLiveData, te as useRowSort, de as validateSearchText, fe as validateXpath };
@@ -1,3 +1,3 @@
1
- import { buildXpath as e, matchName as t, parseXpath as n, validateXpath as r } from "./selector-input.js";
2
- import i from "./selector-input2.js";
3
- export { i as SelectorInput, e as buildXpath, t as matchName, n as parseXpath, r as validateXpath };
1
+ import { buildXpath as e, matchName as t, parseXpath as n, validateSearchText as r, validateXpath as i } from "./selector-xpath.js";
2
+ import a from "./selector-input.js";
3
+ export { a as SelectorInput, e as buildXpath, t as matchName, n as parseXpath, r as validateSearchText, i as validateXpath };
@@ -1,90 +1,5 @@
1
- //#region lib/selector-input/selector-input.ts
2
- var e = "[\\w.-]+", t = RegExp(`^${e}$`), n = "(?:'[^']*'|\"[^\"]*\")", r = `ancestor::\\*\\[local-name\\(\\)='(${e})'\\]\\[1\\]`, i = `local-name\\(\\)='${e}'`, a = `${i}(?: or ${i})*`, o = (e) => `(?:@name=${e(n)}|${e("starts-with|contains")}\\(@name,${e(n)}\\)|substring\\(@name,string-length\\(@name\\)-string-length\\(${e(n)}\\)\\+1\\)=${e(n)})`, s = RegExp(`^${o((e) => `(${e})`)}$`), c = o((e) => `(?:${e})`), l = RegExp(`^(?:${r})?//\\*(?:\\[(${a})\\])?(?:\\[(${c})\\]|\\[ancestor::\\*\\[(${a})\\]\\[1\\]\\[(${c})\\]\\])?$`);
3
- function u({ anchor: e, targets: t, nameFilter: n, nameOwners: r = [] }) {
4
- b(e, { optional: !0 }), t.forEach((e) => b(e)), r.forEach((e) => b(e));
5
- let i = n?.value ? n : void 0;
6
- if (!e && t.length === 0 && !i) return "";
7
- let a = e ? `ancestor::*[local-name()='${e}'][1]` : "", o = i ? h(i) : "", s = i && r.length > 0 ? `[ancestor::*[${p(r)}][1][${o}]]` : i ? `[${o}]` : "";
8
- return `${a}//*${t.length > 0 ? `[${p(t)}]` : ""}${s}`;
9
- }
10
- function d(e) {
11
- let t = l.exec(e);
12
- if (!t) return;
13
- let [, n = "", r = "", i, a, o] = t, s = i ?? o, c = s ? g(s) : void 0;
14
- if (c === null || !n && !r && !c) return;
15
- let u = m(r);
16
- return c ? a ? {
17
- anchor: n,
18
- targets: u,
19
- nameFilter: c,
20
- nameOwners: m(a)
21
- } : {
22
- anchor: n,
23
- targets: u,
24
- nameFilter: c
25
- } : {
26
- anchor: n,
27
- targets: u
28
- };
29
- }
30
- function f({ match: e, value: t }, n) {
31
- if (n === void 0) return !1;
32
- switch (e) {
33
- case "equals": return n === t;
34
- case "starts-with": return n.startsWith(t);
35
- case "ends-with": return n.endsWith(t);
36
- case "contains": return n.includes(t);
37
- }
38
- }
39
- function p(e) {
40
- return e.map((e) => `local-name()='${e}'`).join(" or ");
41
- }
42
- function m(e) {
43
- return [...e.matchAll(/local-name\(\)='([^']+)'/g)].map((e) => e[1]);
44
- }
45
- function h({ match: e, value: t }) {
46
- let n = _(t);
47
- switch (e) {
48
- case "equals": return `@name=${n}`;
49
- case "starts-with":
50
- case "contains": return `${e}(@name,${n})`;
51
- case "ends-with": return `substring(@name,string-length(@name)-string-length(${n})+1)=${n}`;
52
- }
53
- }
54
- function g(e) {
55
- let t = s.exec(e);
56
- if (!t) return null;
57
- let [, n, r, i, a, o] = t;
58
- return n ? {
59
- match: "equals",
60
- value: v(n)
61
- } : r && i ? {
62
- match: r,
63
- value: v(i)
64
- } : a === o ? {
65
- match: "ends-with",
66
- value: v(a)
67
- } : null;
68
- }
69
- function _(e) {
70
- if (!e.includes("'")) return `'${e}'`;
71
- if (!e.includes("\"")) return `"${e}"`;
72
- throw Error("Search text must not contain both single and double quotes");
73
- }
74
- function v(e) {
75
- return e.slice(1, -1);
76
- }
77
- function y(e) {
78
- if (e.trim() !== "") try {
79
- let t = document.implementation.createDocument(null, "root");
80
- t.evaluate(e, t, null, XPathResult.ANY_TYPE, null);
81
- return;
82
- } catch (e) {
83
- return e instanceof Error && e.message || "Invalid XPath";
84
- }
85
- }
86
- function b(e, { optional: n = !1 } = {}) {
87
- if (!(n && e === "") && !t.test(e)) throw Error(`Invalid element name "${e}"`);
88
- }
1
+ import e from "./selector-input.vue_vue_type_script_setup_true_lang.js";
2
+ //#region lib/selector-input/selector-input.vue
3
+ var t = e;
89
4
  //#endregion
90
- export { u as buildXpath, f as matchName, d as parseXpath, y as validateXpath };
5
+ export { t as default };
@@ -1,58 +1,57 @@
1
- import { buildXpath as e, parseXpath as t, validateXpath as n } from "./selector-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, onBeforeUnmount as d, openBlock as f, ref as p, renderList as m, renderSlot as h, toDisplayString as g, useModel as _, vModelText as v, watch as y, withDirectives as b } from "vue";
1
+ import { buildXpath as e, parseXpath as t, validateSearchText as n, validateXpath as r } from "./selector-xpath.js";
2
+ import { Fragment as i, computed as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, defineComponent as l, mergeModels as u, normalizeClass as d, onBeforeUnmount as f, openBlock as p, reactive as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, useModel as y, vModelText as b, watch as x, withDirectives as S } from "vue";
3
3
  //#region lib/selector-input/selector-input.vue?vue&type=script&setup=true&lang.ts
4
- var x = {
4
+ var C = {
5
5
  class: "flex flex-col gap-2",
6
6
  "data-testid": "selector-input"
7
- }, S = { class: "tabs tabs-box w-fit tabs-sm" }, C = {
7
+ }, w = { class: "tabs tabs-box w-fit tabs-sm" }, T = ["data-testid", "onClick"], E = {
8
8
  key: 0,
9
9
  role: "status",
10
10
  class: "alert alert-soft alert-info py-2 text-sm",
11
11
  "data-testid": "selector-input-custom-hint"
12
- }, w = { class: "fieldset" }, T = { class: "flex flex-wrap gap-2" }, E = [
12
+ }, D = { class: "fieldset" }, O = { class: "flex flex-wrap gap-2" }, k = [
13
13
  "aria-pressed",
14
14
  "data-testid",
15
15
  "onClick"
16
- ], D = {
16
+ ], A = {
17
17
  key: 1,
18
18
  class: "fieldset"
19
- }, O = { class: "fieldset-legend text-sm font-medium" }, k = {
19
+ }, j = { class: "fieldset-legend text-sm font-medium" }, M = {
20
20
  class: "join",
21
21
  role: "group",
22
22
  "aria-label": "Name match"
23
- }, A = [
23
+ }, N = [
24
24
  "aria-pressed",
25
25
  "data-testid",
26
26
  "onClick"
27
- ], ee = [
27
+ ], P = [
28
28
  "value",
29
29
  "aria-label",
30
30
  "placeholder"
31
- ], j = {
32
- key: 0,
33
- class: "label text-error",
34
- role: "alert",
35
- "data-testid": "selector-input-search-error"
36
- }, M = {
31
+ ], F = {
37
32
  key: 1,
38
33
  class: "fieldset"
39
- }, N = ["disabled"], P = {
34
+ }, I = ["disabled"], L = {
40
35
  key: 0,
41
36
  class: "label text-error",
42
37
  role: "alert",
43
38
  "data-testid": "selector-input-error"
44
- }, F = {
45
- key: 1,
39
+ }, R = {
40
+ key: 2,
46
41
  class: "label text-error",
47
42
  role: "alert",
48
43
  "data-testid": "selector-input-search-error"
49
- }, I = /*@__PURE__*/ c({
44
+ }, z = /*@__PURE__*/ l({
50
45
  __name: "selector-input",
51
- props: /*@__PURE__*/ l({
46
+ props: /*@__PURE__*/ u({
52
47
  anchors: {},
53
48
  anywhereLabel: { default: "Anywhere" },
54
49
  targets: { default: () => [] },
55
- nameOwners: { default: () => [] },
50
+ nameParent: {
51
+ type: Boolean,
52
+ default: !1
53
+ },
54
+ nameLabel: { default: "Name" },
56
55
  searchable: {
57
56
  type: Boolean,
58
57
  default: !0
@@ -71,8 +70,14 @@ var x = {
71
70
  invalidModifiers: {}
72
71
  }),
73
72
  emits: ["update:modelValue", "update:invalid"],
74
- setup(c) {
75
- let l = [
73
+ setup(l) {
74
+ let u = l, z = y(l, "modelValue"), B = y(l, "invalid"), V = [{
75
+ value: "builder",
76
+ label: "Builder"
77
+ }, {
78
+ value: "xpath",
79
+ label: "XPath"
80
+ }], H = [
76
81
  {
77
82
  value: "equals",
78
83
  label: "Full name"
@@ -89,92 +94,89 @@ var x = {
89
94
  value: "contains",
90
95
  label: "Contains"
91
96
  }
92
- ], I = c, L = _(c, "modelValue"), R = _(c, "invalid"), z = i(() => t(L.value)), B = p(z.value?.anchor ?? ""), V = p(z.value?.targets ?? I.targets), H = p(z.value?.nameFilter?.match ?? "contains"), U = p(z.value?.nameFilter?.value ?? ""), W = p("builder"), G = i(() => L.value !== "" && z.value === void 0), K = i(() => I.allowXpath ? n(L.value) : void 0), q = i(() => I.nameOwners.length > 0 ? "Search by function name" : "Search by name"), J = i(() => U.value.includes("'") && U.value.includes("\"") ? "Search text must not contain both single and double quotes" : void 0), Y = i(() => !!(J.value || K.value)), X = i(() => [{
93
- value: "",
94
- label: I.anywhereLabel
95
- }, ...I.anchors]);
96
- y(Y, (e) => R.value = e, { immediate: !0 }), d(() => R.value = !1), y(L, (e) => {
97
- let n = t(e);
98
- B.value = n?.anchor ?? "", V.value = n?.targets ?? I.targets, U.value = n?.nameFilter?.value ?? "", n?.nameFilter && (H.value = n.nameFilter.match);
97
+ ], U = h("builder"), W = m({
98
+ anchor: "",
99
+ match: "contains",
100
+ search: ""
99
101
  });
100
- function Z(e) {
101
- B.value = e, $();
102
- }
102
+ Q(z.value), x(z, Q);
103
+ let G = a(() => t(z.value)), K = a(() => z.value !== "" && G.value === void 0), q = a(() => u.allowXpath ? r(z.value) : void 0), J = a(() => n(W.search)), Y = a(() => [{
104
+ value: "",
105
+ label: u.anywhereLabel
106
+ }, ...u.anchors]), X = a(() => `Search by ${u.nameLabel.toLowerCase()}`), Z = a(() => `A custom XPath is in use. Choosing a scope${u.searchable ? " or entering a search" : ""} replaces it.`);
107
+ x(() => !!(J.value || q.value), (e) => B.value = e, { immediate: !0 }), f(() => B.value = !1);
103
108
  function Q(e) {
104
- H.value = e, $();
105
- }
106
- function te(e) {
107
- U.value = e, $();
109
+ let n = t(e);
110
+ if (W.anchor = n?.anchor ?? "", n?.nameFilter) {
111
+ W.search = n.nameFilter.value, W.match = n.nameFilter.match;
112
+ return;
113
+ }
114
+ W.search && (W.search = "", W.match = "contains");
108
115
  }
109
- function $() {
110
- J.value || (L.value = e({
111
- anchor: B.value,
112
- targets: V.value,
116
+ function $(t) {
117
+ Object.assign(W, t), !J.value && (z.value = e({
118
+ anchor: W.anchor,
119
+ targets: G.value?.targets ?? u.targets,
113
120
  nameFilter: {
114
- match: H.value,
115
- value: U.value
121
+ match: W.match,
122
+ value: W.search
116
123
  },
117
- nameOwners: I.nameOwners
124
+ nameParent: G.value?.nameParent ?? u.nameParent
118
125
  }));
119
126
  }
120
- return (e, t) => (f(), o("div", x, [
121
- s("div", S, [s("button", {
122
- type: "button",
123
- class: u(["tab", { "tab-active": W.value === "builder" }]),
124
- "data-testid": "selector-input-mode-builder",
125
- onClick: t[0] ||= (e) => W.value = "builder"
126
- }, " Builder ", 2), s("button", {
127
+ return (e, t) => (p(), s("div", C, [
128
+ c("div", w, [(p(), s(i, null, g(V, (e) => c("button", {
129
+ key: e.value,
127
130
  type: "button",
128
- class: u(["tab", { "tab-active": W.value === "xpath" }]),
129
- "data-testid": "selector-input-mode-xpath",
130
- onClick: t[1] ||= (e) => W.value = "xpath"
131
- }, " XPath ", 2)]),
132
- W.value === "builder" ? (f(), o(r, { key: 0 }, [
133
- G.value ? (f(), o("div", C, g(c.searchable ? "A custom XPath is in use. Choosing a scope or entering a search replaces it." : "A custom XPath is in use. Choosing a scope replaces it."), 1)) : a("", !0),
134
- s("fieldset", w, [t[4] ||= s("legend", { class: "fieldset-legend text-sm font-medium" }, "Scope", -1), s("div", T, [(f(!0), o(r, null, m(X.value, (e) => (f(), o("button", {
131
+ class: d(["tab", { "tab-active": U.value === e.value }]),
132
+ "data-testid": `selector-input-mode-${e.value}`,
133
+ onClick: (t) => U.value = e.value
134
+ }, v(e.label), 11, T)), 64))]),
135
+ U.value === "builder" ? (p(), s(i, { key: 0 }, [
136
+ K.value ? (p(), s("div", E, v(Z.value), 1)) : o("", !0),
137
+ c("fieldset", D, [t[2] ||= c("legend", { class: "fieldset-legend text-sm font-medium" }, "Scope", -1), c("div", O, [(p(!0), s(i, null, g(Y.value, (e) => (p(), s("button", {
135
138
  key: e.value,
136
139
  type: "button",
137
- class: u(["badge badge-sm cursor-pointer", !G.value && B.value === e.value ? "badge-primary" : "badge-soft"]),
138
- "aria-pressed": !G.value && B.value === e.value,
140
+ class: d(["badge badge-sm cursor-pointer", !K.value && W.anchor === e.value ? "badge-primary" : "badge-soft"]),
141
+ "aria-pressed": !K.value && W.anchor === e.value,
139
142
  "data-testid": `selector-input-anchor-${e.value || "none"}`,
140
- onClick: (t) => Z(e.value)
141
- }, g(e.label), 11, E))), 128))])]),
142
- c.searchable ? (f(), o("fieldset", D, [
143
- s("legend", O, g(c.nameOwners.length > 0 ? "Function name" : "Name"), 1),
144
- s("div", k, [(f(), o(r, null, m(l, (e) => s("button", {
143
+ onClick: (t) => $({ anchor: e.value })
144
+ }, v(e.label), 11, k))), 128))])]),
145
+ l.searchable ? (p(), s("fieldset", A, [
146
+ c("legend", j, v(l.nameLabel), 1),
147
+ c("div", M, [(p(), s(i, null, g(H, (e) => c("button", {
145
148
  key: e.value,
146
149
  type: "button",
147
- class: u(["btn btn-sm join-item", { "btn-primary": H.value === e.value }]),
148
- "aria-pressed": H.value === e.value,
150
+ class: d(["btn btn-sm join-item", { "btn-primary": W.match === e.value }]),
151
+ "aria-pressed": W.match === e.value,
149
152
  "data-testid": `selector-input-match-${e.value}`,
150
- onClick: (t) => Q(e.value)
151
- }, g(e.label), 11, A)), 64))]),
152
- s("input", {
153
- value: U.value,
153
+ onClick: (t) => $({ match: e.value })
154
+ }, v(e.label), 11, N)), 64))]),
155
+ c("input", {
156
+ value: W.search,
154
157
  type: "search",
155
- "aria-label": q.value,
156
- class: u(["input input-sm w-full", { "input-error": J.value }]),
157
- placeholder: q.value,
158
+ "aria-label": X.value,
159
+ class: d(["input input-sm w-full", { "input-error": J.value }]),
160
+ placeholder: X.value,
158
161
  "data-testid": "selector-input-search",
159
- onInput: t[2] ||= (e) => te(e.target.value)
160
- }, null, 42, ee),
161
- J.value ? (f(), o("p", j, g(J.value), 1)) : a("", !0)
162
- ])) : a("", !0)
163
- ], 64)) : (f(), o("fieldset", M, [
164
- t[5] ||= s("legend", { class: "fieldset-legend" }, "XPath", -1),
165
- b(s("input", {
166
- "onUpdate:modelValue": t[3] ||= (e) => L.value = e,
162
+ onInput: t[0] ||= (e) => $({ search: e.target.value })
163
+ }, null, 42, P)
164
+ ])) : o("", !0)
165
+ ], 64)) : (p(), s("fieldset", F, [
166
+ t[3] ||= c("legend", { class: "fieldset-legend" }, "XPath", -1),
167
+ S(c("input", {
168
+ "onUpdate:modelValue": t[1] ||= (e) => z.value = e,
167
169
  type: "text",
168
- disabled: !c.allowXpath,
169
- class: u(["input w-full font-mono", { "input-error": K.value }]),
170
+ disabled: !l.allowXpath,
171
+ class: d(["input w-full font-mono", { "input-error": q.value }]),
170
172
  "data-testid": "selector-input-raw"
171
- }, null, 10, N), [[v, L.value]]),
172
- K.value ? (f(), o("p", P, g(K.value), 1)) : a("", !0),
173
- J.value ? (f(), o("p", F, g(J.value), 1)) : a("", !0)
173
+ }, null, 10, I), [[b, z.value]]),
174
+ q.value ? (p(), s("p", L, v(q.value), 1)) : o("", !0)
174
175
  ])),
175
- h(e.$slots, "footer")
176
+ J.value ? (p(), s("p", R, v(J.value), 1)) : o("", !0),
177
+ _(e.$slots, "footer")
176
178
  ]));
177
179
  }
178
180
  });
179
181
  //#endregion
180
- export { I as default };
182
+ export { z as default };
@@ -0,0 +1,92 @@
1
+ //#region lib/selector-input/selector-xpath.ts
2
+ var e = "Search text must not contain both single and double quotes", t = "[\\w.-]+", n = RegExp(`^${t}$`), r = "(?:'[^']*'|\"[^\"]*\")", i = `local-name\\(\\)='${t}'`, a = `${i}(?: or ${i})*`, o = `(?:@name=(${r})|(starts-with|contains)\\(@name,(${r})\\)|substring\\(@name,string-length\\(@name\\)-string-length\\((${r})\\)\\+1\\)=(${r}))`, s = RegExp(`^${o}$`), c = RegExp(`^(?:ancestor::\\*\\[local-name\\(\\)='(?<anchor>${t})'\\]\\[1\\])?//\\*(?:\\[(?<targets>${a})\\])?(?:\\[(?<ownName>${o})\\]|\\[ancestor::\\*\\[${a}\\]\\[1\\]\\[(?<ownerName>${o})\\]\\]|\\[parent::\\*\\[(?<parentName>${o})\\]\\])?$`);
3
+ function l({ anchor: e, targets: t, nameFilter: n, nameParent: r = !1 }) {
4
+ e && x(e), t.forEach(x);
5
+ let i = n?.value ? n : void 0;
6
+ return !e && t.length === 0 && !i ? "" : `${e ? `ancestor::*[local-name()='${e}'][1]` : ""}//*${t.length > 0 ? `[${m(t)}]` : ""}${i ? h(i, r) : ""}`;
7
+ }
8
+ function u(e) {
9
+ let t = c.exec(e)?.groups;
10
+ if (!t) return;
11
+ let { anchor: n = "", targets: r = "", ownName: i, ownerName: a, parentName: o } = t, s = i ?? a ?? o, l = s ? v(s) : void 0;
12
+ if (s && !l || !n && !r && !l) return;
13
+ let u = {
14
+ anchor: n,
15
+ targets: _(r)
16
+ };
17
+ return l ? i ? {
18
+ ...u,
19
+ nameFilter: l
20
+ } : {
21
+ ...u,
22
+ nameFilter: l,
23
+ nameParent: !0
24
+ } : u;
25
+ }
26
+ function d({ match: e, value: t }, n) {
27
+ if (n === void 0) return !1;
28
+ switch (e) {
29
+ case "equals": return n === t;
30
+ case "starts-with": return n.startsWith(t);
31
+ case "ends-with": return n.endsWith(t);
32
+ case "contains": return n.includes(t);
33
+ }
34
+ }
35
+ function f(e) {
36
+ if (e.trim() !== "") try {
37
+ let t = document.implementation.createDocument(null, "root");
38
+ t.evaluate(e, t, null, XPathResult.ANY_TYPE, null);
39
+ return;
40
+ } catch (e) {
41
+ return e instanceof Error && e.message || "Invalid XPath";
42
+ }
43
+ }
44
+ function p(t) {
45
+ return t.includes("'") && t.includes("\"") ? e : void 0;
46
+ }
47
+ function m(e) {
48
+ return e.map((e) => `local-name()='${e}'`).join(" or ");
49
+ }
50
+ function h(e, t) {
51
+ let n = g(e);
52
+ return t ? `[parent::*[${n}]]` : `[${n}]`;
53
+ }
54
+ function g({ match: e, value: t }) {
55
+ let n = y(t);
56
+ switch (e) {
57
+ case "equals": return `@name=${n}`;
58
+ case "starts-with":
59
+ case "contains": return `${e}(@name,${n})`;
60
+ case "ends-with": return `substring(@name,string-length(@name)-string-length(${n})+1)=${n}`;
61
+ }
62
+ }
63
+ function _(e) {
64
+ return [...e.matchAll(/local-name\(\)='([^']+)'/g)].map((e) => e[1]);
65
+ }
66
+ function v(e) {
67
+ let t = s.exec(e);
68
+ if (!t) return;
69
+ let [, n, r, i, a, o] = t;
70
+ return n ? {
71
+ match: "equals",
72
+ value: b(n)
73
+ } : r && i ? {
74
+ match: r,
75
+ value: b(i)
76
+ } : a === o ? {
77
+ match: "ends-with",
78
+ value: b(a)
79
+ } : void 0;
80
+ }
81
+ function y(t) {
82
+ if (p(t)) throw Error(e);
83
+ return t.includes("'") ? `"${t}"` : `'${t}'`;
84
+ }
85
+ function b(e) {
86
+ return e.slice(1, -1);
87
+ }
88
+ function x(e) {
89
+ if (!n.test(e)) throw Error(`Invalid element name "${e}"`);
90
+ }
91
+ //#endregion
92
+ export { l as buildXpath, d as matchName, u as parseXpath, p as validateSearchText, f as validateXpath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@septkit/ui",
3
- "version": "0.0.81",
3
+ "version": "0.0.82",
4
4
  "type": "module",
5
5
  "source": "lib/index.ts",
6
6
  "files": [
@@ -1,5 +0,0 @@
1
- import e from "./selector-input.vue_vue_type_script_setup_true_lang.js";
2
- //#region lib/selector-input/selector-input.vue
3
- var t = e;
4
- //#endregion
5
- export { t as default };