@dskripchenko/ui 1.10.0 → 1.11.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/index.mjs
CHANGED
|
@@ -2053,7 +2053,12 @@ var Cr = /* @__PURE__ */ yr(br, [["render", Sr]]), wr = [
|
|
|
2053
2053
|
collapseMenu: {
|
|
2054
2054
|
type: Boolean,
|
|
2055
2055
|
default: !0
|
|
2056
|
-
}
|
|
2056
|
+
},
|
|
2057
|
+
collapseFirst: {
|
|
2058
|
+
type: Boolean,
|
|
2059
|
+
default: !1
|
|
2060
|
+
},
|
|
2061
|
+
container: { default: null }
|
|
2057
2062
|
},
|
|
2058
2063
|
setup(e, { expose: r }) {
|
|
2059
2064
|
let i = e, u = $(), d = O(0);
|
|
@@ -2073,80 +2078,115 @@ var Cr = /* @__PURE__ */ yr(br, [["render", Sr]]), wr = [
|
|
|
2073
2078
|
return;
|
|
2074
2079
|
}
|
|
2075
2080
|
if (g.value = !0, h.value.length > 0 && (h.value = []), await v(), e !== D) return;
|
|
2076
|
-
let t = p.value, n = C(), r = t?.clientWidth ?? 0, a = n.map((e) => e.getBoundingClientRect().width), o = a.reduce((e, t) => e + t, 0), s =
|
|
2077
|
-
|
|
2081
|
+
let t = p.value, n = C(), r = t?.clientWidth ?? 0, a = n.map((e) => e.getBoundingClientRect().width), o = a.reduce((e, t) => e + t, 0), s = n.slice(1, -1);
|
|
2082
|
+
i.collapseFirst && n.length > 1 && s.push(n[0]);
|
|
2083
|
+
let c = 0;
|
|
2084
|
+
if (r > 0 && o > r && n.length > 1) {
|
|
2078
2085
|
let e = m.value?.getBoundingClientRect().width ?? 0;
|
|
2079
|
-
for (
|
|
2086
|
+
for (; c < s.length;) {
|
|
2087
|
+
let t = s[c++];
|
|
2088
|
+
if (o -= a[n.indexOf(t)], o + e <= r) break;
|
|
2089
|
+
}
|
|
2080
2090
|
}
|
|
2081
|
-
|
|
2091
|
+
let l = (e) => n.filter((t) => s.slice(0, e).includes(t));
|
|
2092
|
+
for (h.value = l(c); t && c > 0 && c < s.length;) {
|
|
2093
|
+
if (await v(), e !== D) return;
|
|
2094
|
+
if (t.scrollWidth <= t.clientWidth + .5) break;
|
|
2095
|
+
h.value = l(++c);
|
|
2096
|
+
}
|
|
2097
|
+
g.value = !1;
|
|
2082
2098
|
}
|
|
2083
2099
|
function M() {
|
|
2084
2100
|
j();
|
|
2085
2101
|
}
|
|
2086
|
-
let I = null, R = null;
|
|
2087
|
-
function B() {
|
|
2088
|
-
V(), i.collapse && (typeof ResizeObserver < "u" && f.value && (I = new ResizeObserver(M), I.observe(f.value)), typeof MutationObserver < "u" && p.value && (R = new MutationObserver(M), R.observe(p.value, { childList: !0 })));
|
|
2089
|
-
}
|
|
2102
|
+
let I = null, R = null, B = /* @__PURE__ */ new WeakMap();
|
|
2090
2103
|
function V() {
|
|
2104
|
+
let e = i.container;
|
|
2105
|
+
return e ? typeof e == "string" ? f.value?.closest(e) ?? null : e : null;
|
|
2106
|
+
}
|
|
2107
|
+
function H(e) {
|
|
2108
|
+
let t = !1;
|
|
2109
|
+
for (let n of e) {
|
|
2110
|
+
let e = n.contentRect.width;
|
|
2111
|
+
B.get(n.target) !== e && (B.set(n.target, e), t = !0);
|
|
2112
|
+
}
|
|
2113
|
+
t && M();
|
|
2114
|
+
}
|
|
2115
|
+
function U() {
|
|
2116
|
+
if (W(), !i.collapse) return;
|
|
2117
|
+
let e = f.value;
|
|
2118
|
+
if (typeof ResizeObserver < "u" && e) {
|
|
2119
|
+
I = new ResizeObserver(H);
|
|
2120
|
+
let t = new Set([e]);
|
|
2121
|
+
e.parentElement && t.add(e.parentElement);
|
|
2122
|
+
let n = V();
|
|
2123
|
+
n && t.add(n);
|
|
2124
|
+
for (let e of t) I.observe(e);
|
|
2125
|
+
}
|
|
2126
|
+
typeof MutationObserver < "u" && p.value && (R = new MutationObserver(M), R.observe(p.value, { childList: !0 }));
|
|
2127
|
+
}
|
|
2128
|
+
function W() {
|
|
2091
2129
|
I?.disconnect(), R?.disconnect(), I = null, R = null;
|
|
2092
2130
|
}
|
|
2093
2131
|
S(() => {
|
|
2094
|
-
|
|
2132
|
+
U(), M();
|
|
2095
2133
|
}), G(() => i.collapse, () => {
|
|
2096
|
-
|
|
2097
|
-
}),
|
|
2098
|
-
|
|
2134
|
+
U(), M(), i.collapse || ae();
|
|
2135
|
+
}), G(() => i.container, () => {
|
|
2136
|
+
U(), M();
|
|
2137
|
+
}), G(() => i.collapseFirst, M), x(() => {
|
|
2138
|
+
W(), ie();
|
|
2099
2139
|
});
|
|
2100
|
-
let
|
|
2140
|
+
let K = O(!1), q = O(null), J = O(null), Y = z(), { floatingStyle: X, update: Z } = tr(q, J, {
|
|
2101
2141
|
placement: "bottom-start",
|
|
2102
2142
|
offset: 4
|
|
2103
2143
|
});
|
|
2104
|
-
function
|
|
2144
|
+
function ee(e) {
|
|
2105
2145
|
return e.querySelector(":scope > :not(.uid-breadcrumb__separator):not(.uid-breadcrumb__ellipsis)");
|
|
2106
2146
|
}
|
|
2107
|
-
let
|
|
2108
|
-
let t =
|
|
2147
|
+
let te = a(() => h.value.map((e) => {
|
|
2148
|
+
let t = ee(e), n = t && t.matches("a, button") ? t : null;
|
|
2109
2149
|
return {
|
|
2110
2150
|
el: e,
|
|
2111
2151
|
label: t?.textContent?.trim() ?? "",
|
|
2112
2152
|
target: n
|
|
2113
2153
|
};
|
|
2114
2154
|
}));
|
|
2115
|
-
function
|
|
2116
|
-
return Array.from(
|
|
2155
|
+
function ne() {
|
|
2156
|
+
return Array.from(J.value?.querySelectorAll("[role=\"menuitem\"]") ?? []);
|
|
2117
2157
|
}
|
|
2118
|
-
async function
|
|
2119
|
-
|
|
2158
|
+
async function re(e) {
|
|
2159
|
+
q.value = e, K.value = !0, await v(), Z(), ne()[0]?.focus(), document.addEventListener("pointerdown", oe), window.addEventListener("resize", Z), window.addEventListener("scroll", Z, !0);
|
|
2120
2160
|
}
|
|
2121
|
-
function
|
|
2122
|
-
document.removeEventListener("pointerdown",
|
|
2161
|
+
function ie() {
|
|
2162
|
+
document.removeEventListener("pointerdown", oe), window.removeEventListener("resize", Z), window.removeEventListener("scroll", Z, !0);
|
|
2123
2163
|
}
|
|
2124
|
-
function
|
|
2125
|
-
|
|
2164
|
+
function ae(e = !1) {
|
|
2165
|
+
K.value && (K.value = !1, ie(), e && q.value?.focus());
|
|
2126
2166
|
}
|
|
2127
|
-
function
|
|
2128
|
-
|
|
2167
|
+
function Q(e) {
|
|
2168
|
+
K.value ? ae() : re(e);
|
|
2129
2169
|
}
|
|
2130
|
-
function
|
|
2170
|
+
function oe(e) {
|
|
2131
2171
|
let t = e.target;
|
|
2132
|
-
|
|
2172
|
+
J.value?.contains(t) || q.value?.contains(t) || ae();
|
|
2133
2173
|
}
|
|
2134
|
-
function
|
|
2135
|
-
e.target && (
|
|
2174
|
+
function se(e) {
|
|
2175
|
+
e.target && (ae(), e.target.click());
|
|
2136
2176
|
}
|
|
2137
|
-
function
|
|
2138
|
-
let t =
|
|
2139
|
-
e.key === "ArrowDown" ? (e.preventDefault(), t[(n + 1) % t.length]?.focus()) : e.key === "ArrowUp" ? (e.preventDefault(), t[(n - 1 + t.length) % t.length]?.focus()) : e.key === "Home" ? (e.preventDefault(), t[0]?.focus()) : e.key === "End" ? (e.preventDefault(), t[t.length - 1]?.focus()) : e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(),
|
|
2177
|
+
function ce(e) {
|
|
2178
|
+
let t = ne(), n = t.indexOf(document.activeElement);
|
|
2179
|
+
e.key === "ArrowDown" ? (e.preventDefault(), t[(n + 1) % t.length]?.focus()) : e.key === "ArrowUp" ? (e.preventDefault(), t[(n - 1 + t.length) % t.length]?.focus()) : e.key === "Home" ? (e.preventDefault(), t[0]?.focus()) : e.key === "End" ? (e.preventDefault(), t[t.length - 1]?.focus()) : e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(), ae(!0)) : e.key === "Tab" && ae();
|
|
2140
2180
|
}
|
|
2141
2181
|
return G(h, (e) => {
|
|
2142
|
-
e.length === 0 &&
|
|
2182
|
+
e.length === 0 && ae();
|
|
2143
2183
|
}), E(Br, {
|
|
2144
2184
|
tick: d,
|
|
2145
2185
|
hidden: h,
|
|
2146
2186
|
menu: F(i, "collapseMenu"),
|
|
2147
|
-
menuId:
|
|
2148
|
-
menuOpen:
|
|
2149
|
-
toggleMenu:
|
|
2187
|
+
menuId: Y,
|
|
2188
|
+
menuOpen: K,
|
|
2189
|
+
toggleMenu: Q
|
|
2150
2190
|
}), r({ recompute: j }), (r, i) => (T(), c("nav", {
|
|
2151
2191
|
ref_key: "navRef",
|
|
2152
2192
|
ref: f,
|
|
@@ -2170,28 +2210,28 @@ var Cr = /* @__PURE__ */ yr(br, [["render", Sr]]), wr = [
|
|
|
2170
2210
|
class: "uid-breadcrumb__item uid-breadcrumb__probe",
|
|
2171
2211
|
style: b({ "--uid-breadcrumb-sep": `'${e.separator}'` }),
|
|
2172
2212
|
"aria-hidden": "true"
|
|
2173
|
-
}, [
|
|
2213
|
+
}, [i[0] ||= l("span", { class: "uid-breadcrumb__separator" }, null, -1), l("span", { class: y(["uid-breadcrumb__ellipsis", { "uid-breadcrumb__ellipsis--button": e.collapseMenu }]) }, "…", 2)], 4)) : s("", !0),
|
|
2174
2214
|
e.collapse && e.collapseMenu ? (T(), o(n, {
|
|
2175
2215
|
key: 1,
|
|
2176
2216
|
to: "body"
|
|
2177
|
-
}, [
|
|
2217
|
+
}, [K.value ? (T(), c("div", {
|
|
2178
2218
|
key: 0,
|
|
2179
|
-
id: L(
|
|
2219
|
+
id: L(Y),
|
|
2180
2220
|
ref_key: "menuRef",
|
|
2181
|
-
ref:
|
|
2221
|
+
ref: J,
|
|
2182
2222
|
class: "uid-breadcrumb__menu",
|
|
2183
2223
|
role: "menu",
|
|
2184
2224
|
"aria-label": L(u).breadcrumb?.showHidden,
|
|
2185
|
-
style: b(L(
|
|
2186
|
-
onKeydown:
|
|
2187
|
-
}, [(T(!0), c(t, null, k(
|
|
2225
|
+
style: b(L(X)),
|
|
2226
|
+
onKeydown: ce
|
|
2227
|
+
}, [(T(!0), c(t, null, k(te.value, (e, t) => (T(), c("button", {
|
|
2188
2228
|
key: t,
|
|
2189
2229
|
type: "button",
|
|
2190
2230
|
role: "menuitem",
|
|
2191
2231
|
class: "uid-breadcrumb__menu-item",
|
|
2192
2232
|
tabindex: "-1",
|
|
2193
2233
|
"aria-disabled": e.target ? void 0 : "true",
|
|
2194
|
-
onClick: (t) =>
|
|
2234
|
+
onClick: (t) => se(e)
|
|
2195
2235
|
}, P(e.label), 9, Ur))), 128))], 44, Hr)) : s("", !0)])) : s("", !0)
|
|
2196
2236
|
], 10, Vr));
|
|
2197
2237
|
}
|