@cngx/ui 0.1.0-rc.7 → 0.1.0-rc.9

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.
Files changed (101) hide show
  1. package/README.md +0 -1
  2. package/a11y/README.md +11 -5
  3. package/accordion/README.md +4 -2
  4. package/breadcrumb/README.md +262 -0
  5. package/collection/README.md +6 -0
  6. package/command-palette/README.md +227 -0
  7. package/data-grid-accordion/README.md +76 -2
  8. package/feedback/README.md +40 -0
  9. package/fesm2022/cngx-ui-a11y.mjs +189 -57
  10. package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
  11. package/fesm2022/cngx-ui-accordion.mjs +120 -36
  12. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  13. package/fesm2022/cngx-ui-action-button.mjs +121 -56
  14. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  15. package/fesm2022/cngx-ui-breadcrumb.mjs +228 -108
  16. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  17. package/fesm2022/cngx-ui-chart-panel.mjs +180 -23
  18. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
  19. package/fesm2022/cngx-ui-collection.mjs +204 -62
  20. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  21. package/fesm2022/cngx-ui-command-palette.mjs +395 -119
  22. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
  23. package/fesm2022/cngx-ui-context-menu.mjs +209 -40
  24. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
  25. package/fesm2022/cngx-ui-data-grid-accordion.mjs +498 -101
  26. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  27. package/fesm2022/cngx-ui-empty-state.mjs +16 -6
  28. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
  29. package/fesm2022/cngx-ui-feedback.mjs +1074 -460
  30. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  31. package/fesm2022/cngx-ui-mat-accordion.mjs +76 -7
  32. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  33. package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
  34. package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
  35. package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
  36. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
  37. package/fesm2022/cngx-ui-mat-tabs.mjs +555 -204
  38. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  39. package/fesm2022/cngx-ui-overlay.mjs +69 -13
  40. package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
  41. package/fesm2022/cngx-ui-paginator.mjs +553 -198
  42. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  43. package/fesm2022/cngx-ui-sidenav.mjs +344 -109
  44. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  45. package/fesm2022/cngx-ui-skeleton.mjs +4 -16
  46. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  47. package/fesm2022/cngx-ui-speak.mjs +107 -8
  48. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  49. package/fesm2022/cngx-ui-stat-card.mjs +146 -46
  50. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
  51. package/fesm2022/cngx-ui-stepper.mjs +234 -99
  52. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  53. package/fesm2022/cngx-ui-tabs.mjs +88 -25
  54. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  55. package/fesm2022/cngx-ui-timeline.mjs +98 -23
  56. package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
  57. package/fesm2022/cngx-ui-toc.mjs +101 -33
  58. package/fesm2022/cngx-ui-toc.mjs.map +1 -1
  59. package/fesm2022/cngx-ui.mjs +15 -20
  60. package/fesm2022/cngx-ui.mjs.map +1 -1
  61. package/mat-paginator/README.md +9 -2
  62. package/mat-tabs/README.md +30 -6
  63. package/mat-tabs/styles/mat-tabs.css +188 -42
  64. package/overlay/README.md +9 -4
  65. package/package.json +31 -7
  66. package/paginator/README.md +8 -4
  67. package/schematics/collection.json +9 -0
  68. package/schematics/ng-add/index.js +9 -0
  69. package/schematics/ng-add/schema.json +91 -0
  70. package/schematics/package.json +3 -0
  71. package/sidenav/README.md +33 -11
  72. package/speak/README.md +3 -2
  73. package/stepper/README.md +14 -2
  74. package/timeline/README.md +1 -1
  75. package/toc/README.md +4 -1
  76. package/types/cngx-ui-a11y.d.ts +121 -30
  77. package/types/cngx-ui-accordion.d.ts +100 -28
  78. package/types/cngx-ui-action-button.d.ts +44 -3
  79. package/types/cngx-ui-breadcrumb.d.ts +167 -60
  80. package/types/cngx-ui-chart-panel.d.ts +122 -18
  81. package/types/cngx-ui-collection.d.ts +157 -55
  82. package/types/cngx-ui-command-palette.d.ts +297 -183
  83. package/types/cngx-ui-context-menu.d.ts +140 -10
  84. package/types/cngx-ui-data-grid-accordion.d.ts +278 -39
  85. package/types/cngx-ui-empty-state.d.ts +9 -2
  86. package/types/cngx-ui-feedback.d.ts +605 -59
  87. package/types/cngx-ui-mat-accordion.d.ts +30 -1
  88. package/types/cngx-ui-mat-paginator.d.ts +37 -8
  89. package/types/cngx-ui-mat-stepper.d.ts +23 -11
  90. package/types/cngx-ui-mat-tabs.d.ts +250 -34
  91. package/types/cngx-ui-overlay.d.ts +56 -10
  92. package/types/cngx-ui-paginator.d.ts +425 -136
  93. package/types/cngx-ui-sidenav.d.ts +248 -74
  94. package/types/cngx-ui-skeleton.d.ts +6 -7
  95. package/types/cngx-ui-speak.d.ts +118 -5
  96. package/types/cngx-ui-stat-card.d.ts +117 -33
  97. package/types/cngx-ui-stepper.d.ts +88 -49
  98. package/types/cngx-ui-tabs.d.ts +6 -4
  99. package/types/cngx-ui-timeline.d.ts +35 -11
  100. package/types/cngx-ui-toc.d.ts +93 -16
  101. package/types/cngx-ui.d.ts +7 -4
