@leavepulse/ui 0.18.2 → 0.18.3
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.
|
@@ -38,11 +38,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
38
38
|
const flatItems = computed(
|
|
39
39
|
() => props.sections ? props.sections.flatMap((s) => s.items) : props.items ?? []
|
|
40
40
|
);
|
|
41
|
-
function
|
|
42
|
-
if (props.path == null) return item.id === props.modelValue;
|
|
41
|
+
function matchesPath(item) {
|
|
43
42
|
if (item.id === "/") return props.path === "/";
|
|
44
43
|
return props.path === item.id || props.path.startsWith(`${item.id}/`);
|
|
45
44
|
}
|
|
45
|
+
function defaultActive(item) {
|
|
46
|
+
if (props.path == null) return item.id === props.modelValue;
|
|
47
|
+
if (!matchesPath(item)) return false;
|
|
48
|
+
return !flatItems.value.some(
|
|
49
|
+
(other) => other.id !== item.id && other.id.length > item.id.length && matchesPath(other)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
46
52
|
const activeTest = computed(() => props.isActive ?? defaultActive);
|
|
47
53
|
const pageTitle = computed(() => {
|
|
48
54
|
if (props.title != null) return props.title;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { _ as _2 } from "./chunks/LpAddressInput-Dfyn88Dd.js";
|
|
|
3
3
|
import { _ as _3 } from "./chunks/LpMapPicker-DFKrd1Ne.js";
|
|
4
4
|
import { OSM_TILES, createNominatimProvider, emptyAddress, formatAddress, project, tileUrl, unproject } from "./components/address.js";
|
|
5
5
|
import { _ as _4 } from "./chunks/LpAlert-BAYHDSS1.js";
|
|
6
|
-
import { _ as _5 } from "./chunks/LpAppShell-
|
|
6
|
+
import { _ as _5 } from "./chunks/LpAppShell-BvAVgVLW.js";
|
|
7
7
|
import { _ as _6 } from "./chunks/LpAutocomplete-DIgXmtCA.js";
|
|
8
8
|
import { _ as _7 } from "./chunks/LpAvatar-B1Ez0ZAx.js";
|
|
9
9
|
import { _ as _8 } from "./chunks/LpBadge-CXzBPnwO.js";
|
package/package.json
CHANGED
|
@@ -83,10 +83,23 @@ const flatItems = computed<SidebarItem[]>(() =>
|
|
|
83
83
|
|
|
84
84
|
// Default active test: exact match for "/", prefix match (on a segment
|
|
85
85
|
// boundary) otherwise — so "/billing" doesn't light up on "/billing-x".
|
|
86
|
+
function matchesPath(item: SidebarItem): boolean {
|
|
87
|
+
if (item.id === "/") return props.path === "/"
|
|
88
|
+
return props.path === item.id || props.path!.startsWith(`${item.id}/`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Only the LONGEST match lights up. A parent whose id prefixes its children —
|
|
92
|
+
// "/dcim" over "/dcim/power" — otherwise stays lit alongside whichever child is
|
|
93
|
+
// open, and two highlighted items read as two current pages.
|
|
86
94
|
function defaultActive(item: SidebarItem): boolean {
|
|
87
95
|
if (props.path == null) return item.id === props.modelValue
|
|
88
|
-
if (item
|
|
89
|
-
return
|
|
96
|
+
if (!matchesPath(item)) return false
|
|
97
|
+
return !flatItems.value.some(
|
|
98
|
+
(other) =>
|
|
99
|
+
other.id !== item.id &&
|
|
100
|
+
other.id.length > item.id.length &&
|
|
101
|
+
matchesPath(other),
|
|
102
|
+
)
|
|
90
103
|
}
|
|
91
104
|
const activeTest = computed(() => props.isActive ?? defaultActive)
|
|
92
105
|
|