@cngx/ui 0.1.0-rc.6 → 0.1.0-rc.8
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/README.md +112 -1
- package/a11y/README.md +87 -0
- package/accordion/README.md +4 -2
- package/breadcrumb/README.md +262 -0
- package/collection/README.md +6 -0
- package/command-palette/README.md +224 -0
- package/context-menu/README.md +98 -0
- package/data-grid-accordion/README.md +103 -2
- package/feedback/README.md +42 -0
- package/fesm2022/cngx-ui-a11y.mjs +452 -0
- package/fesm2022/cngx-ui-a11y.mjs.map +1 -0
- package/fesm2022/cngx-ui-accordion.mjs +116 -38
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +115 -50
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +181 -96
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-chart-panel.mjs +586 -0
- package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -0
- package/fesm2022/cngx-ui-collection.mjs +207 -66
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +1281 -0
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -0
- package/fesm2022/cngx-ui-context-menu.mjs +857 -0
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -0
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +498 -111
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-empty-state.mjs +16 -6
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +1095 -521
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-layout.mjs +18 -9
- package/fesm2022/cngx-ui-layout.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +84 -16
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
- package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +370 -203
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-overlay.mjs +69 -13
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +501 -182
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +327 -106
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +22 -21
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +107 -8
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stat-card.mjs +718 -0
- package/fesm2022/cngx-ui-stat-card.mjs.map +1 -0
- package/fesm2022/cngx-ui-stepper.mjs +217 -76
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +40 -19
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +548 -0
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -0
- package/fesm2022/cngx-ui-toc.mjs +748 -0
- package/fesm2022/cngx-ui-toc.mjs.map +1 -0
- package/fesm2022/cngx-ui.mjs +16 -21
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/mat-accordion/README.md +1 -1
- package/mat-paginator/README.md +9 -2
- package/mat-tabs/styles/mat-tabs.css +29 -27
- package/overlay/README.md +9 -4
- package/package.json +32 -1
- package/paginator/README.md +8 -4
- package/sidenav/README.md +33 -11
- package/skeleton/README.md +2 -0
- package/speak/README.md +3 -2
- package/stepper/README.md +15 -3
- package/timeline/README.md +350 -0
- package/toc/README.md +186 -0
- package/types/cngx-ui-a11y.d.ts +394 -0
- package/types/cngx-ui-accordion.d.ts +100 -30
- package/types/cngx-ui-action-button.d.ts +47 -3
- package/types/cngx-ui-breadcrumb.d.ts +159 -58
- package/types/cngx-ui-chart-panel.d.ts +382 -0
- package/types/cngx-ui-collection.d.ts +159 -58
- package/types/cngx-ui-command-palette.d.ts +565 -0
- package/types/cngx-ui-context-menu.d.ts +559 -0
- package/types/cngx-ui-data-grid-accordion.d.ts +344 -51
- package/types/cngx-ui-empty-state.d.ts +9 -2
- package/types/cngx-ui-feedback.d.ts +664 -73
- package/types/cngx-ui-layout.d.ts +8 -3
- package/types/cngx-ui-mat-accordion.d.ts +32 -4
- package/types/cngx-ui-mat-paginator.d.ts +37 -8
- package/types/cngx-ui-mat-stepper.d.ts +23 -11
- package/types/cngx-ui-mat-tabs.d.ts +218 -23
- package/types/cngx-ui-overlay.d.ts +56 -10
- package/types/cngx-ui-paginator.d.ts +416 -132
- package/types/cngx-ui-sidenav.d.ts +248 -74
- package/types/cngx-ui-skeleton.d.ts +18 -7
- package/types/cngx-ui-speak.d.ts +118 -5
- package/types/cngx-ui-stat-card.d.ts +411 -0
- package/types/cngx-ui-stepper.d.ts +81 -29
- package/types/cngx-ui-tabs.d.ts +22 -6
- package/types/cngx-ui-timeline.d.ts +495 -0
- package/types/cngx-ui-toc.d.ts +581 -0
- package/types/cngx-ui.d.ts +8 -5
|
@@ -0,0 +1,857 @@
|
|
|
1
|
+
import { NgTemplateOutlet, DOCUMENT } from '@angular/common';
|
|
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';
|
|
4
|
+
import { outputToObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
+
import * as i1$1 from '@cngx/common/interactive';
|
|
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';
|
|
7
|
+
import * as i1 from '@cngx/common/popover';
|
|
8
|
+
import { CngxPopover } from '@cngx/common/popover';
|
|
9
|
+
import { injectDirection } from '@cngx/core';
|
|
10
|
+
import { CngxActiveDescendant } from '@cngx/common/a11y';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Lazy content slot for {@link CngxContextMenu}. The template renders only
|
|
14
|
+
* while the menu is open and receives the trigger's per-open datum as
|
|
15
|
+
* `$implicit`, so one panel declaration serves every target of a delegated
|
|
16
|
+
* trigger with row-correct content.
|
|
17
|
+
*
|
|
18
|
+
* ```html
|
|
19
|
+
* <cngx-context-menu #menu ariaLabel="Row actions">
|
|
20
|
+
* <ng-template cngxContextMenuContent let-row>
|
|
21
|
+
* <cngx-context-menu-item (select)="edit(row)">Edit {{ row.name }}</cngx-context-menu-item>
|
|
22
|
+
* </ng-template>
|
|
23
|
+
* </cngx-context-menu>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/grid/delegated-resolver</example-url>
|
|
27
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/table/row-context-data</example-url>
|
|
28
|
+
* @category ui/context-menu
|
|
29
|
+
* @wcag AA
|
|
30
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-content.directive.ts
|
|
31
|
+
* @since 0.1.0
|
|
32
|
+
* @relatedTo CngxContextMenu, CngxContextMenuFor
|
|
33
|
+
*/
|
|
34
|
+
class CngxContextMenuContent {
|
|
35
|
+
/** The projected `<ng-template>`, rendered by the panel while open. */
|
|
36
|
+
templateRef = inject(TemplateRef);
|
|
37
|
+
/** Narrows `let-` bindings to {@link CngxContextMenuContentContext} under strict templates. */
|
|
38
|
+
static ngTemplateContextGuard(_dir, _ctx) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuContent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
42
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxContextMenuContent, isStandalone: true, selector: "ng-template[cngxContextMenuContent]", exportAs: ["cngxContextMenuContent"], ngImport: i0 });
|
|
43
|
+
}
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuContent, decorators: [{
|
|
45
|
+
type: Directive,
|
|
46
|
+
args: [{
|
|
47
|
+
selector: 'ng-template[cngxContextMenuContent]',
|
|
48
|
+
exportAs: 'cngxContextMenuContent',
|
|
49
|
+
standalone: true,
|
|
50
|
+
}]
|
|
51
|
+
}] });
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @internal DI token the panel provides via `useExisting` so a projected
|
|
55
|
+
* `CngxContextMenuItem` can read its enclosing panel's `context()` and mirror
|
|
56
|
+
* it into a sibling-declared submenu. Not part of the public API - the child
|
|
57
|
+
* talks to the panel through this structural seam rather than injecting the
|
|
58
|
+
* concrete `CngxContextMenu` class (`CNGX_MENU_HOST` precedent).
|
|
59
|
+
*/
|
|
60
|
+
const CNGX_CONTEXT_MENU_PANEL = new InjectionToken('CNGX_CONTEXT_MENU_PANEL');
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Declarative context-menu panel. Stacks `CngxPopover` (the top-layer popup
|
|
64
|
+
* surface) and `CngxMenu` (the `role="menu"` keyboard + ARIA brain) as host
|
|
65
|
+
* directives on its own element, so projected items and the lazy content
|
|
66
|
+
* template resolve `CngxActiveDescendant` / `CNGX_MENU_HOST` against the panel
|
|
67
|
+
* host's injector chain. Pair it with `[cngxContextMenuFor]` on a target.
|
|
68
|
+
*
|
|
69
|
+
* The brains live on the host - not inside an inner `[cngxMenu]` element -
|
|
70
|
+
* because Angular resolves DI for projected and template content at the
|
|
71
|
+
* declaration site, not the projection site; an inner menu directive would
|
|
72
|
+
* be invisible to items rendered through `<ng-content>` or the content slot.
|
|
73
|
+
* Construction mirrors `CngxPopoverPanel`.
|
|
74
|
+
*
|
|
75
|
+
* `context()` is derived, never synced: it reads the trigger's per-open datum
|
|
76
|
+
* while the popover is visible and `null` once it closes - no manual reset on
|
|
77
|
+
* dismiss (Pillar 1).
|
|
78
|
+
*
|
|
79
|
+
* ### Static menu
|
|
80
|
+
* ```html
|
|
81
|
+
* <div [cngxContextMenuFor]="menu">Right-click me</div>
|
|
82
|
+
* <cngx-context-menu #menu ariaLabel="Actions">
|
|
83
|
+
* <cngx-context-menu-item (select)="copy()">Copy</cngx-context-menu-item>
|
|
84
|
+
* <cngx-context-menu-item (select)="paste()">Paste</cngx-context-menu-item>
|
|
85
|
+
* </cngx-context-menu>
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* ### Per-row content
|
|
89
|
+
* ```html
|
|
90
|
+
* <cngx-context-menu #menu ariaLabel="Row actions">
|
|
91
|
+
* <ng-template cngxContextMenuContent let-row>
|
|
92
|
+
* <cngx-context-menu-item (select)="edit(row)">Edit {{ row.name }}</cngx-context-menu-item>
|
|
93
|
+
* </ng-template>
|
|
94
|
+
* </cngx-context-menu>
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/basic/static-items</example-url>
|
|
98
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/grid/delegated-resolver</example-url>
|
|
99
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/submenu/nested-export-menu</example-url>
|
|
100
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/selection/checkbox-radio-items</example-url>
|
|
101
|
+
* @category ui/context-menu
|
|
102
|
+
* @docsKind primary
|
|
103
|
+
* @wcag AA
|
|
104
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu.component.ts
|
|
105
|
+
* @since 0.1.0
|
|
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).
|
|
108
|
+
*/
|
|
109
|
+
class CngxContextMenu {
|
|
110
|
+
/** The popover surface this panel drives. Consumed by the trigger core. */
|
|
111
|
+
popover = inject(CngxPopover, { self: true });
|
|
112
|
+
/** The menu brain (`role="menu"`, active-descendant registry). */
|
|
113
|
+
menuHost = inject(CngxMenu, { self: true });
|
|
114
|
+
/** Per-open datum set by the trigger before `show()`. */
|
|
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();
|
|
126
|
+
/**
|
|
127
|
+
* The datum the menu opened over while visible, `null` once closed. Gated on
|
|
128
|
+
* `popover.isVisible()` so the reset on dismiss is derived, not synced.
|
|
129
|
+
*/
|
|
130
|
+
context = computed(() => (this.popover.isVisible() ? this.datum() : null), ...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
|
|
131
|
+
contentTemplate = contentChild(CngxContextMenuContent, ...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
|
|
132
|
+
/**
|
|
133
|
+
* @internal Store the per-open datum. Called by `CngxContextMenuFor` in the
|
|
134
|
+
* `contextmenu` event path, before the popover opens.
|
|
135
|
+
*/
|
|
136
|
+
setContext(value) {
|
|
137
|
+
this.datum.set(value);
|
|
138
|
+
}
|
|
139
|
+
/** @internal Claim the current open for `owner`. See {@link CngxContextMenuPanel.claimOpen}. */
|
|
140
|
+
claimOpen(owner) {
|
|
141
|
+
this.openOwnerState.set(owner);
|
|
142
|
+
// A trigger claim is always a ROOT open: it must not inherit the sticky
|
|
143
|
+
// submenu policy (non-exclusive, right-start + flip chain) a previous
|
|
144
|
+
// openAsSubmenu installed on this panel. Clearing here - in the open
|
|
145
|
+
// gesture, before show() - keeps the reset out of any effect;
|
|
146
|
+
// openAsSubmenu re-installs the overrides right before its own show().
|
|
147
|
+
this.popover.setExclusiveOverride(null);
|
|
148
|
+
this.popover.setPlacementOverride(null);
|
|
149
|
+
this.popover.setPositionTryFallbacksOverride(null);
|
|
150
|
+
}
|
|
151
|
+
/** @internal Release the open claim if `owner` still holds it. */
|
|
152
|
+
releaseOpen(owner) {
|
|
153
|
+
if (this.openOwnerState() === owner) {
|
|
154
|
+
this.openOwnerState.set(null);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @internal Open this panel as a nested submenu of a parent item. Installs the
|
|
159
|
+
* inline-end placement + flip chain, opens non-exclusively (the parent panel
|
|
160
|
+
* survives), mirrors the parent's per-open datum, then shows. Owns the submenu
|
|
161
|
+
* placement policy so `CngxContextMenuItem` drives one seam rather than
|
|
162
|
+
* reaching into the popover's `@internal` override setters - the ejected item
|
|
163
|
+
* skin stays off `CngxPopover` internals (decompose).
|
|
164
|
+
*/
|
|
165
|
+
openAsSubmenu(context) {
|
|
166
|
+
this.popover.setExclusiveOverride(false);
|
|
167
|
+
this.popover.setPlacementOverride('right-start');
|
|
168
|
+
this.popover.setPositionTryFallbacksOverride(CNGX_SUBMENU_TRY_FALLBACKS);
|
|
169
|
+
this.setContext(context);
|
|
170
|
+
this.popover.show();
|
|
171
|
+
}
|
|
172
|
+
/** Keydown forwarder registered by the trigger; `null` while none is bound. */
|
|
173
|
+
keydownHandler = null;
|
|
174
|
+
/** Activation forwarder registered by the trigger; `null` while none bound. */
|
|
175
|
+
activationHandler = null;
|
|
176
|
+
/** Push-only submenu-note forwarder registered by the trigger; `null` while none bound. */
|
|
177
|
+
submenuNoteHandler = null;
|
|
178
|
+
constructor() {
|
|
179
|
+
// Open moves focus into the menu container, so the container's
|
|
180
|
+
// CngxActiveDescendant owns Enter/Space and a forwarded keydown reaches the
|
|
181
|
+
// trigger core too late to open a submenu parent. Drive the open off the
|
|
182
|
+
// deterministic `activated` event instead - it fires once, after the AD
|
|
183
|
+
// decides, on both keyboard activation and pointer click.
|
|
184
|
+
outputToObservable(this.menuHost.ad.activated)
|
|
185
|
+
.pipe(takeUntilDestroyed())
|
|
186
|
+
.subscribe(() => this.activationHandler?.());
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @internal Register the trigger core's keydown handler. The core owns
|
|
190
|
+
* submenu ArrowRight/ArrowLeft/Escape routing, but open moves focus into
|
|
191
|
+
* this panel, so keydown lands here rather than on the trigger host.
|
|
192
|
+
*/
|
|
193
|
+
setKeydownHandler(handler) {
|
|
194
|
+
this.keydownHandler = handler;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* @internal Register the trigger core's activation handler, invoked on every
|
|
198
|
+
* `CngxActiveDescendant.activated` (keyboard activation + pointer click) so a
|
|
199
|
+
* submenu parent opens deterministically off the event rather than a racing
|
|
200
|
+
* keydown.
|
|
201
|
+
*/
|
|
202
|
+
setActivationHandler(handler) {
|
|
203
|
+
this.activationHandler = handler;
|
|
204
|
+
}
|
|
205
|
+
/** @internal Register the trigger core's push-only submenu-note handler. */
|
|
206
|
+
setSubmenuNoteHandler(handler) {
|
|
207
|
+
this.submenuNoteHandler = handler;
|
|
208
|
+
}
|
|
209
|
+
/** @internal A projected item calls this after its openAsSubmenu terminal
|
|
210
|
+
* ran, so the trigger's focus stack records an externally opened submenu
|
|
211
|
+
* (idempotent no-op for stack-driven hover/click opens). */
|
|
212
|
+
noteActiveSubmenuOpened() {
|
|
213
|
+
this.submenuNoteHandler?.();
|
|
214
|
+
}
|
|
215
|
+
handleKeydown(event) {
|
|
216
|
+
this.keydownHandler?.(event);
|
|
217
|
+
}
|
|
218
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenu, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
219
|
+
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
|
+
@if (contentTemplate(); as content) {
|
|
221
|
+
@if (popover.isVisible()) {
|
|
222
|
+
<ng-container *ngTemplateOutlet="content.templateRef; context: { $implicit: context() }" />
|
|
223
|
+
}
|
|
224
|
+
} @else {
|
|
225
|
+
<ng-content />
|
|
226
|
+
}
|
|
227
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-context-menu-surface{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-context-menu-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.2 .01 250);}@property --cngx-context-menu-border{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(.88 .005 250);}@property --cngx-context-menu-radius{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-context-menu-shadow{syntax: \"*\"; inherits: true; initial-value: 0 4px 16px oklch(0 0 0 / .12);}@property --cngx-context-menu-padding{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-context-menu-separator-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.88 .005 250);}@property --cngx-context-menu-separator-inset{syntax: \"<length>\"; inherits: false; initial-value: 4px;}:root{--cngx-context-menu-surface: var(--cngx-color-surface, oklch(1 0 0));--cngx-context-menu-color: var(--cngx-color-text, oklch(.2 .01 250));--cngx-context-menu-border: 1px solid var(--cngx-color-border, oklch(.88 .005 250));--cngx-context-menu-shadow: var(--cngx-shadow-md, 0 4px 16px oklch(0 0 0 / .12));--cngx-context-menu-separator-color: var(--cngx-color-border, oklch(.88 .005 250))}}@layer cngx.components{cngx-context-menu{--cngx-context-menu-padding: var(--cngx-space-xs);--cngx-context-menu-separator-inset: var(--cngx-space-xs);box-sizing:border-box;position:fixed;inset:unset;min-inline-size:max-content;background:var(--cngx-context-menu-surface, var(--cngx-color-surface, oklch(1 0 0)));color:var(--cngx-context-menu-color, var(--cngx-color-text, oklch(.2 .01 250)));border:var(--cngx-context-menu-border, 1px solid oklch(.88 .005 250));border-radius:var(--cngx-context-menu-radius, 8px);box-shadow:var(--cngx-context-menu-shadow, 0 4px 16px oklch(0 0 0 / .12));padding:var(--cngx-context-menu-padding, 4px);outline:none;transition:opacity var(--cngx-duration-base, .2s) var(--cngx-easing-standard, cubic-bezier(.4, 0, .2, 1)),transform var(--cngx-duration-base, .2s) var(--cngx-easing-standard, cubic-bezier(.4, 0, .2, 1))}cngx-context-menu:popover-open{display:flex;flex-direction:column}cngx-context-menu.cngx-popover--opening,cngx-context-menu.cngx-popover--closing{opacity:0;transform:translateY(4px) scale(.98)}cngx-context-menu.cngx-popover--open{opacity:1;transform:translateY(0) scale(1)}@media(prefers-reduced-motion:reduce){cngx-context-menu{transition:none}}cngx-context-menu:focus-visible{outline:2px solid var(--cngx-color-primary, oklch(.66 .19 50));outline-offset:-2px}cngx-context-menu-divider,hr[cngxContextMenuDivider]{display:block;block-size:1px;border:0;margin-block:var(--cngx-context-menu-separator-inset, 4px);margin-inline:var(--cngx-space-sm, 8px);background:var(--cngx-context-menu-separator-color, var(--cngx-color-border, oklch(.88 .005 250)))}}@media(forced-colors:active){cngx-context-menu-divider,hr[cngxContextMenuDivider]{background:CanvasText}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
228
|
+
}
|
|
229
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenu, decorators: [{
|
|
230
|
+
type: Component,
|
|
231
|
+
args: [{ selector: 'cngx-context-menu', standalone: true, imports: [NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cngxContextMenu', providers: [{ provide: CNGX_CONTEXT_MENU_PANEL, useExisting: CngxContextMenu }], host: {
|
|
232
|
+
'(keydown)': 'handleKeydown($event)',
|
|
233
|
+
}, hostDirectives: [
|
|
234
|
+
{ directive: CngxPopover, inputs: ['offset', 'closeOnEscape'] },
|
|
235
|
+
{ directive: CngxMenu, inputs: ['label: ariaLabel'] },
|
|
236
|
+
], template: `
|
|
237
|
+
@if (contentTemplate(); as content) {
|
|
238
|
+
@if (popover.isVisible()) {
|
|
239
|
+
<ng-container *ngTemplateOutlet="content.templateRef; context: { $implicit: context() }" />
|
|
240
|
+
}
|
|
241
|
+
} @else {
|
|
242
|
+
<ng-content />
|
|
243
|
+
}
|
|
244
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-context-menu-surface{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-context-menu-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.2 .01 250);}@property --cngx-context-menu-border{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(.88 .005 250);}@property --cngx-context-menu-radius{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-context-menu-shadow{syntax: \"*\"; inherits: true; initial-value: 0 4px 16px oklch(0 0 0 / .12);}@property --cngx-context-menu-padding{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-context-menu-separator-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.88 .005 250);}@property --cngx-context-menu-separator-inset{syntax: \"<length>\"; inherits: false; initial-value: 4px;}:root{--cngx-context-menu-surface: var(--cngx-color-surface, oklch(1 0 0));--cngx-context-menu-color: var(--cngx-color-text, oklch(.2 .01 250));--cngx-context-menu-border: 1px solid var(--cngx-color-border, oklch(.88 .005 250));--cngx-context-menu-shadow: var(--cngx-shadow-md, 0 4px 16px oklch(0 0 0 / .12));--cngx-context-menu-separator-color: var(--cngx-color-border, oklch(.88 .005 250))}}@layer cngx.components{cngx-context-menu{--cngx-context-menu-padding: var(--cngx-space-xs);--cngx-context-menu-separator-inset: var(--cngx-space-xs);box-sizing:border-box;position:fixed;inset:unset;min-inline-size:max-content;background:var(--cngx-context-menu-surface, var(--cngx-color-surface, oklch(1 0 0)));color:var(--cngx-context-menu-color, var(--cngx-color-text, oklch(.2 .01 250)));border:var(--cngx-context-menu-border, 1px solid oklch(.88 .005 250));border-radius:var(--cngx-context-menu-radius, 8px);box-shadow:var(--cngx-context-menu-shadow, 0 4px 16px oklch(0 0 0 / .12));padding:var(--cngx-context-menu-padding, 4px);outline:none;transition:opacity var(--cngx-duration-base, .2s) var(--cngx-easing-standard, cubic-bezier(.4, 0, .2, 1)),transform var(--cngx-duration-base, .2s) var(--cngx-easing-standard, cubic-bezier(.4, 0, .2, 1))}cngx-context-menu:popover-open{display:flex;flex-direction:column}cngx-context-menu.cngx-popover--opening,cngx-context-menu.cngx-popover--closing{opacity:0;transform:translateY(4px) scale(.98)}cngx-context-menu.cngx-popover--open{opacity:1;transform:translateY(0) scale(1)}@media(prefers-reduced-motion:reduce){cngx-context-menu{transition:none}}cngx-context-menu:focus-visible{outline:2px solid var(--cngx-color-primary, oklch(.66 .19 50));outline-offset:-2px}cngx-context-menu-divider,hr[cngxContextMenuDivider]{display:block;block-size:1px;border:0;margin-block:var(--cngx-context-menu-separator-inset, 4px);margin-inline:var(--cngx-space-sm, 8px);background:var(--cngx-context-menu-separator-color, var(--cngx-color-border, oklch(.88 .005 250)))}}@media(forced-colors:active){cngx-context-menu-divider,hr[cngxContextMenuDivider]{background:CanvasText}}\n"] }]
|
|
245
|
+
}], ctorParameters: () => [], propDecorators: { contentTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxContextMenuContent), { isSignal: true }] }] } });
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Docks a {@link CngxContextMenu} onto a target element. Opens the panel at
|
|
249
|
+
* pointer coordinates on `contextmenu` (right-click) or `Shift+F10`, feeding
|
|
250
|
+
* the panel a per-open datum so one declaration serves many targets.
|
|
251
|
+
*
|
|
252
|
+
* Three ways to obtain the datum `T`:
|
|
253
|
+
* - `[cngxContextMenuData]` - a fixed datum for this single target.
|
|
254
|
+
* - `[cngxContextMenuResolve]` - a resolver run against the `contextmenu`
|
|
255
|
+
* event, so a container (table, grid, treetable, virtualized list) keeps a
|
|
256
|
+
* single trigger instance and derives the row from `event.target`. The
|
|
257
|
+
* resolver wins when both are bound. A `null` resolver result leaves the
|
|
258
|
+
* native context menu untouched (no `preventDefault`, no open).
|
|
259
|
+
* - `[cngxContextMenuKeyboardResolve]` - the keyboard counterpart, run
|
|
260
|
+
* against the `Shift+F10` keydown so a delegated container derives the
|
|
261
|
+
* row from the focused element (`event.target`). Without it a keyboard
|
|
262
|
+
* open commits `[cngxContextMenuData]` (or `null` in resolver-only mode).
|
|
263
|
+
*
|
|
264
|
+
* A thin shell over `createContextMenuTriggerCore` (shared with
|
|
265
|
+
* `CngxContextMenuTrigger`): the core owns the preventDefault decision through
|
|
266
|
+
* its `resolveOpen` seam, so the veto lives in one place and this directive
|
|
267
|
+
* only feeds the resolver.
|
|
268
|
+
*
|
|
269
|
+
* Many triggers may dock the same panel. Each open claims ownership on the
|
|
270
|
+
* panel, so only the opening trigger reports `aria-expanded="true"`, forwards
|
|
271
|
+
* the panel's keydown into its core, and runs its dismiss binding - sibling
|
|
272
|
+
* triggers stay collapsed and inert for opens they did not perform.
|
|
273
|
+
*
|
|
274
|
+
* ```html
|
|
275
|
+
* <tr [cngxContextMenuFor]="menu" [cngxContextMenuData]="row" tabindex="0"></tr>
|
|
276
|
+
* <cngx-context-menu #menu ariaLabel="Row actions">…</cngx-context-menu>
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/grid/delegated-resolver</example-url>
|
|
280
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/basic/static-items</example-url>
|
|
281
|
+
* @category ui/context-menu
|
|
282
|
+
* @wcag AA
|
|
283
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-for.directive.ts
|
|
284
|
+
* @since 0.1.0
|
|
285
|
+
* @relatedTo CngxContextMenu, CngxContextMenuItem, CngxContextMenuTrigger
|
|
286
|
+
*/
|
|
287
|
+
class CngxContextMenuFor {
|
|
288
|
+
/** Panel this trigger opens. Typed to the {@link CngxContextMenuPanel} seam. */
|
|
289
|
+
panel = input.required({ ...(ngDevMode ? { debugName: "panel" } : /* istanbul ignore next */ {}), alias: 'cngxContextMenuFor' });
|
|
290
|
+
/** Fixed datum handed to the panel for this single target. */
|
|
291
|
+
data = input(undefined, { ...(ngDevMode ? { debugName: "data" } : /* istanbul ignore next */ {}), alias: 'cngxContextMenuData' });
|
|
292
|
+
/**
|
|
293
|
+
* Resolver run against the `contextmenu` event. Return the datum to open
|
|
294
|
+
* with, or `null` to let the native menu show. Wins over `[cngxContextMenuData]`.
|
|
295
|
+
* Keyboard opens (`Shift+F10`) carry no pointer event - they resolve via
|
|
296
|
+
* `[cngxContextMenuKeyboardResolve]`, or fall back to the fixed datum.
|
|
297
|
+
*/
|
|
298
|
+
resolve = input(undefined, { ...(ngDevMode ? { debugName: "resolve" } : /* istanbul ignore next */ {}), alias: 'cngxContextMenuResolve' });
|
|
299
|
+
/**
|
|
300
|
+
* Resolver run against the `Shift+F10` keydown. `event.target` is the
|
|
301
|
+
* focused element inside this trigger's host, so a delegated container
|
|
302
|
+
* (focusable rows, roving grid cells) derives the row for keyboard users
|
|
303
|
+
* exactly like `[cngxContextMenuResolve]` does for pointer users. Return
|
|
304
|
+
* `null` to skip the open (the browser's own Shift+F10 behaviour stays
|
|
305
|
+
* untouched). Wins over `[cngxContextMenuData]` for keyboard opens.
|
|
306
|
+
*/
|
|
307
|
+
keyboardResolve = input(undefined, { ...(ngDevMode ? { debugName: "keyboardResolve" } : /* istanbul ignore next */ {}), alias: 'cngxContextMenuKeyboardResolve' });
|
|
308
|
+
/**
|
|
309
|
+
* `true` while the panel is visible AND this trigger performed the open.
|
|
310
|
+
* N triggers can dock one panel; each reports `aria-expanded` only for its
|
|
311
|
+
* own opens (a shared panel opened by a sibling trigger, `openAsSubmenu`,
|
|
312
|
+
* or a programmatic `popover.show()` leaves this trigger collapsed).
|
|
313
|
+
* Panels without the ownership seam fall back to plain visibility.
|
|
314
|
+
*/
|
|
315
|
+
isOpen = computed(() => {
|
|
316
|
+
const panel = this.panel();
|
|
317
|
+
if (!panel.popover.isVisible()) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
return panel.openOwner ? panel.openOwner() === this : true;
|
|
321
|
+
}, ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
322
|
+
core = createContextMenuTriggerCore({
|
|
323
|
+
menu: () => this.panel().menuHost,
|
|
324
|
+
popover: () => this.panel().popover,
|
|
325
|
+
hostElement: inject(ElementRef).nativeElement,
|
|
326
|
+
document: inject(DOCUMENT),
|
|
327
|
+
menuConfig: injectMenuConfig(),
|
|
328
|
+
dismissFactory: inject(CNGX_MENU_DISMISS_HANDLER_FACTORY),
|
|
329
|
+
announcer: inject(CNGX_MENU_ANNOUNCER_FACTORY)(),
|
|
330
|
+
nav: inject(CNGX_MENU_NAV_STRATEGY),
|
|
331
|
+
direction: injectDirection(),
|
|
332
|
+
focusStackFactory: inject(CNGX_MENU_FOCUS_STACK_FACTORY),
|
|
333
|
+
resolveOpen: (event) => {
|
|
334
|
+
const resolver = this.resolve();
|
|
335
|
+
if (resolver) {
|
|
336
|
+
const resolved = resolver(event);
|
|
337
|
+
return resolved === null ? { open: false } : { open: true, context: resolved };
|
|
338
|
+
}
|
|
339
|
+
return { open: true, context: this.data() ?? null };
|
|
340
|
+
},
|
|
341
|
+
commitContext: (context) => {
|
|
342
|
+
// Runs exactly once per successful open (pointer AND Shift+F10), before
|
|
343
|
+
// the popover shows - the claim must land here (not in an effect) so the
|
|
344
|
+
// handler registration belongs to the opener when N triggers share a panel.
|
|
345
|
+
this.claimPanel();
|
|
346
|
+
this.panel().setContext(context);
|
|
347
|
+
},
|
|
348
|
+
resolveKeyboardOpen: (event) => {
|
|
349
|
+
// Shift+F10 has no MouseEvent for the pointer resolver; the keyboard
|
|
350
|
+
// resolver reads the focused element instead. Without one, commit the
|
|
351
|
+
// fixed datum (null in resolver-only mode) rather than leaving whatever
|
|
352
|
+
// an earlier right-click stored on the shared panel.
|
|
353
|
+
const resolver = this.keyboardResolve();
|
|
354
|
+
if (resolver) {
|
|
355
|
+
const resolved = resolver(event);
|
|
356
|
+
return resolved === null ? { open: false } : { open: true, context: resolved };
|
|
357
|
+
}
|
|
358
|
+
return { open: true, context: this.data() ?? null };
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
/** Panel-forwarded seams, stable identities so registration is idempotent. */
|
|
362
|
+
forwardKeydown = (event) => this.core.handleKeydown(event);
|
|
363
|
+
forwardActivation = () => this.core.openActiveSubmenu();
|
|
364
|
+
forwardSubmenuNote = () => this.core.noteActiveSubmenuOpened();
|
|
365
|
+
/**
|
|
366
|
+
* Claim the shared panel for this trigger's open: record ownership, then
|
|
367
|
+
* register the keydown/activation/submenu-note forwarders. Registration
|
|
368
|
+
* happens on open (not on construction), so the OPENING trigger owns the
|
|
369
|
+
* handlers instead of whichever sibling was constructed last.
|
|
370
|
+
*/
|
|
371
|
+
claimPanel() {
|
|
372
|
+
const panel = this.panel();
|
|
373
|
+
panel.claimOpen?.(this);
|
|
374
|
+
panel.setKeydownHandler?.(this.forwardKeydown);
|
|
375
|
+
panel.setActivationHandler?.(this.forwardActivation);
|
|
376
|
+
panel.setSubmenuNoteHandler?.(this.forwardSubmenuNote);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Clear the panel's forwarders and release the claim - but only while this
|
|
380
|
+
* trigger still owns the open (or the panel has no ownership seam). A stale
|
|
381
|
+
* release must never clobber a sibling's newer claim.
|
|
382
|
+
*/
|
|
383
|
+
releasePanel(panel) {
|
|
384
|
+
if (panel.openOwner && panel.openOwner() !== this) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
panel.setKeydownHandler?.(null);
|
|
388
|
+
panel.setActivationHandler?.(null);
|
|
389
|
+
panel.setSubmenuNoteHandler?.(null);
|
|
390
|
+
panel.releaseOpen?.(this);
|
|
391
|
+
}
|
|
392
|
+
constructor() {
|
|
393
|
+
const destroyRef = inject(DestroyRef);
|
|
394
|
+
destroyRef.onDestroy(() => this.core.destroy());
|
|
395
|
+
effect(() => {
|
|
396
|
+
const open = this.isOpen();
|
|
397
|
+
untracked(() => {
|
|
398
|
+
if (open) {
|
|
399
|
+
this.core.syncOpenState(true);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (this.panel().popover.isVisible()) {
|
|
403
|
+
// Ownership handoff: a sibling trigger claimed the still-visible
|
|
404
|
+
// panel. Stand down without restoring focus - the new owner's menu
|
|
405
|
+
// holds focus and a restore would yank it away.
|
|
406
|
+
this.core.standDown();
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
this.core.syncOpenState(false);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
// Hover routing: route submenu hover-intent edges through the core's
|
|
414
|
+
// focus stack, same primitives as keyboard/click (see CngxMenuTrigger).
|
|
415
|
+
connectSubmenuHoverToFocusStack({
|
|
416
|
+
focusStack: this.core.focusStack,
|
|
417
|
+
rootMenu: () => this.panel().menuHost,
|
|
418
|
+
rootOpen: () => this.isOpen(),
|
|
419
|
+
});
|
|
420
|
+
// Open moves focus into the panel (a sibling of this trigger), so submenu
|
|
421
|
+
// ArrowRight/ArrowLeft/Escape land on the panel and are forwarded to the
|
|
422
|
+
// core through the handlers claimPanel() registers per open. Release the
|
|
423
|
+
// claim when the popover closes, so the next opener starts clean.
|
|
424
|
+
effect(() => {
|
|
425
|
+
const panel = this.panel();
|
|
426
|
+
if (!panel.popover.isVisible()) {
|
|
427
|
+
untracked(() => this.releasePanel(panel));
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
// Release from a swapped-out panel (rebind) and on destroy, so a replaced
|
|
431
|
+
// panel never keeps stale handlers pointing at this trigger's core.
|
|
432
|
+
effect((onCleanup) => {
|
|
433
|
+
const panel = this.panel();
|
|
434
|
+
onCleanup(() => untracked(() => this.releasePanel(panel)));
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
handleContextMenu(event) {
|
|
438
|
+
this.core.handleContextMenu(event);
|
|
439
|
+
}
|
|
440
|
+
handleKeydown(event) {
|
|
441
|
+
this.core.handleKeydown(event);
|
|
442
|
+
}
|
|
443
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuFor, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
444
|
+
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 });
|
|
445
|
+
}
|
|
446
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuFor, decorators: [{
|
|
447
|
+
type: Directive,
|
|
448
|
+
args: [{
|
|
449
|
+
selector: '[cngxContextMenuFor]',
|
|
450
|
+
exportAs: 'cngxContextMenuFor',
|
|
451
|
+
standalone: true,
|
|
452
|
+
host: {
|
|
453
|
+
'[attr.aria-haspopup]': '"menu"',
|
|
454
|
+
'[attr.aria-expanded]': 'isOpen()',
|
|
455
|
+
'(contextmenu)': 'handleContextMenu($event)',
|
|
456
|
+
'(keydown)': 'handleKeydown($event)',
|
|
457
|
+
},
|
|
458
|
+
}]
|
|
459
|
+
}], 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 }] }] } });
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Build the popover-facade adapter the submenu brain (`CngxMenuItemSubmenu`)
|
|
463
|
+
* drives instead of a `[cngxMenuItemSubmenu]` popover input. Every member
|
|
464
|
+
* delegates to the target panel's own `CngxPopover`, reading `target()` lazily
|
|
465
|
+
* so the facade stays valid across `[submenu]` changes and inert (no visible,
|
|
466
|
+
* empty id) while the target is unbound. `show()` delegates to the supplied
|
|
467
|
+
* `open` routing rather than `popover.show()`, so opening goes through the
|
|
468
|
+
* trigger's focus stack (Pillar 1) instead of bypassing it.
|
|
469
|
+
*
|
|
470
|
+
* Internal decompose glue, not a consumer contract - NOT exported from
|
|
471
|
+
* `public-api.ts`. Extracting it keeps `CngxContextMenuItem`'s class body a
|
|
472
|
+
* thin shell (reference_atomic_decompose rule 1).
|
|
473
|
+
*
|
|
474
|
+
* @category ui/context-menu
|
|
475
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-item-submenu-facade.ts
|
|
476
|
+
* @since 0.1.0
|
|
477
|
+
*/
|
|
478
|
+
function createContextMenuItemSubmenuFacade(target, open) {
|
|
479
|
+
return {
|
|
480
|
+
isVisible: () => target()?.popover.isVisible() ?? false,
|
|
481
|
+
show: () => open(),
|
|
482
|
+
hide: () => target()?.popover.hide(),
|
|
483
|
+
setAnchorElement: (el) => target()?.popover.setAnchorElement(el),
|
|
484
|
+
id: () => target()?.popover.id() ?? '',
|
|
485
|
+
elementRef: {
|
|
486
|
+
get nativeElement() {
|
|
487
|
+
return target().popover.elementRef.nativeElement;
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Default single-character glyphs for the context-menu item skin. Plain
|
|
495
|
+
* `as const` (not `TemplateRef`, not a `Directive`) so the strings stay inline
|
|
496
|
+
* at their `aria-hidden` call sites and tree-shake when unused. Consolidates
|
|
497
|
+
* the trailing submenu caret and the checkbox / radio checked indicators into
|
|
498
|
+
* one source, mirroring `CNGX_SELECT_GLYPHS`.
|
|
499
|
+
*
|
|
500
|
+
* Internal to this organism: not exported from `public-api.ts`, not a consumer
|
|
501
|
+
* override surface (that tier stays deferred, menu-accepted-debt §2). Lives
|
|
502
|
+
* here rather than in `@cngx/common/interactive` because the base menu
|
|
503
|
+
* directives hardcode none of these glyphs, so the organism is the only
|
|
504
|
+
* consumer today; hoisting to the brain lib waits for a second menu consumer.
|
|
505
|
+
*
|
|
506
|
+
* @internal
|
|
507
|
+
*/
|
|
508
|
+
const CNGX_MENU_GLYPHS = {
|
|
509
|
+
/** Trailing caret on an item that opens a submenu. */
|
|
510
|
+
submenuCaret: '▸',
|
|
511
|
+
/** Leading indicator on a checked `menuitemcheckbox`. */
|
|
512
|
+
checkboxChecked: '✓',
|
|
513
|
+
/** Leading indicator on a checked `menuitemradio`. */
|
|
514
|
+
radioChecked: '●',
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* A single actionable context-menu item. Thin shell over `CngxMenuItem`: the
|
|
519
|
+
* brain owns `role="menuitem"`, the active-descendant registration, the
|
|
520
|
+
* keyboard/pointer activation and the disabled semantics. Dual selector, so it
|
|
521
|
+
* works both as an element and as an attribute on a native `<button>` (the
|
|
522
|
+
* `button[mat-menu-item]` precedent).
|
|
523
|
+
*
|
|
524
|
+
* Emits `select` when this item is activated by click or Enter/Space. Give
|
|
525
|
+
* each item a distinct `[value]` (forwarded to the brain) so pointer
|
|
526
|
+
* activation targets the right row - matching the base `CngxMenuItem`
|
|
527
|
+
* convention; a value-less item still works when it is the only item.
|
|
528
|
+
*
|
|
529
|
+
* ### Submenu
|
|
530
|
+
* Bind `[submenu]` to a sibling `<cngx-context-menu>` to open a nested menu.
|
|
531
|
+
* The `CngxMenuItemSubmenu` brain (a host directive here) is wired internally
|
|
532
|
+
* through `CNGX_MENU_SUBMENU_WIRING`, so the consumer needs no `[exclusive]`
|
|
533
|
+
* handgrip and no popover plumbing - just the sibling reference. The nested
|
|
534
|
+
* panel opens non-exclusively (the parent stays open) and inherits the parent
|
|
535
|
+
* panel's row context.
|
|
536
|
+
*
|
|
537
|
+
* ```html
|
|
538
|
+
* <cngx-context-menu-item value="copy" kbd="⌘C" (select)="copy()">Copy</cngx-context-menu-item>
|
|
539
|
+
* <button cngxContextMenuItem value="delete" [disabled]="locked()" (select)="remove()">Delete</button>
|
|
540
|
+
*
|
|
541
|
+
* <cngx-context-menu-item [submenu]="exportMenu">Export</cngx-context-menu-item>
|
|
542
|
+
* <cngx-context-menu #exportMenu ariaLabel="Export as">
|
|
543
|
+
* <cngx-context-menu-item (select)="export('pdf')">PDF</cngx-context-menu-item>
|
|
544
|
+
* </cngx-context-menu>
|
|
545
|
+
* ```
|
|
546
|
+
*
|
|
547
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/basic/static-items</example-url>
|
|
548
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/submenu/nested-export-menu</example-url>
|
|
549
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/attribute-form/native-buttons</example-url>
|
|
550
|
+
* @category ui/context-menu
|
|
551
|
+
* @wcag AA
|
|
552
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-item.component.ts
|
|
553
|
+
* @since 0.1.0
|
|
554
|
+
* @relatedTo CngxContextMenu, CngxContextMenuDivider, CngxMenuItem, CngxMenuItemSubmenu
|
|
555
|
+
*/
|
|
556
|
+
class CngxContextMenuItem {
|
|
557
|
+
/**
|
|
558
|
+
* Leading glyph shorthand rendered in the icon slot (decorative,
|
|
559
|
+
* `aria-hidden`). A convenience for single-character icons; suppressed when
|
|
560
|
+
* the consumer projects a richer `[cngxMenuItemIcon]` marker (SVG / icon
|
|
561
|
+
* component), which wins.
|
|
562
|
+
*/
|
|
563
|
+
icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
564
|
+
/**
|
|
565
|
+
* A consumer-projected `[cngxMenuItemIcon]` marker, when present. Gates the
|
|
566
|
+
* string `[icon]` shorthand off so the projected icon is the only one drawn.
|
|
567
|
+
*/
|
|
568
|
+
projectedIcon = contentChild(CngxMenuItemIcon, ...(ngDevMode ? [{ debugName: "projectedIcon" }] : /* istanbul ignore next */ []));
|
|
569
|
+
/** Keyboard-shortcut hint rendered in the kbd slot (decorative). */
|
|
570
|
+
kbd = input(...(ngDevMode ? [undefined, { debugName: "kbd" }] : /* istanbul ignore next */ []));
|
|
571
|
+
/**
|
|
572
|
+
* Sibling `<cngx-context-menu>` opened as a nested submenu. When set, the
|
|
573
|
+
* item renders a caret, gains `aria-haspopup="menu"` (from the submenu
|
|
574
|
+
* brain) and routes ArrowRight/ArrowLeft into the nested panel.
|
|
575
|
+
*/
|
|
576
|
+
submenu = input(...(ngDevMode ? [undefined, { debugName: "submenu" }] : /* istanbul ignore next */ []));
|
|
577
|
+
/** Fires when this item is activated by click or Enter/Space. */
|
|
578
|
+
select = output();
|
|
579
|
+
/** @internal Decorative caret rendered while `submenu` is set. RTL flip is
|
|
580
|
+
* a CSS concern (`.cngx-menu-item__suffix` under `[dir='rtl']`), not a
|
|
581
|
+
* swapped glyph. */
|
|
582
|
+
caret = CNGX_MENU_GLYPHS.submenuCaret;
|
|
583
|
+
parentPanel = inject(CNGX_CONTEXT_MENU_PANEL, { optional: true });
|
|
584
|
+
/**
|
|
585
|
+
* Facade the submenu brain drives instead of a `[cngxMenuItemSubmenu]`
|
|
586
|
+
* input. `show()` opens the target panel non-exclusively and mirrors the
|
|
587
|
+
* parent panel's row context in first; every other member delegates to the
|
|
588
|
+
* target's `CngxPopover`. Built once, reads `submenu()` lazily so it stays
|
|
589
|
+
* valid across target changes. The adapter itself lives in
|
|
590
|
+
* `createContextMenuItemSubmenuFacade` so this class stays a thin shell.
|
|
591
|
+
*/
|
|
592
|
+
submenuPopoverFacade = createContextMenuItemSubmenuFacade(() => this.submenu(), () => this.openSubmenu());
|
|
593
|
+
constructor() {
|
|
594
|
+
const brain = inject(CngxMenuItem);
|
|
595
|
+
const ad = inject(CngxActiveDescendant, { optional: true });
|
|
596
|
+
if (!ad) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
// Activation flows through the surrounding CngxActiveDescendant (click and
|
|
600
|
+
// keyboard both funnel into activateCurrent). Filter to this item's brain
|
|
601
|
+
// id so only the activated row emits - the same identity CngxMenu uses. A
|
|
602
|
+
// submenu parent never emits a leaf action: activating it opens the submenu
|
|
603
|
+
// (the panel routes `activated` to the trigger core), so gate on
|
|
604
|
+
// `!submenu()` to keep leaf `select` from firing on a parent.
|
|
605
|
+
outputToObservable(ad.activated)
|
|
606
|
+
.pipe(takeUntilDestroyed())
|
|
607
|
+
.subscribe(() => {
|
|
608
|
+
if (ad.activeId() === brain.id && !this.submenu()) {
|
|
609
|
+
this.select.emit();
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
/** @internal `CngxMenuSubmenuWiring` - the nested panel's menu brain, or
|
|
614
|
+
* `undefined` while no `[submenu]` is bound so the brain stays inert. */
|
|
615
|
+
menu() {
|
|
616
|
+
return this.submenu()?.menuHost;
|
|
617
|
+
}
|
|
618
|
+
/** @internal `CngxMenuSubmenuWiring` - the popover facade the brain drives,
|
|
619
|
+
* or `undefined` while no `[submenu]` is bound so the brain stays inert. */
|
|
620
|
+
popover() {
|
|
621
|
+
return this.submenu() ? this.submenuPopoverFacade : undefined;
|
|
622
|
+
}
|
|
623
|
+
openSubmenu() {
|
|
624
|
+
const target = this.submenu();
|
|
625
|
+
if (!target) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
// Delegate the whole submenu-open policy - inline-end placement, flip chain,
|
|
629
|
+
// non-exclusive open, parent-datum mirror - to the panel. The item drives
|
|
630
|
+
// one seam instead of reaching into the popover's override signals, so an
|
|
631
|
+
// ejected item skin never carries CngxPopover internals (decompose).
|
|
632
|
+
target.openAsSubmenu(this.parentPanel?.context() ?? null);
|
|
633
|
+
// openAsSubmenu is the terminal for every open path (hover, keyboard,
|
|
634
|
+
// click all funnel here through the trigger's focus stack). The note is
|
|
635
|
+
// the safety net for opens the stack did not perform itself
|
|
636
|
+
// (programmatic openAsSubmenu); for stack-driven opens it is an
|
|
637
|
+
// idempotent no-op. Push-only - it never re-enters the open path, so no
|
|
638
|
+
// recursion; the stack stays the single source of the active chain
|
|
639
|
+
// (Pillar 1).
|
|
640
|
+
this.parentPanel?.noteActiveSubmenuOpened?.();
|
|
641
|
+
}
|
|
642
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
643
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxContextMenuItem, isStandalone: true, selector: "cngx-context-menu-item, button[cngxContextMenuItem]", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, kbd: { classPropertyName: "kbd", publicName: "kbd", isSignal: true, isRequired: false, transformFunction: null }, submenu: { classPropertyName: "submenu", publicName: "submenu", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { select: "select" }, providers: [{ provide: CNGX_MENU_SUBMENU_WIRING, useExisting: CngxContextMenuItem }], queries: [{ propertyName: "projectedIcon", first: true, predicate: CngxMenuItemIcon, descendants: true, isSignal: true }], exportAs: ["cngxContextMenuItem"], hostDirectives: [{ directive: i1$1.CngxMenuItem, inputs: ["disabled", "disabled", "value", "value"] }, { directive: i1$1.CngxMenuItemSubmenu }], ngImport: i0, template: `
|
|
644
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
645
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
646
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
647
|
+
}
|
|
648
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
649
|
+
@if (kbd(); as shortcut) {
|
|
650
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
651
|
+
}
|
|
652
|
+
@if (submenu()) {
|
|
653
|
+
<span cngxMenuItemSuffix>{{ caret }}</span>
|
|
654
|
+
}
|
|
655
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-context-menu-item-padding{syntax: \"*\"; inherits: false; initial-value: 6px 10px;}@property --cngx-context-menu-item-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-context-menu-item-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-context-menu-item-caret-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .01 250);}@property --cngx-context-menu-item-check-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.66 .19 50);}:root{--cngx-context-menu-item-caret-color: var(--cngx-color-text-muted, oklch(.5 .01 250));--cngx-context-menu-item-check-color: var(--cngx-color-primary, oklch(.66 .19 50))}}@layer cngx.components{cngx-context-menu-item,button[cngxContextMenuItem],cngx-context-menu-item-checkbox,button[cngxContextMenuItemCheckbox],cngx-context-menu-item-radio,button[cngxContextMenuItemRadio]{--cngx-context-menu-item-padding: var(--cngx-space-xs) var(--cngx-space-sm);--cngx-context-menu-item-gap: var(--cngx-space-sm);display:flex;align-items:center;gap:var(--cngx-context-menu-item-gap, 8px);padding:var(--cngx-context-menu-item-padding, 6px 10px);border-radius:var(--cngx-context-menu-item-radius, 4px);cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;min-block-size:var(--cngx-target-min, 0px)}cngx-context-menu-item .cngx-menu-item__suffix,button[cngxContextMenuItem] .cngx-menu-item__suffix{color:var(--cngx-context-menu-item-caret-color, var(--cngx-color-text-muted, oklch(.5 .01 250)))}cngx-context-menu-item:dir(rtl) .cngx-menu-item__suffix,button[cngxContextMenuItem]:dir(rtl) .cngx-menu-item__suffix{transform:scaleX(-1)}cngx-context-menu-item-checkbox.cngx-menu-item--checked:before,button[cngxContextMenuItemCheckbox].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:700}cngx-context-menu-item-radio.cngx-menu-item--checked:before,button[cngxContextMenuItemRadio].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-size:.875em}}\n"], dependencies: [{ kind: "directive", type: CngxMenuItemIcon, selector: "[cngxMenuItemIcon]", exportAs: ["cngxMenuItemIcon"] }, { kind: "directive", type: CngxMenuItemLabel, selector: "[cngxMenuItemLabel]", exportAs: ["cngxMenuItemLabel"] }, { kind: "directive", type: CngxMenuItemKbd, selector: "[cngxMenuItemKbd]", exportAs: ["cngxMenuItemKbd"] }, { kind: "directive", type: CngxMenuItemSuffix, selector: "[cngxMenuItemSuffix]", exportAs: ["cngxMenuItemSuffix"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
656
|
+
}
|
|
657
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItem, decorators: [{
|
|
658
|
+
type: Component,
|
|
659
|
+
args: [{ selector: 'cngx-context-menu-item, button[cngxContextMenuItem]', standalone: true, imports: [CngxMenuItemIcon, CngxMenuItemLabel, CngxMenuItemKbd, CngxMenuItemSuffix], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cngxContextMenuItem', providers: [{ provide: CNGX_MENU_SUBMENU_WIRING, useExisting: CngxContextMenuItem }], hostDirectives: [
|
|
660
|
+
{ directive: CngxMenuItem, inputs: ['disabled', 'value'] },
|
|
661
|
+
CngxMenuItemSubmenu,
|
|
662
|
+
], template: `
|
|
663
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
664
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
665
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
666
|
+
}
|
|
667
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
668
|
+
@if (kbd(); as shortcut) {
|
|
669
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
670
|
+
}
|
|
671
|
+
@if (submenu()) {
|
|
672
|
+
<span cngxMenuItemSuffix>{{ caret }}</span>
|
|
673
|
+
}
|
|
674
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-context-menu-item-padding{syntax: \"*\"; inherits: false; initial-value: 6px 10px;}@property --cngx-context-menu-item-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-context-menu-item-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-context-menu-item-caret-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .01 250);}@property --cngx-context-menu-item-check-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.66 .19 50);}:root{--cngx-context-menu-item-caret-color: var(--cngx-color-text-muted, oklch(.5 .01 250));--cngx-context-menu-item-check-color: var(--cngx-color-primary, oklch(.66 .19 50))}}@layer cngx.components{cngx-context-menu-item,button[cngxContextMenuItem],cngx-context-menu-item-checkbox,button[cngxContextMenuItemCheckbox],cngx-context-menu-item-radio,button[cngxContextMenuItemRadio]{--cngx-context-menu-item-padding: var(--cngx-space-xs) var(--cngx-space-sm);--cngx-context-menu-item-gap: var(--cngx-space-sm);display:flex;align-items:center;gap:var(--cngx-context-menu-item-gap, 8px);padding:var(--cngx-context-menu-item-padding, 6px 10px);border-radius:var(--cngx-context-menu-item-radius, 4px);cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;min-block-size:var(--cngx-target-min, 0px)}cngx-context-menu-item .cngx-menu-item__suffix,button[cngxContextMenuItem] .cngx-menu-item__suffix{color:var(--cngx-context-menu-item-caret-color, var(--cngx-color-text-muted, oklch(.5 .01 250)))}cngx-context-menu-item:dir(rtl) .cngx-menu-item__suffix,button[cngxContextMenuItem]:dir(rtl) .cngx-menu-item__suffix{transform:scaleX(-1)}cngx-context-menu-item-checkbox.cngx-menu-item--checked:before,button[cngxContextMenuItemCheckbox].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:700}cngx-context-menu-item-radio.cngx-menu-item--checked:before,button[cngxContextMenuItemRadio].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-size:.875em}}\n"] }]
|
|
675
|
+
}], ctorParameters: () => [], propDecorators: { icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], projectedIcon: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMenuItemIcon), { isSignal: true }] }], kbd: [{ type: i0.Input, args: [{ isSignal: true, alias: "kbd", required: false }] }], submenu: [{ type: i0.Input, args: [{ isSignal: true, alias: "submenu", required: false }] }], select: [{ type: i0.Output, args: ["select"] }] } });
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Non-interactive separator between context-menu item groups. Thin shell over
|
|
679
|
+
* `CngxMenuSeparator` (`role="separator"`, `aria-orientation="horizontal"`),
|
|
680
|
+
* skipped by active-descendant navigation and typeahead. Dual selector: use as
|
|
681
|
+
* an element or as an attribute on a native `<hr>`.
|
|
682
|
+
*
|
|
683
|
+
* ```html
|
|
684
|
+
* <cngx-context-menu-divider />
|
|
685
|
+
* <hr cngxContextMenuDivider />
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/basic/static-items</example-url>
|
|
689
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/attribute-form/native-buttons</example-url>
|
|
690
|
+
* @category ui/context-menu
|
|
691
|
+
* @wcag AA
|
|
692
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-divider.component.ts
|
|
693
|
+
* @since 0.1.0
|
|
694
|
+
* @relatedTo CngxContextMenu, CngxContextMenuItem, CngxMenuSeparator
|
|
695
|
+
*/
|
|
696
|
+
class CngxContextMenuDivider {
|
|
697
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuDivider, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
698
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.4", type: CngxContextMenuDivider, isStandalone: true, selector: "cngx-context-menu-divider, hr[cngxContextMenuDivider]", exportAs: ["cngxContextMenuDivider"], hostDirectives: [{ directive: i1$1.CngxMenuSeparator }], ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
699
|
+
}
|
|
700
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuDivider, decorators: [{
|
|
701
|
+
type: Component,
|
|
702
|
+
args: [{
|
|
703
|
+
selector: 'cngx-context-menu-divider, hr[cngxContextMenuDivider]',
|
|
704
|
+
standalone: true,
|
|
705
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
706
|
+
encapsulation: ViewEncapsulation.None,
|
|
707
|
+
exportAs: 'cngxContextMenuDivider',
|
|
708
|
+
hostDirectives: [CngxMenuSeparator],
|
|
709
|
+
template: '',
|
|
710
|
+
}]
|
|
711
|
+
}] });
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* A checkable context-menu item (`role="menuitemcheckbox"`). Thin shell over
|
|
715
|
+
* `CngxMenuItemCheckbox`: the brain owns the role, the active-descendant
|
|
716
|
+
* registration, the toggle-on-activation semantics and the reactive
|
|
717
|
+
* `aria-checked`. `checked` is a two-way model forwarded through the host
|
|
718
|
+
* directive, so `[(checked)]` binds straight to consumer state.
|
|
719
|
+
*
|
|
720
|
+
* ```html
|
|
721
|
+
* <cngx-context-menu-item-checkbox [(checked)]="wrap">Word wrap</cngx-context-menu-item-checkbox>
|
|
722
|
+
* ```
|
|
723
|
+
*
|
|
724
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/selection/checkbox-radio-items</example-url>
|
|
725
|
+
* @category ui/context-menu
|
|
726
|
+
* @wcag AA
|
|
727
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-item-checkbox.component.ts
|
|
728
|
+
* @since 0.1.0
|
|
729
|
+
* @relatedTo CngxContextMenu, CngxContextMenuItem, CngxContextMenuItemRadio, CngxMenuItemCheckbox
|
|
730
|
+
*/
|
|
731
|
+
class CngxContextMenuItemCheckbox {
|
|
732
|
+
/**
|
|
733
|
+
* Leading glyph shorthand rendered in the icon slot (decorative,
|
|
734
|
+
* `aria-hidden`). Suppressed when the consumer projects a richer
|
|
735
|
+
* `[cngxMenuItemIcon]` marker. The checked-indicator gutter renders
|
|
736
|
+
* independently of the icon, so a checked item stays visibly checked beside
|
|
737
|
+
* a custom icon.
|
|
738
|
+
*/
|
|
739
|
+
icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
740
|
+
/** Keyboard-shortcut hint rendered in the kbd slot (decorative). */
|
|
741
|
+
kbd = input(...(ngDevMode ? [undefined, { debugName: "kbd" }] : /* istanbul ignore next */ []));
|
|
742
|
+
/**
|
|
743
|
+
* A consumer-projected `[cngxMenuItemIcon]` marker, when present. Gates the
|
|
744
|
+
* string `[icon]` shorthand off so the projected icon is the only one drawn.
|
|
745
|
+
*/
|
|
746
|
+
projectedIcon = contentChild(CngxMenuItemIcon, ...(ngDevMode ? [{ debugName: "projectedIcon" }] : /* istanbul ignore next */ []));
|
|
747
|
+
/** @internal Seeds the CSS `content` of the default checked indicator from
|
|
748
|
+
* the shared glyph const (CSS-string quoted for `content:`). */
|
|
749
|
+
checkGlyph = `'${CNGX_MENU_GLYPHS.checkboxChecked}'`;
|
|
750
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItemCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
751
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxContextMenuItemCheckbox, isStandalone: true, selector: "cngx-context-menu-item-checkbox, button[cngxContextMenuItemCheckbox]", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, kbd: { classPropertyName: "kbd", publicName: "kbd", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.--cngx-context-menu-item-check-glyph": "checkGlyph" } }, queries: [{ propertyName: "projectedIcon", first: true, predicate: CngxMenuItemIcon, descendants: true, isSignal: true }], exportAs: ["cngxContextMenuItemCheckbox"], hostDirectives: [{ directive: i1$1.CngxMenuItemCheckbox, inputs: ["disabled", "disabled", "value", "value", "checked", "checked", "label", "label"], outputs: ["checkedChange", "checkedChange"] }], ngImport: i0, template: `
|
|
752
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
753
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
754
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
755
|
+
}
|
|
756
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
757
|
+
@if (kbd(); as shortcut) {
|
|
758
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
759
|
+
}
|
|
760
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-context-menu-item-padding{syntax: \"*\"; inherits: false; initial-value: 6px 10px;}@property --cngx-context-menu-item-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-context-menu-item-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-context-menu-item-caret-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .01 250);}@property --cngx-context-menu-item-check-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.66 .19 50);}:root{--cngx-context-menu-item-caret-color: var(--cngx-color-text-muted, oklch(.5 .01 250));--cngx-context-menu-item-check-color: var(--cngx-color-primary, oklch(.66 .19 50))}}@layer cngx.components{cngx-context-menu-item,button[cngxContextMenuItem],cngx-context-menu-item-checkbox,button[cngxContextMenuItemCheckbox],cngx-context-menu-item-radio,button[cngxContextMenuItemRadio]{--cngx-context-menu-item-padding: var(--cngx-space-xs) var(--cngx-space-sm);--cngx-context-menu-item-gap: var(--cngx-space-sm);display:flex;align-items:center;gap:var(--cngx-context-menu-item-gap, 8px);padding:var(--cngx-context-menu-item-padding, 6px 10px);border-radius:var(--cngx-context-menu-item-radius, 4px);cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;min-block-size:var(--cngx-target-min, 0px)}cngx-context-menu-item .cngx-menu-item__suffix,button[cngxContextMenuItem] .cngx-menu-item__suffix{color:var(--cngx-context-menu-item-caret-color, var(--cngx-color-text-muted, oklch(.5 .01 250)))}cngx-context-menu-item:dir(rtl) .cngx-menu-item__suffix,button[cngxContextMenuItem]:dir(rtl) .cngx-menu-item__suffix{transform:scaleX(-1)}cngx-context-menu-item-checkbox.cngx-menu-item--checked:before,button[cngxContextMenuItemCheckbox].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:700}cngx-context-menu-item-radio.cngx-menu-item--checked:before,button[cngxContextMenuItemRadio].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-size:.875em}}\n"], dependencies: [{ kind: "directive", type: CngxMenuItemIcon, selector: "[cngxMenuItemIcon]", exportAs: ["cngxMenuItemIcon"] }, { kind: "directive", type: CngxMenuItemLabel, selector: "[cngxMenuItemLabel]", exportAs: ["cngxMenuItemLabel"] }, { kind: "directive", type: CngxMenuItemKbd, selector: "[cngxMenuItemKbd]", exportAs: ["cngxMenuItemKbd"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
761
|
+
}
|
|
762
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItemCheckbox, decorators: [{
|
|
763
|
+
type: Component,
|
|
764
|
+
args: [{ selector: 'cngx-context-menu-item-checkbox, button[cngxContextMenuItemCheckbox]', standalone: true, imports: [CngxMenuItemIcon, CngxMenuItemLabel, CngxMenuItemKbd], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cngxContextMenuItemCheckbox', host: { '[style.--cngx-context-menu-item-check-glyph]': 'checkGlyph' }, hostDirectives: [
|
|
765
|
+
{
|
|
766
|
+
directive: CngxMenuItemCheckbox,
|
|
767
|
+
inputs: ['disabled', 'value', 'checked', 'label'],
|
|
768
|
+
outputs: ['checkedChange'],
|
|
769
|
+
},
|
|
770
|
+
], template: `
|
|
771
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
772
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
773
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
774
|
+
}
|
|
775
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
776
|
+
@if (kbd(); as shortcut) {
|
|
777
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
778
|
+
}
|
|
779
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-context-menu-item-padding{syntax: \"*\"; inherits: false; initial-value: 6px 10px;}@property --cngx-context-menu-item-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-context-menu-item-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-context-menu-item-caret-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .01 250);}@property --cngx-context-menu-item-check-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.66 .19 50);}:root{--cngx-context-menu-item-caret-color: var(--cngx-color-text-muted, oklch(.5 .01 250));--cngx-context-menu-item-check-color: var(--cngx-color-primary, oklch(.66 .19 50))}}@layer cngx.components{cngx-context-menu-item,button[cngxContextMenuItem],cngx-context-menu-item-checkbox,button[cngxContextMenuItemCheckbox],cngx-context-menu-item-radio,button[cngxContextMenuItemRadio]{--cngx-context-menu-item-padding: var(--cngx-space-xs) var(--cngx-space-sm);--cngx-context-menu-item-gap: var(--cngx-space-sm);display:flex;align-items:center;gap:var(--cngx-context-menu-item-gap, 8px);padding:var(--cngx-context-menu-item-padding, 6px 10px);border-radius:var(--cngx-context-menu-item-radius, 4px);cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;min-block-size:var(--cngx-target-min, 0px)}cngx-context-menu-item .cngx-menu-item__suffix,button[cngxContextMenuItem] .cngx-menu-item__suffix{color:var(--cngx-context-menu-item-caret-color, var(--cngx-color-text-muted, oklch(.5 .01 250)))}cngx-context-menu-item:dir(rtl) .cngx-menu-item__suffix,button[cngxContextMenuItem]:dir(rtl) .cngx-menu-item__suffix{transform:scaleX(-1)}cngx-context-menu-item-checkbox.cngx-menu-item--checked:before,button[cngxContextMenuItemCheckbox].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:700}cngx-context-menu-item-radio.cngx-menu-item--checked:before,button[cngxContextMenuItemRadio].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-size:.875em}}\n"] }]
|
|
780
|
+
}], propDecorators: { icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], kbd: [{ type: i0.Input, args: [{ isSignal: true, alias: "kbd", required: false }] }], projectedIcon: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMenuItemIcon), { isSignal: true }] }] } });
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* A radio-style context-menu item (`role="menuitemradio"`). Thin shell over
|
|
784
|
+
* `CngxMenuItemRadio`: the brain owns the role, the active-descendant
|
|
785
|
+
* registration and the reactive `aria-checked`. Mutual exclusion is scoped to
|
|
786
|
+
* the enclosing `[cngxMenuGroup]` - the group owns the selected value, the
|
|
787
|
+
* item forwards its `value`.
|
|
788
|
+
*
|
|
789
|
+
* ```html
|
|
790
|
+
* <div cngxMenuGroup label="Density" [(selectedValue)]="density">
|
|
791
|
+
* <cngx-context-menu-item-radio value="cozy">Cozy</cngx-context-menu-item-radio>
|
|
792
|
+
* <cngx-context-menu-item-radio value="compact">Compact</cngx-context-menu-item-radio>
|
|
793
|
+
* </div>
|
|
794
|
+
* ```
|
|
795
|
+
*
|
|
796
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/selection/checkbox-radio-items</example-url>
|
|
797
|
+
* @category ui/context-menu
|
|
798
|
+
* @wcag AA
|
|
799
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-item-radio.component.ts
|
|
800
|
+
* @since 0.1.0
|
|
801
|
+
* @relatedTo CngxContextMenu, CngxContextMenuItem, CngxContextMenuItemCheckbox, CngxMenuItemRadio, CngxMenuGroup
|
|
802
|
+
*/
|
|
803
|
+
class CngxContextMenuItemRadio {
|
|
804
|
+
/**
|
|
805
|
+
* Leading glyph shorthand rendered in the icon slot (decorative,
|
|
806
|
+
* `aria-hidden`). Suppressed when the consumer projects a richer
|
|
807
|
+
* `[cngxMenuItemIcon]` marker. The checked-indicator gutter renders
|
|
808
|
+
* independently of the icon, so a checked item stays visibly checked beside
|
|
809
|
+
* a custom icon.
|
|
810
|
+
*/
|
|
811
|
+
icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
812
|
+
/** Keyboard-shortcut hint rendered in the kbd slot (decorative). */
|
|
813
|
+
kbd = input(...(ngDevMode ? [undefined, { debugName: "kbd" }] : /* istanbul ignore next */ []));
|
|
814
|
+
/**
|
|
815
|
+
* A consumer-projected `[cngxMenuItemIcon]` marker, when present. Gates the
|
|
816
|
+
* string `[icon]` shorthand off so the projected icon is the only one drawn.
|
|
817
|
+
*/
|
|
818
|
+
projectedIcon = contentChild(CngxMenuItemIcon, ...(ngDevMode ? [{ debugName: "projectedIcon" }] : /* istanbul ignore next */ []));
|
|
819
|
+
/** @internal Seeds the CSS `content` of the default checked indicator from
|
|
820
|
+
* the shared glyph const (CSS-string quoted for `content:`). */
|
|
821
|
+
checkGlyph = `'${CNGX_MENU_GLYPHS.radioChecked}'`;
|
|
822
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItemRadio, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
823
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxContextMenuItemRadio, isStandalone: true, selector: "cngx-context-menu-item-radio, button[cngxContextMenuItemRadio]", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, kbd: { classPropertyName: "kbd", publicName: "kbd", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.--cngx-context-menu-item-check-glyph": "checkGlyph" } }, queries: [{ propertyName: "projectedIcon", first: true, predicate: CngxMenuItemIcon, descendants: true, isSignal: true }], exportAs: ["cngxContextMenuItemRadio"], hostDirectives: [{ directive: i1$1.CngxMenuItemRadio, inputs: ["disabled", "disabled", "value", "value", "label", "label"] }], ngImport: i0, template: `
|
|
824
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
825
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
826
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
827
|
+
}
|
|
828
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
829
|
+
@if (kbd(); as shortcut) {
|
|
830
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
831
|
+
}
|
|
832
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-context-menu-item-padding{syntax: \"*\"; inherits: false; initial-value: 6px 10px;}@property --cngx-context-menu-item-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-context-menu-item-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-context-menu-item-caret-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .01 250);}@property --cngx-context-menu-item-check-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.66 .19 50);}:root{--cngx-context-menu-item-caret-color: var(--cngx-color-text-muted, oklch(.5 .01 250));--cngx-context-menu-item-check-color: var(--cngx-color-primary, oklch(.66 .19 50))}}@layer cngx.components{cngx-context-menu-item,button[cngxContextMenuItem],cngx-context-menu-item-checkbox,button[cngxContextMenuItemCheckbox],cngx-context-menu-item-radio,button[cngxContextMenuItemRadio]{--cngx-context-menu-item-padding: var(--cngx-space-xs) var(--cngx-space-sm);--cngx-context-menu-item-gap: var(--cngx-space-sm);display:flex;align-items:center;gap:var(--cngx-context-menu-item-gap, 8px);padding:var(--cngx-context-menu-item-padding, 6px 10px);border-radius:var(--cngx-context-menu-item-radius, 4px);cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;min-block-size:var(--cngx-target-min, 0px)}cngx-context-menu-item .cngx-menu-item__suffix,button[cngxContextMenuItem] .cngx-menu-item__suffix{color:var(--cngx-context-menu-item-caret-color, var(--cngx-color-text-muted, oklch(.5 .01 250)))}cngx-context-menu-item:dir(rtl) .cngx-menu-item__suffix,button[cngxContextMenuItem]:dir(rtl) .cngx-menu-item__suffix{transform:scaleX(-1)}cngx-context-menu-item-checkbox.cngx-menu-item--checked:before,button[cngxContextMenuItemCheckbox].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:700}cngx-context-menu-item-radio.cngx-menu-item--checked:before,button[cngxContextMenuItemRadio].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-size:.875em}}\n"], dependencies: [{ kind: "directive", type: CngxMenuItemIcon, selector: "[cngxMenuItemIcon]", exportAs: ["cngxMenuItemIcon"] }, { kind: "directive", type: CngxMenuItemLabel, selector: "[cngxMenuItemLabel]", exportAs: ["cngxMenuItemLabel"] }, { kind: "directive", type: CngxMenuItemKbd, selector: "[cngxMenuItemKbd]", exportAs: ["cngxMenuItemKbd"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
833
|
+
}
|
|
834
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItemRadio, decorators: [{
|
|
835
|
+
type: Component,
|
|
836
|
+
args: [{ selector: 'cngx-context-menu-item-radio, button[cngxContextMenuItemRadio]', standalone: true, imports: [CngxMenuItemIcon, CngxMenuItemLabel, CngxMenuItemKbd], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cngxContextMenuItemRadio', host: { '[style.--cngx-context-menu-item-check-glyph]': 'checkGlyph' }, hostDirectives: [{ directive: CngxMenuItemRadio, inputs: ['disabled', 'value', 'label'] }], template: `
|
|
837
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
838
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
839
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
840
|
+
}
|
|
841
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
842
|
+
@if (kbd(); as shortcut) {
|
|
843
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
844
|
+
}
|
|
845
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-context-menu-item-padding{syntax: \"*\"; inherits: false; initial-value: 6px 10px;}@property --cngx-context-menu-item-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-context-menu-item-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-context-menu-item-caret-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .01 250);}@property --cngx-context-menu-item-check-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.66 .19 50);}:root{--cngx-context-menu-item-caret-color: var(--cngx-color-text-muted, oklch(.5 .01 250));--cngx-context-menu-item-check-color: var(--cngx-color-primary, oklch(.66 .19 50))}}@layer cngx.components{cngx-context-menu-item,button[cngxContextMenuItem],cngx-context-menu-item-checkbox,button[cngxContextMenuItemCheckbox],cngx-context-menu-item-radio,button[cngxContextMenuItemRadio]{--cngx-context-menu-item-padding: var(--cngx-space-xs) var(--cngx-space-sm);--cngx-context-menu-item-gap: var(--cngx-space-sm);display:flex;align-items:center;gap:var(--cngx-context-menu-item-gap, 8px);padding:var(--cngx-context-menu-item-padding, 6px 10px);border-radius:var(--cngx-context-menu-item-radius, 4px);cursor:pointer;-webkit-user-select:none;user-select:none;color:inherit;min-block-size:var(--cngx-target-min, 0px)}cngx-context-menu-item .cngx-menu-item__suffix,button[cngxContextMenuItem] .cngx-menu-item__suffix{color:var(--cngx-context-menu-item-caret-color, var(--cngx-color-text-muted, oklch(.5 .01 250)))}cngx-context-menu-item:dir(rtl) .cngx-menu-item__suffix,button[cngxContextMenuItem]:dir(rtl) .cngx-menu-item__suffix{transform:scaleX(-1)}cngx-context-menu-item-checkbox.cngx-menu-item--checked:before,button[cngxContextMenuItemCheckbox].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:700}cngx-context-menu-item-radio.cngx-menu-item--checked:before,button[cngxContextMenuItemRadio].cngx-menu-item--checked:before{content:var(--cngx-context-menu-item-check-glyph) / \"\";display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;color:var(--cngx-context-menu-item-check-color, var(--cngx-color-primary, oklch(.66 .19 50)));font-size:.875em}}\n"] }]
|
|
846
|
+
}], propDecorators: { icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], kbd: [{ type: i0.Input, args: [{ isSignal: true, alias: "kbd", required: false }] }], projectedIcon: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMenuItemIcon), { isSignal: true }] }] } });
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* @module @cngx/ui/context-menu
|
|
850
|
+
*/
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* Generated bundle index. Do not edit.
|
|
854
|
+
*/
|
|
855
|
+
|
|
856
|
+
export { CNGX_CONTEXT_MENU_PANEL, CngxContextMenu, CngxContextMenuContent, CngxContextMenuDivider, CngxContextMenuFor, CngxContextMenuItem, CngxContextMenuItemCheckbox, CngxContextMenuItemRadio };
|
|
857
|
+
//# sourceMappingURL=cngx-ui-context-menu.mjs.map
|