@@ -1,6 +1,6 @@
1
1
  import { NgTemplateOutlet, DOCUMENT } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { inject, TemplateRef, Directive, InjectionToken, signal, computed, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component, input, ElementRef, DestroyRef, effect, untracked, output } from '@angular/core';
3
+ import { inject, TemplateRef, Directive, InjectionToken, signal, computed, contentChild, linkedSignal, ViewEncapsulation, ChangeDetectionStrategy, Component, input, ElementRef, DestroyRef, effect, untracked, output } from '@angular/core';
4
4
  import { outputToObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
5
  import * as i1$1 from '@cngx/common/interactive';
6
6
  import { CngxMenu, CNGX_SUBMENU_TRY_FALLBACKS, createContextMenuTriggerCore, CNGX_MENU_FOCUS_STACK_FACTORY, CNGX_MENU_NAV_STRATEGY, CNGX_MENU_ANNOUNCER_FACTORY, CNGX_MENU_DISMISS_HANDLER_FACTORY, injectMenuConfig, connectSubmenuHoverToFocusStack, CngxMenuItemIcon, CngxMenuItem, CngxMenuItemLabel, CngxMenuItemKbd, CngxMenuItemSuffix, CNGX_MENU_SUBMENU_WIRING, CngxMenuItemSubmenu, CngxMenuSeparator, CngxMenuItemCheckbox, CngxMenuItemRadio } from '@cngx/common/interactive';
@@ -104,6 +104,7 @@ const CNGX_CONTEXT_MENU_PANEL = new InjectionToken('CNGX_CONTEXT_MENU_PANEL');
104
104
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu.component.ts
105
105
  * @since 0.1.0
106
106
  * @relatedTo CngxContextMenuFor, CngxContextMenuItem, CngxContextMenuContent, CngxMenu, CngxPopover
107
+ * @slot cngxContextMenuContent Replaces the projected items with lazy content rendered only while the menu is open; gets the trigger's per-open datum as $implicit (let-row).
107
108
  */
108
109
  class CngxContextMenu {
109
110
  /** The popover surface this panel drives. Consumed by the trigger core. */
@@ -112,6 +113,16 @@ class CngxContextMenu {
112
113
  menuHost = inject(CngxMenu, { self: true });
113
114
  /** Per-open datum set by the trigger before `show()`. */
114
115
  datum = signal(null, ...(ngDevMode ? [{ debugName: "datum" }] : /* istanbul ignore next */ []));
116
+ /** Backing state for {@link openOwner}. */
117
+ openOwnerState = signal(null, ...(ngDevMode ? [{ debugName: "openOwnerState" }] : /* istanbul ignore next */ []));
118
+ /**
119
+ * @internal The trigger that owns the current open, `null` while unowned.
120
+ * Claimed by the opening `CngxContextMenuFor` before the popover shows;
121
+ * direct opens (`openAsSubmenu`, programmatic `popover.show()`) leave it
122
+ * `null`, so docked triggers keep `aria-expanded="false"` for opens they
123
+ * did not perform.
124
+ */
125
+ openOwner = this.openOwnerState.asReadonly();
115
126
  /**
116
127
  * The datum the menu opened over while visible, `null` once closed. Gated on
117
128
  * `popover.isVisible()` so the reset on dismiss is derived, not synced.
@@ -125,20 +136,44 @@ class CngxContextMenu {
125
136
  setContext(value) {
126
137
  this.datum.set(value);
127
138
  }
139
+ /** @internal Claim the current open for `owner`. See {@link CngxContextMenuPanel.claimOpen}. */
140
+ claimOpen(owner) {
141
+ this.openOwnerState.set(owner);
142
+ // A trigger open makes this a root: activation routes to the trigger,
143
+ // never to the panel a previous openAsSubmenu came from.
144
+ this.openedFrom.set(null);
145
+ // A trigger claim is always a ROOT open: it must not inherit the sticky
146
+ // submenu policy (non-exclusive, right-start + flip chain) a previous
147
+ // openAsSubmenu installed on this panel. Clearing here - in the open
148
+ // gesture, before show() - keeps the reset out of any effect;
149
+ // openAsSubmenu re-installs the overrides right before its own show().
150
+ this.popover.setExclusiveOverride(null);
151
+ this.popover.setPlacementOverride(null);
152
+ this.popover.setPositionTryFallbacksOverride(null);
153
+ }
154
+ /** @internal Release the open claim if `owner` still holds it. */
155
+ releaseOpen(owner) {
156
+ if (this.openOwnerState() === owner) {
157
+ this.openOwnerState.set(null);
158
+ }
159
+ }
128
160
  /**
129
161
  * @internal Open this panel as a nested submenu of a parent item. Installs the
130
162
  * inline-end placement + flip chain, opens non-exclusively (the parent panel
131
163
  * survives), mirrors the parent's per-open datum, then shows. Owns the submenu
132
164
  * placement policy so `CngxContextMenuItem` drives one seam rather than
133
- * reaching into the popover's `@internal` override signals - the ejected item
165
+ * reaching into the popover's `@internal` override setters - the ejected item
134
166
  * skin stays off `CngxPopover` internals (decompose).
135
167
  */
136
- openAsSubmenu(context) {
137
- this.popover.exclusiveOverride.set(false);
138
- this.popover.placementOverride.set('right-start');
139
- this.popover.positionTryFallbacksOverride.set(CNGX_SUBMENU_TRY_FALLBACKS);
168
+ openAsSubmenu(context, parent) {
169
+ this.popover.setExclusiveOverride(false);
170
+ this.popover.setPlacementOverride('right-start');
171
+ this.popover.setPositionTryFallbacksOverride(CNGX_SUBMENU_TRY_FALLBACKS);
140
172
  this.setContext(context);
141
173
  this.popover.show();
174
+ // After show(): the link resets on every visibility edge, so it is set
175
+ // once this open has flipped the popover visible.
176
+ this.openedFrom.set(parent ?? null);
142
177
  }
143
178
  /** Keydown forwarder registered by the trigger; `null` while none is bound. */
144
179
  keydownHandler = null;
@@ -146,6 +181,21 @@ class CngxContextMenu {
146
181
  activationHandler = null;
147
182
  /** Push-only submenu-note forwarder registered by the trigger; `null` while none bound. */
148
183
  submenuNoteHandler = null;
184
+ /**
185
+ * The panel whose item opened this one as a submenu, `null` for a trigger
186
+ * open. Reset to `null` whenever this panel opens or closes, so a direct
187
+ * reopen never routes to the parent of an earlier open. Activation, keydown
188
+ * and the submenu note climb it to the root, whose trigger core resolves the
189
+ * deepest open menu itself.
190
+ */
191
+ openedFrom = linkedSignal({ ...(ngDevMode ? { debugName: "openedFrom" } : /* istanbul ignore next */ {}), source: () => this.popover.isVisible(),
192
+ computation: () => null });
193
+ /**
194
+ * Set while this panel routes an event up the parent chain. A chain that
195
+ * leads back to a panel already routing is a submenu cycle; the event stops
196
+ * there instead of recursing without end.
197
+ */
198
+ routingUp = false;
149
199
  constructor() {
150
200
  // Open moves focus into the menu container, so the container's
151
201
  // CngxActiveDescendant owns Enter/Space and a forwarded keydown reaches the
@@ -154,7 +204,15 @@ class CngxContextMenu {
154
204
  // decides, on both keyboard activation and pointer click.
155
205
  outputToObservable(this.menuHost.ad.activated)
156
206
  .pipe(takeUntilDestroyed())
157
- .subscribe(() => this.activationHandler?.());
207
+ .subscribe(() => this.handleActivated());
208
+ }
209
+ /** @internal Route an activation to the trigger, else up the parent chain. */
210
+ handleActivated() {
211
+ if (this.activationHandler) {
212
+ this.activationHandler();
213
+ return;
214
+ }
215
+ this.routeUp((parent) => parent.handleActivated?.());
158
216
  }
159
217
  /**
160
218
  * @internal Register the trigger core's keydown handler. The core owns
@@ -181,10 +239,35 @@ class CngxContextMenu {
181
239
  * ran, so the trigger's focus stack records an externally opened submenu
182
240
  * (idempotent no-op for stack-driven hover/click opens). */
183
241
  noteActiveSubmenuOpened() {
184
- this.submenuNoteHandler?.();
242
+ if (this.submenuNoteHandler) {
243
+ this.submenuNoteHandler();
244
+ return;
245
+ }
246
+ this.routeUp((parent) => parent.noteActiveSubmenuOpened?.());
247
+ }
248
+ /** @internal Route a keydown to the trigger, else up the parent chain. */
249
+ routeKeydown(event) {
250
+ if (this.keydownHandler) {
251
+ this.keydownHandler(event);
252
+ return;
253
+ }
254
+ this.routeUp((parent) => parent.routeKeydown?.(event));
255
+ }
256
+ routeUp(forward) {
257
+ const parent = this.openedFrom();
258
+ if (!parent || this.routingUp) {
259
+ return;
260
+ }
261
+ this.routingUp = true;
262
+ try {
263
+ forward(parent);
264
+ }
265
+ finally {
266
+ this.routingUp = false;
267
+ }
185
268
  }
186
269
  handleKeydown(event) {
187
- this.keydownHandler?.(event);
270
+ this.routeKeydown(event);
188
271
  }
189
272
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenu, deps: [], target: i0.ɵɵFactoryTarget.Component });
190
273
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxContextMenu, isStandalone: true, selector: "cngx-context-menu", host: { listeners: { "keydown": "handleKeydown($event)" } }, providers: [{ provide: CNGX_CONTEXT_MENU_PANEL, useExisting: CngxContextMenu }], queries: [{ propertyName: "contentTemplate", first: true, predicate: CngxContextMenuContent, descendants: true, isSignal: true }], exportAs: ["cngxContextMenu"], hostDirectives: [{ directive: i1.CngxPopover, inputs: ["offset", "offset", "closeOnEscape", "closeOnEscape"] }, { directive: i1$1.CngxMenu, inputs: ["label", "ariaLabel"] }], ngImport: i0, template: `
@@ -220,19 +303,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
220
303
  * pointer coordinates on `contextmenu` (right-click) or `Shift+F10`, feeding
221
304
  * the panel a per-open datum so one declaration serves many targets.
222
305
  *
223
- * Two ways to obtain the datum `T`:
306
+ * Three ways to obtain the datum `T`:
224
307
  * - `[cngxContextMenuData]` - a fixed datum for this single target.
225
308
  * - `[cngxContextMenuResolve]` - a resolver run against the `contextmenu`
226
309
  * event, so a container (table, grid, treetable, virtualized list) keeps a
227
310
  * single trigger instance and derives the row from `event.target`. The
228
311
  * resolver wins when both are bound. A `null` resolver result leaves the
229
312
  * native context menu untouched (no `preventDefault`, no open).
313
+ * - `[cngxContextMenuKeyboardResolve]` - the keyboard counterpart, run
314
+ * against the `Shift+F10` keydown so a delegated container derives the
315
+ * row from the focused element (`event.target`). Without it a keyboard
316
+ * open commits `[cngxContextMenuData]` (or `null` in resolver-only mode).
230
317
  *
231
318
  * A thin shell over `createContextMenuTriggerCore` (shared with
232
319
  * `CngxContextMenuTrigger`): the core owns the preventDefault decision through
233
320
  * its `resolveOpen` seam, so the veto lives in one place and this directive
234
321
  * only feeds the resolver.
235
322
  *
323
+ * Many triggers may dock the same panel. Each open claims ownership on the
324
+ * panel, so only the opening trigger reports `aria-expanded="true"`, forwards
325
+ * the panel's keydown into its core, and runs its dismiss binding - sibling
326
+ * triggers stay collapsed and inert for opens they did not perform.
327
+ *
236
328
  * ```html
237
329
  * <tr [cngxContextMenuFor]="menu" [cngxContextMenuData]="row" tabindex="0"></tr>
238
330
  * <cngx-context-menu #menu ariaLabel="Row actions">…</cngx-context-menu>
@@ -254,10 +346,33 @@ class CngxContextMenuFor {
254
346
  /**
255
347
  * Resolver run against the `contextmenu` event. Return the datum to open
256
348
  * with, or `null` to let the native menu show. Wins over `[cngxContextMenuData]`.
349
+ * Keyboard opens (`Shift+F10`) carry no pointer event - they resolve via
350
+ * `[cngxContextMenuKeyboardResolve]`, or fall back to the fixed datum.
257
351
  */
258
352
  resolve = input(undefined, { ...(ngDevMode ? { debugName: "resolve" } : /* istanbul ignore next */ {}), alias: 'cngxContextMenuResolve' });
259
- /** Mirrors the panel popover's visibility. */
260
- isOpen = computed(() => this.panel().popover.isVisible(), ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
353
+ /**
354
+ * Resolver run against the `Shift+F10` keydown. `event.target` is the
355
+ * focused element inside this trigger's host, so a delegated container
356
+ * (focusable rows, roving grid cells) derives the row for keyboard users
357
+ * exactly like `[cngxContextMenuResolve]` does for pointer users. Return
358
+ * `null` to skip the open (the browser's own Shift+F10 behaviour stays
359
+ * untouched). Wins over `[cngxContextMenuData]` for keyboard opens.
360
+ */
361
+ keyboardResolve = input(undefined, { ...(ngDevMode ? { debugName: "keyboardResolve" } : /* istanbul ignore next */ {}), alias: 'cngxContextMenuKeyboardResolve' });
362
+ /**
363
+ * `true` while the panel is visible AND this trigger performed the open.
364
+ * N triggers can dock one panel; each reports `aria-expanded` only for its
365
+ * own opens (a shared panel opened by a sibling trigger, `openAsSubmenu`,
366
+ * or a programmatic `popover.show()` leaves this trigger collapsed).
367
+ * Panels without the ownership seam fall back to plain visibility.
368
+ */
369
+ isOpen = computed(() => {
370
+ const panel = this.panel();
371
+ if (!panel.popover.isVisible()) {
372
+ return false;
373
+ }
374
+ return panel.openOwner ? panel.openOwner() === this : true;
375
+ }, ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
261
376
  core = createContextMenuTriggerCore({
262
377
  menu: () => this.panel().menuHost,
263
378
  popover: () => this.panel().popover,
@@ -277,14 +392,77 @@ class CngxContextMenuFor {
277
392
  }
278
393
  return { open: true, context: this.data() ?? null };
279
394
  },
280
- commitContext: (context) => this.panel().setContext(context),
395
+ commitContext: (context) => {
396
+ // Runs exactly once per successful open (pointer AND Shift+F10), before
397
+ // the popover shows - the claim must land here (not in an effect) so the
398
+ // handler registration belongs to the opener when N triggers share a panel.
399
+ this.claimPanel();
400
+ this.panel().setContext(context);
401
+ },
402
+ resolveKeyboardOpen: (event) => {
403
+ // Shift+F10 has no MouseEvent for the pointer resolver; the keyboard
404
+ // resolver reads the focused element instead. Without one, commit the
405
+ // fixed datum (null in resolver-only mode) rather than leaving whatever
406
+ // an earlier right-click stored on the shared panel.
407
+ const resolver = this.keyboardResolve();
408
+ if (resolver) {
409
+ const resolved = resolver(event);
410
+ return resolved === null ? { open: false } : { open: true, context: resolved };
411
+ }
412
+ return { open: true, context: this.data() ?? null };
413
+ },
281
414
  });
415
+ /** Panel-forwarded seams, stable identities so registration is idempotent. */
416
+ forwardKeydown = (event) => this.core.handleKeydown(event);
417
+ forwardActivation = () => this.core.openActiveSubmenu();
418
+ forwardSubmenuNote = () => this.core.noteActiveSubmenuOpened();
419
+ /**
420
+ * Claim the shared panel for this trigger's open: record ownership, then
421
+ * register the keydown/activation/submenu-note forwarders. Registration
422
+ * happens on open (not on construction), so the OPENING trigger owns the
423
+ * handlers instead of whichever sibling was constructed last.
424
+ */
425
+ claimPanel() {
426
+ const panel = this.panel();
427
+ panel.claimOpen?.(this);
428
+ panel.setKeydownHandler?.(this.forwardKeydown);
429
+ panel.setActivationHandler?.(this.forwardActivation);
430
+ panel.setSubmenuNoteHandler?.(this.forwardSubmenuNote);
431
+ }
432
+ /**
433
+ * Clear the panel's forwarders and release the claim - but only while this
434
+ * trigger still owns the open (or the panel has no ownership seam). A stale
435
+ * release must never clobber a sibling's newer claim.
436
+ */
437
+ releasePanel(panel) {
438
+ if (panel.openOwner && panel.openOwner() !== this) {
439
+ return;
440
+ }
441
+ panel.setKeydownHandler?.(null);
442
+ panel.setActivationHandler?.(null);
443
+ panel.setSubmenuNoteHandler?.(null);
444
+ panel.releaseOpen?.(this);
445
+ }
282
446
  constructor() {
283
447
  const destroyRef = inject(DestroyRef);
284
448
  destroyRef.onDestroy(() => this.core.destroy());
285
449
  effect(() => {
286
450
  const open = this.isOpen();
287
- untracked(() => this.core.syncOpenState(open));
451
+ untracked(() => {
452
+ if (open) {
453
+ this.core.syncOpenState(true);
454
+ return;
455
+ }
456
+ if (this.panel().popover.isVisible()) {
457
+ // Ownership handoff: a sibling trigger claimed the still-visible
458
+ // panel. Stand down without restoring focus - the new owner's menu
459
+ // holds focus and a restore would yank it away.
460
+ this.core.standDown();
461
+ }
462
+ else {
463
+ this.core.syncOpenState(false);
464
+ }
465
+ });
288
466
  });
289
467
  // Hover routing: route submenu hover-intent edges through the core's
290
468
  // focus stack, same primitives as keyboard/click (see CngxMenuTrigger).
@@ -294,29 +472,20 @@ class CngxContextMenuFor {
294
472
  rootOpen: () => this.isOpen(),
295
473
  });
296
474
  // Open moves focus into the panel (a sibling of this trigger), so submenu
297
- // ArrowRight/ArrowLeft/Escape land on the panel. Forward the panel's
298
- // keydown into the core, which owns that routing. The panel also drives the
299
- // core's activation (open a submenu parent off `ad.activated`) and the
300
- // push-only note (stack-track a hover-opened submenu) through the same
301
- // register-a-handler seam.
302
- const forwardKeydown = (event) => this.core.handleKeydown(event);
303
- const openActiveSubmenu = () => this.core.openActiveSubmenu();
304
- const noteActiveSubmenuOpened = () => this.core.noteActiveSubmenuOpened();
475
+ // ArrowRight/ArrowLeft/Escape land on the panel and are forwarded to the
476
+ // core through the handlers claimPanel() registers per open. Release the
477
+ // claim when the popover closes, so the next opener starts clean.
478
+ effect(() => {
479
+ const panel = this.panel();
480
+ if (!panel.popover.isVisible()) {
481
+ untracked(() => this.releasePanel(panel));
482
+ }
483
+ });
484
+ // Release from a swapped-out panel (rebind) and on destroy, so a replaced
485
+ // panel never keeps stale handlers pointing at this trigger's core.
305
486
  effect((onCleanup) => {
306
487
  const panel = this.panel();
307
- untracked(() => {
308
- panel.setKeydownHandler?.(forwardKeydown);
309
- panel.setActivationHandler?.(openActiveSubmenu);
310
- panel.setSubmenuNoteHandler?.(noteActiveSubmenuOpened);
311
- });
312
- // Clear the handlers on the panel this run registered - fires before the
313
- // next run (panel rebind) and on destroy, so a swapped-out panel never
314
- // keeps stale handlers pointing at this trigger's core.
315
- onCleanup(() => {
316
- panel.setKeydownHandler?.(null);
317
- panel.setActivationHandler?.(null);
318
- panel.setSubmenuNoteHandler?.(null);
319
- });
488
+ onCleanup(() => untracked(() => this.releasePanel(panel)));
320
489
  });
321
490
  }
322
491
  handleContextMenu(event) {
@@ -326,7 +495,7 @@ class CngxContextMenuFor {
326
495
  this.core.handleKeydown(event);
327
496
  }
328
497
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuFor, deps: [], target: i0.ɵɵFactoryTarget.Directive });
329
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxContextMenuFor, isStandalone: true, selector: "[cngxContextMenuFor]", inputs: { panel: { classPropertyName: "panel", publicName: "cngxContextMenuFor", isSignal: true, isRequired: true, transformFunction: null }, data: { classPropertyName: "data", publicName: "cngxContextMenuData", isSignal: true, isRequired: false, transformFunction: null }, resolve: { classPropertyName: "resolve", publicName: "cngxContextMenuResolve", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "contextmenu": "handleContextMenu($event)", "keydown": "handleKeydown($event)" }, properties: { "attr.aria-haspopup": "\"menu\"", "attr.aria-expanded": "isOpen()" } }, exportAs: ["cngxContextMenuFor"], ngImport: i0 });
498
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxContextMenuFor, isStandalone: true, selector: "[cngxContextMenuFor]", inputs: { panel: { classPropertyName: "panel", publicName: "cngxContextMenuFor", isSignal: true, isRequired: true, transformFunction: null }, data: { classPropertyName: "data", publicName: "cngxContextMenuData", isSignal: true, isRequired: false, transformFunction: null }, resolve: { classPropertyName: "resolve", publicName: "cngxContextMenuResolve", isSignal: true, isRequired: false, transformFunction: null }, keyboardResolve: { classPropertyName: "keyboardResolve", publicName: "cngxContextMenuKeyboardResolve", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "contextmenu": "handleContextMenu($event)", "keydown": "handleKeydown($event)" }, properties: { "attr.aria-haspopup": "\"menu\"", "attr.aria-expanded": "isOpen()" } }, exportAs: ["cngxContextMenuFor"], ngImport: i0 });
330
499
  }
