@ferrlabs/ui-ng 1.44.4 → 1.44.5

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.
@@ -8202,6 +8202,42 @@ i0.ɵɵngDeclareClassMetadata({
8202
8202
  }]
8203
8203
  }
8204
8204
  });
8205
+ function parse(url) {
8206
+ const [path, query = ""] = url.split("#")[0].split("?");
8207
+ return {
8208
+ path,
8209
+ query: new URLSearchParams(query)
8210
+ };
8211
+ }
8212
+ function containsPath(current, target) {
8213
+ if (target === "/") return current === "/";
8214
+ return current === target || current.startsWith(`${target}/`);
8215
+ }
8216
+ function containsQuery(current, target) {
8217
+ for (const [key, value] of target) if (current.get(key) !== value) return false;
8218
+ return true;
8219
+ }
8220
+ function activeNavItemId(groups, currentUrl) {
8221
+ const current = parse(currentUrl);
8222
+ let bestId = null;
8223
+ let bestPathLength = -1;
8224
+ let bestQuerySize = -1;
8225
+ for (const group of groups) for (const item of group.items) {
8226
+ if (!item.href) continue;
8227
+ const target = parse(item.href);
8228
+ if (!containsPath(current.path, target.path)) continue;
8229
+ if (!containsQuery(current.query, target.query)) continue;
8230
+ const querySize = [...target.query].length;
8231
+ const longer = target.path.length > bestPathLength;
8232
+ const moreSpecific = target.path.length === bestPathLength && querySize > bestQuerySize;
8233
+ if (longer || moreSpecific) {
8234
+ bestId = item.id;
8235
+ bestPathLength = target.path.length;
8236
+ bestQuerySize = querySize;
8237
+ }
8238
+ }
8239
+ return bestId;
8240
+ }
8205
8241
  const SHELL_CONTEXT = new InjectionToken("SHELL_CONTEXT");
8206
8242
  var ShellComponent = class ShellComponent {
8207
8243
  constructor() {
@@ -8216,13 +8252,10 @@ var ShellComponent = class ShellComponent {
8216
8252
  this.navigate = output();
8217
8253
  this.search = output();
8218
8254
  this.sanitizer = inject(DomSanitizer);
8255
+ this.activeItemId = computed(() => activeNavItemId(this.sections(), this.currentPath()), ...ngDevMode ? [{ debugName: "activeItemId" }] : /* istanbul ignore next */ []);
8219
8256
  }
8220
8257
  isActive(item) {
8221
- const href = item.href;
8222
- if (!href) return false;
8223
- const path = this.currentPath();
8224
- if (href === "/") return path === "/";
8225
- return path === href || path.startsWith(`${href}/`);
8258
+ return item.href !== void 0 && item.id === this.activeItemId();
8226
8259
  }
8227
8260
  onSelect(item) {
8228
8261
  if (item.href) this.navigate.emit(item.href);