@cngx/ui 0.1.0-rc.6 → 0.1.0-rc.7
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 -0
- package/a11y/README.md +81 -0
- package/context-menu/README.md +98 -0
- package/data-grid-accordion/README.md +27 -0
- package/feedback/README.md +2 -0
- package/fesm2022/cngx-ui-a11y.mjs +320 -0
- package/fesm2022/cngx-ui-a11y.mjs.map +1 -0
- package/fesm2022/cngx-ui-accordion.mjs +17 -6
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +5 -2
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +11 -6
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-chart-panel.mjs +429 -0
- package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -0
- package/fesm2022/cngx-ui-collection.mjs +15 -6
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +1005 -0
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -0
- package/fesm2022/cngx-ui-context-menu.mjs +742 -0
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -0
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +88 -18
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +97 -106
- 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 +9 -9
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +64 -70
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +18 -8
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +2 -2
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +20 -7
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +2 -2
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stat-card.mjs +618 -0
- package/fesm2022/cngx-ui-stat-card.mjs.map +1 -0
- package/fesm2022/cngx-ui-stepper.mjs +30 -12
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +36 -19
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +495 -0
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -0
- package/fesm2022/cngx-ui-toc.mjs +704 -0
- package/fesm2022/cngx-ui-toc.mjs.map +1 -0
- package/fesm2022/cngx-ui.mjs +2 -2
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/mat-accordion/README.md +1 -1
- package/mat-tabs/styles/mat-tabs.css +20 -17
- package/package.json +32 -1
- package/skeleton/README.md +2 -0
- package/stepper/README.md +2 -2
- package/timeline/README.md +350 -0
- package/toc/README.md +183 -0
- package/types/cngx-ui-a11y.d.ts +303 -0
- package/types/cngx-ui-accordion.d.ts +9 -4
- package/types/cngx-ui-action-button.d.ts +3 -0
- package/types/cngx-ui-breadcrumb.d.ts +5 -0
- package/types/cngx-ui-chart-panel.d.ts +278 -0
- package/types/cngx-ui-collection.d.ts +12 -3
- package/types/cngx-ui-command-palette.d.ts +451 -0
- package/types/cngx-ui-context-menu.d.ts +467 -0
- package/types/cngx-ui-data-grid-accordion.d.ts +72 -15
- package/types/cngx-ui-feedback.d.ts +71 -18
- package/types/cngx-ui-layout.d.ts +8 -3
- package/types/cngx-ui-mat-accordion.d.ts +3 -3
- package/types/cngx-ui-mat-tabs.d.ts +11 -9
- package/types/cngx-ui-paginator.d.ts +13 -3
- package/types/cngx-ui-skeleton.d.ts +13 -1
- package/types/cngx-ui-stat-card.d.ts +327 -0
- package/types/cngx-ui-stepper.d.ts +15 -2
- package/types/cngx-ui-tabs.d.ts +20 -4
- package/types/cngx-ui-timeline.d.ts +479 -0
- package/types/cngx-ui-toc.d.ts +514 -0
- package/types/cngx-ui.d.ts +1 -1
|
@@ -0,0 +1,742 @@
|
|
|
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
|
+
*/
|
|
108
|
+
class CngxContextMenu {
|
|
109
|
+
/** The popover surface this panel drives. Consumed by the trigger core. */
|
|
110
|
+
popover = inject(CngxPopover, { self: true });
|
|
111
|
+
/** The menu brain (`role="menu"`, active-descendant registry). */
|
|
112
|
+
menuHost = inject(CngxMenu, { self: true });
|
|
113
|
+
/** Per-open datum set by the trigger before `show()`. */
|
|
114
|
+
datum = signal(null, ...(ngDevMode ? [{ debugName: "datum" }] : /* istanbul ignore next */ []));
|
|
115
|
+
/**
|
|
116
|
+
* The datum the menu opened over while visible, `null` once closed. Gated on
|
|
117
|
+
* `popover.isVisible()` so the reset on dismiss is derived, not synced.
|
|
118
|
+
*/
|
|
119
|
+
context = computed(() => (this.popover.isVisible() ? this.datum() : null), ...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
|
|
120
|
+
contentTemplate = contentChild(CngxContextMenuContent, ...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
|
|
121
|
+
/**
|
|
122
|
+
* @internal Store the per-open datum. Called by `CngxContextMenuFor` in the
|
|
123
|
+
* `contextmenu` event path, before the popover opens.
|
|
124
|
+
*/
|
|
125
|
+
setContext(value) {
|
|
126
|
+
this.datum.set(value);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @internal Open this panel as a nested submenu of a parent item. Installs the
|
|
130
|
+
* inline-end placement + flip chain, opens non-exclusively (the parent panel
|
|
131
|
+
* survives), mirrors the parent's per-open datum, then shows. Owns the submenu
|
|
132
|
+
* placement policy so `CngxContextMenuItem` drives one seam rather than
|
|
133
|
+
* reaching into the popover's `@internal` override signals - the ejected item
|
|
134
|
+
* skin stays off `CngxPopover` internals (decompose).
|
|
135
|
+
*/
|
|
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);
|
|
140
|
+
this.setContext(context);
|
|
141
|
+
this.popover.show();
|
|
142
|
+
}
|
|
143
|
+
/** Keydown forwarder registered by the trigger; `null` while none is bound. */
|
|
144
|
+
keydownHandler = null;
|
|
145
|
+
/** Activation forwarder registered by the trigger; `null` while none bound. */
|
|
146
|
+
activationHandler = null;
|
|
147
|
+
/** Push-only submenu-note forwarder registered by the trigger; `null` while none bound. */
|
|
148
|
+
submenuNoteHandler = null;
|
|
149
|
+
constructor() {
|
|
150
|
+
// Open moves focus into the menu container, so the container's
|
|
151
|
+
// CngxActiveDescendant owns Enter/Space and a forwarded keydown reaches the
|
|
152
|
+
// trigger core too late to open a submenu parent. Drive the open off the
|
|
153
|
+
// deterministic `activated` event instead - it fires once, after the AD
|
|
154
|
+
// decides, on both keyboard activation and pointer click.
|
|
155
|
+
outputToObservable(this.menuHost.ad.activated)
|
|
156
|
+
.pipe(takeUntilDestroyed())
|
|
157
|
+
.subscribe(() => this.activationHandler?.());
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* @internal Register the trigger core's keydown handler. The core owns
|
|
161
|
+
* submenu ArrowRight/ArrowLeft/Escape routing, but open moves focus into
|
|
162
|
+
* this panel, so keydown lands here rather than on the trigger host.
|
|
163
|
+
*/
|
|
164
|
+
setKeydownHandler(handler) {
|
|
165
|
+
this.keydownHandler = handler;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @internal Register the trigger core's activation handler, invoked on every
|
|
169
|
+
* `CngxActiveDescendant.activated` (keyboard activation + pointer click) so a
|
|
170
|
+
* submenu parent opens deterministically off the event rather than a racing
|
|
171
|
+
* keydown.
|
|
172
|
+
*/
|
|
173
|
+
setActivationHandler(handler) {
|
|
174
|
+
this.activationHandler = handler;
|
|
175
|
+
}
|
|
176
|
+
/** @internal Register the trigger core's push-only submenu-note handler. */
|
|
177
|
+
setSubmenuNoteHandler(handler) {
|
|
178
|
+
this.submenuNoteHandler = handler;
|
|
179
|
+
}
|
|
180
|
+
/** @internal A projected item calls this after its openAsSubmenu terminal
|
|
181
|
+
* ran, so the trigger's focus stack records an externally opened submenu
|
|
182
|
+
* (idempotent no-op for stack-driven hover/click opens). */
|
|
183
|
+
noteActiveSubmenuOpened() {
|
|
184
|
+
this.submenuNoteHandler?.();
|
|
185
|
+
}
|
|
186
|
+
handleKeydown(event) {
|
|
187
|
+
this.keydownHandler?.(event);
|
|
188
|
+
}
|
|
189
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenu, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
190
|
+
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: `
|
|
191
|
+
@if (contentTemplate(); as content) {
|
|
192
|
+
@if (popover.isVisible()) {
|
|
193
|
+
<ng-container *ngTemplateOutlet="content.templateRef; context: { $implicit: context() }" />
|
|
194
|
+
}
|
|
195
|
+
} @else {
|
|
196
|
+
<ng-content />
|
|
197
|
+
}
|
|
198
|
+
`, 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 });
|
|
199
|
+
}
|
|
200
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenu, decorators: [{
|
|
201
|
+
type: Component,
|
|
202
|
+
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: {
|
|
203
|
+
'(keydown)': 'handleKeydown($event)',
|
|
204
|
+
}, hostDirectives: [
|
|
205
|
+
{ directive: CngxPopover, inputs: ['offset', 'closeOnEscape'] },
|
|
206
|
+
{ directive: CngxMenu, inputs: ['label: ariaLabel'] },
|
|
207
|
+
], template: `
|
|
208
|
+
@if (contentTemplate(); as content) {
|
|
209
|
+
@if (popover.isVisible()) {
|
|
210
|
+
<ng-container *ngTemplateOutlet="content.templateRef; context: { $implicit: context() }" />
|
|
211
|
+
}
|
|
212
|
+
} @else {
|
|
213
|
+
<ng-content />
|
|
214
|
+
}
|
|
215
|
+
`, 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"] }]
|
|
216
|
+
}], ctorParameters: () => [], propDecorators: { contentTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxContextMenuContent), { isSignal: true }] }] } });
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Docks a {@link CngxContextMenu} onto a target element. Opens the panel at
|
|
220
|
+
* pointer coordinates on `contextmenu` (right-click) or `Shift+F10`, feeding
|
|
221
|
+
* the panel a per-open datum so one declaration serves many targets.
|
|
222
|
+
*
|
|
223
|
+
* Two ways to obtain the datum `T`:
|
|
224
|
+
* - `[cngxContextMenuData]` - a fixed datum for this single target.
|
|
225
|
+
* - `[cngxContextMenuResolve]` - a resolver run against the `contextmenu`
|
|
226
|
+
* event, so a container (table, grid, treetable, virtualized list) keeps a
|
|
227
|
+
* single trigger instance and derives the row from `event.target`. The
|
|
228
|
+
* resolver wins when both are bound. A `null` resolver result leaves the
|
|
229
|
+
* native context menu untouched (no `preventDefault`, no open).
|
|
230
|
+
*
|
|
231
|
+
* A thin shell over `createContextMenuTriggerCore` (shared with
|
|
232
|
+
* `CngxContextMenuTrigger`): the core owns the preventDefault decision through
|
|
233
|
+
* its `resolveOpen` seam, so the veto lives in one place and this directive
|
|
234
|
+
* only feeds the resolver.
|
|
235
|
+
*
|
|
236
|
+
* ```html
|
|
237
|
+
* <tr [cngxContextMenuFor]="menu" [cngxContextMenuData]="row" tabindex="0"></tr>
|
|
238
|
+
* <cngx-context-menu #menu ariaLabel="Row actions">…</cngx-context-menu>
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/grid/delegated-resolver</example-url>
|
|
242
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/basic/static-items</example-url>
|
|
243
|
+
* @category ui/context-menu
|
|
244
|
+
* @wcag AA
|
|
245
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-for.directive.ts
|
|
246
|
+
* @since 0.1.0
|
|
247
|
+
* @relatedTo CngxContextMenu, CngxContextMenuItem, CngxContextMenuTrigger
|
|
248
|
+
*/
|
|
249
|
+
class CngxContextMenuFor {
|
|
250
|
+
/** Panel this trigger opens. Typed to the {@link CngxContextMenuPanel} seam. */
|
|
251
|
+
panel = input.required({ ...(ngDevMode ? { debugName: "panel" } : /* istanbul ignore next */ {}), alias: 'cngxContextMenuFor' });
|
|
252
|
+
/** Fixed datum handed to the panel for this single target. */
|
|
253
|
+
data = input(undefined, { ...(ngDevMode ? { debugName: "data" } : /* istanbul ignore next */ {}), alias: 'cngxContextMenuData' });
|
|
254
|
+
/**
|
|
255
|
+
* Resolver run against the `contextmenu` event. Return the datum to open
|
|
256
|
+
* with, or `null` to let the native menu show. Wins over `[cngxContextMenuData]`.
|
|
257
|
+
*/
|
|
258
|
+
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 */ []));
|
|
261
|
+
core = createContextMenuTriggerCore({
|
|
262
|
+
menu: () => this.panel().menuHost,
|
|
263
|
+
popover: () => this.panel().popover,
|
|
264
|
+
hostElement: inject(ElementRef).nativeElement,
|
|
265
|
+
document: inject(DOCUMENT),
|
|
266
|
+
menuConfig: injectMenuConfig(),
|
|
267
|
+
dismissFactory: inject(CNGX_MENU_DISMISS_HANDLER_FACTORY),
|
|
268
|
+
announcer: inject(CNGX_MENU_ANNOUNCER_FACTORY)(),
|
|
269
|
+
nav: inject(CNGX_MENU_NAV_STRATEGY),
|
|
270
|
+
direction: injectDirection(),
|
|
271
|
+
focusStackFactory: inject(CNGX_MENU_FOCUS_STACK_FACTORY),
|
|
272
|
+
resolveOpen: (event) => {
|
|
273
|
+
const resolver = this.resolve();
|
|
274
|
+
if (resolver) {
|
|
275
|
+
const resolved = resolver(event);
|
|
276
|
+
return resolved === null ? { open: false } : { open: true, context: resolved };
|
|
277
|
+
}
|
|
278
|
+
return { open: true, context: this.data() ?? null };
|
|
279
|
+
},
|
|
280
|
+
commitContext: (context) => this.panel().setContext(context),
|
|
281
|
+
});
|
|
282
|
+
constructor() {
|
|
283
|
+
const destroyRef = inject(DestroyRef);
|
|
284
|
+
destroyRef.onDestroy(() => this.core.destroy());
|
|
285
|
+
effect(() => {
|
|
286
|
+
const open = this.isOpen();
|
|
287
|
+
untracked(() => this.core.syncOpenState(open));
|
|
288
|
+
});
|
|
289
|
+
// Hover routing: route submenu hover-intent edges through the core's
|
|
290
|
+
// focus stack, same primitives as keyboard/click (see CngxMenuTrigger).
|
|
291
|
+
connectSubmenuHoverToFocusStack({
|
|
292
|
+
focusStack: this.core.focusStack,
|
|
293
|
+
rootMenu: () => this.panel().menuHost,
|
|
294
|
+
rootOpen: () => this.isOpen(),
|
|
295
|
+
});
|
|
296
|
+
// 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();
|
|
305
|
+
effect((onCleanup) => {
|
|
306
|
+
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
|
+
});
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
handleContextMenu(event) {
|
|
323
|
+
this.core.handleContextMenu(event);
|
|
324
|
+
}
|
|
325
|
+
handleKeydown(event) {
|
|
326
|
+
this.core.handleKeydown(event);
|
|
327
|
+
}
|
|
328
|
+
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 });
|
|
330
|
+
}
|
|
331
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuFor, decorators: [{
|
|
332
|
+
type: Directive,
|
|
333
|
+
args: [{
|
|
334
|
+
selector: '[cngxContextMenuFor]',
|
|
335
|
+
exportAs: 'cngxContextMenuFor',
|
|
336
|
+
standalone: true,
|
|
337
|
+
host: {
|
|
338
|
+
'[attr.aria-haspopup]': '"menu"',
|
|
339
|
+
'[attr.aria-expanded]': 'isOpen()',
|
|
340
|
+
'(contextmenu)': 'handleContextMenu($event)',
|
|
341
|
+
'(keydown)': 'handleKeydown($event)',
|
|
342
|
+
},
|
|
343
|
+
}]
|
|
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 }] }] } });
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Build the popover-facade adapter the submenu brain (`CngxMenuItemSubmenu`)
|
|
348
|
+
* drives instead of a `[cngxMenuItemSubmenu]` popover input. Every member
|
|
349
|
+
* delegates to the target panel's own `CngxPopover`, reading `target()` lazily
|
|
350
|
+
* so the facade stays valid across `[submenu]` changes and inert (no visible,
|
|
351
|
+
* empty id) while the target is unbound. `show()` delegates to the supplied
|
|
352
|
+
* `open` routing rather than `popover.show()`, so opening goes through the
|
|
353
|
+
* trigger's focus stack (Pillar 1) instead of bypassing it.
|
|
354
|
+
*
|
|
355
|
+
* Internal decompose glue, not a consumer contract - NOT exported from
|
|
356
|
+
* `public-api.ts`. Extracting it keeps `CngxContextMenuItem`'s class body a
|
|
357
|
+
* thin shell (reference_atomic_decompose rule 1).
|
|
358
|
+
*
|
|
359
|
+
* @category ui/context-menu
|
|
360
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-item-submenu-facade.ts
|
|
361
|
+
* @since 0.1.0
|
|
362
|
+
*/
|
|
363
|
+
function createContextMenuItemSubmenuFacade(target, open) {
|
|
364
|
+
return {
|
|
365
|
+
isVisible: () => target()?.popover.isVisible() ?? false,
|
|
366
|
+
show: () => open(),
|
|
367
|
+
hide: () => target()?.popover.hide(),
|
|
368
|
+
anchorElement: { set: (el) => target()?.popover.anchorElement.set(el) },
|
|
369
|
+
id: () => target()?.popover.id() ?? '',
|
|
370
|
+
elementRef: {
|
|
371
|
+
get nativeElement() {
|
|
372
|
+
return target().popover.elementRef.nativeElement;
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Default single-character glyphs for the context-menu item skin. Plain
|
|
380
|
+
* `as const` (not `TemplateRef`, not a `Directive`) so the strings stay inline
|
|
381
|
+
* at their `aria-hidden` call sites and tree-shake when unused. Consolidates
|
|
382
|
+
* the trailing submenu caret and the checkbox / radio checked indicators into
|
|
383
|
+
* one source, mirroring `CNGX_SELECT_GLYPHS`.
|
|
384
|
+
*
|
|
385
|
+
* Internal to this organism: not exported from `public-api.ts`, not a consumer
|
|
386
|
+
* override surface (that tier stays deferred, menu-accepted-debt §2). Lives
|
|
387
|
+
* here rather than in `@cngx/common/interactive` because the base menu
|
|
388
|
+
* directives hardcode none of these glyphs, so the organism is the only
|
|
389
|
+
* consumer today; hoisting to the brain lib waits for a second menu consumer.
|
|
390
|
+
*
|
|
391
|
+
* @internal
|
|
392
|
+
*/
|
|
393
|
+
const CNGX_MENU_GLYPHS = {
|
|
394
|
+
/** Trailing caret on an item that opens a submenu. */
|
|
395
|
+
submenuCaret: '▸',
|
|
396
|
+
/** Leading indicator on a checked `menuitemcheckbox`. */
|
|
397
|
+
checkboxChecked: '✓',
|
|
398
|
+
/** Leading indicator on a checked `menuitemradio`. */
|
|
399
|
+
radioChecked: '●',
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* A single actionable context-menu item. Thin shell over `CngxMenuItem`: the
|
|
404
|
+
* brain owns `role="menuitem"`, the active-descendant registration, the
|
|
405
|
+
* keyboard/pointer activation and the disabled semantics. Dual selector, so it
|
|
406
|
+
* works both as an element and as an attribute on a native `<button>` (the
|
|
407
|
+
* `button[mat-menu-item]` precedent).
|
|
408
|
+
*
|
|
409
|
+
* Emits `select` when this item is activated by click or Enter/Space. Give
|
|
410
|
+
* each item a distinct `[value]` (forwarded to the brain) so pointer
|
|
411
|
+
* activation targets the right row - matching the base `CngxMenuItem`
|
|
412
|
+
* convention; a value-less item still works when it is the only item.
|
|
413
|
+
*
|
|
414
|
+
* ### Submenu
|
|
415
|
+
* Bind `[submenu]` to a sibling `<cngx-context-menu>` to open a nested menu.
|
|
416
|
+
* The `CngxMenuItemSubmenu` brain (a host directive here) is wired internally
|
|
417
|
+
* through `CNGX_MENU_SUBMENU_WIRING`, so the consumer needs no `[exclusive]`
|
|
418
|
+
* handgrip and no popover plumbing - just the sibling reference. The nested
|
|
419
|
+
* panel opens non-exclusively (the parent stays open) and inherits the parent
|
|
420
|
+
* panel's row context.
|
|
421
|
+
*
|
|
422
|
+
* ```html
|
|
423
|
+
* <cngx-context-menu-item value="copy" kbd="⌘C" (select)="copy()">Copy</cngx-context-menu-item>
|
|
424
|
+
* <button cngxContextMenuItem value="delete" [disabled]="locked()" (select)="remove()">Delete</button>
|
|
425
|
+
*
|
|
426
|
+
* <cngx-context-menu-item [submenu]="exportMenu">Export</cngx-context-menu-item>
|
|
427
|
+
* <cngx-context-menu #exportMenu ariaLabel="Export as">
|
|
428
|
+
* <cngx-context-menu-item (select)="export('pdf')">PDF</cngx-context-menu-item>
|
|
429
|
+
* </cngx-context-menu>
|
|
430
|
+
* ```
|
|
431
|
+
*
|
|
432
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/basic/static-items</example-url>
|
|
433
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/submenu/nested-export-menu</example-url>
|
|
434
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/attribute-form/native-buttons</example-url>
|
|
435
|
+
* @category ui/context-menu
|
|
436
|
+
* @wcag AA
|
|
437
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-item.component.ts
|
|
438
|
+
* @since 0.1.0
|
|
439
|
+
* @relatedTo CngxContextMenu, CngxContextMenuDivider, CngxMenuItem, CngxMenuItemSubmenu
|
|
440
|
+
*/
|
|
441
|
+
class CngxContextMenuItem {
|
|
442
|
+
/**
|
|
443
|
+
* Leading glyph shorthand rendered in the icon slot (decorative,
|
|
444
|
+
* `aria-hidden`). A convenience for single-character icons; suppressed when
|
|
445
|
+
* the consumer projects a richer `[cngxMenuItemIcon]` marker (SVG / icon
|
|
446
|
+
* component), which wins.
|
|
447
|
+
*/
|
|
448
|
+
icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
449
|
+
/**
|
|
450
|
+
* A consumer-projected `[cngxMenuItemIcon]` marker, when present. Gates the
|
|
451
|
+
* string `[icon]` shorthand off so the projected icon is the only one drawn.
|
|
452
|
+
*/
|
|
453
|
+
projectedIcon = contentChild(CngxMenuItemIcon, ...(ngDevMode ? [{ debugName: "projectedIcon" }] : /* istanbul ignore next */ []));
|
|
454
|
+
/** Keyboard-shortcut hint rendered in the kbd slot (decorative). */
|
|
455
|
+
kbd = input(...(ngDevMode ? [undefined, { debugName: "kbd" }] : /* istanbul ignore next */ []));
|
|
456
|
+
/**
|
|
457
|
+
* Sibling `<cngx-context-menu>` opened as a nested submenu. When set, the
|
|
458
|
+
* item renders a caret, gains `aria-haspopup="menu"` (from the submenu
|
|
459
|
+
* brain) and routes ArrowRight/ArrowLeft into the nested panel.
|
|
460
|
+
*/
|
|
461
|
+
submenu = input(...(ngDevMode ? [undefined, { debugName: "submenu" }] : /* istanbul ignore next */ []));
|
|
462
|
+
/** Fires when this item is activated by click or Enter/Space. */
|
|
463
|
+
select = output();
|
|
464
|
+
/** @internal Decorative caret rendered while `submenu` is set. RTL flip is
|
|
465
|
+
* a CSS concern (`.cngx-menu-item__suffix` under `[dir='rtl']`), not a
|
|
466
|
+
* swapped glyph. */
|
|
467
|
+
caret = CNGX_MENU_GLYPHS.submenuCaret;
|
|
468
|
+
parentPanel = inject(CNGX_CONTEXT_MENU_PANEL, { optional: true });
|
|
469
|
+
/**
|
|
470
|
+
* Facade the submenu brain drives instead of a `[cngxMenuItemSubmenu]`
|
|
471
|
+
* input. `show()` opens the target panel non-exclusively and mirrors the
|
|
472
|
+
* parent panel's row context in first; every other member delegates to the
|
|
473
|
+
* target's `CngxPopover`. Built once, reads `submenu()` lazily so it stays
|
|
474
|
+
* valid across target changes. The adapter itself lives in
|
|
475
|
+
* `createContextMenuItemSubmenuFacade` so this class stays a thin shell.
|
|
476
|
+
*/
|
|
477
|
+
submenuPopoverFacade = createContextMenuItemSubmenuFacade(() => this.submenu(), () => this.openSubmenu());
|
|
478
|
+
constructor() {
|
|
479
|
+
const brain = inject(CngxMenuItem);
|
|
480
|
+
const ad = inject(CngxActiveDescendant, { optional: true });
|
|
481
|
+
if (!ad) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
// Activation flows through the surrounding CngxActiveDescendant (click and
|
|
485
|
+
// keyboard both funnel into activateCurrent). Filter to this item's brain
|
|
486
|
+
// id so only the activated row emits - the same identity CngxMenu uses. A
|
|
487
|
+
// submenu parent never emits a leaf action: activating it opens the submenu
|
|
488
|
+
// (the panel routes `activated` to the trigger core), so gate on
|
|
489
|
+
// `!submenu()` to keep leaf `select` from firing on a parent.
|
|
490
|
+
outputToObservable(ad.activated)
|
|
491
|
+
.pipe(takeUntilDestroyed())
|
|
492
|
+
.subscribe(() => {
|
|
493
|
+
if (ad.activeId() === brain.id && !this.submenu()) {
|
|
494
|
+
this.select.emit();
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
/** @internal `CngxMenuSubmenuWiring` - the nested panel's menu brain, or
|
|
499
|
+
* `undefined` while no `[submenu]` is bound so the brain stays inert. */
|
|
500
|
+
menu() {
|
|
501
|
+
return this.submenu()?.menuHost;
|
|
502
|
+
}
|
|
503
|
+
/** @internal `CngxMenuSubmenuWiring` - the popover facade the brain drives,
|
|
504
|
+
* or `undefined` while no `[submenu]` is bound so the brain stays inert. */
|
|
505
|
+
popover() {
|
|
506
|
+
return this.submenu() ? this.submenuPopoverFacade : undefined;
|
|
507
|
+
}
|
|
508
|
+
openSubmenu() {
|
|
509
|
+
const target = this.submenu();
|
|
510
|
+
if (!target) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
// Delegate the whole submenu-open policy - inline-end placement, flip chain,
|
|
514
|
+
// non-exclusive open, parent-datum mirror - to the panel. The item drives
|
|
515
|
+
// one seam instead of reaching into the popover's override signals, so an
|
|
516
|
+
// ejected item skin never carries CngxPopover internals (decompose).
|
|
517
|
+
target.openAsSubmenu(this.parentPanel?.context() ?? null);
|
|
518
|
+
// openAsSubmenu is the terminal for every open path (hover, keyboard,
|
|
519
|
+
// click all funnel here through the trigger's focus stack). The note is
|
|
520
|
+
// the safety net for opens the stack did not perform itself
|
|
521
|
+
// (programmatic openAsSubmenu); for stack-driven opens it is an
|
|
522
|
+
// idempotent no-op. Push-only - it never re-enters the open path, so no
|
|
523
|
+
// recursion; the stack stays the single source of the active chain
|
|
524
|
+
// (Pillar 1).
|
|
525
|
+
this.parentPanel?.noteActiveSubmenuOpened?.();
|
|
526
|
+
}
|
|
527
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
528
|
+
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: `
|
|
529
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
530
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
531
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
532
|
+
}
|
|
533
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
534
|
+
@if (kbd(); as shortcut) {
|
|
535
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
536
|
+
}
|
|
537
|
+
@if (submenu()) {
|
|
538
|
+
<span cngxMenuItemSuffix>{{ caret }}</span>
|
|
539
|
+
}
|
|
540
|
+
`, 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 });
|
|
541
|
+
}
|
|
542
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItem, decorators: [{
|
|
543
|
+
type: Component,
|
|
544
|
+
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: [
|
|
545
|
+
{ directive: CngxMenuItem, inputs: ['disabled', 'value'] },
|
|
546
|
+
CngxMenuItemSubmenu,
|
|
547
|
+
], template: `
|
|
548
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
549
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
550
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
551
|
+
}
|
|
552
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
553
|
+
@if (kbd(); as shortcut) {
|
|
554
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
555
|
+
}
|
|
556
|
+
@if (submenu()) {
|
|
557
|
+
<span cngxMenuItemSuffix>{{ caret }}</span>
|
|
558
|
+
}
|
|
559
|
+
`, 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"] }]
|
|
560
|
+
}], 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"] }] } });
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Non-interactive separator between context-menu item groups. Thin shell over
|
|
564
|
+
* `CngxMenuSeparator` (`role="separator"`, `aria-orientation="horizontal"`),
|
|
565
|
+
* skipped by active-descendant navigation and typeahead. Dual selector: use as
|
|
566
|
+
* an element or as an attribute on a native `<hr>`.
|
|
567
|
+
*
|
|
568
|
+
* ```html
|
|
569
|
+
* <cngx-context-menu-divider />
|
|
570
|
+
* <hr cngxContextMenuDivider />
|
|
571
|
+
* ```
|
|
572
|
+
*
|
|
573
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/basic/static-items</example-url>
|
|
574
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/attribute-form/native-buttons</example-url>
|
|
575
|
+
* @category ui/context-menu
|
|
576
|
+
* @wcag AA
|
|
577
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-divider.component.ts
|
|
578
|
+
* @since 0.1.0
|
|
579
|
+
* @relatedTo CngxContextMenu, CngxContextMenuItem, CngxMenuSeparator
|
|
580
|
+
*/
|
|
581
|
+
class CngxContextMenuDivider {
|
|
582
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuDivider, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
583
|
+
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 });
|
|
584
|
+
}
|
|
585
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuDivider, decorators: [{
|
|
586
|
+
type: Component,
|
|
587
|
+
args: [{
|
|
588
|
+
selector: 'cngx-context-menu-divider, hr[cngxContextMenuDivider]',
|
|
589
|
+
standalone: true,
|
|
590
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
591
|
+
encapsulation: ViewEncapsulation.None,
|
|
592
|
+
exportAs: 'cngxContextMenuDivider',
|
|
593
|
+
hostDirectives: [CngxMenuSeparator],
|
|
594
|
+
template: '',
|
|
595
|
+
}]
|
|
596
|
+
}] });
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* A checkable context-menu item (`role="menuitemcheckbox"`). Thin shell over
|
|
600
|
+
* `CngxMenuItemCheckbox`: the brain owns the role, the active-descendant
|
|
601
|
+
* registration, the toggle-on-activation semantics and the reactive
|
|
602
|
+
* `aria-checked`. `checked` is a two-way model forwarded through the host
|
|
603
|
+
* directive, so `[(checked)]` binds straight to consumer state.
|
|
604
|
+
*
|
|
605
|
+
* ```html
|
|
606
|
+
* <cngx-context-menu-item-checkbox [(checked)]="wrap">Word wrap</cngx-context-menu-item-checkbox>
|
|
607
|
+
* ```
|
|
608
|
+
*
|
|
609
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/selection/checkbox-radio-items</example-url>
|
|
610
|
+
* @category ui/context-menu
|
|
611
|
+
* @wcag AA
|
|
612
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-item-checkbox.component.ts
|
|
613
|
+
* @since 0.1.0
|
|
614
|
+
* @relatedTo CngxContextMenu, CngxContextMenuItem, CngxContextMenuItemRadio, CngxMenuItemCheckbox
|
|
615
|
+
*/
|
|
616
|
+
class CngxContextMenuItemCheckbox {
|
|
617
|
+
/**
|
|
618
|
+
* Leading glyph shorthand rendered in the icon slot (decorative,
|
|
619
|
+
* `aria-hidden`). Suppressed when the consumer projects a richer
|
|
620
|
+
* `[cngxMenuItemIcon]` marker. The checked-indicator gutter renders
|
|
621
|
+
* independently of the icon, so a checked item stays visibly checked beside
|
|
622
|
+
* a custom icon.
|
|
623
|
+
*/
|
|
624
|
+
icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
625
|
+
/** Keyboard-shortcut hint rendered in the kbd slot (decorative). */
|
|
626
|
+
kbd = input(...(ngDevMode ? [undefined, { debugName: "kbd" }] : /* istanbul ignore next */ []));
|
|
627
|
+
/**
|
|
628
|
+
* A consumer-projected `[cngxMenuItemIcon]` marker, when present. Gates the
|
|
629
|
+
* string `[icon]` shorthand off so the projected icon is the only one drawn.
|
|
630
|
+
*/
|
|
631
|
+
projectedIcon = contentChild(CngxMenuItemIcon, ...(ngDevMode ? [{ debugName: "projectedIcon" }] : /* istanbul ignore next */ []));
|
|
632
|
+
/** @internal Seeds the CSS `content` of the default checked indicator from
|
|
633
|
+
* the shared glyph const (CSS-string quoted for `content:`). */
|
|
634
|
+
checkGlyph = `'${CNGX_MENU_GLYPHS.checkboxChecked}'`;
|
|
635
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItemCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
636
|
+
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: `
|
|
637
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
638
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
639
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
640
|
+
}
|
|
641
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
642
|
+
@if (kbd(); as shortcut) {
|
|
643
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
644
|
+
}
|
|
645
|
+
`, 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 });
|
|
646
|
+
}
|
|
647
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItemCheckbox, decorators: [{
|
|
648
|
+
type: Component,
|
|
649
|
+
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: [
|
|
650
|
+
{
|
|
651
|
+
directive: CngxMenuItemCheckbox,
|
|
652
|
+
inputs: ['disabled', 'value', 'checked', 'label'],
|
|
653
|
+
outputs: ['checkedChange'],
|
|
654
|
+
},
|
|
655
|
+
], template: `
|
|
656
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
657
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
658
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
659
|
+
}
|
|
660
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
661
|
+
@if (kbd(); as shortcut) {
|
|
662
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
663
|
+
}
|
|
664
|
+
`, 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"] }]
|
|
665
|
+
}], 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 }] }] } });
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* A radio-style context-menu item (`role="menuitemradio"`). Thin shell over
|
|
669
|
+
* `CngxMenuItemRadio`: the brain owns the role, the active-descendant
|
|
670
|
+
* registration and the reactive `aria-checked`. Mutual exclusion is scoped to
|
|
671
|
+
* the enclosing `[cngxMenuGroup]` - the group owns the selected value, the
|
|
672
|
+
* item forwards its `value`.
|
|
673
|
+
*
|
|
674
|
+
* ```html
|
|
675
|
+
* <div cngxMenuGroup label="Density" [(selectedValue)]="density">
|
|
676
|
+
* <cngx-context-menu-item-radio value="cozy">Cozy</cngx-context-menu-item-radio>
|
|
677
|
+
* <cngx-context-menu-item-radio value="compact">Compact</cngx-context-menu-item-radio>
|
|
678
|
+
* </div>
|
|
679
|
+
* ```
|
|
680
|
+
*
|
|
681
|
+
* <example-url>http://localhost:4200/#/ui/context-menu/selection/checkbox-radio-items</example-url>
|
|
682
|
+
* @category ui/context-menu
|
|
683
|
+
* @wcag AA
|
|
684
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/context-menu/context-menu-item-radio.component.ts
|
|
685
|
+
* @since 0.1.0
|
|
686
|
+
* @relatedTo CngxContextMenu, CngxContextMenuItem, CngxContextMenuItemCheckbox, CngxMenuItemRadio, CngxMenuGroup
|
|
687
|
+
*/
|
|
688
|
+
class CngxContextMenuItemRadio {
|
|
689
|
+
/**
|
|
690
|
+
* Leading glyph shorthand rendered in the icon slot (decorative,
|
|
691
|
+
* `aria-hidden`). Suppressed when the consumer projects a richer
|
|
692
|
+
* `[cngxMenuItemIcon]` marker. The checked-indicator gutter renders
|
|
693
|
+
* independently of the icon, so a checked item stays visibly checked beside
|
|
694
|
+
* a custom icon.
|
|
695
|
+
*/
|
|
696
|
+
icon = input(...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
697
|
+
/** Keyboard-shortcut hint rendered in the kbd slot (decorative). */
|
|
698
|
+
kbd = input(...(ngDevMode ? [undefined, { debugName: "kbd" }] : /* istanbul ignore next */ []));
|
|
699
|
+
/**
|
|
700
|
+
* A consumer-projected `[cngxMenuItemIcon]` marker, when present. Gates the
|
|
701
|
+
* string `[icon]` shorthand off so the projected icon is the only one drawn.
|
|
702
|
+
*/
|
|
703
|
+
projectedIcon = contentChild(CngxMenuItemIcon, ...(ngDevMode ? [{ debugName: "projectedIcon" }] : /* istanbul ignore next */ []));
|
|
704
|
+
/** @internal Seeds the CSS `content` of the default checked indicator from
|
|
705
|
+
* the shared glyph const (CSS-string quoted for `content:`). */
|
|
706
|
+
checkGlyph = `'${CNGX_MENU_GLYPHS.radioChecked}'`;
|
|
707
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItemRadio, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
708
|
+
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: `
|
|
709
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
710
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
711
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
712
|
+
}
|
|
713
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
714
|
+
@if (kbd(); as shortcut) {
|
|
715
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
716
|
+
}
|
|
717
|
+
`, 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 });
|
|
718
|
+
}
|
|
719
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxContextMenuItemRadio, decorators: [{
|
|
720
|
+
type: Component,
|
|
721
|
+
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: `
|
|
722
|
+
<ng-content select="[cngxMenuItemIcon]" />
|
|
723
|
+
@if (!projectedIcon() && icon(); as glyph) {
|
|
724
|
+
<span cngxMenuItemIcon>{{ glyph }}</span>
|
|
725
|
+
}
|
|
726
|
+
<span cngxMenuItemLabel><ng-content /></span>
|
|
727
|
+
@if (kbd(); as shortcut) {
|
|
728
|
+
<span cngxMenuItemKbd>{{ shortcut }}</span>
|
|
729
|
+
}
|
|
730
|
+
`, 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"] }]
|
|
731
|
+
}], 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 }] }] } });
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* @module @cngx/ui/context-menu
|
|
735
|
+
*/
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Generated bundle index. Do not edit.
|
|
739
|
+
*/
|
|
740
|
+
|
|
741
|
+
export { CngxContextMenu, CngxContextMenuContent, CngxContextMenuDivider, CngxContextMenuFor, CngxContextMenuItem, CngxContextMenuItemCheckbox, CngxContextMenuItemRadio };
|
|
742
|
+
//# sourceMappingURL=cngx-ui-context-menu.mjs.map
|