@cngx/common 0.1.0-rc.8 → 0.3.0
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/a11y/README.md +15 -2
- package/button/README.md +258 -0
- package/command/README.md +42 -2
- package/data/README.md +15 -12
- package/fesm2022/cngx-common-a11y.mjs +1076 -319
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +99 -77
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-button.mjs +1084 -0
- package/fesm2022/cngx-common-button.mjs.map +1 -0
- package/fesm2022/cngx-common-card.mjs +138 -78
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +799 -327
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +101 -25
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +861 -423
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +198 -160
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +693 -329
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +7303 -2774
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +2174 -442
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-menu-button.mjs +557 -0
- package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
- package/fesm2022/cngx-common-popover.mjs +2109 -557
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +548 -419
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +442 -331
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +44 -71
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +10 -10
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +30 -19
- package/layout/README.md +17 -1
- package/menu-button/README.md +234 -0
- package/package.json +31 -8
- package/popover/README.md +81 -4
- package/popover/tooltip-indicator.scss +52 -0
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +96 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +5 -5
- package/theming/components/cngx-accordion.css +36 -7
- package/theming/components/cngx-async.css +185 -37
- package/theming/components/cngx-backdrop.css +3 -1
- package/theming/components/cngx-badge.css +20 -5
- package/theming/components/cngx-bottom-sheet.css +2 -0
- package/theming/components/cngx-breadcrumb.css +3 -1
- package/theming/components/cngx-button-group.css +325 -0
- package/theming/components/cngx-button-toggle.css +55 -23
- package/theming/components/cngx-button.css +975 -0
- package/theming/components/cngx-data-grid.css +2 -0
- package/theming/components/cngx-dialog.css +3 -1
- package/theming/components/cngx-divider.css +24 -9
- package/theming/components/cngx-drawer.css +153 -0
- package/theming/components/cngx-icon-glyph.css +76 -0
- package/theming/components/cngx-listbox.css +79 -25
- package/theming/components/cngx-menu.css +112 -52
- package/theming/components/cngx-nav.css +1220 -0
- package/theming/components/cngx-popover-sheet.css +434 -0
- package/theming/components/cngx-popover.css +37 -9
- package/theming/components/cngx-recycler-placeholder.css +2 -0
- package/theming/components/cngx-ripple.css +74 -16
- package/theming/components/cngx-sidebar.css +71 -0
- package/theming/components/cngx-slider.css +3 -1
- package/theming/components/cngx-tooltip.css +2 -0
- package/timeline/README.md +2 -2
- package/types/cngx-common-a11y.d.ts +488 -112
- package/types/cngx-common-audio.d.ts +60 -88
- package/types/cngx-common-button.d.ts +698 -0
- package/types/cngx-common-card.d.ts +104 -78
- package/types/cngx-common-chart.d.ts +677 -389
- package/types/cngx-common-command.d.ts +55 -41
- package/types/cngx-common-data.d.ts +506 -360
- package/types/cngx-common-dialog.d.ts +94 -127
- package/types/cngx-common-display.d.ts +475 -300
- package/types/cngx-common-interactive.d.ts +4383 -1721
- package/types/cngx-common-layout.d.ts +1399 -288
- package/types/cngx-common-menu-button.d.ts +382 -0
- package/types/cngx-common-popover.d.ts +990 -268
- package/types/cngx-common-stepper.d.ts +374 -465
- package/types/cngx-common-tabs.d.ts +309 -403
- package/types/cngx-common-timeline.d.ts +50 -109
package/layout/README.md
CHANGED
|
@@ -132,7 +132,7 @@ Manages text truncation with expand/collapse state detection. Applies `-webkit-l
|
|
|
132
132
|
|
|
133
133
|
## injectQueryParamSync
|
|
134
134
|
|
|
135
|
-
Bidirectional sync between a caller-owned `WritableSignal<T>` and a named URL query param. The URL wins on initial load (deep-link / shareable-link intent)
|
|
135
|
+
Bidirectional sync between a caller-owned `WritableSignal<T>` and a named URL query param. The URL wins on initial load (deep-link / shareable-link intent): the hydrate happens on the first effect run, before the caller's view first renders, not synchronously in the call, so a key bound through an input is read after binding. After that the signal is the source and reflects outward. Re-hydrates on browser back/forward, dev-warns once and no-ops when `@angular/router` is absent.
|
|
136
136
|
|
|
137
137
|
Call it in an injection context (a component field/constructor, a directive) on a signal you own:
|
|
138
138
|
|
|
@@ -168,6 +168,22 @@ injectQueryParamSync(this.tab, {
|
|
|
168
168
|
- `onSyncError(err)` receives `router.navigate` rejections - no silent failures.
|
|
169
169
|
- Returns `void`; it wires effects on the caller's signal and tears them down with the injection context.
|
|
170
170
|
|
|
171
|
+
## createPinnedScrollLock
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
const release = createPinnedScrollLock(document.documentElement);
|
|
175
|
+
// ... bottom sheet open ...
|
|
176
|
+
release();
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Ref-counted scroll lock for overlays pinned to the bottom of the viewport. `createScrollLock` sets `overflow: hidden` on the root, which iOS Safari ignores once the page is scrolled: the page keeps scrolling and the visual viewport drifts, so a bottom-fixed sheet ends above the visible bottom. The pinned lock also fixes `body` at `top: -scrollY` and scrolls back to the saved position on the last release.
|
|
180
|
+
|
|
181
|
+
### Notes
|
|
182
|
+
|
|
183
|
+
- Shares the root overflow count with `createScrollLock`, so interleaved owners never restore each other's styles.
|
|
184
|
+
- The release function is idempotent.
|
|
185
|
+
- `CngxDialog` and `CngxScrollLock` keep `createScrollLock`.
|
|
186
|
+
|
|
171
187
|
## Other Exports
|
|
172
188
|
|
|
173
189
|
`CngxIntersectionObserver`, `CngxResizeObserver`, `CngxScrollLock`, `CngxBackdrop`,
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# @cngx/common/menu-button
|
|
2
|
+
|
|
3
|
+
Buttons that open a menu, after the WAI-ARIA APG Menu Button Pattern. The entry composes
|
|
4
|
+
`@cngx/common/button`, `@cngx/common/interactive` and `@cngx/common/popover` into three button
|
|
5
|
+
types:
|
|
6
|
+
|
|
7
|
+
- `button[cngxMenuButton]`: a `cngxButton` with an end caret that opens a `cngxMenu` in a
|
|
8
|
+
`cngxPopover`.
|
|
9
|
+
- `button[cngxIconMenuButton]`: the square, icon-only kebab or "more" button.
|
|
10
|
+
- `[cngxSplitButton]`: a main action and a caret that opens the alternatives, framed as one
|
|
11
|
+
button group.
|
|
12
|
+
|
|
13
|
+
All three render on `CngxButtonBrain`. Variant, tone, size, group, `disabled` with a reason and
|
|
14
|
+
the busy layer work as on `cngxButton`; see the [`@cngx/common/button` README](../button/README.md).
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { Component, signal } from '@angular/core';
|
|
20
|
+
import { CngxMenu, CngxMenuItem } from '@cngx/common/interactive';
|
|
21
|
+
import { CngxMenuButton } from '@cngx/common/menu-button';
|
|
22
|
+
import { CngxPopover } from '@cngx/common/popover';
|
|
23
|
+
|
|
24
|
+
@Component({
|
|
25
|
+
selector: 'app-export',
|
|
26
|
+
imports: [CngxMenu, CngxMenuItem, CngxMenuButton, CngxPopover],
|
|
27
|
+
template: `
|
|
28
|
+
<button cngxMenuButton="outline" [menu]="menu" [popover]="pop">Export</button>
|
|
29
|
+
<div cngxPopover placement="bottom-start" #pop="cngxPopover">
|
|
30
|
+
<ul cngxMenu label="Export format" (itemActivated)="format.set($event)" #menu="cngxMenu">
|
|
31
|
+
<li cngxMenuItem value="pdf">PDF</li>
|
|
32
|
+
<li cngxMenuItem value="csv">CSV</li>
|
|
33
|
+
</ul>
|
|
34
|
+
</div>
|
|
35
|
+
`,
|
|
36
|
+
})
|
|
37
|
+
export class AppExport {
|
|
38
|
+
readonly format = signal<unknown>(null);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Menu button
|
|
43
|
+
|
|
44
|
+
`[menu]` takes the `cngxMenu` and `[popover]` the `cngxPopover` around it. The button carries
|
|
45
|
+
`CngxMenuTrigger` and `CngxPopoverTrigger` as host directives and toggles the popover on click.
|
|
46
|
+
|
|
47
|
+
`aria-haspopup` reads `menu` and `aria-controls` names the `role="menu"` element, without a
|
|
48
|
+
`[haspopup]` binding. A popover presented as a sheet or fullscreen reads `dialog` and names the
|
|
49
|
+
popover instead.
|
|
50
|
+
|
|
51
|
+
- ArrowDown, Enter or Space opens the menu on the first item, ArrowUp on the last.
|
|
52
|
+
- Focus moves into the menu, which tracks the highlighted item with `aria-activedescendant`.
|
|
53
|
+
- Escape or an activation closes the menu and returns focus to the button.
|
|
54
|
+
- Tab and Shift+Tab close it and leave focus where it went.
|
|
55
|
+
|
|
56
|
+
`expanded()` mirrors the popover's visibility, and the host carries `data-expanded`.
|
|
57
|
+
|
|
58
|
+
A disabled menu button opens on neither click nor key, and an open menu closes when the button
|
|
59
|
+
becomes disabled. The menu button has no action of its own, since a click opens the menu. Put
|
|
60
|
+
async work on the menu items, not on a `cngxAsyncClick` co-hosted on the button.
|
|
61
|
+
|
|
62
|
+
A projected `cngxButtonStart` element leads the label, as on `cngxButton`.
|
|
63
|
+
|
|
64
|
+
## Caret
|
|
65
|
+
|
|
66
|
+
The end of the button renders the `CNGX_ICON_CHEVRON_DOWN` chevron at `1em` of the button font,
|
|
67
|
+
turned half a turn while the menu is open. It is decorative and hidden from assistive
|
|
68
|
+
technology.
|
|
69
|
+
|
|
70
|
+
- `--cngx-menu-button-caret-size` sizes it.
|
|
71
|
+
- The turn takes `--cngx-button-transition` and is instant under reduced motion.
|
|
72
|
+
- `provideButtonCaretIcon(MyCaret)` swaps the glyph for every menu button and split caret below
|
|
73
|
+
the provider, in `providers` or `viewProviders`. A custom host reads it with
|
|
74
|
+
`injectButtonCaretIcon()`.
|
|
75
|
+
- A projected `cngxButtonEnd` element replaces the caret on one button.
|
|
76
|
+
|
|
77
|
+
## Icon menu button
|
|
78
|
+
|
|
79
|
+
`button[cngxIconMenuButton]` has the bindings and keyboard model of `cngxMenuButton` on the
|
|
80
|
+
icon-button skin: square, `ghost` by default, no caret. It renders the glyph you project.
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<button cngxIconMenuButton aria-label="Actions for Q3 report" [menu]="menu" [popover]="pop">
|
|
84
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="currentColor">
|
|
85
|
+
<circle cx="12" cy="5" r="2" /><circle cx="12" cy="12" r="2" /><circle cx="12" cy="19" r="2" />
|
|
86
|
+
</svg>
|
|
87
|
+
</button>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Name the button after what the menu acts on, not after the glyph. Without `aria-label`,
|
|
91
|
+
`aria-labelledby` or `title` it warns [`CNGX1071`](../../../core-concepts/error-codes/cngx1071.md)
|
|
92
|
+
in development.
|
|
93
|
+
|
|
94
|
+
## Split button
|
|
95
|
+
|
|
96
|
+
`[cngxSplitButton]` frames a main button that runs the default action and a
|
|
97
|
+
`cngxIconMenuButton` caret that opens the alternatives. It is a button group with
|
|
98
|
+
`role="group"`: `variant` and `size` pass to both buttons, and the group needs a name
|
|
99
|
+
([`CNGX1072`](../../../core-concepts/error-codes/cngx1072.md)).
|
|
100
|
+
|
|
101
|
+
```html
|
|
102
|
+
<div cngxSplitButton variant="solid" aria-label="Publish">
|
|
103
|
+
<button cngxButton [cngxAsyncClick]="publish">Publish</button>
|
|
104
|
+
<button cngxIconMenuButton [menu]="menu" [popover]="pop"></button>
|
|
105
|
+
</div>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The split finds its two roles among its direct children. An `ng-container` in between is fine.
|
|
109
|
+
|
|
110
|
+
- The caret is the child that carries `CngxSplitCaret`, as `cngxIconMenuButton` does.
|
|
111
|
+
- The main action is the first other cngx button: `cngxButton`, `cngxIconButton`,
|
|
112
|
+
`cngxActionButton` or a custom host on `CngxButtonBrain`. The split reads it through
|
|
113
|
+
`CNGX_BUTTON_STATE`.
|
|
114
|
+
- Without a main button the split warns
|
|
115
|
+
[`CNGX1073`](../../../core-concepts/error-codes/cngx1073.md).
|
|
116
|
+
- A button deeper inside, for example a kebab in a projected panel, takes neither role and
|
|
117
|
+
keeps its own name and state.
|
|
118
|
+
|
|
119
|
+
The caret follows the main action. While the main button is disabled, running or refused by
|
|
120
|
+
`[enabled]="false"`, the caret reads `aria-disabled`, opens on neither click nor key, and an
|
|
121
|
+
open menu closes. Its `aria-describedby` names the cause: the main button's reason, or "The main
|
|
122
|
+
action is running" while the main action runs. The main button keeps `aria-busy` and the
|
|
123
|
+
announcement. `[disabled]` on the caret blocks only the alternatives and reads the caret's own
|
|
124
|
+
`disabledReason`.
|
|
125
|
+
|
|
126
|
+
The caret needs no glyph and no name. Inside a split it renders the caret in place of any
|
|
127
|
+
projected content, named "More options" by visually hidden text. An `aria-label` on the caret
|
|
128
|
+
wins, and the caret never writes one itself. Both strings come from the language pack (see
|
|
129
|
+
[Configuration](#configuration)).
|
|
130
|
+
|
|
131
|
+
The caret's menu hangs under the whole group, not under the caret. The split takes the explicit
|
|
132
|
+
anchor slot of the caret's popover while it is free, so a `[cngxPopoverAnchor]` of your own on
|
|
133
|
+
that popover keeps precedence. A pointerdown on the main button still closes an open menu.
|
|
134
|
+
|
|
135
|
+
The split has no run method. To run a menu choice through the main action, click the main
|
|
136
|
+
button from the menu's `(itemActivated)` handler, so the busy state and the announcement stay in
|
|
137
|
+
one place. Bind `succeededAnnouncement` and `failedAnnouncement` on its `cngxAsyncClick` to name
|
|
138
|
+
the chosen action.
|
|
139
|
+
|
|
140
|
+
### Custom caret host
|
|
141
|
+
|
|
142
|
+
`CngxSplitCaret` is the caret role as a host directive. Declare it on a
|
|
143
|
+
[custom button host](../button/README.md#building-a-custom-button-host), next to
|
|
144
|
+
`CngxMenuTrigger` and `CngxPopoverTrigger`. As a direct child of a split the host becomes the
|
|
145
|
+
caret, anywhere else it stays an ordinary button. The split hangs the menu under the group only
|
|
146
|
+
when the host co-hosts `CngxPopoverTrigger`, since it reads the caret's popover through it.
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import { Component, inject } from '@angular/core';
|
|
150
|
+
import { CngxButtonBrain, provideButtonHost } from '@cngx/common/button';
|
|
151
|
+
import { CngxMenuTrigger } from '@cngx/common/interactive';
|
|
152
|
+
import { CngxSplitCaret } from '@cngx/common/menu-button';
|
|
153
|
+
import { CngxPopoverTrigger } from '@cngx/common/popover';
|
|
154
|
+
|
|
155
|
+
@Component({
|
|
156
|
+
selector: 'button[appCaret]',
|
|
157
|
+
hostDirectives: [
|
|
158
|
+
{ directive: CngxButtonBrain, inputs: ['variant: appCaret', 'disabled', 'disabledReason'] },
|
|
159
|
+
{ directive: CngxMenuTrigger, inputs: ['cngxMenuTrigger: menu', 'popover'] },
|
|
160
|
+
{ directive: CngxPopoverTrigger, inputs: ['cngxPopoverTrigger: popover'] },
|
|
161
|
+
CngxSplitCaret,
|
|
162
|
+
],
|
|
163
|
+
providers: [provideButtonHost('appCaret', { defaultVariant: 'solid', iconOnly: true })],
|
|
164
|
+
host: { '(click)': 'handleClick()' },
|
|
165
|
+
template: `
|
|
166
|
+
<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z" /></svg>
|
|
167
|
+
@if (caret.isCaret()) {
|
|
168
|
+
<span class="cngx-sr-only">{{ caret.label() }}</span>
|
|
169
|
+
<span [id]="caret.busyNoteId" hidden>{{ caret.busyNote() }}</span>
|
|
170
|
+
}
|
|
171
|
+
`,
|
|
172
|
+
})
|
|
173
|
+
export class AppCaret {
|
|
174
|
+
protected readonly caret = inject(CngxSplitCaret);
|
|
175
|
+
private readonly brain = inject(CngxButtonBrain);
|
|
176
|
+
private readonly popover = inject(CngxPopoverTrigger);
|
|
177
|
+
|
|
178
|
+
protected handleClick(): void {
|
|
179
|
+
if (this.brain.blocked()) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
this.popover.popoverRef().toggle();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The directive hands the refusal to the brain as `CNGX_BUTTON_HOST_STATE` and adds the cause to
|
|
188
|
+
`aria-describedby`. A host that provides `CNGX_BUTTON_HOST_STATE` itself replaces that entry and
|
|
189
|
+
folds `caret.refusing()` into its own state.
|
|
190
|
+
|
|
191
|
+
## Configuration
|
|
192
|
+
|
|
193
|
+
Each concern has one provider, and each works in `providers` and `viewProviders`:
|
|
194
|
+
|
|
195
|
+
| Concern | Provider |
|
|
196
|
+
|-|-|
|
|
197
|
+
| Caret glyph | `provideButtonCaretIcon(MyCaret)` |
|
|
198
|
+
| Copy | `provideMenuButtonI18n(withMenuButtonI18nLabels({ ... }))` |
|
|
199
|
+
|
|
200
|
+
Button-wide defaults, the close glyph and the busy glyph have their own providers in
|
|
201
|
+
`@cngx/common/button`.
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
providers: [
|
|
205
|
+
provideButtonCaretIcon(MyCaret),
|
|
206
|
+
provideMenuButtonI18n(withMenuButtonI18nLabels({ splitToggle: 'More actions' })),
|
|
207
|
+
];
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The labels are the `menuButton` section of the [language pack](../../../core-concepts/i18n.md):
|
|
211
|
+
`splitToggle` names the split caret and `splitMainBusy` describes it while the main action runs.
|
|
212
|
+
`provideMenuButtonI18n(withMenuButtonI18nLabels({ ... }))` overrides single keys on a subtree,
|
|
213
|
+
and a `Signal` passed to `withMenuButtonI18nLabels` follows a runtime language switch. A nested
|
|
214
|
+
provider starts again from the language pack instead of merging onto the outer one, so it repeats
|
|
215
|
+
every outer override it still needs; a runtime language switch reaches the menu buttons below it
|
|
216
|
+
only through that nested provider.
|
|
217
|
+
|
|
218
|
+
## Material
|
|
219
|
+
|
|
220
|
+
`@cngx/themes/material/button-theme` renders menu buttons and split buttons as Material 3 next
|
|
221
|
+
to `[matMenuTriggerFor]`. The split takes the M3 split-button anatomy, which Angular Material
|
|
222
|
+
does not ship. `@cngx/themes/material/menu-theme` makes the `cngxMenu` dropdown read like
|
|
223
|
+
`mat-menu`. The `common/menu-button/menu-button/material-bridge` example shows both.
|
|
224
|
+
|
|
225
|
+
## Not a menu
|
|
226
|
+
|
|
227
|
+
A menu holds actions. Pick another trigger for anything else:
|
|
228
|
+
|
|
229
|
+
- Navigation links behind a button: a popover disclosure, `cngxButton` with
|
|
230
|
+
`cngxPopoverTrigger` and `haspopup="none"`.
|
|
231
|
+
- Content that opens in place: `cngxDisclosure`.
|
|
232
|
+
- A control whose label shows the chosen value: `cngxSelect`.
|
|
233
|
+
|
|
234
|
+
The full decision table is in [Choosing a Trigger](../../../core-concepts/choosing-a-trigger.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cngx/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Atoms and molecules (a11y, interactive, layout, dialog, popover, display) for the CNGX Angular component library.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cngx",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"directory": "projects/common"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@cngx/utils": "0.
|
|
27
|
-
"@cngx/core": "0.
|
|
28
|
-
"@angular/cdk": "
|
|
29
|
-
"@angular/common": "
|
|
30
|
-
"@angular/core": "
|
|
31
|
-
"@angular/router": "
|
|
26
|
+
"@cngx/utils": "0.3.0",
|
|
27
|
+
"@cngx/core": "0.3.0",
|
|
28
|
+
"@angular/cdk": ">=21.1.0 <23.0.0",
|
|
29
|
+
"@angular/common": ">=21.1.0 <23.0.0",
|
|
30
|
+
"@angular/core": ">=21.1.0 <23.0.0",
|
|
31
|
+
"@angular/router": ">=21.1.0 <23.0.0",
|
|
32
32
|
"rxjs": "^7.8.0",
|
|
33
33
|
"@floating-ui/dom": "^1.0.0"
|
|
34
34
|
},
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"exports": {
|
|
48
48
|
"./theming/*.css": "./theming/*.css",
|
|
49
|
+
"./popover/*.scss": "./popover/*.scss",
|
|
49
50
|
"./package.json": {
|
|
50
51
|
"default": "./package.json"
|
|
51
52
|
},
|
|
@@ -61,6 +62,10 @@
|
|
|
61
62
|
"types": "./types/cngx-common-audio.d.ts",
|
|
62
63
|
"default": "./fesm2022/cngx-common-audio.mjs"
|
|
63
64
|
},
|
|
65
|
+
"./button": {
|
|
66
|
+
"types": "./types/cngx-common-button.d.ts",
|
|
67
|
+
"default": "./fesm2022/cngx-common-button.mjs"
|
|
68
|
+
},
|
|
64
69
|
"./card": {
|
|
65
70
|
"types": "./types/cngx-common-card.d.ts",
|
|
66
71
|
"default": "./fesm2022/cngx-common-card.mjs"
|
|
@@ -93,6 +98,10 @@
|
|
|
93
98
|
"types": "./types/cngx-common-layout.d.ts",
|
|
94
99
|
"default": "./fesm2022/cngx-common-layout.mjs"
|
|
95
100
|
},
|
|
101
|
+
"./menu-button": {
|
|
102
|
+
"types": "./types/cngx-common-menu-button.d.ts",
|
|
103
|
+
"default": "./fesm2022/cngx-common-menu-button.mjs"
|
|
104
|
+
},
|
|
96
105
|
"./popover": {
|
|
97
106
|
"types": "./types/cngx-common-popover.d.ts",
|
|
98
107
|
"default": "./fesm2022/cngx-common-popover.mjs"
|
|
@@ -110,6 +119,20 @@
|
|
|
110
119
|
"default": "./fesm2022/cngx-common-timeline.mjs"
|
|
111
120
|
}
|
|
112
121
|
},
|
|
122
|
+
"schematics": "./schematics/collection.json",
|
|
123
|
+
"ng-update": {
|
|
124
|
+
"packageGroup": [
|
|
125
|
+
"@cngx/utils",
|
|
126
|
+
"@cngx/core",
|
|
127
|
+
"@cngx/common",
|
|
128
|
+
"@cngx/interop",
|
|
129
|
+
"@cngx/forms",
|
|
130
|
+
"@cngx/data-display",
|
|
131
|
+
"@cngx/ui",
|
|
132
|
+
"@cngx/themes"
|
|
133
|
+
]
|
|
134
|
+
},
|
|
113
135
|
"module": "fesm2022/cngx-common.mjs",
|
|
114
|
-
"typings": "types/cngx-common.d.ts"
|
|
136
|
+
"typings": "types/cngx-common.d.ts",
|
|
137
|
+
"type": "module"
|
|
115
138
|
}
|
package/popover/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Signal-driven popover, tooltip, and popover panel components built on the native
|
|
|
12
12
|
- WCAG 1.4.13 compliant tooltips (dismissable, hoverable, persistent)
|
|
13
13
|
- Material theme SCSS with M3 tokens
|
|
14
14
|
- Exclusive mode (one popover at a time by default)
|
|
15
|
-
- Dismissal defaults: `mode` is `'manual'` (you control open/close; `'auto'` enables native light-dismiss), `[closeOnEscape]` is `true
|
|
15
|
+
- Dismissal defaults: `mode` is `'manual'` (you control open/close; `'auto'` enables native light-dismiss), `[closeOnEscape]` is `true` (it also takes a `Signal<boolean>`, read at keydown time, for a gate that flips inside an event handler), and `[closeOnOutsideClick]` (outside-pointer dismiss) is `false` - opt in when you want click-away to close
|
|
16
16
|
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
@@ -67,6 +67,20 @@ The explicit anchor wins over the trigger. When the anchor unmounts, the trigger
|
|
|
67
67
|
</div>
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
### Focus return
|
|
71
|
+
|
|
72
|
+
On close, `CngxPopoverTrigger` can return focus to the element that was focused before the popover opened. It only does so when focus would otherwise be lost (on `body` or inside the panel); a close that moved focus to another control leaves it there. The decision resolves in this order:
|
|
73
|
+
|
|
74
|
+
1. `[restoreFocus]` on the trigger, when bound.
|
|
75
|
+
2. The composer claim on the popover (`restoreFocusHint()`). `CngxPopoverPanel` claims `true`, so a panel returns focus to its trigger by default. A menu trigger claims `false`, because the menu focus stack restores.
|
|
76
|
+
3. `false`. A bare `[cngxPopover]` stays opt-in.
|
|
77
|
+
|
|
78
|
+
Bind `[restoreFocus]="false"` on a panel's trigger to keep focus where the browser leaves it. In a sheet or fullscreen presentation the claim is ignored and `CngxPopoverSheet` restores.
|
|
79
|
+
|
|
80
|
+
Composers hint the trigger through owner-keyed claims on `CngxPopover`: `claimHaspopup(owner, value)`, `claimControls(owner, idSignal)` and `claimRestoreFocus(owner, value)`, each with a `release*(owner)` partner called on destroy. With several composers on one popover (a panel around a menu), the last live claim wins and a release removes only that owner's claim.
|
|
81
|
+
|
|
82
|
+
The popover itself reads one more claim: `claimPositionTryFallbacks(owner, chain)` / `releasePositionTryFallbacks(owner)` supplies the `position-try-fallbacks` chain when no `[positionTryFallbacks]` is bound. The menu and context-menu triggers claim `CngxMenuConfig.tryFallbacks` this way, so a clipped menu flips. A bound `[positionTryFallbacks]="[]"` still opts the popover out.
|
|
83
|
+
|
|
70
84
|
## Popover Panel
|
|
71
85
|
|
|
72
86
|
Rich popover molecule with header/body/footer slots, variant styling, arrow, close button, and async action buttons.
|
|
@@ -79,6 +93,7 @@ import {
|
|
|
79
93
|
CngxPopoverBody,
|
|
80
94
|
CngxPopoverFooter,
|
|
81
95
|
CngxPopoverAction,
|
|
96
|
+
CngxPopoverDismiss,
|
|
82
97
|
providePopoverPanel,
|
|
83
98
|
withCloseButton,
|
|
84
99
|
withArrow,
|
|
@@ -102,17 +117,35 @@ import { CngxPending, CngxSucceeded, CngxFailed } from '@cngx/common/interactive
|
|
|
102
117
|
<p cngxPopoverBody>This action cannot be undone.</p>
|
|
103
118
|
|
|
104
119
|
<div cngxPopoverFooter>
|
|
105
|
-
<
|
|
106
|
-
<
|
|
120
|
+
<button cngxPopoverDismiss>Cancel</button>
|
|
121
|
+
<button cngxPopoverAction="solid" tone="danger" [action]="deleteItem" [showDelay]="120">
|
|
107
122
|
Delete
|
|
108
123
|
<ng-template cngxPending>Deleting...</ng-template>
|
|
109
124
|
<ng-template cngxSucceeded>Deleted!</ng-template>
|
|
110
125
|
<ng-template cngxFailed let-err>{{ err }}</ng-template>
|
|
111
|
-
</
|
|
126
|
+
</button>
|
|
112
127
|
</div>
|
|
113
128
|
</cngx-popover-panel>
|
|
114
129
|
```
|
|
115
130
|
|
|
131
|
+
Both footer hosts are button-family hosts on the native `<button>`: `cngx-button.css` from `@cngx/themes/cngx.css` paints them, the size is pinned to `sm` (a bound `size` wins), the default variant is `outline` and the tone comes from `tone`, not from the panel variant. `button[cngxPopoverDismiss]` closes the panel; `button[cngxPopoverAction]` requires `[action]`. Focus returns to the trigger through the panel's restore claim.
|
|
132
|
+
|
|
133
|
+
`button[cngxPopoverAction]` is skin over four host directives: `CngxButtonBrain`, `CngxAsyncClick` (the run and its live region), `CngxActionStatusBrain` from `@cngx/common/interactive` (`succeededAnnouncement`, `failedAnnouncement`, `announce`, `pendingLabel`, `succeededLabel`, `failedLabel`, `externalState`, `(outcome)`; the label cells and the settle announcement, read through `CNGX_ACTION_STATUS`) and `CngxPopoverCloseOnSuccess` (`closeOnSuccessDelay`). The close directive closes the composing `CngxPopover` after each success outcome of the status brain, own run or external edge (`withCloseOnSuccess()` or the per-instance delay, `null` turns it off), cancels the close when a follow-up run starts, and speaks a closing success through `CngxLiveAnnouncer` outside the panel; it covers that outcome through `CNGX_ANNOUNCEMENT_COVER`, so the region inside the panel stays empty and the success is heard once.
|
|
134
|
+
|
|
135
|
+
#### Migration
|
|
136
|
+
|
|
137
|
+
| Old markup | New markup |
|
|
138
|
+
|-|-|
|
|
139
|
+
| `<cngx-popover-action role="dismiss">` | `<button cngxPopoverDismiss>` |
|
|
140
|
+
| `<cngx-popover-action role="confirm" [action]="a">` | `<button cngxPopoverAction [action]="a">` |
|
|
141
|
+
| `variant="primary"` | `cngxPopoverAction="solid" tone="primary"` |
|
|
142
|
+
| `variant="danger"` | `cngxPopoverAction="solid" tone="danger"` |
|
|
143
|
+
| `variant="ghost"` | `cngxPopoverAction="ghost"` |
|
|
144
|
+
| `variant="secondary"` | default (`outline`) |
|
|
145
|
+
| `--cngx-popover-action-*` tokens | `--cngx-button-*` tokens |
|
|
146
|
+
|
|
147
|
+
The confirm action times its busy visual through the loading gate. The `cngxPending` template shows only after `showDelay` (unbound, `CNGX_LOADING_CONFIG.showDelay`), so a run that settles before the delay never flashes "Deleting..."; once shown it is held for `minDwell` past the run, and for that whole window the action is painted busy (not disabled) and refuses a second click. Bind `[showDelay]` / `[minDwell]` to override per instance, or leave them unbound to inherit the config.
|
|
148
|
+
|
|
116
149
|
### Content States
|
|
117
150
|
|
|
118
151
|
```html
|
|
@@ -124,6 +157,8 @@ import { CngxPending, CngxSucceeded, CngxFailed } from '@cngx/common/interactive
|
|
|
124
157
|
</cngx-popover-panel>
|
|
125
158
|
```
|
|
126
159
|
|
|
160
|
+
**State copy.** Without a slot template, the loading, error and empty views still say something. The text resolves in this order: the projected `*cngxPopoverLoading` / `*cngxPopoverError` / `*cngxPopoverEmpty` template (it replaces the whole node), then `[loadingText]` / `[errorText]` / `[emptyText]`, then `providePopoverPanel(withPopoverPanelLabels({ loading, error, empty }))`, then the `popover` section of the language pack ("Loading", "Could not load", "Nothing to show"). The header row and its close button stay in every view. In the error and empty views `aria-describedby` points at that surface; loading speaks through `aria-busy` and the visible text. A slot template still gets the resolved copy: `let-text` on `*cngxPopoverLoading` / `*cngxPopoverEmpty`, and `let-text="text"` next to the raw error (`let-err`) on `*cngxPopoverError`, so a template that only restyles a state can print the default text.
|
|
161
|
+
|
|
127
162
|
### Custom Close Button
|
|
128
163
|
|
|
129
164
|
```html
|
|
@@ -137,6 +172,46 @@ import { CngxPending, CngxSucceeded, CngxFailed } from '@cngx/common/interactive
|
|
|
137
172
|
</cngx-popover-panel>
|
|
138
173
|
```
|
|
139
174
|
|
|
175
|
+
## Mobile sheet
|
|
176
|
+
|
|
177
|
+
Add `cngxPopoverSheet` to a `[cngxPopover]` and the popover opens as a modal bottom sheet on coarse, narrow screens (`(pointer: coarse) and (max-width: 48rem)`, written once in `cngx-popover-sheet.css`) and stays anchored everywhere else.
|
|
178
|
+
|
|
179
|
+
```html
|
|
180
|
+
<button type="button" [cngxPopoverTrigger]="pop" (click)="pop.show()">Choose city</button>
|
|
181
|
+
<div cngxPopover #pop="cngxPopover" cngxPopoverSheet #sheet="cngxPopoverSheet">
|
|
182
|
+
<header cngxPopoverSheetHeader cngxSwipeDismiss="down">
|
|
183
|
+
<span cngxPopoverSheetHandle></span>
|
|
184
|
+
<h2 cngxPopoverSheetTitle>City</h2>
|
|
185
|
+
<button cngxCloseButton aria-label="Close" (click)="sheet.requestClose('close')"></button>
|
|
186
|
+
</header>
|
|
187
|
+
<ul>...</ul>
|
|
188
|
+
</div>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
| Input / output | Purpose |
|
|
192
|
+
|-|-|
|
|
193
|
+
| `[cngxPopoverSheet]` | `'auto'` (default) follows the breakpoint; `'anchored'`, `'sheet'`, `'fullscreen'` force a presentation |
|
|
194
|
+
| `[autoPresentation]` | What `'auto'` resolves to on a phone: `'sheet'` (content-sized, default) or `'fullscreen'` (for panels led by a text input) |
|
|
195
|
+
| `[labelledBy]` | Id that names the dialog; wins over `cngxPopoverSheetTitle` |
|
|
196
|
+
| `[closeOnRequest]` | `false` turns close requests into notifications only |
|
|
197
|
+
| `[restoreFocus]` / `[restoreTarget]` | Focus return on close (default: the element focused before open) |
|
|
198
|
+
| `(closeRequested)` | `'swipe'`, `'backdrop'`, `'back'` or `'close'` |
|
|
199
|
+
| `(closing)` | Synchronous, inside `hide()`, with the page already live; move focus here when you restore it yourself |
|
|
200
|
+
|
|
201
|
+
**Parts.** `cngxPopoverSheetHeader` stays fixed while the rest of the panel scrolls; with `cngxSwipeDismiss="down"` a downward swipe requests a close. `cngxPopoverSheetTitle` names the dialog (put it on the heading, not on the header that also holds buttons). `cngxPopoverSheetHandle` is decorative and always `aria-hidden`; screen-reader users close through the close control because their swipes drive navigation. `cngxPopoverSheetInitialFocus` marks the element that receives focus on open; with several marks the first enabled one in document order wins, and `[cngxPopoverSheetInitialFocus]="false"` takes a mark out of the next open.
|
|
202
|
+
|
|
203
|
+
**Modality.** Sheet and fullscreen are both modal: `role="dialog"` + `aria-modal="true"`, a focus trap, `inert` on every page sibling (live regions stay live), and a pinned scroll lock (`createPinnedScrollLock`). VoiceOver and TalkBack both read content behind a top-layer popover by touch exploration, so `aria-modal` alone does not contain them; `inert` does.
|
|
204
|
+
|
|
205
|
+
**Focus.** Focus moves into the panel inside `show()`, in the same call stack as the tap that opened it, so a tap-opened fullscreen search keeps the iOS keyboard. A programmatic `open()` outside a user gesture moves focus but cannot raise the iOS keyboard. On close, the page is live again and focus is back on the opener before the close transition starts.
|
|
206
|
+
|
|
207
|
+
**Close vectors.** A swipe on the header, a tap outside the panel and the Android back gesture (through `CloseWatcher`) arrive as `closeRequested`. Escape closes through `[closeOnEscape]` on `CngxPopover`. The tap outside does not reach the element underneath it. If your own code also closes the popover on outside clicks, disable that path while the sheet is not anchored, so one tap has one close path. Under VoiceOver a double tap activates the element under the VoiceOver cursor, which stays inside the sheet, so a double tap on the dimmed area does not close it: give every sheet a close control.
|
|
208
|
+
|
|
209
|
+
**Announcements.** While the sheet is modal, announce through `sheet.announce(message, politeness)`. The message is spoken from a live region inside the panel; VoiceOver ignores body-level regions under `aria-modal` and reads them late, after the sheet closes. A message still pending when the sheet closes is handed to `CngxLiveAnnouncer`.
|
|
210
|
+
|
|
211
|
+
**Platform limits.** iOS Safari has no `CloseWatcher`: the edge back-swipe navigates back with the sheet open. For edge-to-edge landscape on notched iPhones, the app opts into `viewport-fit=cover` in its viewport meta tag; the sheet pads with the safe-area insets either way.
|
|
212
|
+
|
|
213
|
+
**Styling.** Tokens are `--cngx-popover-sheet-*` (block size, radius, padding, header gap, handle, surface, colour, shadow, backdrop, duration, easing), documented in `cngx-popover-sheet.css`; the Material bridge is `@cngx/themes/material/popover-sheet-theme`. The sheet rules live in the `cngx.components` layer, so unlayered app CSS on the popover host (padding, border, radius) wins over them; scope such rules to `:not([data-cngx-presentation='sheet'])`.
|
|
214
|
+
|
|
140
215
|
## Configuration
|
|
141
216
|
|
|
142
217
|
### Global Defaults
|
|
@@ -168,6 +243,8 @@ The `variant` input is a free-form string mapped to CSS class `cngx-popover-pane
|
|
|
168
243
|
|
|
169
244
|
### Native Support (zero polyfills needed)
|
|
170
245
|
|
|
246
|
+
<!-- compodocx: inline -->
|
|
247
|
+
|
|
171
248
|
- Chrome 125+
|
|
172
249
|
- Firefox 131+
|
|
173
250
|
- Safari 18.4+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Optional CSS-only indicator for tooltip triggers. Shows a small
|
|
2
|
+
// info icon next to elements with `[cngxTooltip]`.
|
|
3
|
+
//
|
|
4
|
+
// By default, the indicator only appears on touch devices (hover: none).
|
|
5
|
+
// To show on all devices, import the `always` mixin instead.
|
|
6
|
+
//
|
|
7
|
+
// @use '@cngx/common/popover/tooltip-indicator' as indicator;
|
|
8
|
+
//
|
|
9
|
+
// // Touch-only (recommended)
|
|
10
|
+
// @include indicator.touch-only();
|
|
11
|
+
//
|
|
12
|
+
// // Always visible
|
|
13
|
+
// @include indicator.always();
|
|
14
|
+
//
|
|
15
|
+
// Customizable via CSS custom properties on the trigger element:
|
|
16
|
+
//
|
|
17
|
+
// --cngx-tooltip-indicator-size (default: 14px)
|
|
18
|
+
// --cngx-tooltip-indicator-gap (default: 4px)
|
|
19
|
+
// --cngx-tooltip-indicator-color (default: --cngx-color-text-muted)
|
|
20
|
+
// --cngx-tooltip-indicator-icon (default: info circle SVG)
|
|
21
|
+
|
|
22
|
+
// Info circle icon (Heroicons 20/solid - MIT)
|
|
23
|
+
$_default-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z' clip-rule='evenodd'/%3E%3C/svg%3E");
|
|
24
|
+
|
|
25
|
+
@mixin _indicator-styles() {
|
|
26
|
+
[cngxTooltip]::after {
|
|
27
|
+
content: '';
|
|
28
|
+
display: inline-block;
|
|
29
|
+
width: var(--cngx-tooltip-indicator-size, 14px);
|
|
30
|
+
height: var(--cngx-tooltip-indicator-size, 14px);
|
|
31
|
+
margin-inline-start: var(--cngx-tooltip-indicator-gap, 4px);
|
|
32
|
+
vertical-align: middle;
|
|
33
|
+
// Quiet by colour, never opacity: the muted text colour.
|
|
34
|
+
background: var(--cngx-tooltip-indicator-color, var(--cngx-color-text-muted, oklch(0.5 0.01 250)));
|
|
35
|
+
mask-image: var(--cngx-tooltip-indicator-icon, #{$_default-icon});
|
|
36
|
+
mask-size: contain;
|
|
37
|
+
mask-repeat: no-repeat;
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/// Show indicator only on touch devices (no hover capability).
|
|
43
|
+
@mixin touch-only() {
|
|
44
|
+
@media (hover: none) {
|
|
45
|
+
@include _indicator-styles();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// Show indicator on all devices (desktop + mobile).
|
|
50
|
+
@mixin always() {
|
|
51
|
+
@include _indicator-styles();
|
|
52
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";var fe=Object.create;var y=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty;var xe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),be=(n,e)=>{for(var r in e)y(n,r,{get:e[r],enumerable:!0})},V=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ge(e))!ye.call(n,o)&&o!==r&&y(n,o,{get:()=>e[o],enumerable:!(t=ue(e,o))||t.enumerable});return n};var he=(n,e,r)=>(r=n!=null?fe(me(n)):{},V(e||!n||!n.__esModule?y(r,"default",{value:n,enumerable:!0}):r,n)),Se=n=>V(y({},"__esModule",{value:!0}),n);var oe=xe((mn,B)=>{"use strict";var A=process||{},re=A.argv||[],O=A.env||{},je=!(O.NO_COLOR||re.includes("--no-color"))&&(!!O.FORCE_COLOR||re.includes("--color")||A.platform==="win32"||(A.stdout||{}).isTTY&&O.TERM!=="dumb"||!!O.CI),De=(n,e,r=n)=>t=>{let o=""+t,i=o.indexOf(e,n.length);return~i?n+Ve(o,e,r,i)+e:n+o+e},Ve=(n,e,r,t)=>{let o="",i=0;do o+=n.substring(i,t)+r,i=t+e.length,t=n.indexOf(e,i);while(~t);return o+n.substring(i)},te=(n=je)=>{let e=n?De:()=>String;return{isColorSupported:n,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};B.exports=te();B.exports.createColors=te});var Qe={};be(Qe,{ngAdd:()=>j});module.exports=Se(Qe);var S=require("@schematics/angular/utility");var U=require("@angular-devkit/schematics"),J=require("@schematics/angular/utility");function P(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function M(n){return n instanceof Error?n.message:String(n)}function G(n){return n.includes(`\r
|
|
2
|
+
`)?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`}var g="package.json";function Re(n){return/\n([ \t]+)\S/.exec(n)?.[1]??" "}function Te(n,e){return JSON.stringify(JSON.parse(n),null," ").replace(/^\t+/gm,r=>e.repeat(r.length))}function x(...n){return e=>{let r=e.exists(g)?e.readText(g):void 0;return(0,U.chain)([(0,J.addDependency)(...n),t=>{if(r===void 0||!t.exists(g))return;let o=t.readText(g);if(o===r)return;let i=Re(r),s=i===" "?o:Te(o,i),l=G(r),d=r.endsWith(`
|
|
5
|
+
`)&&!s.endsWith(`
|
|
6
|
+
`)?`${s}
|
|
7
|
+
`:s,c=l===`
|
|
8
|
+
`?d:d.replace(/\r?\n/g,l);c!==o&&t.overwrite(g,c)}])}}var v=require("node:fs"),Y=require("node:path"),L=require("@angular-devkit/schematics");function w(n){return P(n)?Object.fromEntries(Object.entries(n).filter(e=>typeof e[1]=="string")):{}}function Ee(n){try{return JSON.parse(n)}catch(e){let r=e instanceof Error?e.message:String(e);throw new L.SchematicsException(`package.json is not valid JSON: ${r.replace(/\.$/,"")}.`)}}function u(n){let e=Ee(n);if(!P(e))throw new L.SchematicsException("package.json is not a JSON object.");return{name:typeof e.name=="string"?e.name:void 0,version:typeof e.version=="string"?e.version:void 0,dependencies:w(e.dependencies),devDependencies:w(e.devDependencies),peerDependencies:w(e.peerDependencies)}}function W(n){let{version:e}=u((0,v.readFileSync)(b(n),"utf8"));if(e===void 0)throw new Error(`No version in ${b(n)}.`);return e}function q(n){let{name:e}=u((0,v.readFileSync)(b(n),"utf8"));if(e===void 0)throw new Error(`No name in ${b(n)}.`);return e}function b(n){return(0,Y.join)(n,"..","..","package.json")}function m(n,e){return n.dependencies[e]??n.devDependencies[e]}var Ce=/^[\s^~<>=v]*(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?/;function H(n){let e=Ce.exec(n??"");if(e===null)return;let[,r,t="0",o="0",i]=e;return{major:Number(r),minor:Number(t),patch:Number(o),prerelease:i===void 0?[]:i.split(".").map(s=>/^\d+$/.test(s)?Number(s):s)}}function Oe(n,e){return typeof n=="number"&&typeof e=="number"?n-e:typeof n=="number"?-1:typeof e=="number"?1:n===e?0:n<e?-1:1}function X(n,e){let r=H(n),t=H(e);if(r===void 0||t===void 0)return;let o=r.major-t.major||r.minor-t.minor||r.patch-t.patch;if(o!==0)return o;if(r.prerelease.length===0||t.prerelease.length===0)return t.prerelease.length-r.prerelease.length;let i=Math.max(r.prerelease.length,t.prerelease.length);for(let s=0;s<i;s++){let l=r.prerelease[s],d=t.prerelease[s];if(l===void 0||d===void 0)return l===void 0?-1:1;let c=Oe(l,d);if(c!==0)return c}return 0}function h(n,e){let r=n.read(`node_modules/${e}/package.json`);if(r!==null)try{return u(r.toString("utf8")).version}catch{return}}var Ae="package.json",Ne=/^[\s\d.^~<>=|xX*v-]+$/;function Pe(n,e){if(n!==void 0&&Ne.test(n)&&/\d/.test(n))return n;let r=/^(\d+)\.(\d+)\.\d+(-.+)?/.exec(e??"");if(r!==null)return r[3]===void 0?`^${r[1]}.${r[2]}.0`:`^${e}`}function K(n,e){return(r,t)=>{let o=e??t.logger,i=u(r.readText(Ae));if(m(i,n)!==void 0)return;let s=Pe(m(i,"@angular/core"),h(r,"@angular/core"));if(s===void 0){o.info(`Add ${n} matching your @angular/core yourself; cngx cannot read an Angular version to match it to.`);return}return o.info(`Adding ${n}@${s} to match @angular/core, so the install does not pick the ${n} of a newer Angular.`),x(n,s,{install:S.InstallBehavior.None,existing:S.ExistingBehavior.Skip})}}var R=require("@schematics/angular/utility"),z=require("@schematics/angular/utility/json-file");var Z="package.json";function k(n,e,r=!1){return(t,o)=>{let i=m(u(t.readText(Z)),n);if(i!==void 0&&i!==e){r&&o.logger.info(`Replacing ${n}@${i} with ${e} so every @cngx package stays on one version.`);let s=new z.JSONFile(t,Z);s.remove(["dependencies",n]),s.remove(["devDependencies",n])}return x(n,e,{install:R.InstallBehavior.None,existing:R.ExistingBehavior.Replace})}}var T=require("@angular-devkit/schematics"),we=["minimal","recommended","full"],E=["utils","core","common","interop","forms","data-display","ui"],ve=["cngx","material","none"],Le=["en","de"],ke=["claude","cursor","vscode"];function C(n,e){return n.some(r=>r===e)}function $e(n,e){return Array.isArray(e)&&e.every(r=>C(n,r))}function Fe(n){return typeof n=="boolean"}function F(n){return`--${n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`}function _e(n,e){let r=e.length===1?"is":"are";return new T.SchematicsException(`"${e.join('", "')}" ${r} given more than once for ${F(n)}.`)}function Be(n,e){let r=F(n);return new T.SchematicsException(`${r} has an empty entry. Separate the values with single commas, for example ${r} ${e.slice(0,2).join(",")}.`)}function _(n,e,r){return new T.SchematicsException(`"${e.join('", "')}" is not a valid answer for ${F(n)}. Expected one of: ${r.join(", ")}.`)}var Q=["true","false"];function ee(n,e,r){if(r===void 0)return;let t=typeof r=="string"?r.split(",").map(i=>i.trim()):r;if(t.length===0)return;if(t.includes(""))throw Be(n,e);if(!$e(e,t))throw _(n,t.filter(i=>!C(e,i)),e);let o=t.filter((i,s)=>t.indexOf(i)!==s);if(o.length>0)throw _e(n,[...new Set(o)]);return t}function $(n,e,r){if(r!==void 0){if(!C(e,r))throw _(n,[r],e);return r}}function f(n,e){if(e===void 0||Fe(e))return e;if(!C(Q,e))throw _(n,[e],Q);return e==="true"}function Ie(n){return(typeof n=="string"?n.split(",").map(r=>r.trim()):Array.isArray(n)?n:void 0)?.filter(r=>typeof r=="string"&&r.startsWith("@cngx/"))}function ne(n){return{project:n.project,preset:$("preset",we,n.preset),libs:ee("libs",E,n.libs),theme:$("theme",ve,n.theme),i18n:$("i18n",Le,n.i18n),runtimeSwitch:f("runtimeSwitch",n.runtimeSwitch),lint:f("lint",n.lint),a11yPreferences:f("a11yPreferences",n.a11yPreferences),feedback:f("feedback",n.feedback),floatingFallback:f("floatingFallback",n.floatingFallback),starter:f("starter",n.starter),aiTools:ee("aiTools",ke,n.aiTools),yes:f("yes",n.yes),prompts:f("prompts",n.prompts),quiet:f("quiet",n.quiet),pins:Ie(n.pins)}}var p=require("@angular-devkit/schematics"),N=require("@angular-devkit/schematics/tasks");var ie=he(oe());function Me(n,e){if(n.NO_COLOR!==void 0&&n.NO_COLOR!=="")return!1;let r=n.FORCE_COLOR;return r!==void 0?r!=="0"&&r!=="false":e}function se(n,e){let r=Me(n,e),t=(0,ie.createColors)(r);return{enabled:r,bold:t.bold,dim:t.dim,green:t.green,yellow:t.yellow,red:t.red}}function ae(n){let e=n?.toLowerCase();return e==="1"||e==="true"?!0:e==="0"||e==="false"?!1:void 0}function Ge(n){return ae(n.CI)===!0}function Ue(n,e){return ae(n.NG_FORCE_TTY)??(e.isTTY===!0&&!Ge(n))}function de(n,e,r,t,o){let i=Ue(n,e);return{isTTY:i,color:se(n,i),quiet:o,logger:t,terminal:i?Je(e,r):void 0}}function Je(n,e){if(n.write===void 0)return;let r=o=>i=>{o.write?.(`${i}
|
|
9
|
+
`)},t=r(e.write===void 0?n:e);return{info:r(n),warn:t,error:t}}var He=["0.0.0","PLACEHOLDER"].join("-");function le(n){return n===He}var a="@cngx/core",Ye="@angular/cdk";function We(n){return n!=="@cngx/utils"}function qe(n){return n instanceof Error&&n.constructor.name==="CollectionCannotBeResolvedException"}function I(n){try{n.engine.createCollection(a)}catch(e){let r=qe(e)?"it cannot be resolved":M(e);throw new p.SchematicsException(`${a} is installed but its ng-add collection failed to load: ${r}`)}}function Xe(n){return E.find(e=>`@cngx/${e}`===n)}function Ke(n,e){let r=Xe(e),t=ne({libs:n.libs}).libs;if(t===void 0||r===void 0)return n;let o=new Set([...t,r]);return{...n,libs:E.filter(i=>o.has(i))}}function Ze(n){let e=de(process.env,process.stdout,process.stderr,n.logger,!1);return e.terminal??e.logger}function ze(n,e,r,t){return n===void 0?`${a} is not installed yet; installing it before its ng-add runs.`:e===void 0?`${a} ${n} is installed with a version cngx cannot read; installing ${t} before its ng-add runs.`:`${a} ${n} is installed, older than ${r} ${t}; installing ${t} before its ng-add runs.`}function j(n,e=__dirname){return(r,t)=>{let o=W(e),i=q(e),s=Ke(n,i),l=Ze(t),d=h(r,a),c=d===void 0?void 0:X(d,o);if(le(o)){if(d===void 0)throw new p.SchematicsException(`${i} is an unstamped local build (${o}) and ${a} is not installed; pack the libs with node scripts/pack-libs.mjs and install the tarballs.`);return l.info(`${i} is an unstamped local build (${o}); pinning nothing and following the installed ${a} ${d}.`),I(t),(0,p.externalSchematic)(a,"ng-add",s)}if(c!==void 0&&c>0)return l.info(`${a} ${d} is installed, newer than ${i} ${o}; following the installed core.`),I(t),(0,p.externalSchematic)(a,"ng-add",s);if(c===0)return I(t),(0,p.externalSchematic)(a,"ng-add",{...s,pins:[a,i]});let ce=(0,p.chain)([k(a,o,!0),k(i,o,!0)]);return l.info(ze(d,c,i,o)),(0,p.chain)([ce,...We(i)?[K(Ye,l)]:[],(en,D)=>{let pe=D.addTask(new N.NodePackageInstallTask);D.addTask(new N.RunSchematicTask(a,"ng-add",{...s}),[pe])}])}}0&&(module.exports={ngAdd});
|