331
500
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuFor, decorators: [{
332
501
  type: Directive,
@@ -341,7 +510,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
341
510
  '(keydown)': 'handleKeydown($event)',
342
511
  },
343
512
  }]
344
- }], ctorParameters: () => [], propDecorators: { panel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxContextMenuFor", required: true }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxContextMenuData", required: false }] }], resolve: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxContextMenuResolve", required: false }] }] } });
513
+ }], ctorParameters: () => [], propDecorators: { panel: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxContextMenuFor", required: true }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxContextMenuData", required: false }] }], resolve: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxContextMenuResolve", required: false }] }], keyboardResolve: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxContextMenuKeyboardResolve", required: false }] }] } });
345
514
 
346
515
  /**
347
516
  * Build the popover-facade adapter the submenu brain (`CngxMenuItemSubmenu`)
@@ -365,7 +534,7 @@ function createContextMenuItemSubmenuFacade(target, open) {
365
534
  isVisible: () => target()?.popover.isVisible() ?? false,
366
535
  show: () => open(),
367
536
  hide: () => target()?.popover.hide(),
368
- anchorElement: { set: (el) => target()?.popover.anchorElement.set(el) },
537
+ setAnchorElement: (el) => target()?.popover.setAnchorElement(el),
369
538
  id: () => target()?.popover.id() ?? '',
370
539
  elementRef: {
371
540
  get nativeElement() {
@@ -514,7 +683,7 @@ class CngxContextMenuItem {
514
683
  // non-exclusive open, parent-datum mirror - to the panel. The item drives
515
684
  // one seam instead of reaching into the popover's override signals, so an
516
685
  // ejected item skin never carries CngxPopover internals (decompose).
517
- target.openAsSubmenu(this.parentPanel?.context() ?? null);
686
+ target.openAsSubmenu(this.parentPanel?.context() ?? null, this.parentPanel ?? undefined);
518
687
  // openAsSubmenu is the terminal for every open path (hover, keyboard,
519
688
  // click all funnel here through the trigger's focus stack). The note is
520
689
  // the safety net for opens the stack did not perform itself
@@ -738,5 +907,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
738
907
  * Generated bundle index. Do not edit.
739
908
  */
740
909
 
741
- export { CngxContextMenu, CngxContextMenuContent, CngxContextMenuDivider, CngxContextMenuFor, CngxContextMenuItem, CngxContextMenuItemCheckbox, CngxContextMenuItemRadio };
910
+ export { CNGX_CONTEXT_MENU_PANEL, CngxContextMenu, CngxContextMenuContent, CngxContextMenuDivider, CngxContextMenuFor, CngxContextMenuItem, CngxContextMenuItemCheckbox, CngxContextMenuItemRadio };
742
911
  //# sourceMappingURL=cngx-ui-context-menu.mjs.map