@opentiny/tiny-robot 0.4.1 → 0.4.2-alpha.1
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/content-nav/index.js +856 -0
- package/dist/index.d.ts +433 -184
- package/dist/index.js +103 -99
- package/dist/index4.js +85 -79
- package/dist/index5.js +81 -81
- package/dist/index6.js +453 -413
- package/dist/sender/index.js +782 -783
- package/dist/style.css +1 -1
- package/dist/suggestion-popover/index.js +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
import { defineComponent as G, ref as M, computed as g, watch as F, openBlock as _, createElementBlock as H, normalizeClass as pe, createElementVNode as D, renderSlot as L, Fragment as W, renderList as ye, toDisplayString as te, createTextVNode as Te, createCommentVNode as re, createBlock as xe, createSlots as ne, withCtx as P, mergeProps as ae, useSlots as Se, normalizeStyle as Ne, onBeforeUnmount as oe, nextTick as ke, useAttrs as be, toRefs as _e, unref as E, createVNode as ce, normalizeProps as ue, guardReactiveProps as de } from "vue";
|
|
2
|
+
import { h as Ee, i as Me, g as z, j as fe } from "../index4.js";
|
|
3
|
+
import { _ as Y } from "../_plugin-vue_export-helper.js";
|
|
4
|
+
const Oe = ["data-tooltip"], we = ["data-item-id", "aria-current", "tabindex"], Ae = { class: "tr-content-nav__marker-slot" }, He = { class: "tr-content-nav__item-content" }, Le = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "tr-content-nav__highlight"
|
|
7
|
+
}, $e = /* @__PURE__ */ G({
|
|
8
|
+
name: "ContentNavItem",
|
|
9
|
+
__name: "ContentNavItem",
|
|
10
|
+
props: {
|
|
11
|
+
entry: {},
|
|
12
|
+
activeId: {},
|
|
13
|
+
expanded: { type: Boolean },
|
|
14
|
+
highlighted: { type: Boolean },
|
|
15
|
+
placement: {},
|
|
16
|
+
tooltipDelay: {}
|
|
17
|
+
},
|
|
18
|
+
emits: ["select"],
|
|
19
|
+
setup(e, { emit: a }) {
|
|
20
|
+
const l = e, i = a, f = M(null), r = M(!1), n = M(!1), { start: c, stop: u } = Ee(
|
|
21
|
+
() => {
|
|
22
|
+
requestAnimationFrame(() => {
|
|
23
|
+
C();
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
() => Math.max(0, l.tooltipDelay),
|
|
27
|
+
{ immediate: !1 }
|
|
28
|
+
), d = g(() => l.entry.item.id === l.activeId), v = g(() => [
|
|
29
|
+
"tr-content-nav__list-item",
|
|
30
|
+
`is-${l.placement}`,
|
|
31
|
+
{
|
|
32
|
+
"is-active": d.value,
|
|
33
|
+
"is-expanded": l.expanded,
|
|
34
|
+
"is-highlighted": l.highlighted,
|
|
35
|
+
"is-tooltip-visible": n.value
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
function y(p) {
|
|
39
|
+
return !!(p && p.scrollWidth > p.clientWidth);
|
|
40
|
+
}
|
|
41
|
+
function N() {
|
|
42
|
+
var p;
|
|
43
|
+
return ((p = f.value) == null ? void 0 : p.querySelector(".tr-content-nav__item-label")) ?? null;
|
|
44
|
+
}
|
|
45
|
+
function C() {
|
|
46
|
+
n.value = l.expanded && r.value && y(N());
|
|
47
|
+
}
|
|
48
|
+
function I() {
|
|
49
|
+
u(), n.value = !1, !(!l.expanded || !r.value) && c();
|
|
50
|
+
}
|
|
51
|
+
function k() {
|
|
52
|
+
u(), n.value = !1;
|
|
53
|
+
}
|
|
54
|
+
function $() {
|
|
55
|
+
r.value = !0, I();
|
|
56
|
+
}
|
|
57
|
+
function w() {
|
|
58
|
+
r.value = !1, k();
|
|
59
|
+
}
|
|
60
|
+
function S(p) {
|
|
61
|
+
p.propertyName === "max-width" && r.value && C();
|
|
62
|
+
}
|
|
63
|
+
return F(
|
|
64
|
+
() => l.expanded,
|
|
65
|
+
(p) => {
|
|
66
|
+
if (!p) {
|
|
67
|
+
k();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
r.value && I();
|
|
71
|
+
}
|
|
72
|
+
), (p, o) => (_(), H("li", {
|
|
73
|
+
class: pe(v.value),
|
|
74
|
+
"data-tooltip": e.entry.item.tooltipText || e.entry.item.label
|
|
75
|
+
}, [
|
|
76
|
+
D("button", {
|
|
77
|
+
ref_key: "itemButtonRef",
|
|
78
|
+
ref: f,
|
|
79
|
+
type: "button",
|
|
80
|
+
class: "tr-content-nav__item",
|
|
81
|
+
"data-item-id": e.entry.item.id,
|
|
82
|
+
"aria-current": d.value ? "location" : void 0,
|
|
83
|
+
tabindex: e.highlighted ? 0 : -1,
|
|
84
|
+
onMouseenter: $,
|
|
85
|
+
onMouseleave: w,
|
|
86
|
+
onClick: o[0] || (o[0] = (t) => i("select", e.entry.item))
|
|
87
|
+
}, [
|
|
88
|
+
D("span", Ae, [
|
|
89
|
+
L(p.$slots, "marker", {
|
|
90
|
+
item: e.entry.item,
|
|
91
|
+
active: d.value
|
|
92
|
+
}, () => [
|
|
93
|
+
o[1] || (o[1] = D("span", { class: "tr-content-nav__marker" }, null, -1))
|
|
94
|
+
], !0)
|
|
95
|
+
]),
|
|
96
|
+
D("span", He, [
|
|
97
|
+
L(p.$slots, "item", {
|
|
98
|
+
item: e.entry.item,
|
|
99
|
+
segments: e.entry.segments,
|
|
100
|
+
active: d.value,
|
|
101
|
+
expanded: e.expanded,
|
|
102
|
+
highlighted: l.highlighted || r.value
|
|
103
|
+
}, () => [
|
|
104
|
+
D("span", {
|
|
105
|
+
class: "tr-content-nav__item-label",
|
|
106
|
+
onTransitionend: S
|
|
107
|
+
}, [
|
|
108
|
+
(_(!0), H(W, null, ye(e.entry.segments, (t, s) => (_(), H(W, {
|
|
109
|
+
key: `${e.entry.item.id}-${s}`
|
|
110
|
+
}, [
|
|
111
|
+
t.highlighted ? (_(), H("mark", Le, te(t.text), 1)) : (_(), H(W, { key: 1 }, [
|
|
112
|
+
Te(te(t.text), 1)
|
|
113
|
+
], 64))
|
|
114
|
+
], 64))), 128))
|
|
115
|
+
], 32)
|
|
116
|
+
], !0)
|
|
117
|
+
])
|
|
118
|
+
], 40, we)
|
|
119
|
+
], 10, Oe));
|
|
120
|
+
}
|
|
121
|
+
}), Re = /* @__PURE__ */ Y($e, [["__scopeId", "data-v-c22afe17"]]), Be = {
|
|
122
|
+
class: "tr-content-nav__list",
|
|
123
|
+
role: "list"
|
|
124
|
+
}, De = {
|
|
125
|
+
key: 0,
|
|
126
|
+
class: "tr-content-nav__empty",
|
|
127
|
+
"aria-live": "polite"
|
|
128
|
+
}, Fe = /* @__PURE__ */ G({
|
|
129
|
+
name: "ContentNavList",
|
|
130
|
+
__name: "ContentNavList",
|
|
131
|
+
props: {
|
|
132
|
+
items: {},
|
|
133
|
+
activeId: {},
|
|
134
|
+
expanded: { type: Boolean },
|
|
135
|
+
highlightedIndex: {},
|
|
136
|
+
placement: {},
|
|
137
|
+
tooltipDelay: {},
|
|
138
|
+
emptyText: {}
|
|
139
|
+
},
|
|
140
|
+
emits: ["select"],
|
|
141
|
+
setup(e, { emit: a }) {
|
|
142
|
+
const l = a;
|
|
143
|
+
return (i, f) => (_(), H("ul", Be, [
|
|
144
|
+
e.expanded && e.items.length === 0 ? (_(), H("li", De, [
|
|
145
|
+
L(i.$slots, "empty", {}, () => [
|
|
146
|
+
Te(te(e.emptyText), 1)
|
|
147
|
+
], !0)
|
|
148
|
+
])) : re("", !0),
|
|
149
|
+
(_(!0), H(W, null, ye(e.items, (r, n) => (_(), xe(Re, {
|
|
150
|
+
key: r.item.id,
|
|
151
|
+
entry: r,
|
|
152
|
+
"active-id": e.activeId,
|
|
153
|
+
expanded: e.expanded,
|
|
154
|
+
highlighted: n === e.highlightedIndex,
|
|
155
|
+
placement: e.placement,
|
|
156
|
+
"tooltip-delay": e.tooltipDelay,
|
|
157
|
+
onSelect: f[0] || (f[0] = (c) => l("select", c))
|
|
158
|
+
}, ne({ _: 2 }, [
|
|
159
|
+
i.$slots.item ? {
|
|
160
|
+
name: "item",
|
|
161
|
+
fn: P((c) => [
|
|
162
|
+
L(i.$slots, "item", ae({ ref_for: !0 }, c), void 0, !0)
|
|
163
|
+
]),
|
|
164
|
+
key: "0"
|
|
165
|
+
} : void 0,
|
|
166
|
+
i.$slots.marker ? {
|
|
167
|
+
name: "marker",
|
|
168
|
+
fn: P((c) => [
|
|
169
|
+
L(i.$slots, "marker", ae({ ref_for: !0 }, c), void 0, !0)
|
|
170
|
+
]),
|
|
171
|
+
key: "1"
|
|
172
|
+
} : void 0
|
|
173
|
+
]), 1032, ["entry", "active-id", "expanded", "highlighted", "placement", "tooltip-delay"]))), 128))
|
|
174
|
+
]));
|
|
175
|
+
}
|
|
176
|
+
}), Qe = /* @__PURE__ */ Y(Fe, [["__scopeId", "data-v-1b8c77f5"]]), Pe = {
|
|
177
|
+
key: 0,
|
|
178
|
+
class: "tr-content-nav__search-cap"
|
|
179
|
+
}, Ue = { class: "tr-content-nav__surface" }, Ke = /* @__PURE__ */ G({
|
|
180
|
+
name: "ContentNavOverlay",
|
|
181
|
+
__name: "ContentNavOverlay",
|
|
182
|
+
props: {
|
|
183
|
+
expanded: { type: Boolean },
|
|
184
|
+
placement: {},
|
|
185
|
+
floatingOffset: { default: 0 }
|
|
186
|
+
},
|
|
187
|
+
setup(e, { expose: a }) {
|
|
188
|
+
const l = e, i = M(null), f = M(null), r = M(null), n = Se(), c = g(() => [
|
|
189
|
+
"tr-content-nav",
|
|
190
|
+
`is-${l.placement}`,
|
|
191
|
+
{
|
|
192
|
+
"is-expanded": l.expanded,
|
|
193
|
+
"has-search-cap": !!n.search
|
|
194
|
+
}
|
|
195
|
+
]), u = g(() => ({
|
|
196
|
+
transform: `translate3d(0, ${l.floatingOffset}px, 0)`
|
|
197
|
+
}));
|
|
198
|
+
return a({
|
|
199
|
+
hostEl: i,
|
|
200
|
+
overlayEl: f,
|
|
201
|
+
navEl: r
|
|
202
|
+
}), (d, v) => (_(), H("div", {
|
|
203
|
+
ref_key: "hostEl",
|
|
204
|
+
ref: i,
|
|
205
|
+
class: pe(c.value),
|
|
206
|
+
style: Ne(u.value)
|
|
207
|
+
}, [
|
|
208
|
+
D("div", {
|
|
209
|
+
ref_key: "overlayEl",
|
|
210
|
+
ref: f,
|
|
211
|
+
class: "tr-content-nav__overlay",
|
|
212
|
+
"data-testid": "content-nav-overlay"
|
|
213
|
+
}, [
|
|
214
|
+
d.$slots.search ? (_(), H("div", Pe, [
|
|
215
|
+
L(d.$slots, "search", {}, void 0, !0)
|
|
216
|
+
])) : re("", !0),
|
|
217
|
+
D("div", Ue, [
|
|
218
|
+
D("nav", {
|
|
219
|
+
ref_key: "navEl",
|
|
220
|
+
ref: r,
|
|
221
|
+
class: "tr-content-nav__panel",
|
|
222
|
+
"aria-label": "Content navigation"
|
|
223
|
+
}, [
|
|
224
|
+
L(d.$slots, "default", {}, void 0, !0)
|
|
225
|
+
], 512)
|
|
226
|
+
])
|
|
227
|
+
], 512)
|
|
228
|
+
], 6));
|
|
229
|
+
}
|
|
230
|
+
}), Ve = /* @__PURE__ */ Y(Ke, [["__scopeId", "data-v-017456fd"]]), qe = ["value", "placeholder", "aria-label"], ze = /* @__PURE__ */ G({
|
|
231
|
+
name: "ContentNavSearch",
|
|
232
|
+
__name: "ContentNavSearch",
|
|
233
|
+
props: {
|
|
234
|
+
searchQuery: {},
|
|
235
|
+
searchOptions: {}
|
|
236
|
+
},
|
|
237
|
+
emits: ["update:searchQuery"],
|
|
238
|
+
setup(e, { emit: a }) {
|
|
239
|
+
const l = e, i = a;
|
|
240
|
+
return (f, r) => {
|
|
241
|
+
var n, c;
|
|
242
|
+
return _(), H("input", {
|
|
243
|
+
class: "tr-content-nav__search",
|
|
244
|
+
type: "search",
|
|
245
|
+
value: l.searchQuery,
|
|
246
|
+
placeholder: ((n = l.searchOptions) == null ? void 0 : n.placeholder) ?? "Search",
|
|
247
|
+
"aria-label": ((c = l.searchOptions) == null ? void 0 : c.placeholder) ?? "Search content navigation",
|
|
248
|
+
"data-testid": "content-nav-search",
|
|
249
|
+
onInput: r[0] || (r[0] = (u) => i("update:searchQuery", u.target.value))
|
|
250
|
+
}, null, 40, qe);
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}), Ge = /* @__PURE__ */ Y(ze, [["__scopeId", "data-v-5faf8941"]]), We = (e, a) => {
|
|
254
|
+
const l = a.trim().toLowerCase(), i = (e.searchText || e.label).trim();
|
|
255
|
+
if (!l)
|
|
256
|
+
return [{ text: e.label, highlighted: !1 }];
|
|
257
|
+
const r = e.label.toLowerCase().indexOf(l);
|
|
258
|
+
return r !== -1 ? [
|
|
259
|
+
{ text: e.label.slice(0, r), highlighted: !1 },
|
|
260
|
+
{ text: e.label.slice(r, r + l.length), highlighted: !0 },
|
|
261
|
+
{ text: e.label.slice(r + l.length), highlighted: !1 }
|
|
262
|
+
].filter((n) => n.text.length > 0) : i.toLowerCase().includes(l) ? [{ text: e.label, highlighted: !1 }] : !1;
|
|
263
|
+
};
|
|
264
|
+
function je(e) {
|
|
265
|
+
var c, u;
|
|
266
|
+
const { viewport: a, anchors: l } = e;
|
|
267
|
+
if (!l.length)
|
|
268
|
+
return;
|
|
269
|
+
const i = a.scrollHeight - a.clientHeight > 2, f = a.scrollTop + a.clientHeight >= a.scrollHeight - 2;
|
|
270
|
+
if (i && f)
|
|
271
|
+
return (c = l[l.length - 1]) == null ? void 0 : c.id;
|
|
272
|
+
const r = a.top + Math.max(0, e.activeOffset ?? 120);
|
|
273
|
+
let n = (u = l[0]) == null ? void 0 : u.id;
|
|
274
|
+
for (const d of l)
|
|
275
|
+
if (d.el.getBoundingClientRect().top <= r)
|
|
276
|
+
n = d.id;
|
|
277
|
+
else
|
|
278
|
+
break;
|
|
279
|
+
return n;
|
|
280
|
+
}
|
|
281
|
+
function Ye(e, a) {
|
|
282
|
+
return !a || a.length === 0 ? [{ text: e.label, highlighted: !1 }] : a;
|
|
283
|
+
}
|
|
284
|
+
function Ze(e) {
|
|
285
|
+
const a = M(!1), l = M(""), i = M(void 0), f = M(!1), r = g(() => {
|
|
286
|
+
var t;
|
|
287
|
+
return (t = e.searchOptions) == null ? void 0 : t.value;
|
|
288
|
+
}), n = g(() => e.expandTrigger.value === "manual"), c = g(
|
|
289
|
+
() => n.value ? e.expanded.value ?? !1 : a.value
|
|
290
|
+
), u = g(() => {
|
|
291
|
+
var t;
|
|
292
|
+
return ((t = e.searchQuery) == null ? void 0 : t.value) ?? l.value;
|
|
293
|
+
}), d = g(() => {
|
|
294
|
+
var t;
|
|
295
|
+
return ((t = r.value) == null ? void 0 : t.matcher) ?? We;
|
|
296
|
+
}), v = g(() => {
|
|
297
|
+
const t = u.value.trim();
|
|
298
|
+
return e.items.value.map((s) => {
|
|
299
|
+
const m = d.value(s, t), T = Array.isArray(m) && m.length > 0;
|
|
300
|
+
return t && !T ? null : {
|
|
301
|
+
item: s,
|
|
302
|
+
segments: Ye(s, m)
|
|
303
|
+
};
|
|
304
|
+
}).filter((s) => s !== null);
|
|
305
|
+
}), y = g(
|
|
306
|
+
() => {
|
|
307
|
+
var t;
|
|
308
|
+
return (t = v.value.find((s) => s.item.id === e.activeId.value)) == null ? void 0 : t.item.id;
|
|
309
|
+
}
|
|
310
|
+
), N = g(() => {
|
|
311
|
+
var t;
|
|
312
|
+
return f.value && i.value && v.value.some((s) => s.item.id === i.value) ? i.value : y.value ?? ((t = v.value[0]) == null ? void 0 : t.item.id);
|
|
313
|
+
}), C = g(() => {
|
|
314
|
+
if (!v.value.length)
|
|
315
|
+
return 0;
|
|
316
|
+
const t = v.value.findIndex((s) => s.item.id === N.value);
|
|
317
|
+
return t === -1 ? 0 : t;
|
|
318
|
+
}), I = g(() => N.value);
|
|
319
|
+
function k() {
|
|
320
|
+
f.value = !1, i.value = void 0;
|
|
321
|
+
}
|
|
322
|
+
function $(t) {
|
|
323
|
+
var s, m;
|
|
324
|
+
n.value || (a.value = t), (s = e.onUpdateExpanded) == null || s.call(e, t), !t && ((m = r.value) != null && m.clearOnCollapse) && u.value && w("");
|
|
325
|
+
}
|
|
326
|
+
function w(t) {
|
|
327
|
+
var s, m;
|
|
328
|
+
((s = e.searchQuery) == null ? void 0 : s.value) === void 0 && (l.value = t), (m = e.onUpdateSearchQuery) == null || m.call(e, t);
|
|
329
|
+
}
|
|
330
|
+
function S(t) {
|
|
331
|
+
var m;
|
|
332
|
+
if (!v.value.length) {
|
|
333
|
+
k();
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const s = Math.max(0, Math.min(t, v.value.length - 1));
|
|
337
|
+
i.value = (m = v.value[s]) == null ? void 0 : m.item.id, f.value = !0;
|
|
338
|
+
}
|
|
339
|
+
function p() {
|
|
340
|
+
var t;
|
|
341
|
+
return (t = v.value[C.value]) == null ? void 0 : t.item;
|
|
342
|
+
}
|
|
343
|
+
function o(t) {
|
|
344
|
+
return t.key === "ArrowDown" ? (t.preventDefault(), S(C.value + 1), !0) : t.key === "ArrowUp" ? (t.preventDefault(), S(C.value - 1), !0) : t.key === "Home" ? (t.preventDefault(), S(0), !0) : t.key === "End" ? (t.preventDefault(), S(v.value.length - 1), !0) : t.key === "Escape" ? n.value ? !1 : (t.preventDefault(), $(!1), !0) : !1;
|
|
345
|
+
}
|
|
346
|
+
return F(
|
|
347
|
+
v,
|
|
348
|
+
(t) => {
|
|
349
|
+
if (!t.length) {
|
|
350
|
+
k();
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (y.value) {
|
|
354
|
+
k();
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
f.value && i.value && t.some((s) => s.item.id === i.value) || k();
|
|
358
|
+
},
|
|
359
|
+
{ immediate: !0, flush: "sync" }
|
|
360
|
+
), F(
|
|
361
|
+
() => e.activeId.value,
|
|
362
|
+
(t) => {
|
|
363
|
+
t && k();
|
|
364
|
+
},
|
|
365
|
+
{ immediate: !0, flush: "sync" }
|
|
366
|
+
), {
|
|
367
|
+
expanded: c,
|
|
368
|
+
searchQuery: u,
|
|
369
|
+
filteredItems: v,
|
|
370
|
+
highlightedIndex: C,
|
|
371
|
+
highlightedId: I,
|
|
372
|
+
setExpanded: $,
|
|
373
|
+
setSearchQuery: w,
|
|
374
|
+
getHighlightedItem: p,
|
|
375
|
+
handleNavigationKeydown: o
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function Z(e) {
|
|
379
|
+
return typeof HTMLElement < "u" && e instanceof HTMLElement;
|
|
380
|
+
}
|
|
381
|
+
function Ie() {
|
|
382
|
+
return typeof document > "u" ? null : document.scrollingElement ?? document.documentElement ?? document.body ?? null;
|
|
383
|
+
}
|
|
384
|
+
function le(e) {
|
|
385
|
+
return e || (typeof window < "u" ? window : null);
|
|
386
|
+
}
|
|
387
|
+
function ve(e) {
|
|
388
|
+
if (!e)
|
|
389
|
+
return 0;
|
|
390
|
+
if (Z(e))
|
|
391
|
+
return e.scrollTop;
|
|
392
|
+
const a = Ie();
|
|
393
|
+
return e.scrollY || e.pageYOffset || (a == null ? void 0 : a.scrollTop) || 0;
|
|
394
|
+
}
|
|
395
|
+
function ee(e) {
|
|
396
|
+
return e ? Z(e) ? e.clientHeight : e.innerHeight : 0;
|
|
397
|
+
}
|
|
398
|
+
function he(e) {
|
|
399
|
+
if (!e)
|
|
400
|
+
return 0;
|
|
401
|
+
if (Z(e))
|
|
402
|
+
return e.scrollHeight;
|
|
403
|
+
const a = Ie(), l = typeof document < "u" ? document.documentElement : null, i = typeof document < "u" ? document.body : null;
|
|
404
|
+
return Math.max((a == null ? void 0 : a.scrollHeight) || 0, (l == null ? void 0 : l.scrollHeight) || 0, (i == null ? void 0 : i.scrollHeight) || 0);
|
|
405
|
+
}
|
|
406
|
+
function me(e) {
|
|
407
|
+
return e && Z(e) ? e.getBoundingClientRect().top : 0;
|
|
408
|
+
}
|
|
409
|
+
function Je(e, a, l) {
|
|
410
|
+
e && e.scrollTo({
|
|
411
|
+
top: a,
|
|
412
|
+
behavior: l
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
function Xe(e) {
|
|
416
|
+
var p;
|
|
417
|
+
const i = M((p = e.activeId) == null ? void 0 : p.value);
|
|
418
|
+
let f = null, r = null;
|
|
419
|
+
const n = g(() => {
|
|
420
|
+
var o;
|
|
421
|
+
return ((o = e.activeId) == null ? void 0 : o.value) ?? i.value;
|
|
422
|
+
}), c = Me();
|
|
423
|
+
function u(o) {
|
|
424
|
+
var t, s;
|
|
425
|
+
n.value !== o && (((t = e.activeId) == null ? void 0 : t.value) === void 0 && (i.value = o), (s = e.onUpdateActiveId) == null || s.call(e, o));
|
|
426
|
+
}
|
|
427
|
+
function d() {
|
|
428
|
+
f = null;
|
|
429
|
+
}
|
|
430
|
+
function v() {
|
|
431
|
+
r = null;
|
|
432
|
+
}
|
|
433
|
+
function y() {
|
|
434
|
+
d(), v();
|
|
435
|
+
}
|
|
436
|
+
function N(o) {
|
|
437
|
+
return o instanceof HTMLElement ? o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement || o instanceof HTMLSelectElement || o.isContentEditable : !1;
|
|
438
|
+
}
|
|
439
|
+
function C(o) {
|
|
440
|
+
return [...o].sort((t, s) => {
|
|
441
|
+
if (t.el === s.el)
|
|
442
|
+
return 0;
|
|
443
|
+
const m = t.el.compareDocumentPosition(s.el);
|
|
444
|
+
return m & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : m & Node.DOCUMENT_POSITION_PRECEDING ? 1 : t.el.getBoundingClientRect().top - s.el.getBoundingClientRect().top;
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function I(o) {
|
|
448
|
+
const t = Number.parseFloat(window.getComputedStyle(o).scrollMarginTop || "0");
|
|
449
|
+
return Number.isFinite(t) ? t : 0;
|
|
450
|
+
}
|
|
451
|
+
function k() {
|
|
452
|
+
var Q, K;
|
|
453
|
+
const o = le(e.container.value);
|
|
454
|
+
if (!o)
|
|
455
|
+
return;
|
|
456
|
+
const t = ve(o), s = me(o), m = s + ee(o), T = s + Math.max(0, ((Q = e.activeOffset) == null ? void 0 : Q.value) ?? 120);
|
|
457
|
+
if (f) {
|
|
458
|
+
const b = Math.abs(t - f.top) <= 2, A = Date.now() - f.startedAt > 2e3;
|
|
459
|
+
if (!b && !A)
|
|
460
|
+
return;
|
|
461
|
+
d();
|
|
462
|
+
}
|
|
463
|
+
if (r) {
|
|
464
|
+
const b = e.resolveTarget(r);
|
|
465
|
+
if (b != null && b.isConnected) {
|
|
466
|
+
const A = b.getBoundingClientRect(), J = A.bottom <= T, q = A.top >= m;
|
|
467
|
+
if (!J && !q) {
|
|
468
|
+
u(r);
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
r && v();
|
|
473
|
+
}
|
|
474
|
+
const x = C(
|
|
475
|
+
e.items.value.flatMap((b) => {
|
|
476
|
+
const A = e.resolveTarget(b.id);
|
|
477
|
+
return A ? [{ id: b.id, el: A }] : [];
|
|
478
|
+
})
|
|
479
|
+
), U = je({
|
|
480
|
+
viewport: {
|
|
481
|
+
top: s,
|
|
482
|
+
scrollTop: t,
|
|
483
|
+
clientHeight: ee(o),
|
|
484
|
+
scrollHeight: he(o)
|
|
485
|
+
},
|
|
486
|
+
anchors: x,
|
|
487
|
+
activeOffset: (K = e.activeOffset) == null ? void 0 : K.value
|
|
488
|
+
});
|
|
489
|
+
U !== void 0 && u(U);
|
|
490
|
+
}
|
|
491
|
+
function $(o) {
|
|
492
|
+
const t = le(e.container.value), s = e.resolveTarget(o);
|
|
493
|
+
if (!t || !s)
|
|
494
|
+
return;
|
|
495
|
+
const m = ve(t), T = s.getBoundingClientRect(), x = m + T.top - me(t) - I(s), U = Math.max(0, he(t) - ee(t)), Q = Math.max(0, Math.min(x, U));
|
|
496
|
+
f = {
|
|
497
|
+
top: Q,
|
|
498
|
+
startedAt: Date.now()
|
|
499
|
+
}, r = o, u(o), Je(t, Q, c.value === "reduce" ? "auto" : "smooth");
|
|
500
|
+
}
|
|
501
|
+
function w() {
|
|
502
|
+
y();
|
|
503
|
+
}
|
|
504
|
+
function S(o) {
|
|
505
|
+
var s;
|
|
506
|
+
if (o.defaultPrevented || o.altKey || o.ctrlKey || o.metaKey)
|
|
507
|
+
return;
|
|
508
|
+
const t = (s = e.host) == null ? void 0 : s.value;
|
|
509
|
+
t && o.target instanceof Node && t.contains(o.target) || N(o.target) || ["ArrowDown", "ArrowUp", "PageDown", "PageUp", "Home", "End", " "].includes(o.key) && y();
|
|
510
|
+
}
|
|
511
|
+
return F(
|
|
512
|
+
() => {
|
|
513
|
+
var o;
|
|
514
|
+
return (o = e.activeId) == null ? void 0 : o.value;
|
|
515
|
+
},
|
|
516
|
+
(o) => {
|
|
517
|
+
i.value = o, r && o !== r && v();
|
|
518
|
+
}
|
|
519
|
+
), oe(() => {
|
|
520
|
+
d(), v();
|
|
521
|
+
}), {
|
|
522
|
+
activeId: n,
|
|
523
|
+
scrollTo: $,
|
|
524
|
+
sync: k,
|
|
525
|
+
clearPendingScroll: d,
|
|
526
|
+
releaseSelectionLock: y,
|
|
527
|
+
handleUserScrollIntent: w,
|
|
528
|
+
handleScrollIntentKeydown: S
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function et(e) {
|
|
532
|
+
const a = M(0);
|
|
533
|
+
function l() {
|
|
534
|
+
const r = e.host.value, n = r == null ? void 0 : r.firstElementChild;
|
|
535
|
+
if (!(n instanceof HTMLElement))
|
|
536
|
+
return {
|
|
537
|
+
hostEl: r ?? null,
|
|
538
|
+
floatingEl: null,
|
|
539
|
+
measuredEl: null
|
|
540
|
+
};
|
|
541
|
+
const c = n.querySelector(".tr-content-nav__surface") ?? n.querySelector(".tr-content-nav__panel") ?? n;
|
|
542
|
+
return {
|
|
543
|
+
hostEl: r ?? null,
|
|
544
|
+
floatingEl: n,
|
|
545
|
+
measuredEl: c
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
const i = g(() => {
|
|
549
|
+
const { hostEl: r, floatingEl: n, measuredEl: c } = l(), u = [];
|
|
550
|
+
return r && u.push(r), n && u.push(n), c && c !== n && u.push(c), u;
|
|
551
|
+
});
|
|
552
|
+
function f() {
|
|
553
|
+
const { hostEl: r, floatingEl: n, measuredEl: c } = l(), u = e.container.value, d = r == null ? void 0 : r.parentElement;
|
|
554
|
+
if (!r || !u || !d || !n || !c) {
|
|
555
|
+
a.value = 0;
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
const v = d.getBoundingClientRect(), y = u.getBoundingClientRect(), N = c.getBoundingClientRect().height || 0;
|
|
559
|
+
if (!y.height || !N) {
|
|
560
|
+
a.value = 0;
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const C = y.top - v.top, I = y.bottom - v.top, $ = C + y.height / 2 - N / 2, w = C + 24, S = Math.max(w, I - N - 24);
|
|
564
|
+
a.value = Math.max(w, Math.min($, S));
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
offset: a,
|
|
568
|
+
sync: f,
|
|
569
|
+
resizeTargets: i
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
const tt = "data-content-nav-id", nt = `[${tt}]`, at = "data-item-id", lt = `[${at}]`;
|
|
573
|
+
function Ce(e, a, l, i) {
|
|
574
|
+
return Array.from(e.querySelectorAll(a)).find((f) => f.dataset[l] === i);
|
|
575
|
+
}
|
|
576
|
+
function ge(e, a) {
|
|
577
|
+
return Ce(e, nt, "contentNavId", a);
|
|
578
|
+
}
|
|
579
|
+
function rt(e, a) {
|
|
580
|
+
return Ce(e, lt, "itemId", a);
|
|
581
|
+
}
|
|
582
|
+
function ot(e) {
|
|
583
|
+
function a(n) {
|
|
584
|
+
return n instanceof HTMLElement ? n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement || n.isContentEditable : !1;
|
|
585
|
+
}
|
|
586
|
+
function l() {
|
|
587
|
+
ke(() => {
|
|
588
|
+
var u, d;
|
|
589
|
+
const n = e.highlightedId.value, c = (u = e.overlay.value) == null ? void 0 : u.navEl;
|
|
590
|
+
!n || !c || (d = rt(c, n)) == null || d.focus();
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
function i(n) {
|
|
594
|
+
if (a(n.target))
|
|
595
|
+
return;
|
|
596
|
+
const c = e.handleNavigationKeydown(n);
|
|
597
|
+
if (n.key === "Enter" || n.key === " ") {
|
|
598
|
+
const u = e.getHighlightedItem();
|
|
599
|
+
if (u) {
|
|
600
|
+
n.preventDefault(), e.onSelectItem(u.id);
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
c && l();
|
|
605
|
+
}
|
|
606
|
+
function f() {
|
|
607
|
+
var u;
|
|
608
|
+
if (!e.shouldAutoCollapse.value)
|
|
609
|
+
return;
|
|
610
|
+
const n = ((u = e.overlay.value) == null ? void 0 : u.overlayEl) ?? null, c = document.activeElement;
|
|
611
|
+
n && c instanceof Node && n.contains(c) || e.setExpanded(!1);
|
|
612
|
+
}
|
|
613
|
+
function r(n) {
|
|
614
|
+
var d;
|
|
615
|
+
if (!e.shouldAutoCollapse.value)
|
|
616
|
+
return;
|
|
617
|
+
const c = n.relatedTarget, u = ((d = e.overlay.value) == null ? void 0 : d.overlayEl) ?? null;
|
|
618
|
+
(!c || !(u != null && u.contains(c))) && e.setExpanded(!1);
|
|
619
|
+
}
|
|
620
|
+
return {
|
|
621
|
+
handleKeydown: i,
|
|
622
|
+
handleMouseLeave: f,
|
|
623
|
+
handleFocusOut: r
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function it(e) {
|
|
627
|
+
return (e ?? "").split(/\s+/).map((a) => a.trim()).filter(Boolean);
|
|
628
|
+
}
|
|
629
|
+
function st(e) {
|
|
630
|
+
let a = null, l = [];
|
|
631
|
+
function i() {
|
|
632
|
+
a && l.length && a.classList.remove(...l), a = null, l = [];
|
|
633
|
+
}
|
|
634
|
+
const { start: f, stop: r } = Ee(
|
|
635
|
+
() => {
|
|
636
|
+
i();
|
|
637
|
+
},
|
|
638
|
+
() => Math.max(0, e.feedbackDuration.value ?? 0),
|
|
639
|
+
{ immediate: !1 }
|
|
640
|
+
);
|
|
641
|
+
function n() {
|
|
642
|
+
r(), i();
|
|
643
|
+
}
|
|
644
|
+
function c(u) {
|
|
645
|
+
const d = it(e.feedbackClass.value);
|
|
646
|
+
if (n(), !d.length)
|
|
647
|
+
return;
|
|
648
|
+
const v = e.resolveTarget(u);
|
|
649
|
+
v && (v.classList.remove(...d), v.offsetWidth, v.classList.add(...d), a = v, l = d, f());
|
|
650
|
+
}
|
|
651
|
+
return F(
|
|
652
|
+
() => e.feedbackClass.value,
|
|
653
|
+
() => {
|
|
654
|
+
n();
|
|
655
|
+
}
|
|
656
|
+
), oe(() => {
|
|
657
|
+
n();
|
|
658
|
+
}), {
|
|
659
|
+
activate: c,
|
|
660
|
+
clear: n
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
const j = /* @__PURE__ */ G({
|
|
664
|
+
name: "TrContentNav",
|
|
665
|
+
inheritAttrs: !1,
|
|
666
|
+
__name: "index",
|
|
667
|
+
props: {
|
|
668
|
+
items: {},
|
|
669
|
+
scrollContainer: {},
|
|
670
|
+
activeId: {},
|
|
671
|
+
activeOffset: { default: 120 },
|
|
672
|
+
expanded: { type: Boolean },
|
|
673
|
+
searchQuery: {},
|
|
674
|
+
placement: { default: "right" },
|
|
675
|
+
expandTrigger: { default: "hover" },
|
|
676
|
+
searchOptions: {},
|
|
677
|
+
tooltipDelay: { default: 260 },
|
|
678
|
+
targetFeedbackClass: {},
|
|
679
|
+
targetFeedbackDuration: { default: 700 },
|
|
680
|
+
emptyText: { default: "No matching items" }
|
|
681
|
+
},
|
|
682
|
+
emits: ["update:activeId", "update:expanded", "update:searchQuery", "select"],
|
|
683
|
+
setup(e, { emit: a }) {
|
|
684
|
+
const l = e, i = a, f = be(), {
|
|
685
|
+
activeId: r,
|
|
686
|
+
activeOffset: n,
|
|
687
|
+
emptyText: c,
|
|
688
|
+
expandTrigger: u,
|
|
689
|
+
expanded: d,
|
|
690
|
+
items: v,
|
|
691
|
+
placement: y,
|
|
692
|
+
searchOptions: N,
|
|
693
|
+
searchQuery: C,
|
|
694
|
+
scrollContainer: I,
|
|
695
|
+
targetFeedbackClass: k,
|
|
696
|
+
targetFeedbackDuration: $,
|
|
697
|
+
tooltipDelay: w
|
|
698
|
+
} = _e(l), S = M(null), p = g(() => {
|
|
699
|
+
var h;
|
|
700
|
+
return ((h = S.value) == null ? void 0 : h.hostEl) ?? null;
|
|
701
|
+
}), o = g(() => N.value), t = g(() => o.value ?? {});
|
|
702
|
+
function s(h) {
|
|
703
|
+
const O = I.value;
|
|
704
|
+
return O ? ge(O, h) ?? null : ge(document, h) ?? null;
|
|
705
|
+
}
|
|
706
|
+
const m = g(() => v.value), T = Xe({
|
|
707
|
+
items: m,
|
|
708
|
+
resolveTarget: s,
|
|
709
|
+
container: I,
|
|
710
|
+
host: p,
|
|
711
|
+
activeId: r,
|
|
712
|
+
activeOffset: n,
|
|
713
|
+
onUpdateActiveId: (h) => i("update:activeId", h)
|
|
714
|
+
}), x = Ze({
|
|
715
|
+
items: m,
|
|
716
|
+
activeId: T.activeId,
|
|
717
|
+
expanded: d,
|
|
718
|
+
expandTrigger: u,
|
|
719
|
+
searchQuery: C,
|
|
720
|
+
searchOptions: N,
|
|
721
|
+
onUpdateExpanded: (h) => i("update:expanded", h),
|
|
722
|
+
onUpdateSearchQuery: (h) => i("update:searchQuery", h)
|
|
723
|
+
}), U = g(() => m.value.length > 0), Q = g(() => !!o.value && x.expanded.value), K = g(() => u.value === "hover"), b = g(() => le(I.value)), A = et({
|
|
724
|
+
container: I,
|
|
725
|
+
host: p
|
|
726
|
+
}), J = st({
|
|
727
|
+
resolveTarget: s,
|
|
728
|
+
feedbackClass: k,
|
|
729
|
+
feedbackDuration: $
|
|
730
|
+
});
|
|
731
|
+
function q(h) {
|
|
732
|
+
x.setExpanded(h);
|
|
733
|
+
}
|
|
734
|
+
function ie(h) {
|
|
735
|
+
x.setSearchQuery(h);
|
|
736
|
+
}
|
|
737
|
+
function se(h) {
|
|
738
|
+
const O = m.value.find((R) => R.id === h);
|
|
739
|
+
O && (T.scrollTo(h), J.activate(h), B(), i("select", O));
|
|
740
|
+
}
|
|
741
|
+
const X = ot({
|
|
742
|
+
overlay: S,
|
|
743
|
+
highlightedId: x.highlightedId,
|
|
744
|
+
shouldAutoCollapse: K,
|
|
745
|
+
handleNavigationKeydown: x.handleNavigationKeydown,
|
|
746
|
+
getHighlightedItem: x.getHighlightedItem,
|
|
747
|
+
onSelectItem: se,
|
|
748
|
+
setExpanded: q
|
|
749
|
+
});
|
|
750
|
+
let V = null;
|
|
751
|
+
function B() {
|
|
752
|
+
V !== null && cancelAnimationFrame(V), V = requestAnimationFrame(() => {
|
|
753
|
+
V = null, T.sync(), A.sync();
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
return z(b, "scroll", B, { passive: !0 }), z(b, "wheel", T.handleUserScrollIntent, { passive: !0 }), z(b, "touchmove", T.handleUserScrollIntent, { passive: !0 }), z("keydown", T.handleScrollIntentKeydown), z("resize", B, { passive: !0 }), fe(I, () => {
|
|
757
|
+
B();
|
|
758
|
+
}), fe(A.resizeTargets, () => {
|
|
759
|
+
B();
|
|
760
|
+
}), F(
|
|
761
|
+
() => I.value,
|
|
762
|
+
() => {
|
|
763
|
+
T.clearPendingScroll(), B();
|
|
764
|
+
},
|
|
765
|
+
{ immediate: !0 }
|
|
766
|
+
), F(
|
|
767
|
+
() => p.value,
|
|
768
|
+
() => {
|
|
769
|
+
B();
|
|
770
|
+
}
|
|
771
|
+
), F(
|
|
772
|
+
() => m.value.map((h) => h.id).join(","),
|
|
773
|
+
() => {
|
|
774
|
+
T.clearPendingScroll(), B();
|
|
775
|
+
},
|
|
776
|
+
{ immediate: !0 }
|
|
777
|
+
), oe(() => {
|
|
778
|
+
V !== null && cancelAnimationFrame(V), T.clearPendingScroll();
|
|
779
|
+
}), (h, O) => U.value ? (_(), xe(Ve, ae({
|
|
780
|
+
key: 0,
|
|
781
|
+
ref_key: "overlayShellRef",
|
|
782
|
+
ref: S
|
|
783
|
+
}, E(f), {
|
|
784
|
+
expanded: E(x).expanded.value,
|
|
785
|
+
placement: E(y),
|
|
786
|
+
"floating-offset": E(A).offset.value,
|
|
787
|
+
onMouseenter: O[1] || (O[1] = (R) => K.value && q(!0)),
|
|
788
|
+
onMouseleave: E(X).handleMouseLeave,
|
|
789
|
+
onFocusin: O[2] || (O[2] = (R) => K.value && q(!0)),
|
|
790
|
+
onFocusout: E(X).handleFocusOut,
|
|
791
|
+
onKeydown: E(X).handleKeydown
|
|
792
|
+
}), ne({
|
|
793
|
+
default: P(() => [
|
|
794
|
+
ce(Qe, {
|
|
795
|
+
items: E(x).filteredItems.value,
|
|
796
|
+
"active-id": E(T).activeId.value,
|
|
797
|
+
expanded: E(x).expanded.value,
|
|
798
|
+
"highlighted-index": E(x).highlightedIndex.value,
|
|
799
|
+
placement: E(y),
|
|
800
|
+
"tooltip-delay": E(w),
|
|
801
|
+
"empty-text": E(c),
|
|
802
|
+
onSelect: O[0] || (O[0] = (R) => se(R.id))
|
|
803
|
+
}, ne({ _: 2 }, [
|
|
804
|
+
h.$slots.marker ? {
|
|
805
|
+
name: "marker",
|
|
806
|
+
fn: P((R) => [
|
|
807
|
+
L(h.$slots, "marker", ue(de(R)))
|
|
808
|
+
]),
|
|
809
|
+
key: "0"
|
|
810
|
+
} : void 0,
|
|
811
|
+
h.$slots.item ? {
|
|
812
|
+
name: "item",
|
|
813
|
+
fn: P((R) => [
|
|
814
|
+
L(h.$slots, "item", ue(de(R)))
|
|
815
|
+
]),
|
|
816
|
+
key: "1"
|
|
817
|
+
} : void 0,
|
|
818
|
+
h.$slots.empty ? {
|
|
819
|
+
name: "empty",
|
|
820
|
+
fn: P(() => [
|
|
821
|
+
L(h.$slots, "empty")
|
|
822
|
+
]),
|
|
823
|
+
key: "2"
|
|
824
|
+
} : void 0
|
|
825
|
+
]), 1032, ["items", "active-id", "expanded", "highlighted-index", "placement", "tooltip-delay", "empty-text"])
|
|
826
|
+
]),
|
|
827
|
+
_: 2
|
|
828
|
+
}, [
|
|
829
|
+
Q.value ? {
|
|
830
|
+
name: "search",
|
|
831
|
+
fn: P(() => [
|
|
832
|
+
L(h.$slots, "search", {
|
|
833
|
+
searchQuery: E(x).searchQuery.value,
|
|
834
|
+
setSearchQuery: ie,
|
|
835
|
+
searchOptions: t.value
|
|
836
|
+
}, () => [
|
|
837
|
+
ce(Ge, {
|
|
838
|
+
"search-query": E(x).searchQuery.value,
|
|
839
|
+
"search-options": t.value,
|
|
840
|
+
"onUpdate:searchQuery": ie
|
|
841
|
+
}, null, 8, ["search-query", "search-options"])
|
|
842
|
+
])
|
|
843
|
+
]),
|
|
844
|
+
key: "0"
|
|
845
|
+
} : void 0
|
|
846
|
+
]), 1040, ["expanded", "placement", "floating-offset", "onMouseleave", "onFocusout", "onKeydown"])) : re("", !0);
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
j.name = "TrContentNav";
|
|
850
|
+
const ct = function(e) {
|
|
851
|
+
e.component(j.name, j);
|
|
852
|
+
};
|
|
853
|
+
j.install = ct;
|
|
854
|
+
export {
|
|
855
|
+
j as default
|
|
856
|
+
};
|