@acorex/components 20.7.52 → 20.7.53
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/fesm2022/acorex-components-menu.mjs +20 -7
- package/fesm2022/acorex-components-menu.mjs.map +1 -1
- package/fesm2022/acorex-components-time-duration.mjs +6 -2
- package/fesm2022/acorex-components-time-duration.mjs.map +1 -1
- package/menu/index.d.ts +6 -2
- package/package.json +15 -15
- package/time-duration/index.d.ts +1 -0
|
@@ -116,6 +116,7 @@ class AXMenuItemComponent extends NXComponent {
|
|
|
116
116
|
this.parent = inject(AXMenuItemComponent, { optional: true, skipSelf: true });
|
|
117
117
|
this.isFirstLevel = computed(() => this.getParentMenuItem() == null, ...(ngDevMode ? [{ debugName: "isFirstLevel" }] : []));
|
|
118
118
|
this.childMenuItems = contentChildren(AXMenuItemComponent, ...(ngDevMode ? [{ debugName: "childMenuItems", descendants: false }] : [{ descendants: false }]));
|
|
119
|
+
this.discoveredSubmenuNodeCount = signal(0, ...(ngDevMode ? [{ debugName: "discoveredSubmenuNodeCount" }] : []));
|
|
119
120
|
this.submenuSlot = viewChild('submenuSlot', ...(ngDevMode ? [{ debugName: "submenuSlot" }] : []));
|
|
120
121
|
this.platformId = inject(PLATFORM_ID);
|
|
121
122
|
this.destroyRef = inject(DestroyRef);
|
|
@@ -126,7 +127,9 @@ class AXMenuItemComponent extends NXComponent {
|
|
|
126
127
|
* because `contentChildren` does not traverse those embedded views.
|
|
127
128
|
*/
|
|
128
129
|
this.subItems = input([], ...(ngDevMode ? [{ debugName: "subItems" }] : []));
|
|
129
|
-
this.hasSubItems = computed(() => (this.subItems()?.length ?? 0) > 0 ||
|
|
130
|
+
this.hasSubItems = computed(() => (this.subItems()?.length ?? 0) > 0 ||
|
|
131
|
+
this.childMenuItems().length > 0 ||
|
|
132
|
+
this.discoveredSubmenuNodeCount() > 0, ...(ngDevMode ? [{ debugName: "hasSubItems" }] : []));
|
|
130
133
|
this.root = inject(AXRootMenu);
|
|
131
134
|
this.service = inject(AXMenuService);
|
|
132
135
|
this.unsuscriber = inject(AXUnsubscriber);
|
|
@@ -153,6 +156,7 @@ class AXMenuItemComponent extends NXComponent {
|
|
|
153
156
|
return;
|
|
154
157
|
}
|
|
155
158
|
this.reparentOrphanedChildren();
|
|
159
|
+
this.updateDiscoveredSubmenuNodeCount();
|
|
156
160
|
this.childObserver = new MutationObserver((records) => {
|
|
157
161
|
if (!this.hasRelevantChildMutation(records)) {
|
|
158
162
|
return;
|
|
@@ -332,7 +336,7 @@ class AXMenuItemComponent extends NXComponent {
|
|
|
332
336
|
if (!container) {
|
|
333
337
|
return;
|
|
334
338
|
}
|
|
335
|
-
for (const el of this.
|
|
339
|
+
for (const el of this.getDirectSubmenuNodes()) {
|
|
336
340
|
if (!container.contains(el)) {
|
|
337
341
|
try {
|
|
338
342
|
container.appendChild(el);
|
|
@@ -343,15 +347,23 @@ class AXMenuItemComponent extends NXComponent {
|
|
|
343
347
|
}
|
|
344
348
|
}
|
|
345
349
|
}
|
|
346
|
-
/**
|
|
347
|
-
|
|
348
|
-
|
|
350
|
+
/**
|
|
351
|
+
* Nested submenu nodes rendered by custom recursive templates (direct children of this item only).
|
|
352
|
+
*/
|
|
353
|
+
getDirectSubmenuNodes() {
|
|
354
|
+
return Array.from(this.nativeElement.querySelectorAll('ax-menu-item, ax-title, ax-divider')).filter((el) => {
|
|
349
355
|
if (el === this.nativeElement) {
|
|
350
356
|
return false;
|
|
351
357
|
}
|
|
352
|
-
|
|
358
|
+
if (el.tagName === 'AX-MENU-ITEM') {
|
|
359
|
+
return el.parentElement?.closest('ax-menu-item') === this.nativeElement;
|
|
360
|
+
}
|
|
361
|
+
return el.closest('ax-menu-item') === this.nativeElement;
|
|
353
362
|
});
|
|
354
363
|
}
|
|
364
|
+
updateDiscoveredSubmenuNodeCount() {
|
|
365
|
+
this.discoveredSubmenuNodeCount.set(this.getDirectSubmenuNodes().length);
|
|
366
|
+
}
|
|
355
367
|
scheduleChildRefresh() {
|
|
356
368
|
if (this.childRefreshScheduled) {
|
|
357
369
|
return;
|
|
@@ -360,6 +372,7 @@ class AXMenuItemComponent extends NXComponent {
|
|
|
360
372
|
requestAnimationFrame(() => {
|
|
361
373
|
this.childRefreshScheduled = false;
|
|
362
374
|
this.reparentOrphanedChildren();
|
|
375
|
+
this.updateDiscoveredSubmenuNodeCount();
|
|
363
376
|
});
|
|
364
377
|
}
|
|
365
378
|
hasRelevantChildMutation(records) {
|
|
@@ -455,7 +468,7 @@ class AXMenuItemComponent extends NXComponent {
|
|
|
455
468
|
if (this.nativeElement.contains(node)) {
|
|
456
469
|
return true;
|
|
457
470
|
}
|
|
458
|
-
return this.
|
|
471
|
+
return this.getDirectSubmenuNodes().some((child) => child.contains(node));
|
|
459
472
|
}
|
|
460
473
|
ngOnDestroy() {
|
|
461
474
|
if (this.isOpen()) {
|