@cngx/common 0.1.0-rc.7 → 0.1.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/card/README.md +2 -1
- package/data/README.md +10 -1
- package/dialog/README.md +23 -1
- package/fesm2022/cngx-common-a11y.mjs +125 -111
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +47 -5
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +300 -46
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +1176 -453
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +37 -10
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +1318 -469
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +151 -14
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +340 -73
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +1744 -952
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +841 -114
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +350 -60
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +727 -317
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1601 -1243
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +137 -53
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/interactive/README.md +15 -4
- package/layout/README.md +21 -1
- package/package.json +3 -3
- package/popover/README.md +18 -2
- package/stepper/README.md +6 -4
- package/theming/components/cngx-accordion.css +1 -1
- package/theming/components/cngx-backdrop.css +12 -0
- package/theming/components/cngx-button-toggle.css +29 -3
- package/theming/components/cngx-data-grid.css +168 -1
- package/theming/components/cngx-dialog.css +13 -0
- package/theming/components/cngx-listbox.css +21 -12
- package/theming/components/cngx-menu.css +56 -16
- package/theming/components/cngx-popover.css +24 -0
- package/theming/components/cngx-recycler-placeholder.css +196 -0
- package/theming/components/cngx-ripple.css +1 -1
- package/theming/components/cngx-slider.css +32 -1
- package/theming/components/cngx-tooltip.css +12 -0
- package/timeline/README.md +155 -0
- package/types/cngx-common-a11y.d.ts +42 -18
- package/types/cngx-common-card.d.ts +201 -17
- package/types/cngx-common-chart.d.ts +343 -47
- package/types/cngx-common-command.d.ts +31 -8
- package/types/cngx-common-data.d.ts +581 -68
- package/types/cngx-common-dialog.d.ts +158 -3
- package/types/cngx-common-display.d.ts +356 -142
- package/types/cngx-common-interactive.d.ts +859 -210
- package/types/cngx-common-layout.d.ts +567 -28
- package/types/cngx-common-popover.d.ts +262 -39
- package/types/cngx-common-stepper.d.ts +366 -116
- package/types/cngx-common-tabs.d.ts +214 -50
- package/types/cngx-common-timeline.d.ts +82 -16
|
@@ -1,24 +1,149 @@
|
|
|
1
|
+
import { isPlatformBrowser, DOCUMENT, NgTemplateOutlet, NgComponentOutlet } from '@angular/common';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, DestroyRef, input, signal, computed, Directive, TemplateRef, isDevMode, contentChild, output, ViewEncapsulation, ChangeDetectionStrategy, Component, Injectable,
|
|
3
|
-
import { buildAsyncStateView,
|
|
3
|
+
import { InjectionToken, inject, ElementRef, DestroyRef, input, signal, PLATFORM_ID, Renderer2, effect, untracked, computed, Directive, TemplateRef, isDevMode, contentChild, output, viewChild, ViewEncapsulation, ChangeDetectionStrategy, Component, Injectable, afterNextRender, makeEnvironmentProviders, SkipSelf, Optional, model, booleanAttribute, linkedSignal, contentChildren, Injector, provideEnvironmentInitializer } from '@angular/core';
|
|
4
|
+
import { createOverrideMerge, buildAsyncStateView, createMediaQuerySignal, memoize, injectLocale, numberFormatterFor, CNGX_STATEFUL, nextUid, coerceSignal, CNGX_SELECTION_CONTROLLER_FACTORY, matchesKeyCombo, parseKeyCombo, CNGX_LOCALE, createLabelMatcher } from '@cngx/core/utils';
|
|
4
5
|
import { isObservable, firstValueFrom, timer, take, fromEvent, filter, switchMap, merge, tap, takeUntil, map } from 'rxjs';
|
|
5
|
-
import {
|
|
6
|
-
import { decimalPlaces, arrayEqual, setEqual, flattenTree, isNodeVisible, collectDescendantValues } from '@cngx/utils';
|
|
7
|
-
import { resolveInlineStep, injectDirection, resolveInlineArrowKey } from '@cngx/core';
|
|
6
|
+
import { formatMessage, createLanguageSection, createSectionBundle } from '@cngx/core/i18n';
|
|
7
|
+
import { decimalPlaces, arrayEqual, setEqual, flattenTree, isNodeVisible, collectDescendantValues, clamp as clamp$1 } from '@cngx/utils';
|
|
8
8
|
import { CNGX_FORM_FIELD_HOST, CNGX_FORM_FIELD_CONTROL } from '@cngx/core/tokens';
|
|
9
9
|
import * as i1 from '@cngx/common/a11y';
|
|
10
|
-
import {
|
|
10
|
+
import { CngxLiveAnnouncer, CngxActiveDescendant, CngxRovingTabindex, CngxRovingItem, CNGX_AD_ITEM } from '@cngx/common/a11y';
|
|
11
|
+
import { resolveInlineStep, injectDirection, resolveInlineArrowKey, resolveStepFrom } from '@cngx/core';
|
|
11
12
|
import { CngxCheckboxIndicator, CngxRadioIndicator } from '@cngx/common/display';
|
|
12
13
|
import { takeUntilDestroyed, toObservable, outputFromObservable, outputToObservable } from '@angular/core/rxjs-interop';
|
|
13
14
|
import { Router, NavigationStart } from '@angular/router';
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The English interactive section: the single source of the interactive
|
|
18
|
+
* atoms' English copy. `CNGX_INTERACTIVE_I18N` defaults to it.
|
|
19
|
+
*
|
|
20
|
+
* @category common/interactive/i18n
|
|
21
|
+
* @since 0.1.0
|
|
22
|
+
* @relatedTo CNGX_INTERACTIVE_I18N
|
|
23
|
+
*/
|
|
24
|
+
const CNGX_INTERACTIVE_LANGUAGE_EN = {
|
|
25
|
+
asyncClickSucceeded: 'Action succeeded',
|
|
26
|
+
asyncClickFailed: 'Action failed',
|
|
27
|
+
copy: 'Copy',
|
|
28
|
+
copied: 'Copied!',
|
|
29
|
+
copiedAnnouncement: 'Copied to clipboard',
|
|
30
|
+
rangeMinimum: 'Minimum',
|
|
31
|
+
rangeMaximum: 'Maximum',
|
|
32
|
+
breadcrumb: 'Breadcrumb',
|
|
33
|
+
unsavedChanges: 'You have unsaved changes. Leave anyway?',
|
|
34
|
+
rangeValue: '{start}–{end}',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** @internal Turns an interactive section into the token's keys for a locale. */
|
|
38
|
+
function interactiveBundleFrom(section, locale) {
|
|
39
|
+
return {
|
|
40
|
+
asyncClickSucceeded: section.asyncClickSucceeded,
|
|
41
|
+
asyncClickFailed: section.asyncClickFailed,
|
|
42
|
+
copy: section.copy,
|
|
43
|
+
copied: section.copied,
|
|
44
|
+
copiedAnnouncement: section.copiedAnnouncement,
|
|
45
|
+
rangeMinimum: section.rangeMinimum,
|
|
46
|
+
rangeMaximum: section.rangeMaximum,
|
|
47
|
+
breadcrumb: section.breadcrumb,
|
|
48
|
+
unsavedChanges: section.unsavedChanges,
|
|
49
|
+
rangeValue: (start, end) => formatMessage(section.rangeValue, { start, end }, locale),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** @internal The interactive section of the active pack over English. */
|
|
53
|
+
const injectInteractiveSection = createLanguageSection('interactive', CNGX_INTERACTIVE_LANGUAGE_EN);
|
|
54
|
+
/** @internal Builds and reads the token, formatted for the reading locale. */
|
|
55
|
+
const interactiveBundle = createSectionBundle({
|
|
56
|
+
section: injectInteractiveSection,
|
|
57
|
+
toBundle: interactiveBundleFrom,
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* DI token for the interactive i18n bundle. `providedIn: 'root'`: the
|
|
61
|
+
* interactive section of the active language pack over the English defaults;
|
|
62
|
+
* the value is a `Signal`, shared by every reader under one injector.
|
|
63
|
+
*
|
|
64
|
+
* @category common/interactive/i18n
|
|
65
|
+
* @wcag AA
|
|
66
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/i18n/interactive-i18n.ts
|
|
67
|
+
* @since 0.1.0
|
|
68
|
+
* @relatedTo CngxAsyncClick
|
|
69
|
+
*/
|
|
70
|
+
const CNGX_INTERACTIVE_I18N = new InjectionToken('CngxInteractiveI18n', {
|
|
71
|
+
providedIn: 'root',
|
|
72
|
+
factory: () => interactiveBundle.build(),
|
|
73
|
+
});
|
|
74
|
+
/** @internal */
|
|
75
|
+
function defineInteractiveI18nFeature(fn) {
|
|
76
|
+
return Object.assign(fn, { _target: 'i18n' });
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Override i18n labels via a partial bundle - unset keys keep the language
|
|
80
|
+
* pack's copy, or the English default. Pass a `Signal` of a partial bundle to switch languages at
|
|
81
|
+
* runtime.
|
|
82
|
+
*
|
|
83
|
+
* @category common/interactive/i18n
|
|
84
|
+
* @since 0.1.0
|
|
85
|
+
*/
|
|
86
|
+
function withInteractiveI18nLabels(overrides) {
|
|
87
|
+
return defineInteractiveI18nFeature((bundle) => createOverrideMerge(bundle, overrides));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Provider for the interactive i18n bundle. Returns a plain `Provider`, so it
|
|
91
|
+
* also scopes a subtree through `viewProviders`. The features apply on top of
|
|
92
|
+
* the active language pack.
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* bootstrapApplication(AppComponent, {
|
|
96
|
+
* providers: [
|
|
97
|
+
* provideInteractiveI18n(
|
|
98
|
+
* withInteractiveI18nLabels({ asyncClickSucceeded: 'Erledigt', asyncClickFailed: 'Fehlgeschlagen' }),
|
|
99
|
+
* ),
|
|
100
|
+
* ],
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @category common/interactive/i18n
|
|
105
|
+
* @since 0.1.0
|
|
106
|
+
*/
|
|
107
|
+
function provideInteractiveI18n(...features) {
|
|
108
|
+
return {
|
|
109
|
+
provide: CNGX_INTERACTIVE_I18N,
|
|
110
|
+
useFactory: () => interactiveBundle.build(features),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Inject the resolved interactive i18n bundle signal. Read it inside a
|
|
115
|
+
* `computed()` or template so a runtime override flip re-derives.
|
|
116
|
+
*
|
|
117
|
+
* @category common/interactive/i18n
|
|
118
|
+
* @since 0.1.0
|
|
119
|
+
*/
|
|
120
|
+
function injectInteractiveI18n() {
|
|
121
|
+
return interactiveBundle.resolve(inject(CNGX_INTERACTIVE_I18N));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @internal - {@link injectInteractiveI18n} typed with every key present.
|
|
125
|
+
* The reading-site resolve already fills each key a directly provided token
|
|
126
|
+
* value leaves out from the active pack's section, so no key is ever unset.
|
|
127
|
+
*/
|
|
128
|
+
function injectResolvedInteractiveI18n() {
|
|
129
|
+
return injectInteractiveI18n();
|
|
130
|
+
}
|
|
131
|
+
|
|
15
132
|
/**
|
|
16
133
|
* Async action handler with loading state, auto-disable, and success/error feedback.
|
|
17
134
|
*
|
|
18
135
|
* Place on any clickable element (button, link, div). Executes the provided
|
|
19
|
-
* async action on click, tracks the full lifecycle as a state machine,
|
|
20
|
-
*
|
|
21
|
-
*
|
|
136
|
+
* async action on click, tracks the full lifecycle as a state machine, and
|
|
137
|
+
* guards against double-clicks. While pending it communicates busy via
|
|
138
|
+
* `aria-busy` + `aria-disabled` and swallows clicks WITHOUT the hard
|
|
139
|
+
* `disabled` attribute, so keyboard focus stays on the control instead of
|
|
140
|
+
* dropping to `<body>` mid-action. Note: the guard prevents the ACTION from
|
|
141
|
+
* re-running and calls `preventDefault()`, but a consumer `(click)` handler
|
|
142
|
+
* on the same element still fires while pending - gate it on `pending()`
|
|
143
|
+
* when it must not. Success and failure are announced through
|
|
144
|
+
* an auto-rendered polite live region (sibling of the host - inside a
|
|
145
|
+
* `<button>` the text would pollute the accessible name); opt out with
|
|
146
|
+
* `[autoAnnounce]="false"` and bind `announcement` to your own region.
|
|
22
147
|
*
|
|
23
148
|
* ### Basic usage
|
|
24
149
|
* ```html
|
|
@@ -52,7 +177,7 @@ import { Router, NavigationStart } from '@angular/router';
|
|
|
52
177
|
* @since 0.1.0
|
|
53
178
|
* @relatedTo CngxPending, CngxSucceeded, CngxFailed, CngxActionButton
|
|
54
179
|
* <example-url>http://localhost:4200/#/common/interactive/retry/optimistic-instant-like-toggle</example-url>
|
|
55
|
-
* <example-url>http://localhost:4200/#/common/interactive/retry/
|
|
180
|
+
* <example-url>http://localhost:4200/#/common/interactive/retry/createretry-cngxasyncclick</example-url>
|
|
56
181
|
*/
|
|
57
182
|
class CngxAsyncClick {
|
|
58
183
|
el = inject(ElementRef);
|
|
@@ -61,30 +186,99 @@ class CngxAsyncClick {
|
|
|
61
186
|
action = input.required({ ...(ngDevMode ? { debugName: "action" } : /* istanbul ignore next */ {}), alias: 'cngxAsyncClick' });
|
|
62
187
|
/** Duration in ms to show success/error state before reset. */
|
|
63
188
|
feedbackDuration = input(2000, ...(ngDevMode ? [{ debugName: "feedbackDuration" }] : /* istanbul ignore next */ []));
|
|
64
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* When `false`, clicks are ignored and the element is marked `aria-disabled`
|
|
191
|
+
* (never the hard `disabled` attribute, so focus survives). Communicates the
|
|
192
|
+
* "why" to assistive tech instead of silently swallowing the click.
|
|
193
|
+
*/
|
|
65
194
|
enabled = input(true, ...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
195
|
+
/**
|
|
196
|
+
* External busy override. When `true`, the element is `aria-busy` even though
|
|
197
|
+
* this directive is not running its own action - for a wrapper that tracks an
|
|
198
|
+
* operation outside the click (e.g. an `[externalState]`). Purely an ARIA
|
|
199
|
+
* hint: it does not block clicks (gate those with `[enabled]`).
|
|
200
|
+
*/
|
|
201
|
+
busy = input(false, ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
|
|
202
|
+
i18n = injectInteractiveI18n();
|
|
203
|
+
/**
|
|
204
|
+
* Label announced to screen readers on success. Unbound, it resolves to
|
|
205
|
+
* `CNGX_INTERACTIVE_I18N.asyncClickSucceeded` at announcement time.
|
|
206
|
+
*/
|
|
207
|
+
succeededAnnouncement = input(undefined, ...(ngDevMode ? [{ debugName: "succeededAnnouncement" }] : /* istanbul ignore next */ []));
|
|
208
|
+
/**
|
|
209
|
+
* Label announced to screen readers on failure. Unbound, it resolves to
|
|
210
|
+
* `CNGX_INTERACTIVE_I18N.asyncClickFailed` at announcement time.
|
|
211
|
+
*/
|
|
212
|
+
failedAnnouncement = input(undefined, ...(ngDevMode ? [{ debugName: "failedAnnouncement" }] : /* istanbul ignore next */ []));
|
|
213
|
+
/**
|
|
214
|
+
* Auto-render the polite live region announcing success/failure.
|
|
215
|
+
* Opt out (`false`) to wire {@link announcement} to your own region -
|
|
216
|
+
* also when a toast/alert bridge (`cngxToastOn`, `cngxAlertOn`) on the
|
|
217
|
+
* same element already announces the settle, or the user hears it twice.
|
|
218
|
+
*/
|
|
219
|
+
autoAnnounce = input(true, ...(ngDevMode ? [{ debugName: "autoAnnounce" }] : /* istanbul ignore next */ []));
|
|
70
220
|
pendingState = signal(false, ...(ngDevMode ? [{ debugName: "pendingState" }] : /* istanbul ignore next */ []));
|
|
71
221
|
succeededState = signal(false, ...(ngDevMode ? [{ debugName: "succeededState" }] : /* istanbul ignore next */ []));
|
|
72
222
|
failedState = signal(false, ...(ngDevMode ? [{ debugName: "failedState" }] : /* istanbul ignore next */ []));
|
|
73
223
|
errorState = signal(undefined, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
74
224
|
lastUpdatedState = signal(undefined, ...(ngDevMode ? [{ debugName: "lastUpdatedState" }] : /* istanbul ignore next */ []));
|
|
75
225
|
feedbackTimer = null;
|
|
76
|
-
supportsDisabled;
|
|
77
226
|
destroyed = false;
|
|
78
227
|
constructor() {
|
|
79
|
-
const tag = this.el.nativeElement.tagName;
|
|
80
|
-
this.supportsDisabled =
|
|
81
|
-
tag === 'BUTTON' || tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA';
|
|
82
228
|
this.destroyRef.onDestroy(() => {
|
|
83
229
|
this.destroyed = true;
|
|
84
230
|
if (this.feedbackTimer != null) {
|
|
85
231
|
clearTimeout(this.feedbackTimer);
|
|
86
232
|
}
|
|
87
233
|
});
|
|
234
|
+
if (isPlatformBrowser(inject(PLATFORM_ID))) {
|
|
235
|
+
this.installAnnounceRegion();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
installAnnounceRegion() {
|
|
239
|
+
const renderer = inject(Renderer2);
|
|
240
|
+
const hostEl = this.el.nativeElement;
|
|
241
|
+
let span = null;
|
|
242
|
+
effect(() => {
|
|
243
|
+
const enabled = this.autoAnnounce();
|
|
244
|
+
const text = this.announcement();
|
|
245
|
+
untracked(() => {
|
|
246
|
+
if (!enabled) {
|
|
247
|
+
if (span?.parentNode) {
|
|
248
|
+
renderer.removeChild(span.parentNode, span);
|
|
249
|
+
}
|
|
250
|
+
span = null;
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (!span) {
|
|
254
|
+
const parent = renderer.parentNode(hostEl);
|
|
255
|
+
if (!parent) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const el = renderer.createElement('span');
|
|
259
|
+
renderer.setStyle(el, 'position', 'var(--cngx-sr-only-position, absolute)');
|
|
260
|
+
renderer.setStyle(el, 'width', 'var(--cngx-sr-only-size, 1px)');
|
|
261
|
+
renderer.setStyle(el, 'height', 'var(--cngx-sr-only-size, 1px)');
|
|
262
|
+
renderer.setStyle(el, 'overflow', 'var(--cngx-sr-only-overflow, hidden)');
|
|
263
|
+
renderer.setStyle(el, 'clip', 'var(--cngx-sr-only-clip, rect(0, 0, 0, 0))');
|
|
264
|
+
renderer.setStyle(el, 'white-space', 'var(--cngx-sr-only-white-space, nowrap)');
|
|
265
|
+
renderer.setAttribute(el, 'aria-atomic', 'true');
|
|
266
|
+
renderer.setAttribute(el, 'role', 'status');
|
|
267
|
+
renderer.setAttribute(el, 'aria-live', 'polite');
|
|
268
|
+
// Sibling, not child: inside a <button> host the region's text
|
|
269
|
+
// would land in the control's accessible name.
|
|
270
|
+
renderer.insertBefore(parent, el, hostEl.nextSibling);
|
|
271
|
+
span = el;
|
|
272
|
+
}
|
|
273
|
+
span.textContent = text;
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
this.destroyRef.onDestroy(() => {
|
|
277
|
+
if (span?.parentNode) {
|
|
278
|
+
renderer.removeChild(span.parentNode, span);
|
|
279
|
+
}
|
|
280
|
+
span = null;
|
|
281
|
+
});
|
|
88
282
|
}
|
|
89
283
|
/** `true` while the action is executing. */
|
|
90
284
|
pending = this.pendingState.asReadonly();
|
|
@@ -107,13 +301,19 @@ class CngxAsyncClick {
|
|
|
107
301
|
}
|
|
108
302
|
return 'idle';
|
|
109
303
|
}, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
|
|
110
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* Screen reader announcement for the current state. Rendered automatically
|
|
306
|
+
* into the auto polite region; only needs manual wiring when
|
|
307
|
+
* `autoAnnounce` is `false`.
|
|
308
|
+
*/
|
|
111
309
|
announcement = computed(() => {
|
|
310
|
+
// Copy is read untracked: only a settle re-derives the region, so a
|
|
311
|
+
// language switch never re-voices it; the next settle speaks the new one.
|
|
112
312
|
if (this.succeededState()) {
|
|
113
|
-
return this.succeededAnnouncement();
|
|
313
|
+
return untracked(() => this.succeededAnnouncement() ?? this.i18n().asyncClickSucceeded);
|
|
114
314
|
}
|
|
115
315
|
if (this.failedState()) {
|
|
116
|
-
return this.failedAnnouncement();
|
|
316
|
+
return untracked(() => this.failedAnnouncement() ?? this.i18n().asyncClickFailed);
|
|
117
317
|
}
|
|
118
318
|
return '';
|
|
119
319
|
}, ...(ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []));
|
|
@@ -130,8 +330,6 @@ class CngxAsyncClick {
|
|
|
130
330
|
lastUpdated: this.lastUpdatedState.asReadonly(),
|
|
131
331
|
});
|
|
132
332
|
/** @internal */
|
|
133
|
-
shouldDisable = computed(() => this.pendingState() && this.supportsDisabled ? '' : null, ...(ngDevMode ? [{ debugName: "shouldDisable" }] : /* istanbul ignore next */ []));
|
|
134
|
-
/** @internal */
|
|
135
333
|
async handleClick(event) {
|
|
136
334
|
if (!this.enabled() || this.pendingState()) {
|
|
137
335
|
event.preventDefault();
|
|
@@ -185,7 +383,7 @@ class CngxAsyncClick {
|
|
|
185
383
|
this.errorState.set(undefined);
|
|
186
384
|
}
|
|
187
385
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncClick, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
188
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxAsyncClick, isStandalone: true, selector: "[cngxAsyncClick]", inputs: { action: { classPropertyName: "action", publicName: "cngxAsyncClick", isSignal: true, isRequired: true, transformFunction: null }, feedbackDuration: { classPropertyName: "feedbackDuration", publicName: "feedbackDuration", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null }, succeededAnnouncement: { classPropertyName: "succeededAnnouncement", publicName: "succeededAnnouncement", isSignal: true, isRequired: false, transformFunction: null }, failedAnnouncement: { classPropertyName: "failedAnnouncement", publicName: "failedAnnouncement", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "handleClick($event)" }, properties: { "class.cngx-async--pending": "pending()", "class.cngx-async--success": "succeeded()", "class.cngx-async--error": "failed()", "attr.aria-busy": "pending() || null", "attr.aria-disabled": "pending() ||
|
|
386
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxAsyncClick, isStandalone: true, selector: "[cngxAsyncClick]", inputs: { action: { classPropertyName: "action", publicName: "cngxAsyncClick", isSignal: true, isRequired: true, transformFunction: null }, feedbackDuration: { classPropertyName: "feedbackDuration", publicName: "feedbackDuration", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null }, busy: { classPropertyName: "busy", publicName: "busy", isSignal: true, isRequired: false, transformFunction: null }, succeededAnnouncement: { classPropertyName: "succeededAnnouncement", publicName: "succeededAnnouncement", isSignal: true, isRequired: false, transformFunction: null }, failedAnnouncement: { classPropertyName: "failedAnnouncement", publicName: "failedAnnouncement", isSignal: true, isRequired: false, transformFunction: null }, autoAnnounce: { classPropertyName: "autoAnnounce", publicName: "autoAnnounce", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "handleClick($event)" }, properties: { "class.cngx-async--pending": "pending()", "class.cngx-async--success": "succeeded()", "class.cngx-async--error": "failed()", "attr.aria-busy": "pending() || busy() || null", "attr.aria-disabled": "pending() || !enabled() || null" } }, exportAs: ["cngxAsyncClick"], ngImport: i0 });
|
|
189
387
|
}
|
|
190
388
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncClick, decorators: [{
|
|
191
389
|
type: Directive,
|
|
@@ -198,12 +396,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
198
396
|
'[class.cngx-async--pending]': 'pending()',
|
|
199
397
|
'[class.cngx-async--success]': 'succeeded()',
|
|
200
398
|
'[class.cngx-async--error]': 'failed()',
|
|
201
|
-
'[attr.aria-busy]': 'pending() || null',
|
|
202
|
-
'[attr.aria-disabled]': 'pending() || null',
|
|
203
|
-
'[attr.disabled]': 'shouldDisable()',
|
|
399
|
+
'[attr.aria-busy]': 'pending() || busy() || null',
|
|
400
|
+
'[attr.aria-disabled]': 'pending() || !enabled() || null',
|
|
204
401
|
},
|
|
205
402
|
}]
|
|
206
|
-
}], ctorParameters: () => [], propDecorators: { action: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxAsyncClick", required: true }] }], feedbackDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "feedbackDuration", required: false }] }], enabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "enabled", required: false }] }], succeededAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "succeededAnnouncement", required: false }] }], failedAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "failedAnnouncement", required: false }] }] } });
|
|
403
|
+
}], ctorParameters: () => [], propDecorators: { action: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxAsyncClick", required: true }] }], feedbackDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "feedbackDuration", required: false }] }], enabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "enabled", required: false }] }], busy: [{ type: i0.Input, args: [{ isSignal: true, alias: "busy", required: false }] }], succeededAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "succeededAnnouncement", required: false }] }], failedAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "failedAnnouncement", required: false }] }], autoAnnounce: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoAnnounce", required: false }] }] } });
|
|
207
404
|
|
|
208
405
|
/**
|
|
209
406
|
* Template shown while an async action is executing.
|
|
@@ -285,6 +482,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
285
482
|
args: [{ selector: 'ng-template[cngxFailed]', standalone: true }]
|
|
286
483
|
}] });
|
|
287
484
|
|
|
485
|
+
/**
|
|
486
|
+
* The English menu section: the single source of the menu's English copy.
|
|
487
|
+
* `CNGX_MENU_CONFIG` defaults its `ariaLabels` to it.
|
|
488
|
+
*
|
|
489
|
+
* @category common/interactive/i18n
|
|
490
|
+
* @since 0.1.0
|
|
491
|
+
* @relatedTo CNGX_MENU_CONFIG
|
|
492
|
+
*/
|
|
493
|
+
const CNGX_MENU_LANGUAGE_EN = {
|
|
494
|
+
submenuOpened: 'Submenu opened',
|
|
495
|
+
submenuClosed: 'Submenu closed',
|
|
496
|
+
itemActivated: 'Item activated',
|
|
497
|
+
itemDisabled: 'Item disabled',
|
|
498
|
+
menuDismissed: 'Menu dismissed',
|
|
499
|
+
};
|
|
500
|
+
|
|
288
501
|
/**
|
|
289
502
|
* Single source for collapsing a {@link CngxAsyncState} into its display
|
|
290
503
|
* bucket. Owned by the {@link CngxAsyncStatus} reflector so every consumer
|
|
@@ -460,6 +673,13 @@ class CngxCopyText {
|
|
|
460
673
|
}
|
|
461
674
|
});
|
|
462
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* Host click handler - fire-and-forget wrapper so the event binding
|
|
678
|
+
* does not leak the promise the public {@link copy} API returns.
|
|
679
|
+
*/
|
|
680
|
+
handleClick() {
|
|
681
|
+
void this.copy();
|
|
682
|
+
}
|
|
463
683
|
/** Copies the text to the clipboard. */
|
|
464
684
|
async copy() {
|
|
465
685
|
const value = this.text();
|
|
@@ -502,7 +722,7 @@ class CngxCopyText {
|
|
|
502
722
|
this.doc.body.removeChild(textarea);
|
|
503
723
|
}
|
|
504
724
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCopyText, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
505
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxCopyText, isStandalone: true, selector: "[cngxCopyText]", inputs: { text: { classPropertyName: "text", publicName: "cngxCopyText", isSignal: true, isRequired: true, transformFunction: null }, resetDelay: { classPropertyName: "resetDelay", publicName: "resetDelay", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { didCopy: "didCopy", copyFailed: "copyFailed" }, host: { listeners: { "click": "
|
|
725
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxCopyText, isStandalone: true, selector: "[cngxCopyText]", inputs: { text: { classPropertyName: "text", publicName: "cngxCopyText", isSignal: true, isRequired: true, transformFunction: null }, resetDelay: { classPropertyName: "resetDelay", publicName: "resetDelay", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { didCopy: "didCopy", copyFailed: "copyFailed" }, host: { listeners: { "click": "handleClick()" } }, exportAs: ["cngxCopyText"], ngImport: i0 });
|
|
506
726
|
}
|
|
507
727
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCopyText, decorators: [{
|
|
508
728
|
type: Directive,
|
|
@@ -511,7 +731,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
511
731
|
standalone: true,
|
|
512
732
|
exportAs: 'cngxCopyText',
|
|
513
733
|
host: {
|
|
514
|
-
'(click)': '
|
|
734
|
+
'(click)': 'handleClick()',
|
|
515
735
|
},
|
|
516
736
|
}]
|
|
517
737
|
}], ctorParameters: () => [], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxCopyText", required: true }] }], resetDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "resetDelay", required: false }] }], didCopy: [{ type: i0.Output, args: ["didCopy"] }], copyFailed: [{ type: i0.Output, args: ["copyFailed"] }] } });
|
|
@@ -547,16 +767,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
547
767
|
* <example-url>http://localhost:4200/#/common/interactive/copy/block/code-snippet</example-url>
|
|
548
768
|
*/
|
|
549
769
|
class CngxCopyBlock {
|
|
770
|
+
i18n = injectResolvedInteractiveI18n();
|
|
550
771
|
/** The text value to copy to clipboard. */
|
|
551
772
|
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
552
|
-
/** Label for the copy button. */
|
|
553
|
-
buttonLabel = input(
|
|
554
|
-
/** Label shown after successful copy. */
|
|
555
|
-
copiedLabel = input(
|
|
556
|
-
/**
|
|
557
|
-
|
|
773
|
+
/** Label for the copy button. Unbound, it follows `CNGX_INTERACTIVE_I18N.copy`. */
|
|
774
|
+
buttonLabel = input(undefined, ...(ngDevMode ? [{ debugName: "buttonLabel" }] : /* istanbul ignore next */ []));
|
|
775
|
+
/** Label shown after successful copy. Unbound, it follows `CNGX_INTERACTIVE_I18N.copied`. */
|
|
776
|
+
copiedLabel = input(undefined, ...(ngDevMode ? [{ debugName: "copiedLabel" }] : /* istanbul ignore next */ []));
|
|
777
|
+
/**
|
|
778
|
+
* Screen reader announcement on copy. Unbound, it follows
|
|
779
|
+
* `CNGX_INTERACTIVE_I18N.copiedAnnouncement`.
|
|
780
|
+
*/
|
|
781
|
+
srAnnouncement = input(undefined, ...(ngDevMode ? [{ debugName: "srAnnouncement" }] : /* istanbul ignore next */ []));
|
|
782
|
+
copyText = viewChild(CngxCopyText, ...(ngDevMode ? [{ debugName: "copyText" }] : /* istanbul ignore next */ []));
|
|
783
|
+
resolvedButtonLabel = computed(() => this.buttonLabel() ?? this.i18n().copy, ...(ngDevMode ? [{ debugName: "resolvedButtonLabel" }] : /* istanbul ignore next */ []));
|
|
784
|
+
resolvedCopiedLabel = computed(() => this.copiedLabel() ?? this.i18n().copied, ...(ngDevMode ? [{ debugName: "resolvedCopiedLabel" }] : /* istanbul ignore next */ []));
|
|
785
|
+
/**
|
|
786
|
+
* Live-region text. Only the copied state is tracked: a language switch
|
|
787
|
+
* never re-voices the region; the next copy speaks the new language.
|
|
788
|
+
*/
|
|
789
|
+
liveAnnouncement = computed(() => this.copyText()?.copied()
|
|
790
|
+
? untracked(() => this.srAnnouncement() ?? this.i18n().copiedAnnouncement)
|
|
791
|
+
: '', ...(ngDevMode ? [{ debugName: "liveAnnouncement" }] : /* istanbul ignore next */ []));
|
|
558
792
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCopyBlock, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
559
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
793
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.4", type: CngxCopyBlock, isStandalone: true, selector: "cngx-copy-block", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, buttonLabel: { classPropertyName: "buttonLabel", publicName: "buttonLabel", isSignal: true, isRequired: false, transformFunction: null }, copiedLabel: { classPropertyName: "copiedLabel", publicName: "copiedLabel", isSignal: true, isRequired: false, transformFunction: null }, srAnnouncement: { classPropertyName: "srAnnouncement", publicName: "srAnnouncement", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-copy-block" }, viewQueries: [{ propertyName: "copyText", first: true, predicate: CngxCopyText, descendants: true, isSignal: true }], exportAs: ["cngxCopyBlock"], ngImport: i0, template: `
|
|
560
794
|
<div class="cngx-copy-block__content">
|
|
561
795
|
<ng-content />
|
|
562
796
|
</div>
|
|
@@ -567,12 +801,14 @@ class CngxCopyBlock {
|
|
|
567
801
|
#cp="cngxCopyText"
|
|
568
802
|
[class.cngx-copy-block__button--copied]="cp.copied()"
|
|
569
803
|
>
|
|
570
|
-
{{ cp.copied() ?
|
|
571
|
-
<span aria-live="polite" class="cngx-sr-only">
|
|
572
|
-
{{ cp.copied() ? srAnnouncement() : '' }}
|
|
573
|
-
</span>
|
|
804
|
+
{{ cp.copied() ? resolvedCopiedLabel() : resolvedButtonLabel() }}
|
|
574
805
|
</button>
|
|
575
|
-
|
|
806
|
+
<!-- Outside the button: a child of a button lands in its accessible
|
|
807
|
+
name, so the announcement text would rename the control. -->
|
|
808
|
+
<span aria-live="polite" class="cngx-sr-only">
|
|
809
|
+
{{ liveAnnouncement() }}
|
|
810
|
+
</span>
|
|
811
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-copy-block-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-copy-block-btn-border{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-copy-block-btn-color{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-copy-block-btn-padding{syntax: \"*\"; inherits: true; initial-value: 4px 8px;}@property --cngx-copy-block-btn-font-size{syntax: \"*\"; inherits: false; initial-value: .75rem;}@property --cngx-copy-block-btn-copied-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(.96 .025 145);}@property --cngx-copy-block-btn-copied-border{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .12 145);}@property --cngx-copy-block-btn-copied-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .12 145);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-copy-block-btn-copied-bg: oklch(.32 .06 145);--cngx-copy-block-btn-copied-color: oklch(.85 .13 145)}}[data-color-scheme=dark],.dark{--cngx-copy-block-btn-copied-bg: oklch(.32 .06 145);--cngx-copy-block-btn-copied-color: oklch(.85 .13 145)}[data-color-scheme=light],.light{--cngx-copy-block-btn-copied-bg: oklch(.96 .025 145);--cngx-copy-block-btn-copied-color: oklch(.5 .12 145)}}@layer cngx.components{@scope(.cngx-copy-block){:scope{--cngx-copy-block-gap: var(--cngx-space-sm);--cngx-copy-block-btn-padding: var(--cngx-space-xs) var(--cngx-space-sm);display:flex;align-items:flex-start;gap:var(--cngx-copy-block-gap, var(--cngx-space-sm, 8px))}.cngx-copy-block__content{flex:1;min-width:0;overflow:hidden;unicode-bidi:var(--cngx-copy-block-bidi, isolate)}.cngx-copy-block__button{flex-shrink:0;min-inline-size:var(--cngx-target-min, 0px);min-block-size:var(--cngx-target-min, 0px);cursor:pointer;border:1px solid var(--cngx-copy-block-btn-border, currentColor);background:var(--cngx-copy-block-btn-bg, transparent);color:var(--cngx-copy-block-btn-color, inherit);border-radius:var(--cngx-copy-block-btn-radius, var(--cngx-radius-sm, 4px));padding:var(--cngx-copy-block-btn-padding, 4px 8px);font-size:var(--cngx-copy-block-btn-font-size, var(--cngx-font-size-sm, .75rem));transition:background var(--cngx-duration-fast, .15s),border-color var(--cngx-duration-fast, .15s)}.cngx-copy-block__button--copied{background:var(--cngx-copy-block-btn-copied-bg, oklch(.96 .025 145));border-color:var( --cngx-copy-block-btn-copied-border, var(--cngx-color-success, oklch(.5 .12 145)) );color:var( --cngx-copy-block-btn-copied-color, var(--cngx-color-success, oklch(.5 .12 145)) )}.cngx-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}\n"], dependencies: [{ kind: "directive", type: CngxCopyText, selector: "[cngxCopyText]", inputs: ["cngxCopyText", "resetDelay"], outputs: ["didCopy", "copyFailed"], exportAs: ["cngxCopyText"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
576
812
|
}
|
|
577
813
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCopyBlock, decorators: [{
|
|
578
814
|
type: Component,
|
|
@@ -589,13 +825,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
589
825
|
#cp="cngxCopyText"
|
|
590
826
|
[class.cngx-copy-block__button--copied]="cp.copied()"
|
|
591
827
|
>
|
|
592
|
-
{{ cp.copied() ?
|
|
593
|
-
<span aria-live="polite" class="cngx-sr-only">
|
|
594
|
-
{{ cp.copied() ? srAnnouncement() : '' }}
|
|
595
|
-
</span>
|
|
828
|
+
{{ cp.copied() ? resolvedCopiedLabel() : resolvedButtonLabel() }}
|
|
596
829
|
</button>
|
|
597
|
-
|
|
598
|
-
|
|
830
|
+
<!-- Outside the button: a child of a button lands in its accessible
|
|
831
|
+
name, so the announcement text would rename the control. -->
|
|
832
|
+
<span aria-live="polite" class="cngx-sr-only">
|
|
833
|
+
{{ liveAnnouncement() }}
|
|
834
|
+
</span>
|
|
835
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-copy-block-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-copy-block-btn-border{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-copy-block-btn-color{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-copy-block-btn-padding{syntax: \"*\"; inherits: true; initial-value: 4px 8px;}@property --cngx-copy-block-btn-font-size{syntax: \"*\"; inherits: false; initial-value: .75rem;}@property --cngx-copy-block-btn-copied-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(.96 .025 145);}@property --cngx-copy-block-btn-copied-border{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .12 145);}@property --cngx-copy-block-btn-copied-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .12 145);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-copy-block-btn-copied-bg: oklch(.32 .06 145);--cngx-copy-block-btn-copied-color: oklch(.85 .13 145)}}[data-color-scheme=dark],.dark{--cngx-copy-block-btn-copied-bg: oklch(.32 .06 145);--cngx-copy-block-btn-copied-color: oklch(.85 .13 145)}[data-color-scheme=light],.light{--cngx-copy-block-btn-copied-bg: oklch(.96 .025 145);--cngx-copy-block-btn-copied-color: oklch(.5 .12 145)}}@layer cngx.components{@scope(.cngx-copy-block){:scope{--cngx-copy-block-gap: var(--cngx-space-sm);--cngx-copy-block-btn-padding: var(--cngx-space-xs) var(--cngx-space-sm);display:flex;align-items:flex-start;gap:var(--cngx-copy-block-gap, var(--cngx-space-sm, 8px))}.cngx-copy-block__content{flex:1;min-width:0;overflow:hidden;unicode-bidi:var(--cngx-copy-block-bidi, isolate)}.cngx-copy-block__button{flex-shrink:0;min-inline-size:var(--cngx-target-min, 0px);min-block-size:var(--cngx-target-min, 0px);cursor:pointer;border:1px solid var(--cngx-copy-block-btn-border, currentColor);background:var(--cngx-copy-block-btn-bg, transparent);color:var(--cngx-copy-block-btn-color, inherit);border-radius:var(--cngx-copy-block-btn-radius, var(--cngx-radius-sm, 4px));padding:var(--cngx-copy-block-btn-padding, 4px 8px);font-size:var(--cngx-copy-block-btn-font-size, var(--cngx-font-size-sm, .75rem));transition:background var(--cngx-duration-fast, .15s),border-color var(--cngx-duration-fast, .15s)}.cngx-copy-block__button--copied{background:var(--cngx-copy-block-btn-copied-bg, oklch(.96 .025 145));border-color:var( --cngx-copy-block-btn-copied-border, var(--cngx-color-success, oklch(.5 .12 145)) );color:var( --cngx-copy-block-btn-copied-color, var(--cngx-color-success, oklch(.5 .12 145)) )}.cngx-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}\n"] }]
|
|
836
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], buttonLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "buttonLabel", required: false }] }], copiedLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "copiedLabel", required: false }] }], srAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "srAnnouncement", required: false }] }], copyText: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxCopyText), { isSignal: true }] }] } });
|
|
599
837
|
|
|
600
838
|
/**
|
|
601
839
|
* Touch/click ripple feedback without Material dependency.
|
|
@@ -644,22 +882,24 @@ class CngxRipple {
|
|
|
644
882
|
active = this.activeState.asReadonly();
|
|
645
883
|
el = inject((ElementRef));
|
|
646
884
|
doc = inject(DOCUMENT);
|
|
647
|
-
|
|
885
|
+
destroyRef = inject(DestroyRef);
|
|
886
|
+
prefersReducedMotion = createMediaQuerySignal('(prefers-reduced-motion: reduce)', this.destroyRef, this.doc.defaultView);
|
|
887
|
+
/**
|
|
888
|
+
* Cleanups of waves whose animation has not finished yet. Flushed on
|
|
889
|
+
* destroy so the 1s fallback timer never outlives the directive and
|
|
890
|
+
* detached hosts do not keep orphaned wave elements alive.
|
|
891
|
+
*/
|
|
892
|
+
pendingCleanups = new Set();
|
|
648
893
|
constructor() {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
this.prefersReducedMotion = mql.matches;
|
|
655
|
-
const handler = (e) => (this.prefersReducedMotion = e.matches);
|
|
656
|
-
mql.addEventListener('change', handler);
|
|
657
|
-
destroyRef.onDestroy(() => mql.removeEventListener('change', handler));
|
|
658
|
-
}
|
|
894
|
+
this.destroyRef.onDestroy(() => {
|
|
895
|
+
for (const cleanup of [...this.pendingCleanups]) {
|
|
896
|
+
cleanup();
|
|
897
|
+
}
|
|
898
|
+
});
|
|
659
899
|
}
|
|
660
900
|
/** @internal */
|
|
661
901
|
handlePointerDown(event) {
|
|
662
|
-
if (this.disabled() || this.prefersReducedMotion) {
|
|
902
|
+
if (this.disabled() || this.prefersReducedMotion()) {
|
|
663
903
|
return;
|
|
664
904
|
}
|
|
665
905
|
const host = this.el.nativeElement;
|
|
@@ -678,6 +918,9 @@ class CngxRipple {
|
|
|
678
918
|
const size = Math.max(Math.hypot(x, y), Math.hypot(rect.width - x, y), Math.hypot(x, rect.height - y), Math.hypot(rect.width - x, rect.height - y)) * 2;
|
|
679
919
|
const wave = this.doc.createElement('span');
|
|
680
920
|
wave.className = 'cngx-ripple__wave';
|
|
921
|
+
// Decorative feedback only - keep the transient span out of the
|
|
922
|
+
// accessibility tree so AT never announces an empty inline element.
|
|
923
|
+
wave.setAttribute('aria-hidden', 'true');
|
|
681
924
|
wave.style.setProperty('--cngx-ripple-x', `${x}px`);
|
|
682
925
|
wave.style.setProperty('--cngx-ripple-y', `${y}px`);
|
|
683
926
|
wave.style.setProperty('--cngx-ripple-size', `${size}px`);
|
|
@@ -691,10 +934,12 @@ class CngxRipple {
|
|
|
691
934
|
return;
|
|
692
935
|
}
|
|
693
936
|
cleaned = true;
|
|
937
|
+
this.pendingCleanups.delete(cleanup);
|
|
694
938
|
clearTimeout(fallbackTimer);
|
|
695
939
|
wave.remove();
|
|
696
940
|
this.activeState.set(false);
|
|
697
941
|
};
|
|
942
|
+
this.pendingCleanups.add(cleanup);
|
|
698
943
|
wave.addEventListener('animationend', cleanup, { once: true });
|
|
699
944
|
// Fallback timeout in case animationend doesn't fire (e.g. display:none)
|
|
700
945
|
const fallbackTimer = setTimeout(cleanup, 1000);
|
|
@@ -944,6 +1189,16 @@ function provideNavConfig(...features) {
|
|
|
944
1189
|
...(config.singleAccordion ? [CngxNavGroupRegistry] : []),
|
|
945
1190
|
];
|
|
946
1191
|
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Component-scoped variant - use in `viewProviders` so the nav config
|
|
1194
|
+
* only applies to descendants of this component. Same feature merge as
|
|
1195
|
+
* {@link provideNavConfig}.
|
|
1196
|
+
*
|
|
1197
|
+
* @category common/interactive
|
|
1198
|
+
*/
|
|
1199
|
+
function provideNavConfigAt(...features) {
|
|
1200
|
+
return provideNavConfig(...features);
|
|
1201
|
+
}
|
|
947
1202
|
/**
|
|
948
1203
|
* Enables single-accordion mode - only one nav group can be open at a time.
|
|
949
1204
|
*
|
|
@@ -1041,8 +1296,11 @@ class CngxDisclosure {
|
|
|
1041
1296
|
opened = computed(() => this.openedInput() ?? this.openedState(), ...(ngDevMode ? [{ debugName: "opened" }] : /* istanbul ignore next */ []));
|
|
1042
1297
|
/** Emitted when the opened state changes. */
|
|
1043
1298
|
openedChange = output();
|
|
1044
|
-
/** Opens the disclosure. */
|
|
1299
|
+
/** Opens the disclosure. No-op when already open (parity with `close()`). */
|
|
1045
1300
|
open() {
|
|
1301
|
+
if (this.opened()) {
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1046
1304
|
this.openedState.set(true);
|
|
1047
1305
|
this.openedChange.emit(true);
|
|
1048
1306
|
}
|
|
@@ -1137,6 +1395,11 @@ class CngxNavGroup {
|
|
|
1137
1395
|
depth = input(0, ...(ngDevMode ? [{ debugName: "depth" }] : /* istanbul ignore next */ []));
|
|
1138
1396
|
registry = inject(CngxNavGroupRegistry, { optional: true });
|
|
1139
1397
|
config = inject(CNGX_NAV_CONFIG, { optional: true });
|
|
1398
|
+
// Emitted only when explicitly configured - a default here would sit on
|
|
1399
|
+
// the host element and shadow ancestor-cascade values, breaking the
|
|
1400
|
+
// documented var(--token, fallback) consumer path.
|
|
1401
|
+
navIndent = this.config?.indent !== undefined ? `${this.config.indent}px` : null;
|
|
1402
|
+
navTransition = this.config?.animationDuration !== undefined ? `${this.config.animationDuration}ms` : null;
|
|
1140
1403
|
constructor() {
|
|
1141
1404
|
this.registry?.register(this);
|
|
1142
1405
|
inject(DestroyRef).onDestroy(() => this.registry?.unregister(this));
|
|
@@ -1145,13 +1408,16 @@ class CngxNavGroup {
|
|
|
1145
1408
|
if (singleAccordion && registry) {
|
|
1146
1409
|
effect(() => {
|
|
1147
1410
|
if (this.disclosure.opened()) {
|
|
1148
|
-
|
|
1411
|
+
// untracked: closeOthers reads and writes every sibling's
|
|
1412
|
+
// disclosure state - a service-like call, not a dependency. Only
|
|
1413
|
+
// this group's own opened() may re-trigger the accordion.
|
|
1414
|
+
untracked(() => registry.closeOthers(this));
|
|
1149
1415
|
}
|
|
1150
1416
|
});
|
|
1151
1417
|
}
|
|
1152
1418
|
}
|
|
1153
1419
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxNavGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1154
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxNavGroup, isStandalone: true, selector: "[cngxNavGroup]", inputs: { depth: { classPropertyName: "depth", publicName: "depth", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-nav-group": "true", "class.cngx-nav-group--open": "disclosure.opened()", "style.--cngx-nav-depth": "depth()" } }, exportAs: ["cngxNavGroup"], hostDirectives: [{ directive: CngxDisclosure, inputs: ["cngxDisclosureOpened", "cngxDisclosureOpened", "controls", "controls"], outputs: ["openedChange", "openedChange"] }], ngImport: i0 });
|
|
1420
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxNavGroup, isStandalone: true, selector: "[cngxNavGroup]", inputs: { depth: { classPropertyName: "depth", publicName: "depth", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-nav-group": "true", "class.cngx-nav-group--open": "disclosure.opened()", "style.--cngx-nav-depth": "depth()", "style.--cngx-nav-indent": "navIndent", "style.--cngx-nav-transition": "navTransition" } }, exportAs: ["cngxNavGroup"], hostDirectives: [{ directive: CngxDisclosure, inputs: ["cngxDisclosureOpened", "cngxDisclosureOpened", "controls", "controls"], outputs: ["openedChange", "openedChange"] }], ngImport: i0 });
|
|
1155
1421
|
}
|
|
1156
1422
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxNavGroup, decorators: [{
|
|
1157
1423
|
type: Directive,
|
|
@@ -1170,6 +1436,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1170
1436
|
'[class.cngx-nav-group]': 'true',
|
|
1171
1437
|
'[class.cngx-nav-group--open]': 'disclosure.opened()',
|
|
1172
1438
|
'[style.--cngx-nav-depth]': 'depth()',
|
|
1439
|
+
'[style.--cngx-nav-indent]': 'navIndent',
|
|
1440
|
+
'[style.--cngx-nav-transition]': 'navTransition',
|
|
1173
1441
|
},
|
|
1174
1442
|
}]
|
|
1175
1443
|
}], ctorParameters: () => [], propDecorators: { depth: [{ type: i0.Input, args: [{ isSignal: true, alias: "depth", required: false }] }] } });
|
|
@@ -1222,6 +1490,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1222
1490
|
}]
|
|
1223
1491
|
}], propDecorators: { heading: [{ type: i0.Input, args: [{ isSignal: true, alias: "heading", required: false }] }], level: [{ type: i0.Input, args: [{ isSignal: true, alias: "level", required: false }] }] } });
|
|
1224
1492
|
|
|
1493
|
+
const graphemeSegmenterFor = memoize((locale) => new Intl.Segmenter(locale, { granularity: 'grapheme' }), { cacheLimit: 8 });
|
|
1494
|
+
/** @internal The first user-perceived character: `é` built from `e` + accent, a flag, an emoji. */
|
|
1495
|
+
function firstGrapheme(text, locale) {
|
|
1496
|
+
if (typeof Intl.Segmenter !== 'function') {
|
|
1497
|
+
return Array.from(text)[0] ?? '';
|
|
1498
|
+
}
|
|
1499
|
+
return graphemeSegmenterFor(locale).segment(text)[Symbol.iterator]().next().value?.segment ?? '';
|
|
1500
|
+
}
|
|
1225
1501
|
/**
|
|
1226
1502
|
* Navigation link atom. Applied to `<a>` or `<button>` elements in a
|
|
1227
1503
|
* sidebar or nav menu.
|
|
@@ -1264,6 +1540,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1264
1540
|
* <example-url>http://localhost:4200/#/common/interactive/nav/nav-links-active-state-depth</example-url>
|
|
1265
1541
|
*/
|
|
1266
1542
|
class CngxNavLink {
|
|
1543
|
+
config = inject(CNGX_NAV_CONFIG, { optional: true });
|
|
1544
|
+
// Emitted only when explicitly configured - a default here would sit on
|
|
1545
|
+
// the host element and shadow ancestor-cascade values, breaking the
|
|
1546
|
+
// documented var(--token, fallback) consumer path.
|
|
1547
|
+
navIndent = this.config?.indent !== undefined ? `${this.config.indent}px` : null;
|
|
1548
|
+
navTransition = this.config?.animationDuration !== undefined ? `${this.config.animationDuration}ms` : null;
|
|
1267
1549
|
/**
|
|
1268
1550
|
* `true` when the host `<a>` lacks an `href` attribute and needs `tabindex="0"`
|
|
1269
1551
|
* + `role="link"` for keyboard focusability.
|
|
@@ -1273,6 +1555,15 @@ class CngxNavLink {
|
|
|
1273
1555
|
*/
|
|
1274
1556
|
needsFocusFix = signal(false, ...(ngDevMode ? [{ debugName: "needsFocusFix" }] : /* istanbul ignore next */ []));
|
|
1275
1557
|
initialized = signal(false, ...(ngDevMode ? [{ debugName: "initialized" }] : /* istanbul ignore next */ []));
|
|
1558
|
+
locale = injectLocale();
|
|
1559
|
+
/** Link text read after the first render; `null` when the consumer set `data-initial`. */
|
|
1560
|
+
initialSource = signal(null, ...(ngDevMode ? [{ debugName: "initialSource" }] : /* istanbul ignore next */ []));
|
|
1561
|
+
/** First character of the link text, uppercased with the app locale. */
|
|
1562
|
+
initial = computed(() => {
|
|
1563
|
+
const text = this.initialSource();
|
|
1564
|
+
const locale = this.locale();
|
|
1565
|
+
return text ? firstGrapheme(text, locale).toLocaleUpperCase(locale) : null;
|
|
1566
|
+
}, ...(ngDevMode ? [{ debugName: "initial" }] : /* istanbul ignore next */ []));
|
|
1276
1567
|
constructor() {
|
|
1277
1568
|
const el = inject((ElementRef)).nativeElement;
|
|
1278
1569
|
afterNextRender(() => {
|
|
@@ -1281,10 +1572,16 @@ class CngxNavLink {
|
|
|
1281
1572
|
}
|
|
1282
1573
|
const text = el.textContent?.trim();
|
|
1283
1574
|
if (text && !Object.hasOwn(el.dataset, 'initial')) {
|
|
1284
|
-
|
|
1575
|
+
this.initialSource.set(text);
|
|
1285
1576
|
}
|
|
1286
1577
|
this.initialized.set(true);
|
|
1287
1578
|
});
|
|
1579
|
+
effect(() => {
|
|
1580
|
+
const initial = this.initial();
|
|
1581
|
+
if (initial) {
|
|
1582
|
+
el.dataset['initial'] = initial;
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
1288
1585
|
// Scroll into view when becoming active (e.g., after route change).
|
|
1289
1586
|
// Skips the initial render to avoid scroll jank on page load.
|
|
1290
1587
|
effect(() => {
|
|
@@ -1308,7 +1605,7 @@ class CngxNavLink {
|
|
|
1308
1605
|
/** Nesting depth for indentation. Consumer sets manually - no ancestor injection. */
|
|
1309
1606
|
depth = input(0, ...(ngDevMode ? [{ debugName: "depth" }] : /* istanbul ignore next */ []));
|
|
1310
1607
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxNavLink, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1311
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxNavLink, isStandalone: true, selector: "a[cngxNavLink], button[cngxNavLink]", inputs: { active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null }, scrollOnActive: { classPropertyName: "scrollOnActive", publicName: "scrollOnActive", isSignal: true, isRequired: false, transformFunction: null }, ariaCurrent: { classPropertyName: "ariaCurrent", publicName: "ariaCurrent", isSignal: true, isRequired: false, transformFunction: null }, depth: { classPropertyName: "depth", publicName: "depth", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-nav-link": "true", "class.cngx-nav-link--active": "active()", "attr.aria-current": "active() ? ariaCurrent() : null", "attr.tabindex": "needsFocusFix() ? 0 : null", "attr.role": "needsFocusFix() ? 'link' : null", "style.--cngx-nav-depth": "depth()" } }, exportAs: ["cngxNavLink"], ngImport: i0 });
|
|
1608
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxNavLink, isStandalone: true, selector: "a[cngxNavLink], button[cngxNavLink]", inputs: { active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null }, scrollOnActive: { classPropertyName: "scrollOnActive", publicName: "scrollOnActive", isSignal: true, isRequired: false, transformFunction: null }, ariaCurrent: { classPropertyName: "ariaCurrent", publicName: "ariaCurrent", isSignal: true, isRequired: false, transformFunction: null }, depth: { classPropertyName: "depth", publicName: "depth", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-nav-link": "true", "class.cngx-nav-link--active": "active()", "attr.aria-current": "active() ? ariaCurrent() : null", "attr.tabindex": "needsFocusFix() ? 0 : null", "attr.role": "needsFocusFix() ? 'link' : null", "style.--cngx-nav-depth": "depth()", "style.--cngx-nav-indent": "navIndent", "style.--cngx-nav-transition": "navTransition" } }, exportAs: ["cngxNavLink"], ngImport: i0 });
|
|
1312
1609
|
}
|
|
1313
1610
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxNavLink, decorators: [{
|
|
1314
1611
|
type: Directive,
|
|
@@ -1323,6 +1620,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1323
1620
|
'[attr.tabindex]': 'needsFocusFix() ? 0 : null',
|
|
1324
1621
|
'[attr.role]': "needsFocusFix() ? 'link' : null",
|
|
1325
1622
|
'[style.--cngx-nav-depth]': 'depth()',
|
|
1623
|
+
'[style.--cngx-nav-indent]': 'navIndent',
|
|
1624
|
+
'[style.--cngx-nav-transition]': 'navTransition',
|
|
1326
1625
|
},
|
|
1327
1626
|
}]
|
|
1328
1627
|
}], ctorParameters: () => [], propDecorators: { active: [{ type: i0.Input, args: [{ isSignal: true, alias: "active", required: false }] }], scrollOnActive: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollOnActive", required: false }] }], ariaCurrent: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaCurrent", required: false }] }], depth: [{ type: i0.Input, args: [{ isSignal: true, alias: "depth", required: false }] }] } });
|
|
@@ -1634,6 +1933,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1634
1933
|
*/
|
|
1635
1934
|
const CNGX_CONTROL_VALUE = new InjectionToken('CngxControlValue');
|
|
1636
1935
|
|
|
1936
|
+
const SLIDER_VALUE_OPTIONS = {
|
|
1937
|
+
useGrouping: false,
|
|
1938
|
+
maximumFractionDigits: 20,
|
|
1939
|
+
};
|
|
1940
|
+
/**
|
|
1941
|
+
* @internal - the default `aria-valuetext` of a slider value: the number in
|
|
1942
|
+
* `locale` without grouping (en-US output equals `String(value)` for every
|
|
1943
|
+
* non-exponential value; de-DE gets the decimal comma). Without a locale it
|
|
1944
|
+
* is `String(value)`.
|
|
1945
|
+
*/
|
|
1946
|
+
function formatSliderValue(value, locale) {
|
|
1947
|
+
if (locale === undefined || !Number.isFinite(value)) {
|
|
1948
|
+
return String(value);
|
|
1949
|
+
}
|
|
1950
|
+
// Intl prints -0 as "-0"; String(-0) is "0".
|
|
1951
|
+
return numberFormatterFor(locale, SLIDER_VALUE_OPTIONS).format(value === 0 ? 0 : value);
|
|
1952
|
+
}
|
|
1637
1953
|
function snapToStep(raw, origin, step) {
|
|
1638
1954
|
if (step <= 0 || !Number.isFinite(step)) {
|
|
1639
1955
|
return raw;
|
|
@@ -1682,7 +1998,7 @@ function createSliderCore(options) {
|
|
|
1682
1998
|
const ariaValueText = computed(() => {
|
|
1683
1999
|
const current = clampedValue();
|
|
1684
2000
|
const format = options.valueText;
|
|
1685
|
-
return format ? format(current) :
|
|
2001
|
+
return format ? format(current) : formatSliderValue(current, options.locale?.());
|
|
1686
2002
|
}, ...(ngDevMode ? [{ debugName: "ariaValueText" }] : /* istanbul ignore next */ []));
|
|
1687
2003
|
const atMin = computed(() => clampedValue() <= boundedMin(), ...(ngDevMode ? [{ debugName: "atMin" }] : /* istanbul ignore next */ []));
|
|
1688
2004
|
const atMax = computed(() => clampedValue() >= boundedMax(), ...(ngDevMode ? [{ debugName: "atMax" }] : /* istanbul ignore next */ []));
|
|
@@ -1712,95 +2028,433 @@ function createSliderCore(options) {
|
|
|
1712
2028
|
}
|
|
1713
2029
|
|
|
1714
2030
|
/**
|
|
1715
|
-
*
|
|
1716
|
-
*
|
|
1717
|
-
* via `Renderer2` (the tracks are headless directives on consumer markup,
|
|
1718
|
-
* so there is no template to project into - same constraint and same shape
|
|
1719
|
-
* as `CngxChipInteraction`). Always-in-DOM per Pillar 2; both the span's
|
|
1720
|
-
* `aria-hidden` and the emitted id reference are gated on
|
|
1721
|
-
* `disabled() && reason()` (Toggle/Radio convergence): accname 1.2 §2A
|
|
1722
|
-
* traverses a directly referenced hidden node, so the id must only be
|
|
1723
|
-
* emitted while the description applies.
|
|
2031
|
+
* DI token resolving to the nearest {@link CngxErrorAggregatorContract}
|
|
2032
|
+
* ancestor.
|
|
1724
2033
|
*
|
|
1725
|
-
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
2034
|
+
* Provided by {@link CngxErrorAggregator} via `useExisting`; descendant
|
|
2035
|
+
* `CngxErrorSource` directives inject with `{ optional: true }` so they
|
|
2036
|
+
* function as no-ops outside an aggregator.
|
|
1728
2037
|
*
|
|
1729
|
-
* @category common/interactive/
|
|
2038
|
+
* @category common/interactive/error
|
|
2039
|
+
* @wcag AA
|
|
2040
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/error-aggregator/error-aggregator.token.ts
|
|
2041
|
+
* @since 0.1.0
|
|
1730
2042
|
*/
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
2043
|
+
const CNGX_ERROR_AGGREGATOR = new InjectionToken('CngxErrorAggregator');
|
|
2044
|
+
|
|
2045
|
+
/**
|
|
2046
|
+
* Shared scaffolding for the interactive form-control hosts (toggle,
|
|
2047
|
+
* checkbox, the standalone interactive chip, and the value groups):
|
|
2048
|
+
* stable uid, focus tracking, the
|
|
2049
|
+
* field-host/aggregator error cascade, the `aria-invalid` gate, and
|
|
2050
|
+
* `[state]`-wins-over-`CNGX_STATEFUL` async-state resolution for
|
|
2051
|
+
* `aria-busy`.
|
|
2052
|
+
*
|
|
2053
|
+
* Call from a field initializer (injection context required - the factory
|
|
2054
|
+
* injects `CNGX_FORM_FIELD_HOST`, `CNGX_ERROR_AGGREGATOR`, and
|
|
2055
|
+
* `CNGX_STATEFUL`, each optional). Declare the `invalid` model and the
|
|
2056
|
+
* `state` input above the call site so the option signals exist when the
|
|
2057
|
+
* initializer runs.
|
|
2058
|
+
*
|
|
2059
|
+
* The factory is wiring, not a swap point: it deliberately has no DI
|
|
2060
|
+
* factory token. Consumers authoring their own form-control atoms get the
|
|
2061
|
+
* same field-host, aggregator, and stateful integration by calling it
|
|
2062
|
+
* directly.
|
|
2063
|
+
*
|
|
2064
|
+
* All host communication stays reactive (Pillar 2): `errorState`,
|
|
2065
|
+
* `ariaInvalid`, and `ariaBusy` are `computed()` members of the returned
|
|
2066
|
+
* bundle. `resolvedState` forwards a stable reference (the bound input
|
|
2067
|
+
* value or the provider's `state` field, never a fresh literal), so
|
|
2068
|
+
* `Object.is` dedupes without an `equal` fn.
|
|
2069
|
+
*
|
|
2070
|
+
* ```ts
|
|
2071
|
+
* private readonly groupHost = injectInteractiveGroupHost({
|
|
2072
|
+
* uidPrefix: 'cngx-checkbox-group-',
|
|
2073
|
+
* invalid: this.invalid,
|
|
2074
|
+
* state: this.state,
|
|
2075
|
+
* });
|
|
2076
|
+
* readonly id = this.groupHost.id;
|
|
2077
|
+
* readonly focused = this.groupHost.focused;
|
|
2078
|
+
* readonly errorState = this.groupHost.errorState;
|
|
2079
|
+
* protected readonly ariaBusy = this.groupHost.ariaBusy;
|
|
2080
|
+
* ```
|
|
2081
|
+
*
|
|
2082
|
+
* @category common/interactive
|
|
2083
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/group-host/group-host.ts
|
|
2084
|
+
* @since 0.1.0
|
|
2085
|
+
* @relatedTo CngxToggle, CngxCheckbox, CngxChipInteraction, CngxCheckboxGroup, CngxRadioGroup, CngxButtonToggleGroup, CngxButtonMultiToggleGroup, CngxChipGroup, CngxMultiChipGroup
|
|
2086
|
+
*/
|
|
2087
|
+
function injectInteractiveGroupHost(options) {
|
|
2088
|
+
const fieldHost = inject(CNGX_FORM_FIELD_HOST, { optional: true });
|
|
2089
|
+
const aggregator = inject(CNGX_ERROR_AGGREGATOR, { optional: true, skipSelf: true });
|
|
2090
|
+
const statefulFallback = inject(CNGX_STATEFUL, { optional: true });
|
|
2091
|
+
const focusedState = signal(false, ...(ngDevMode ? [{ debugName: "focusedState" }] : /* istanbul ignore next */ []));
|
|
2092
|
+
const errorState = computed(() => fieldHost?.showError() ?? aggregator?.shouldShow() ?? false, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
2093
|
+
const ariaLabelledBy = computed(() => {
|
|
2094
|
+
const explicit = options.labelledBy?.();
|
|
2095
|
+
if (explicit) {
|
|
2096
|
+
return explicit;
|
|
1755
2097
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
untracked(() => {
|
|
1760
|
-
if (reason) {
|
|
1761
|
-
renderer.removeAttribute(span, 'aria-hidden');
|
|
1762
|
-
span.textContent = reason;
|
|
1763
|
-
}
|
|
1764
|
-
else {
|
|
1765
|
-
renderer.setAttribute(span, 'aria-hidden', 'true');
|
|
1766
|
-
span.textContent = '';
|
|
1767
|
-
}
|
|
1768
|
-
});
|
|
1769
|
-
});
|
|
2098
|
+
return options.label?.() ? null : (fieldHost?.labelId?.() ?? null);
|
|
2099
|
+
}, ...(ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
|
|
2100
|
+
const resolvedState = computed(() => options.state?.() ?? statefulFallback?.state, ...(ngDevMode ? [{ debugName: "resolvedState" }] : /* istanbul ignore next */ []));
|
|
1770
2101
|
return {
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
2102
|
+
id: signal(nextUid(options.uidPrefix)).asReadonly(),
|
|
2103
|
+
focused: focusedState.asReadonly(),
|
|
2104
|
+
errorState,
|
|
2105
|
+
ariaInvalid: computed(() => options.invalid() || errorState()),
|
|
2106
|
+
ariaLabelledBy,
|
|
2107
|
+
resolvedState,
|
|
2108
|
+
ariaBusy: computed(() => resolvedState()?.status() === 'loading'),
|
|
2109
|
+
handleFocusIn() {
|
|
2110
|
+
focusedState.set(true);
|
|
2111
|
+
},
|
|
2112
|
+
handleFocusOut() {
|
|
2113
|
+
focusedState.set(false);
|
|
2114
|
+
fieldHost?.markAsTouched();
|
|
2115
|
+
},
|
|
1777
2116
|
};
|
|
1778
2117
|
}
|
|
1779
2118
|
|
|
1780
2119
|
/**
|
|
1781
|
-
*
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
1784
|
-
* the geometry math lives in exactly one place.
|
|
2120
|
+
* Global polite live-region announcer for the menu family. Delegates to
|
|
2121
|
+
* the shared {@link CngxLiveAnnouncer}, announcing menu state transitions
|
|
2122
|
+
* (submenu open/close, item activation) through its polite region.
|
|
1785
2123
|
*
|
|
1786
|
-
*
|
|
1787
|
-
*
|
|
2124
|
+
* Scoped `providedIn: 'root'` so every menu in the app shares the same
|
|
2125
|
+
* region; the announcer clears then re-sets one frame later so screen
|
|
2126
|
+
* readers treat repeated identical messages as fresh events.
|
|
2127
|
+
*
|
|
2128
|
+
* Default factory output for {@link CNGX_MENU_ANNOUNCER_FACTORY}.
|
|
2129
|
+
* Consumers obtain the announcer via the factory token, never by
|
|
2130
|
+
* `inject(CngxMenuAnnouncer)` directly, so a swap is enterprise-wide.
|
|
2131
|
+
*
|
|
2132
|
+
* @category common/interactive/menu
|
|
2133
|
+
* @wcag AA
|
|
2134
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/menu/menu-announcer.ts
|
|
1788
2135
|
* @since 0.1.0
|
|
2136
|
+
* @relatedTo CngxMenu, CngxMenuTrigger, CngxMenuItemSubmenu
|
|
1789
2137
|
*/
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
2138
|
+
class CngxMenuAnnouncer {
|
|
2139
|
+
announcer = inject(CngxLiveAnnouncer);
|
|
2140
|
+
/**
|
|
2141
|
+
* Announce a message via the polite live region. Empty messages are
|
|
2142
|
+
* ignored. The region is cleared ~16ms before being repopulated so AT
|
|
2143
|
+
* picks up identical-text repeats as a new event.
|
|
2144
|
+
*/
|
|
2145
|
+
announce(message) {
|
|
2146
|
+
if (!message) {
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
2149
|
+
this.announcer.announce(message, 'polite');
|
|
2150
|
+
}
|
|
2151
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMenuAnnouncer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2152
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMenuAnnouncer, providedIn: 'root' });
|
|
1800
2153
|
}
|
|
2154
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMenuAnnouncer, decorators: [{
|
|
2155
|
+
type: Injectable,
|
|
2156
|
+
args: [{ providedIn: 'root' }]
|
|
2157
|
+
}] });
|
|
1801
2158
|
/**
|
|
1802
|
-
*
|
|
1803
|
-
*
|
|
2159
|
+
* Default factory that hands out the root-scoped {@link CngxMenuAnnouncer}
|
|
2160
|
+
* singleton. Consumers wire a custom announcer by replacing
|
|
2161
|
+
* {@link CNGX_MENU_ANNOUNCER_FACTORY}.
|
|
2162
|
+
*
|
|
2163
|
+
* Must run inside an injection context.
|
|
2164
|
+
*
|
|
2165
|
+
* @category common/interactive/menu
|
|
2166
|
+
*/
|
|
2167
|
+
function createMenuAnnouncer() {
|
|
2168
|
+
return inject(CngxMenuAnnouncer);
|
|
2169
|
+
}
|
|
2170
|
+
/**
|
|
2171
|
+
* DI token carrying the factory that yields the menu family's announcer.
|
|
2172
|
+
* Defaults to {@link createMenuAnnouncer} returning the root-scoped
|
|
2173
|
+
* {@link CngxMenuAnnouncer} singleton. Override via `providers` /
|
|
2174
|
+
* `viewProviders` for telemetry-wrapping, locale-aware, or test-doubled
|
|
2175
|
+
* announcers without forking the menu module. Symmetric to
|
|
2176
|
+
* `CNGX_COMMIT_ERROR_ANNOUNCER_FACTORY` from the select family.
|
|
2177
|
+
*
|
|
2178
|
+
* ```ts
|
|
2179
|
+
* bootstrapApplication(AppComponent, {
|
|
2180
|
+
* providers: [
|
|
2181
|
+
* {
|
|
2182
|
+
* provide: CNGX_MENU_ANNOUNCER_FACTORY,
|
|
2183
|
+
* useValue: () => ({ announce: (msg) => myTelemetry.log(msg) }),
|
|
2184
|
+
* },
|
|
2185
|
+
* ],
|
|
2186
|
+
* });
|
|
2187
|
+
* ```
|
|
2188
|
+
*
|
|
2189
|
+
* @category common/interactive/menu
|
|
2190
|
+
* @wcag AA
|
|
2191
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/menu/menu-announcer.ts
|
|
2192
|
+
* @since 0.1.0
|
|
2193
|
+
*/
|
|
2194
|
+
const CNGX_MENU_ANNOUNCER_FACTORY = new InjectionToken('CNGX_MENU_ANNOUNCER_FACTORY', { providedIn: 'root', factory: () => createMenuAnnouncer });
|
|
2195
|
+
/**
|
|
2196
|
+
* Resolve the {@link CngxMenuAnnouncerLike} from the current injection
|
|
2197
|
+
* scope via the factory token. Must run inside an injection context.
|
|
2198
|
+
*
|
|
2199
|
+
* @category common/interactive/menu
|
|
2200
|
+
*/
|
|
2201
|
+
function injectMenuAnnouncer() {
|
|
2202
|
+
return inject(CNGX_MENU_ANNOUNCER_FACTORY)();
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* Internal helper that brands a config-mutator function with the `_target`
|
|
2207
|
+
* discriminator. Every `with*` feature returns one of these.
|
|
2208
|
+
*
|
|
2209
|
+
* @internal
|
|
2210
|
+
*/
|
|
2211
|
+
function defineMenuConfigFeature(fn) {
|
|
2212
|
+
return Object.assign(fn, { _target: 'config' });
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Library-default menu configuration with the English labels. The token's
|
|
2216
|
+
* default reads `ariaLabels` from the menu section of the active language
|
|
2217
|
+
* pack instead; `withAriaLabels` overrides single labels on top.
|
|
2218
|
+
*
|
|
2219
|
+
* @category common/interactive/menu
|
|
2220
|
+
*/
|
|
2221
|
+
const DEFAULT_MENU_CONFIG = {
|
|
2222
|
+
ariaLabels: CNGX_MENU_LANGUAGE_EN,
|
|
2223
|
+
typeaheadDebounce: 300,
|
|
2224
|
+
submenuOpenDelay: 0,
|
|
2225
|
+
submenuCloseDelay: 150,
|
|
2226
|
+
closeOnSelect: true,
|
|
2227
|
+
dismissOnOutsideClick: true,
|
|
2228
|
+
dismissOnScroll: false,
|
|
2229
|
+
dismissOnBlur: true,
|
|
2230
|
+
};
|
|
2231
|
+
/** @internal The menu section of the active pack over the English section. */
|
|
2232
|
+
const injectMenuSection = createLanguageSection('menu', CNGX_MENU_LANGUAGE_EN);
|
|
2233
|
+
/**
|
|
2234
|
+
* @internal {@link DEFAULT_MENU_CONFIG} with `ariaLabels` read from the menu
|
|
2235
|
+
* section of the active language pack. Runs in an injection context.
|
|
2236
|
+
*/
|
|
2237
|
+
function menuConfigDefaultsFromPack() {
|
|
2238
|
+
return { ...DEFAULT_MENU_CONFIG, ariaLabels: injectMenuSection() };
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* DI token carrying the resolved {@link CngxMenuConfig}. Defaults to
|
|
2242
|
+
* {@link DEFAULT_MENU_CONFIG} with the language pack's labels at root;
|
|
2243
|
+
* override via {@link provideMenuConfig} (app-wide) or
|
|
2244
|
+
* {@link provideMenuConfigAt} (component scope via `viewProviders`).
|
|
2245
|
+
*
|
|
2246
|
+
* @category common/interactive/menu
|
|
2247
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/menu/menu-config.ts
|
|
2248
|
+
* @since 0.1.0
|
|
2249
|
+
*/
|
|
2250
|
+
const CNGX_MENU_CONFIG = new InjectionToken('CngxMenuConfig', {
|
|
2251
|
+
providedIn: 'root',
|
|
2252
|
+
factory: menuConfigDefaultsFromPack,
|
|
2253
|
+
});
|
|
2254
|
+
/** @internal */
|
|
2255
|
+
function applyFeatures(base, features) {
|
|
2256
|
+
return features.reduce((cfg, feature) => feature(cfg), base);
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* Provide a menu configuration at app root. Each feature is a partial
|
|
2260
|
+
* override produced by `with*` helpers (see `menu-config-features.ts`).
|
|
2261
|
+
*
|
|
2262
|
+
* ```ts
|
|
2263
|
+
* bootstrapApplication(AppComponent, {
|
|
2264
|
+
* providers: [
|
|
2265
|
+
* provideMenuConfig(
|
|
2266
|
+
* withAriaLabels({ submenuOpened: 'Untermenü geöffnet' }),
|
|
2267
|
+
* withTypeaheadDebounce(500),
|
|
2268
|
+
* ),
|
|
2269
|
+
* ],
|
|
2270
|
+
* });
|
|
2271
|
+
* ```
|
|
2272
|
+
*
|
|
2273
|
+
* @category common/interactive/menu
|
|
2274
|
+
*/
|
|
2275
|
+
function provideMenuConfig(...features) {
|
|
2276
|
+
return makeEnvironmentProviders([
|
|
2277
|
+
{
|
|
2278
|
+
provide: CNGX_MENU_CONFIG,
|
|
2279
|
+
useFactory: () => applyFeatures(menuConfigDefaultsFromPack(), features),
|
|
2280
|
+
},
|
|
2281
|
+
]);
|
|
2282
|
+
}
|
|
2283
|
+
/**
|
|
2284
|
+
* Component-scoped menu configuration override. Pass into a directive or
|
|
2285
|
+
* component's `viewProviders`; features merge on top of the parent
|
|
2286
|
+
* config (root or an enclosing scope).
|
|
2287
|
+
*
|
|
2288
|
+
* @category common/interactive/menu
|
|
2289
|
+
*/
|
|
2290
|
+
function provideMenuConfigAt(...features) {
|
|
2291
|
+
return [
|
|
2292
|
+
{
|
|
2293
|
+
provide: CNGX_MENU_CONFIG,
|
|
2294
|
+
useFactory: (parent) => applyFeatures(parent ?? menuConfigDefaultsFromPack(), features),
|
|
2295
|
+
deps: [[new SkipSelf(), new Optional(), CNGX_MENU_CONFIG]],
|
|
2296
|
+
},
|
|
2297
|
+
];
|
|
2298
|
+
}
|
|
2299
|
+
/**
|
|
2300
|
+
* Resolves the {@link CngxMenuConfig} from the current injection scope.
|
|
2301
|
+
* Must run inside an injection context.
|
|
2302
|
+
*
|
|
2303
|
+
* @category common/interactive/menu
|
|
2304
|
+
*/
|
|
2305
|
+
function injectMenuConfig() {
|
|
2306
|
+
return inject(CNGX_MENU_CONFIG);
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
/**
|
|
2310
|
+
* Shared interaction core of the three menu item variants
|
|
2311
|
+
* (`CngxMenuItem`, `CngxMenuItemCheckbox`, `CngxMenuItemRadio`) -
|
|
2312
|
+
* previously a tripled block. Owns the AD registration surface
|
|
2313
|
+
* (`id`, `isHighlighted`, `label`), the disabled-aware click handler with
|
|
2314
|
+
* the announcer's `itemDisabled` phrase, and the pointer-highlight
|
|
2315
|
+
* handler; only the activation step stays per-variant via `onActivate`.
|
|
2316
|
+
*
|
|
2317
|
+
* Call from a field initializer (injection context required - the core
|
|
2318
|
+
* injects `ElementRef`, the optional surrounding `CngxActiveDescendant`,
|
|
2319
|
+
* the announcer factory, and the menu config). Interaction contract,
|
|
2320
|
+
* preserved verbatim from the variants: a disabled click announces and
|
|
2321
|
+
* stops; without a surrounding active-descendant a click is a complete
|
|
2322
|
+
* no-op (no `onActivate` either); on the AD path the order is
|
|
2323
|
+
* `highlightByValue` -> `onActivate` -> `activateCurrent`.
|
|
2324
|
+
*
|
|
2325
|
+
* @category common/interactive/menu
|
|
2326
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/menu/menu-item-core.ts
|
|
2327
|
+
* @since 0.1.0
|
|
2328
|
+
* @relatedTo CngxMenuItem, CngxMenuItemCheckbox, CngxMenuItemRadio, CngxMenu
|
|
2329
|
+
*/
|
|
2330
|
+
function injectMenuItemCore(options) {
|
|
2331
|
+
const elementRef = inject((ElementRef));
|
|
2332
|
+
const ad = inject(CngxActiveDescendant, { optional: true });
|
|
2333
|
+
const announcer = inject(CNGX_MENU_ANNOUNCER_FACTORY)();
|
|
2334
|
+
const ariaLabels = coerceSignal(injectMenuConfig().ariaLabels);
|
|
2335
|
+
const id = nextUid('cngx-menu-item');
|
|
2336
|
+
return {
|
|
2337
|
+
id,
|
|
2338
|
+
isHighlighted: computed(() => ad?.activeId() === id),
|
|
2339
|
+
label() {
|
|
2340
|
+
const explicit = options.labelInput();
|
|
2341
|
+
if (explicit) {
|
|
2342
|
+
return explicit;
|
|
2343
|
+
}
|
|
2344
|
+
const el = elementRef.nativeElement;
|
|
2345
|
+
return (el.textContent ?? '').trim();
|
|
2346
|
+
},
|
|
2347
|
+
handleClick() {
|
|
2348
|
+
if (options.disabled()) {
|
|
2349
|
+
announcer.announce(ariaLabels().itemDisabled);
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2352
|
+
if (!ad) {
|
|
2353
|
+
return;
|
|
2354
|
+
}
|
|
2355
|
+
ad.highlightByValue(options.value());
|
|
2356
|
+
options.onActivate?.();
|
|
2357
|
+
ad.activateCurrent();
|
|
2358
|
+
},
|
|
2359
|
+
handlePointerEnter() {
|
|
2360
|
+
if (options.disabled()) {
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
ad?.highlightByValue(options.value());
|
|
2364
|
+
},
|
|
2365
|
+
};
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
/**
|
|
2369
|
+
* Internal disabled-"why" mechanism shared by `CngxSliderTrack` and
|
|
2370
|
+
* `CngxRangeSliderTrack`. Appends an sr-only description span to the host
|
|
2371
|
+
* via `Renderer2` (the tracks are headless directives on consumer markup,
|
|
2372
|
+
* so there is no template to project into - same constraint and same shape
|
|
2373
|
+
* as `CngxChipInteraction`). Always-in-DOM per Pillar 2; both the span's
|
|
2374
|
+
* `aria-hidden` and the emitted id reference are gated on
|
|
2375
|
+
* `disabled() && reason()` (Toggle/Radio convergence): accname 1.2 §2A
|
|
2376
|
+
* traverses a directly referenced hidden node, so the id must only be
|
|
2377
|
+
* emitted while the description applies.
|
|
2378
|
+
*
|
|
2379
|
+
* Must run in an injection context (field initializer / constructor).
|
|
2380
|
+
* Not exported from `public-api.ts` - decompose glue, not a consumer
|
|
2381
|
+
* contract.
|
|
2382
|
+
*
|
|
2383
|
+
* @category common/interactive/slider
|
|
2384
|
+
*/
|
|
2385
|
+
function createSliderDisabledReason(opts) {
|
|
2386
|
+
const hostEl = inject(ElementRef).nativeElement;
|
|
2387
|
+
const renderer = inject(Renderer2);
|
|
2388
|
+
const describedId = nextUid(opts.idPrefix);
|
|
2389
|
+
const span = renderer.createElement('span');
|
|
2390
|
+
renderer.setAttribute(span, 'id', describedId);
|
|
2391
|
+
renderer.setAttribute(span, 'aria-hidden', 'true');
|
|
2392
|
+
// sr-only via inline styles - the directive runs in arbitrary markup, so it
|
|
2393
|
+
// cannot require a consumer stylesheet. Every value reads `--cngx-sr-only-*`
|
|
2394
|
+
// first so consumers can still override (structural/thematic split).
|
|
2395
|
+
renderer.setStyle(span, 'position', 'var(--cngx-sr-only-position, absolute)');
|
|
2396
|
+
renderer.setStyle(span, 'width', 'var(--cngx-sr-only-size, 1px)');
|
|
2397
|
+
renderer.setStyle(span, 'height', 'var(--cngx-sr-only-size, 1px)');
|
|
2398
|
+
renderer.setStyle(span, 'overflow', 'var(--cngx-sr-only-overflow, hidden)');
|
|
2399
|
+
renderer.setStyle(span, 'clip', 'var(--cngx-sr-only-clip, rect(0, 0, 0, 0))');
|
|
2400
|
+
renderer.setStyle(span, 'white-space', 'var(--cngx-sr-only-white-space, nowrap)');
|
|
2401
|
+
renderer.appendChild(hostEl, span);
|
|
2402
|
+
// Host may outlive the directive (structural re-projection) - without
|
|
2403
|
+
// explicit removal the span leaks and the next instance collides on id.
|
|
2404
|
+
inject(DestroyRef).onDestroy(() => {
|
|
2405
|
+
// Host may already be detached by a parent structural directive at the
|
|
2406
|
+
// same destroy tick; removeChild on a stale parent throws.
|
|
2407
|
+
if (span.parentNode === hostEl) {
|
|
2408
|
+
renderer.removeChild(hostEl, span);
|
|
2409
|
+
}
|
|
2410
|
+
});
|
|
2411
|
+
effect(() => {
|
|
2412
|
+
const reason = opts.disabled() && opts.reason() ? opts.reason() : '';
|
|
2413
|
+
untracked(() => {
|
|
2414
|
+
if (reason) {
|
|
2415
|
+
renderer.removeAttribute(span, 'aria-hidden');
|
|
2416
|
+
span.textContent = reason;
|
|
2417
|
+
}
|
|
2418
|
+
else {
|
|
2419
|
+
renderer.setAttribute(span, 'aria-hidden', 'true');
|
|
2420
|
+
span.textContent = '';
|
|
2421
|
+
}
|
|
2422
|
+
});
|
|
2423
|
+
});
|
|
2424
|
+
return {
|
|
2425
|
+
resolvedDescribedBy: computed(() => {
|
|
2426
|
+
if (opts.disabled() && opts.reason()) {
|
|
2427
|
+
return describedId;
|
|
2428
|
+
}
|
|
2429
|
+
return opts.describedBy();
|
|
2430
|
+
}),
|
|
2431
|
+
};
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
/**
|
|
2435
|
+
* Maps a pointer position to a `0..1` track fraction against `el`'s geometry.
|
|
2436
|
+
* Vertical sliders measure bottom-up (fraction 0 at the lower edge) to match the
|
|
2437
|
+
* skin's bottom-anchored fill. Shared by the single slider and the range host so
|
|
2438
|
+
* the geometry math lives in exactly one place.
|
|
2439
|
+
*
|
|
2440
|
+
* @category common/interactive/slider
|
|
2441
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/slider-interaction.ts
|
|
2442
|
+
* @since 0.1.0
|
|
2443
|
+
*/
|
|
2444
|
+
function pointerFraction(el, orientation, clientX, clientY) {
|
|
2445
|
+
const rect = el.getBoundingClientRect();
|
|
2446
|
+
const fraction = orientation === 'vertical'
|
|
2447
|
+
? rect.height > 0
|
|
2448
|
+
? (rect.bottom - clientY) / rect.height
|
|
2449
|
+
: 0
|
|
2450
|
+
: rect.width > 0
|
|
2451
|
+
? (clientX - rect.left) / rect.width
|
|
2452
|
+
: 0;
|
|
2453
|
+
return Math.min(1, Math.max(0, fraction));
|
|
2454
|
+
}
|
|
2455
|
+
/**
|
|
2456
|
+
* Pure factory for a slider's keyboard + pointer-drag behaviour - the shared
|
|
2457
|
+
* interaction brain for both {@link CngxSlider} (single) and each
|
|
1804
2458
|
* {@link CngxSliderThumb} (range). Arrow / Page / Home / End map onto the core's
|
|
1805
2459
|
* step helpers; pointer-down captures the pointer and drags via the supplied
|
|
1806
2460
|
* `fractionFromPointer`. Keeping this in one factory means the track and the
|
|
@@ -1966,6 +2620,7 @@ class CngxSliderTrack {
|
|
|
1966
2620
|
/** Optional `aria-valuetext` formatter (currency, dates, named stops). */
|
|
1967
2621
|
valueText = input(undefined, ...(ngDevMode ? [{ debugName: "valueText" }] : /* istanbul ignore next */ []));
|
|
1968
2622
|
el = inject((ElementRef)).nativeElement;
|
|
2623
|
+
locale = injectLocale();
|
|
1969
2624
|
/** Disabled-"why" span + gated `aria-describedby` resolution. */
|
|
1970
2625
|
reason = createSliderDisabledReason({
|
|
1971
2626
|
idPrefix: 'cngx-slider-desc',
|
|
@@ -1981,7 +2636,7 @@ class CngxSliderTrack {
|
|
|
1981
2636
|
step: this.step,
|
|
1982
2637
|
valueText: (v) => {
|
|
1983
2638
|
const format = this.valueText();
|
|
1984
|
-
return format ? format(v) :
|
|
2639
|
+
return format ? format(v) : formatSliderValue(v, this.locale());
|
|
1985
2640
|
},
|
|
1986
2641
|
});
|
|
1987
2642
|
/** Thumb position along the track in `[0, 1]`. For a skin to read. */
|
|
@@ -2095,6 +2750,7 @@ function sliderTickValues(min, max, step, maxCount = 21) {
|
|
|
2095
2750
|
return stops;
|
|
2096
2751
|
}
|
|
2097
2752
|
|
|
2753
|
+
const NUMBER_FORMAT$1 = {};
|
|
2098
2754
|
/**
|
|
2099
2755
|
* Finished single-thumb slider. The 90% API: drop it in, bind `[(value)]`, done -
|
|
2100
2756
|
* it renders the track, fill, and thumb for you and wires the full APG keyboard
|
|
@@ -2144,10 +2800,16 @@ class CngxSlider {
|
|
|
2144
2800
|
marks: this.showTicks,
|
|
2145
2801
|
labels: this.showTickLabels,
|
|
2146
2802
|
});
|
|
2147
|
-
|
|
2803
|
+
locale = injectLocale();
|
|
2804
|
+
/**
|
|
2805
|
+
* Format a value through the bound `valueText` (so tick labels match the
|
|
2806
|
+
* thumb), else with the app locale's number format.
|
|
2807
|
+
*/
|
|
2148
2808
|
format(value) {
|
|
2149
2809
|
const formatter = this.brain.valueText();
|
|
2150
|
-
return formatter
|
|
2810
|
+
return formatter
|
|
2811
|
+
? formatter(value)
|
|
2812
|
+
: numberFormatterFor(this.locale(), NUMBER_FORMAT$1).format(value);
|
|
2151
2813
|
}
|
|
2152
2814
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSlider, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2153
2815
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxSlider, isStandalone: true, selector: "cngx-slider", inputs: { showValue: { classPropertyName: "showValue", publicName: "showValue", isSignal: true, isRequired: false, transformFunction: null }, showValueBubble: { classPropertyName: "showValueBubble", publicName: "showValueBubble", isSignal: true, isRequired: false, transformFunction: null }, showTicks: { classPropertyName: "showTicks", publicName: "showTicks", isSignal: true, isRequired: false, transformFunction: null }, showTickLabels: { classPropertyName: "showTickLabels", publicName: "showTickLabels", isSignal: true, isRequired: false, transformFunction: null }, thumbGlyph: { classPropertyName: "thumbGlyph", publicName: "thumbGlyph", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-slider--ticks": "showTicks()", "class.cngx-slider--bubble": "showValueBubble()", "style.--cngx-slider-tick-interval": "ticks.interval()" }, classAttribute: "cngx-slider" }, exportAs: ["cngxSlider"], hostDirectives: [{ directive: CngxSliderTrack, inputs: ["value", "value", "min", "min", "max", "max", "step", "step", "largeStep", "largeStep", "disabled", "disabled", "disabledReason", "disabledReason", "cngxDescribedBy", "cngxDescribedBy", "orientation", "orientation", "valueText", "valueText"], outputs: ["valueChange", "valueChange"] }], ngImport: i0, template: `
|
|
@@ -2172,7 +2834,7 @@ class CngxSlider {
|
|
|
2172
2834
|
@if (showValueBubble()) {
|
|
2173
2835
|
<span class="cngx-slider__bubble" aria-hidden="true">{{ brain.displayValue() }}</span>
|
|
2174
2836
|
}
|
|
2175
|
-
`, isInline: true, styles: ["cngx-slider{--cngx-slider-value-gap: var(--cngx-space-xs, .25rem);--cngx-slider-bubble-gap: var(--cngx-space-sm, .5rem);--cngx-slider-bubble-padding: var(--cngx-space-xs, .125rem) var(--cngx-space-sm, .4rem);position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-slider[aria-disabled=true]{
|
|
2837
|
+
`, isInline: true, styles: ["cngx-slider{--cngx-slider-value-gap: var(--cngx-space-xs, .25rem);--cngx-slider-bubble-gap: var(--cngx-space-sm, .5rem);--cngx-slider-bubble-padding: var(--cngx-space-xs, .125rem) var(--cngx-space-sm, .4rem);position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-slider[aria-disabled=true]{cursor:not-allowed;--cngx-slider-fill-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 38%, transparent);--cngx-slider-thumb-border-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 38%, transparent);--cngx-slider-track-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 12%, transparent);color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}cngx-slider[aria-disabled=true] :is(.cngx-slider__value,.cngx-slider__tick-label){color:inherit}cngx-slider .cngx-slider__track{position:relative;flex:1 1 auto;block-size:var(--cngx-slider-track-size, 4px);border-radius:999px;background:var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250)))}cngx-slider .cngx-slider__fill{position:absolute;inset-block:0;inset-inline-start:0;inline-size:calc(var(--cngx-slider-fraction, 0) * 100%);border-radius:inherit;background:var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50)))}cngx-slider .cngx-slider__thumb{position:absolute;display:grid;place-items:center;inset-block-start:50%;inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-thumb-size, 16px);border-radius:50%;background:var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));border:var(--cngx-slider-thumb-border-width, 2px) solid var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(.66 .19 50)));translate:-50% -50%;pointer-events:none}cngx-slider.cngx-slider--ticks .cngx-slider__track:before{content:\"\";position:absolute;inset:0;border-radius:inherit;background-image:repeating-linear-gradient(to right,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-slider .cngx-slider__value{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-value-gap, .25rem));inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;color:var(--cngx-color-text, oklch(.2 .01 250));pointer-events:none;white-space:nowrap;unicode-bidi:var(--cngx-slider-value-bidi, isolate)}cngx-slider .cngx-slider__bubble{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-bubble-gap, .5rem));inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 0;padding:var(--cngx-slider-bubble-padding, .125rem .4rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-slider-bubble-bg, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-slider-bubble-color, var(--cngx-color-on-primary, oklch(.99 .01 250)));font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity var(--cngx-duration-fast, .15s) ease;unicode-bidi:var(--cngx-slider-value-bidi, isolate)}cngx-slider:focus .cngx-slider__bubble,cngx-slider:active .cngx-slider__bubble{opacity:1}cngx-slider .cngx-slider__ticks{position:absolute;inset-inline:0;inset-block-start:calc(100% + .35rem);block-size:1em;pointer-events:none}cngx-slider .cngx-slider__tick-label{position:absolute;inset-inline-start:calc(var(--cngx-slider-tick-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-slider-tick-font-size, .6875rem);font-variant-numeric:tabular-nums;color:var(--cngx-slider-tick-label-color, var(--cngx-color-text-muted, oklch(.55 .01 250)));white-space:nowrap;unicode-bidi:var(--cngx-slider-value-bidi, isolate)}cngx-slider:focus-visible{outline:none}cngx-slider:focus-visible .cngx-slider__thumb{outline:var(--cngx-slider-focus-ring-width, 2px) solid var(--cngx-slider-focus-ring-color, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}cngx-slider[aria-orientation=vertical] .cngx-slider__ticks{inset-inline:auto;inset-block:0;inset-inline-start:calc(100% + .35rem);inline-size:3ch;block-size:auto}cngx-slider[aria-orientation=vertical] .cngx-slider__tick-label{inset-inline-start:auto;inset-inline-end:0;inset-block-start:calc(100% - var(--cngx-slider-tick-fraction, 0) * 100%);text-align:end;translate:0 -50%}cngx-slider[aria-orientation=vertical]{flex-direction:column;inline-size:max-content;min-inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-length, 9rem);min-block-size:0}cngx-slider[aria-orientation=vertical] .cngx-slider__track{flex:1 1 auto;inline-size:var(--cngx-slider-track-size, 4px);block-size:auto}cngx-slider[aria-orientation=vertical] .cngx-slider__fill{inset-inline:0;inset-block:auto 0;inline-size:100%;block-size:calc(var(--cngx-slider-fraction, 0) * 100%)}cngx-slider[aria-orientation=vertical].cngx-slider--ticks .cngx-slider__track:before{background-image:repeating-linear-gradient(to top,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-slider[aria-orientation=vertical] .cngx-slider__thumb{inset-inline-start:50%;inset-block-start:auto;inset-block-end:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 50%}cngx-slider[aria-orientation=vertical] .cngx-slider__value{inset-block-end:auto;inset-block-start:calc(100% - var(--cngx-slider-fraction, 0) * 100%);inset-inline-start:auto;inset-inline-end:calc(100% + .5rem);translate:0 -50%}@media(forced-colors:active){cngx-slider{--cngx-slider-track-color: CanvasText;--cngx-slider-fill-color: Highlight}cngx-slider :is(.cngx-slider__track,.cngx-slider__fill){forced-color-adjust:none}cngx-slider[aria-disabled=true]{--cngx-slider-track-color: Canvas;--cngx-slider-fill-color: GrayText;--cngx-slider-thumb-border-color: GrayText;color:GrayText}cngx-slider[aria-disabled=true] .cngx-slider__track{outline:1px solid GrayText;outline-offset:-1px}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2176
2838
|
}
|
|
2177
2839
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSlider, decorators: [{
|
|
2178
2840
|
type: Component,
|
|
@@ -2220,7 +2882,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2220
2882
|
@if (showValueBubble()) {
|
|
2221
2883
|
<span class="cngx-slider__bubble" aria-hidden="true">{{ brain.displayValue() }}</span>
|
|
2222
2884
|
}
|
|
2223
|
-
`, styles: ["cngx-slider{--cngx-slider-value-gap: var(--cngx-space-xs, .25rem);--cngx-slider-bubble-gap: var(--cngx-space-sm, .5rem);--cngx-slider-bubble-padding: var(--cngx-space-xs, .125rem) var(--cngx-space-sm, .4rem);position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-slider[aria-disabled=true]{
|
|
2885
|
+
`, styles: ["cngx-slider{--cngx-slider-value-gap: var(--cngx-space-xs, .25rem);--cngx-slider-bubble-gap: var(--cngx-space-sm, .5rem);--cngx-slider-bubble-padding: var(--cngx-space-xs, .125rem) var(--cngx-space-sm, .4rem);position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-slider[aria-disabled=true]{cursor:not-allowed;--cngx-slider-fill-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 38%, transparent);--cngx-slider-thumb-border-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 38%, transparent);--cngx-slider-track-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 12%, transparent);color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}cngx-slider[aria-disabled=true] :is(.cngx-slider__value,.cngx-slider__tick-label){color:inherit}cngx-slider .cngx-slider__track{position:relative;flex:1 1 auto;block-size:var(--cngx-slider-track-size, 4px);border-radius:999px;background:var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250)))}cngx-slider .cngx-slider__fill{position:absolute;inset-block:0;inset-inline-start:0;inline-size:calc(var(--cngx-slider-fraction, 0) * 100%);border-radius:inherit;background:var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50)))}cngx-slider .cngx-slider__thumb{position:absolute;display:grid;place-items:center;inset-block-start:50%;inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-thumb-size, 16px);border-radius:50%;background:var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));border:var(--cngx-slider-thumb-border-width, 2px) solid var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(.66 .19 50)));translate:-50% -50%;pointer-events:none}cngx-slider.cngx-slider--ticks .cngx-slider__track:before{content:\"\";position:absolute;inset:0;border-radius:inherit;background-image:repeating-linear-gradient(to right,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-slider .cngx-slider__value{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-value-gap, .25rem));inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;color:var(--cngx-color-text, oklch(.2 .01 250));pointer-events:none;white-space:nowrap;unicode-bidi:var(--cngx-slider-value-bidi, isolate)}cngx-slider .cngx-slider__bubble{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-bubble-gap, .5rem));inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 0;padding:var(--cngx-slider-bubble-padding, .125rem .4rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-slider-bubble-bg, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-slider-bubble-color, var(--cngx-color-on-primary, oklch(.99 .01 250)));font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity var(--cngx-duration-fast, .15s) ease;unicode-bidi:var(--cngx-slider-value-bidi, isolate)}cngx-slider:focus .cngx-slider__bubble,cngx-slider:active .cngx-slider__bubble{opacity:1}cngx-slider .cngx-slider__ticks{position:absolute;inset-inline:0;inset-block-start:calc(100% + .35rem);block-size:1em;pointer-events:none}cngx-slider .cngx-slider__tick-label{position:absolute;inset-inline-start:calc(var(--cngx-slider-tick-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-slider-tick-font-size, .6875rem);font-variant-numeric:tabular-nums;color:var(--cngx-slider-tick-label-color, var(--cngx-color-text-muted, oklch(.55 .01 250)));white-space:nowrap;unicode-bidi:var(--cngx-slider-value-bidi, isolate)}cngx-slider:focus-visible{outline:none}cngx-slider:focus-visible .cngx-slider__thumb{outline:var(--cngx-slider-focus-ring-width, 2px) solid var(--cngx-slider-focus-ring-color, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}cngx-slider[aria-orientation=vertical] .cngx-slider__ticks{inset-inline:auto;inset-block:0;inset-inline-start:calc(100% + .35rem);inline-size:3ch;block-size:auto}cngx-slider[aria-orientation=vertical] .cngx-slider__tick-label{inset-inline-start:auto;inset-inline-end:0;inset-block-start:calc(100% - var(--cngx-slider-tick-fraction, 0) * 100%);text-align:end;translate:0 -50%}cngx-slider[aria-orientation=vertical]{flex-direction:column;inline-size:max-content;min-inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-length, 9rem);min-block-size:0}cngx-slider[aria-orientation=vertical] .cngx-slider__track{flex:1 1 auto;inline-size:var(--cngx-slider-track-size, 4px);block-size:auto}cngx-slider[aria-orientation=vertical] .cngx-slider__fill{inset-inline:0;inset-block:auto 0;inline-size:100%;block-size:calc(var(--cngx-slider-fraction, 0) * 100%)}cngx-slider[aria-orientation=vertical].cngx-slider--ticks .cngx-slider__track:before{background-image:repeating-linear-gradient(to top,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-slider[aria-orientation=vertical] .cngx-slider__thumb{inset-inline-start:50%;inset-block-start:auto;inset-block-end:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 50%}cngx-slider[aria-orientation=vertical] .cngx-slider__value{inset-block-end:auto;inset-block-start:calc(100% - var(--cngx-slider-fraction, 0) * 100%);inset-inline-start:auto;inset-inline-end:calc(100% + .5rem);translate:0 -50%}@media(forced-colors:active){cngx-slider{--cngx-slider-track-color: CanvasText;--cngx-slider-fill-color: Highlight}cngx-slider :is(.cngx-slider__track,.cngx-slider__fill){forced-color-adjust:none}cngx-slider[aria-disabled=true]{--cngx-slider-track-color: Canvas;--cngx-slider-fill-color: GrayText;--cngx-slider-thumb-border-color: GrayText;color:GrayText}cngx-slider[aria-disabled=true] .cngx-slider__track{outline:1px solid GrayText;outline-offset:-1px}}\n"] }]
|
|
2224
2886
|
}], propDecorators: { showValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "showValue", required: false }] }], showValueBubble: [{ type: i0.Input, args: [{ isSignal: true, alias: "showValueBubble", required: false }] }], showTicks: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTicks", required: false }] }], showTickLabels: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTickLabels", required: false }] }], thumbGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbGlyph", required: false }] }] } });
|
|
2225
2887
|
|
|
2226
2888
|
/**
|
|
@@ -2410,6 +3072,7 @@ class CngxSliderThumb {
|
|
|
2410
3072
|
position = input.required({ ...(ngDevMode ? { debugName: "position" } : /* istanbul ignore next */ {}), alias: 'cngxSliderThumb' });
|
|
2411
3073
|
range = inject(CNGX_SLIDER_RANGE);
|
|
2412
3074
|
el = inject((ElementRef)).nativeElement;
|
|
3075
|
+
locale = injectLocale();
|
|
2413
3076
|
/** Sibling-clamped bounds for this thumb, selected reactively by position. */
|
|
2414
3077
|
bounds = computed(() => this.range.boundsFor(this.position()), ...(ngDevMode ? [{ debugName: "bounds" }] : /* istanbul ignore next */ []));
|
|
2415
3078
|
value = createThumbValue(this.range, this.position);
|
|
@@ -2423,7 +3086,7 @@ class CngxSliderThumb {
|
|
|
2423
3086
|
boundedMax: computed(() => this.bounds().max()),
|
|
2424
3087
|
valueText: (v) => {
|
|
2425
3088
|
const format = this.range.valueText();
|
|
2426
|
-
return format ? format(v) :
|
|
3089
|
+
return format ? format(v) : formatSliderValue(v, this.locale());
|
|
2427
3090
|
},
|
|
2428
3091
|
});
|
|
2429
3092
|
pageStep = computed(() => {
|
|
@@ -2474,6 +3137,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2474
3137
|
}]
|
|
2475
3138
|
}], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxSliderThumb", required: true }] }] } });
|
|
2476
3139
|
|
|
3140
|
+
const NUMBER_FORMAT = {};
|
|
2477
3141
|
/**
|
|
2478
3142
|
* Finished two-thumb (range) slider. Drop it in, bind `[(value)]` to a
|
|
2479
3143
|
* `[number, number]` tuple - it renders the track, the fill band between the
|
|
@@ -2499,10 +3163,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2499
3163
|
* @relatedTo CngxRangeSliderTrack, CngxSlider, CngxSliderThumb
|
|
2500
3164
|
*/
|
|
2501
3165
|
class CngxRangeSlider {
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
/**
|
|
2505
|
-
|
|
3166
|
+
i18n = injectResolvedInteractiveI18n();
|
|
3167
|
+
locale = injectLocale();
|
|
3168
|
+
/**
|
|
3169
|
+
* Accessible name of the start (minimum) thumb. Unbound, it follows
|
|
3170
|
+
* `CNGX_INTERACTIVE_I18N.rangeMinimum`.
|
|
3171
|
+
*/
|
|
3172
|
+
startLabel = input(undefined, ...(ngDevMode ? [{ debugName: "startLabel" }] : /* istanbul ignore next */ []));
|
|
3173
|
+
/**
|
|
3174
|
+
* Accessible name of the end (maximum) thumb. Unbound, it follows
|
|
3175
|
+
* `CNGX_INTERACTIVE_I18N.rangeMaximum`.
|
|
3176
|
+
*/
|
|
3177
|
+
endLabel = input(undefined, ...(ngDevMode ? [{ debugName: "endLabel" }] : /* istanbul ignore next */ []));
|
|
3178
|
+
resolvedStartLabel = computed(() => this.startLabel() ?? this.i18n().rangeMinimum, ...(ngDevMode ? [{ debugName: "resolvedStartLabel" }] : /* istanbul ignore next */ []));
|
|
3179
|
+
resolvedEndLabel = computed(() => this.endLabel() ?? this.i18n().rangeMaximum, ...(ngDevMode ? [{ debugName: "resolvedEndLabel" }] : /* istanbul ignore next */ []));
|
|
2506
3180
|
/** Render the formatted `start - end` values centred between the thumbs (visual only). */
|
|
2507
3181
|
showValue = input(false, { ...(ngDevMode ? { debugName: "showValue" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2508
3182
|
/** Show the combined `start - end` value as a bubble only while focused / dragged. */
|
|
@@ -2525,19 +3199,30 @@ class CngxRangeSlider {
|
|
|
2525
3199
|
marks: this.showTicks,
|
|
2526
3200
|
labels: this.showTickLabels,
|
|
2527
3201
|
});
|
|
3202
|
+
/** The visible `start - end` value, ordered and joined by the `rangeValue` message. */
|
|
3203
|
+
rangeValueText = computed(() => {
|
|
3204
|
+
const [start, end] = this.brain.value();
|
|
3205
|
+
return this.i18n().rangeValue(this.format(start), this.format(end));
|
|
3206
|
+
}, ...(ngDevMode ? [{ debugName: "rangeValueText" }] : /* istanbul ignore next */ []));
|
|
3207
|
+
/**
|
|
3208
|
+
* Format a value through the bound `valueText` (so tick labels match the
|
|
3209
|
+
* thumbs), else with the app locale's number format.
|
|
3210
|
+
*/
|
|
2528
3211
|
format(value) {
|
|
2529
3212
|
const formatter = this.brain.valueText();
|
|
2530
|
-
return formatter
|
|
3213
|
+
return formatter
|
|
3214
|
+
? formatter(value)
|
|
3215
|
+
: numberFormatterFor(this.locale(), NUMBER_FORMAT).format(value);
|
|
2531
3216
|
}
|
|
2532
3217
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRangeSlider, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2533
3218
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxRangeSlider, isStandalone: true, selector: "cngx-range-slider", inputs: { startLabel: { classPropertyName: "startLabel", publicName: "startLabel", isSignal: true, isRequired: false, transformFunction: null }, endLabel: { classPropertyName: "endLabel", publicName: "endLabel", isSignal: true, isRequired: false, transformFunction: null }, showValue: { classPropertyName: "showValue", publicName: "showValue", isSignal: true, isRequired: false, transformFunction: null }, showValueBubble: { classPropertyName: "showValueBubble", publicName: "showValueBubble", isSignal: true, isRequired: false, transformFunction: null }, showTicks: { classPropertyName: "showTicks", publicName: "showTicks", isSignal: true, isRequired: false, transformFunction: null }, showTickLabels: { classPropertyName: "showTickLabels", publicName: "showTickLabels", isSignal: true, isRequired: false, transformFunction: null }, thumbGlyph: { classPropertyName: "thumbGlyph", publicName: "thumbGlyph", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-slider--ticks": "showTicks()", "class.cngx-slider--bubble": "showValueBubble()", "style.--cngx-slider-tick-interval": "ticks.interval()" }, classAttribute: "cngx-slider cngx-range-slider" }, exportAs: ["cngxRangeSlider"], hostDirectives: [{ directive: CngxRangeSliderTrack, inputs: ["value", "value", "min", "min", "max", "max", "step", "step", "largeStep", "largeStep", "disabled", "disabled", "disabledReason", "disabledReason", "cngxDescribedBy", "cngxDescribedBy", "orientation", "orientation", "valueText", "valueText"], outputs: ["valueChange", "valueChange"] }], ngImport: i0, template: `
|
|
2534
3219
|
<span class="cngx-slider__track"></span>
|
|
2535
|
-
<span cngxSliderThumb="start" [attr.aria-label]="
|
|
3220
|
+
<span cngxSliderThumb="start" [attr.aria-label]="resolvedStartLabel()">
|
|
2536
3221
|
@if (thumbGlyph(); as glyph) {
|
|
2537
3222
|
<ng-container *ngTemplateOutlet="glyph" />
|
|
2538
3223
|
}
|
|
2539
3224
|
</span>
|
|
2540
|
-
<span cngxSliderThumb="end" [attr.aria-label]="
|
|
3225
|
+
<span cngxSliderThumb="end" [attr.aria-label]="resolvedEndLabel()">
|
|
2541
3226
|
@if (thumbGlyph(); as glyph) {
|
|
2542
3227
|
<ng-container *ngTemplateOutlet="glyph" />
|
|
2543
3228
|
}
|
|
@@ -2558,10 +3243,10 @@ class CngxRangeSlider {
|
|
|
2558
3243
|
aria-hidden="true"
|
|
2559
3244
|
[style.--cngx-slider-mid-fraction]="midFraction()"
|
|
2560
3245
|
>
|
|
2561
|
-
{{
|
|
3246
|
+
{{ rangeValueText() }}
|
|
2562
3247
|
</span>
|
|
2563
3248
|
}
|
|
2564
|
-
`, isInline: true, styles: ["cngx-range-slider{--cngx-slider-value-gap: var(--cngx-space-xs, .25rem);--cngx-slider-bubble-gap: var(--cngx-space-sm, .5rem);--cngx-slider-bubble-padding: var(--cngx-space-xs, .125rem) var(--cngx-space-sm, .4rem);position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-range-slider[aria-disabled=true]{
|
|
3249
|
+
`, isInline: true, styles: ["cngx-range-slider{--cngx-slider-value-gap: var(--cngx-space-xs, .25rem);--cngx-slider-bubble-gap: var(--cngx-space-sm, .5rem);--cngx-slider-bubble-padding: var(--cngx-space-xs, .125rem) var(--cngx-space-sm, .4rem);position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-range-slider[aria-disabled=true]{cursor:not-allowed;--cngx-slider-fill-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 38%, transparent);--cngx-slider-thumb-border-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 38%, transparent);--cngx-slider-track-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 12%, transparent);color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}cngx-range-slider[aria-disabled=true] :is(.cngx-slider__value,.cngx-slider__tick-label){color:inherit}cngx-range-slider .cngx-slider__track{position:relative;flex:1 1 auto;block-size:var(--cngx-slider-track-size, 4px);border-radius:999px;background:linear-gradient(to right,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) 0,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-end-fraction, 1) * 100%),var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-end-fraction, 1) * 100%))}cngx-range-slider.cngx-slider--ticks .cngx-slider__track:before{content:\"\";position:absolute;inset:0;border-radius:inherit;background-image:repeating-linear-gradient(to right,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-range-slider [cngxSliderThumb]{position:absolute;display:grid;place-items:center;inset-block-start:50%;inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-thumb-size, 16px);border-radius:50%;background:var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));border:var(--cngx-slider-thumb-border-width, 2px) solid var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(.66 .19 50)));translate:-50% -50%;cursor:grab}cngx-range-slider [cngxSliderThumb]:focus-visible{outline:var(--cngx-slider-focus-ring-width, 2px) solid var(--cngx-slider-focus-ring-color, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}cngx-range-slider .cngx-slider__ticks{position:absolute;inset-inline:0;inset-block-start:calc(100% + .35rem);block-size:1em;pointer-events:none}cngx-range-slider .cngx-slider__tick-label{position:absolute;inset-inline-start:calc(var(--cngx-slider-tick-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-slider-tick-font-size, .6875rem);font-variant-numeric:tabular-nums;color:var(--cngx-slider-tick-label-color, var(--cngx-color-text-muted, oklch(.55 .01 250)));white-space:nowrap}cngx-range-slider[aria-orientation=vertical] .cngx-slider__ticks{inset-inline:auto;inset-block:0;inset-inline-start:calc(100% + .35rem);inline-size:3ch;block-size:auto}cngx-range-slider[aria-orientation=vertical] .cngx-slider__tick-label{inset-inline-start:auto;inset-inline-end:0;inset-block-start:calc(100% - var(--cngx-slider-tick-fraction, 0) * 100%);text-align:end;translate:0 -50%}cngx-range-slider .cngx-slider__value--range{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-value-gap, .25rem));inset-inline-start:calc(var(--cngx-slider-mid-fraction, .5) * 100%);translate:-50% 0;font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;color:var(--cngx-color-text, oklch(.2 .01 250));pointer-events:none;white-space:nowrap;unicode-bidi:var(--cngx-slider-range-bidi, isolate);direction:var(--cngx-slider-range-direction, inherit)}cngx-range-slider .cngx-slider__value--range.cngx-slider__bubble{inset-block-end:calc(100% + var(--cngx-slider-bubble-gap, .5rem));padding:var(--cngx-slider-bubble-padding, .125rem .4rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-slider-bubble-bg, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-slider-bubble-color, var(--cngx-color-on-primary, oklch(.99 .01 250)));opacity:0;transition:opacity var(--cngx-duration-fast, .15s) ease}cngx-range-slider:focus-within .cngx-slider__bubble,cngx-range-slider:active .cngx-slider__bubble{opacity:1}cngx-range-slider[aria-orientation=vertical]{flex-direction:column;inline-size:max-content;min-inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-length, 9rem);min-block-size:0}cngx-range-slider[aria-orientation=vertical] .cngx-slider__track{flex:1 1 auto;inline-size:var(--cngx-slider-track-size, 4px);block-size:auto;background:linear-gradient(to top,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) 0,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-end-fraction, 1) * 100%),var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-end-fraction, 1) * 100%))}cngx-range-slider[aria-orientation=vertical].cngx-slider--ticks .cngx-slider__track:before{background-image:repeating-linear-gradient(to top,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-range-slider[aria-orientation=vertical] [cngxSliderThumb]{inset-inline-start:50%;inset-block-start:auto;inset-block-end:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 50%}cngx-range-slider[aria-orientation=vertical] .cngx-slider__value--range{inset-block-end:auto;inset-block-start:calc(100% - var(--cngx-slider-mid-fraction, .5) * 100%);inset-inline-start:calc(100% + .5rem);translate:0 -50%}@media(forced-colors:active){cngx-range-slider{--cngx-slider-track-color: CanvasText;--cngx-slider-fill-color: Highlight}cngx-range-slider :is(.cngx-slider__track,.cngx-slider__fill){forced-color-adjust:none}cngx-range-slider[aria-disabled=true]{--cngx-slider-track-color: Canvas;--cngx-slider-fill-color: GrayText;--cngx-slider-thumb-border-color: GrayText;color:GrayText}cngx-range-slider[aria-disabled=true] .cngx-slider__track{outline:1px solid GrayText;outline-offset:-1px}}\n"], dependencies: [{ kind: "directive", type: CngxSliderThumb, selector: "[cngxSliderThumb]", inputs: ["cngxSliderThumb"], exportAs: ["cngxSliderThumb"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2565
3250
|
}
|
|
2566
3251
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRangeSlider, decorators: [{
|
|
2567
3252
|
type: Component,
|
|
@@ -2589,12 +3274,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2589
3274
|
'[style.--cngx-slider-tick-interval]': 'ticks.interval()',
|
|
2590
3275
|
}, template: `
|
|
2591
3276
|
<span class="cngx-slider__track"></span>
|
|
2592
|
-
<span cngxSliderThumb="start" [attr.aria-label]="
|
|
3277
|
+
<span cngxSliderThumb="start" [attr.aria-label]="resolvedStartLabel()">
|
|
2593
3278
|
@if (thumbGlyph(); as glyph) {
|
|
2594
3279
|
<ng-container *ngTemplateOutlet="glyph" />
|
|
2595
3280
|
}
|
|
2596
3281
|
</span>
|
|
2597
|
-
<span cngxSliderThumb="end" [attr.aria-label]="
|
|
3282
|
+
<span cngxSliderThumb="end" [attr.aria-label]="resolvedEndLabel()">
|
|
2598
3283
|
@if (thumbGlyph(); as glyph) {
|
|
2599
3284
|
<ng-container *ngTemplateOutlet="glyph" />
|
|
2600
3285
|
}
|
|
@@ -2615,10 +3300,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2615
3300
|
aria-hidden="true"
|
|
2616
3301
|
[style.--cngx-slider-mid-fraction]="midFraction()"
|
|
2617
3302
|
>
|
|
2618
|
-
{{
|
|
3303
|
+
{{ rangeValueText() }}
|
|
2619
3304
|
</span>
|
|
2620
3305
|
}
|
|
2621
|
-
`, styles: ["cngx-range-slider{--cngx-slider-value-gap: var(--cngx-space-xs, .25rem);--cngx-slider-bubble-gap: var(--cngx-space-sm, .5rem);--cngx-slider-bubble-padding: var(--cngx-space-xs, .125rem) var(--cngx-space-sm, .4rem);position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-range-slider[aria-disabled=true]{
|
|
3306
|
+
`, styles: ["cngx-range-slider{--cngx-slider-value-gap: var(--cngx-space-xs, .25rem);--cngx-slider-bubble-gap: var(--cngx-space-sm, .5rem);--cngx-slider-bubble-padding: var(--cngx-space-xs, .125rem) var(--cngx-space-sm, .4rem);position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-range-slider[aria-disabled=true]{cursor:not-allowed;--cngx-slider-fill-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 38%, transparent);--cngx-slider-thumb-border-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 38%, transparent);--cngx-slider-track-color: color-mix(in oklab, var(--cngx-color-text, oklch(.2 .01 250)) 12%, transparent);color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}cngx-range-slider[aria-disabled=true] :is(.cngx-slider__value,.cngx-slider__tick-label){color:inherit}cngx-range-slider .cngx-slider__track{position:relative;flex:1 1 auto;block-size:var(--cngx-slider-track-size, 4px);border-radius:999px;background:linear-gradient(to right,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) 0,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-end-fraction, 1) * 100%),var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-end-fraction, 1) * 100%))}cngx-range-slider.cngx-slider--ticks .cngx-slider__track:before{content:\"\";position:absolute;inset:0;border-radius:inherit;background-image:repeating-linear-gradient(to right,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-range-slider [cngxSliderThumb]{position:absolute;display:grid;place-items:center;inset-block-start:50%;inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-thumb-size, 16px);border-radius:50%;background:var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));border:var(--cngx-slider-thumb-border-width, 2px) solid var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(.66 .19 50)));translate:-50% -50%;cursor:grab}cngx-range-slider [cngxSliderThumb]:focus-visible{outline:var(--cngx-slider-focus-ring-width, 2px) solid var(--cngx-slider-focus-ring-color, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}cngx-range-slider .cngx-slider__ticks{position:absolute;inset-inline:0;inset-block-start:calc(100% + .35rem);block-size:1em;pointer-events:none}cngx-range-slider .cngx-slider__tick-label{position:absolute;inset-inline-start:calc(var(--cngx-slider-tick-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-slider-tick-font-size, .6875rem);font-variant-numeric:tabular-nums;color:var(--cngx-slider-tick-label-color, var(--cngx-color-text-muted, oklch(.55 .01 250)));white-space:nowrap}cngx-range-slider[aria-orientation=vertical] .cngx-slider__ticks{inset-inline:auto;inset-block:0;inset-inline-start:calc(100% + .35rem);inline-size:3ch;block-size:auto}cngx-range-slider[aria-orientation=vertical] .cngx-slider__tick-label{inset-inline-start:auto;inset-inline-end:0;inset-block-start:calc(100% - var(--cngx-slider-tick-fraction, 0) * 100%);text-align:end;translate:0 -50%}cngx-range-slider .cngx-slider__value--range{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-value-gap, .25rem));inset-inline-start:calc(var(--cngx-slider-mid-fraction, .5) * 100%);translate:-50% 0;font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;color:var(--cngx-color-text, oklch(.2 .01 250));pointer-events:none;white-space:nowrap;unicode-bidi:var(--cngx-slider-range-bidi, isolate);direction:var(--cngx-slider-range-direction, inherit)}cngx-range-slider .cngx-slider__value--range.cngx-slider__bubble{inset-block-end:calc(100% + var(--cngx-slider-bubble-gap, .5rem));padding:var(--cngx-slider-bubble-padding, .125rem .4rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-slider-bubble-bg, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-slider-bubble-color, var(--cngx-color-on-primary, oklch(.99 .01 250)));opacity:0;transition:opacity var(--cngx-duration-fast, .15s) ease}cngx-range-slider:focus-within .cngx-slider__bubble,cngx-range-slider:active .cngx-slider__bubble{opacity:1}cngx-range-slider[aria-orientation=vertical]{flex-direction:column;inline-size:max-content;min-inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-length, 9rem);min-block-size:0}cngx-range-slider[aria-orientation=vertical] .cngx-slider__track{flex:1 1 auto;inline-size:var(--cngx-slider-track-size, 4px);block-size:auto;background:linear-gradient(to top,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) 0,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-end-fraction, 1) * 100%),var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-end-fraction, 1) * 100%))}cngx-range-slider[aria-orientation=vertical].cngx-slider--ticks .cngx-slider__track:before{background-image:repeating-linear-gradient(to top,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-range-slider[aria-orientation=vertical] [cngxSliderThumb]{inset-inline-start:50%;inset-block-start:auto;inset-block-end:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 50%}cngx-range-slider[aria-orientation=vertical] .cngx-slider__value--range{inset-block-end:auto;inset-block-start:calc(100% - var(--cngx-slider-mid-fraction, .5) * 100%);inset-inline-start:calc(100% + .5rem);translate:0 -50%}@media(forced-colors:active){cngx-range-slider{--cngx-slider-track-color: CanvasText;--cngx-slider-fill-color: Highlight}cngx-range-slider :is(.cngx-slider__track,.cngx-slider__fill){forced-color-adjust:none}cngx-range-slider[aria-disabled=true]{--cngx-slider-track-color: Canvas;--cngx-slider-fill-color: GrayText;--cngx-slider-thumb-border-color: GrayText;color:GrayText}cngx-range-slider[aria-disabled=true] .cngx-slider__track{outline:1px solid GrayText;outline-offset:-1px}}\n"] }]
|
|
2622
3307
|
}], propDecorators: { startLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "startLabel", required: false }] }], endLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "endLabel", required: false }] }], showValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "showValue", required: false }] }], showValueBubble: [{ type: i0.Input, args: [{ isSignal: true, alias: "showValueBubble", required: false }] }], showTicks: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTicks", required: false }] }], showTickLabels: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTickLabels", required: false }] }], thumbGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbGlyph", required: false }] }] } });
|
|
2623
3308
|
|
|
2624
3309
|
/**
|
|
@@ -2943,14 +3628,14 @@ class CngxAccordionPanel {
|
|
|
2943
3628
|
handleKeydown(event) {
|
|
2944
3629
|
this.accordion.nav.handleKeydown(event);
|
|
2945
3630
|
}
|
|
2946
|
-
|
|
3631
|
+
handleClick() {
|
|
2947
3632
|
if (this.disabled()) {
|
|
2948
3633
|
return;
|
|
2949
3634
|
}
|
|
2950
3635
|
this.accordion.toggle(this.panelId());
|
|
2951
3636
|
}
|
|
2952
3637
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAccordionPanel, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2953
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxAccordionPanel, isStandalone: true, selector: "[cngxAccordionPanel]", inputs: { panelId: { classPropertyName: "panelId", publicName: "panelId", isSignal: true, isRequired: true, transformFunction: null }, controls: { classPropertyName: "controls", publicName: "controls", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "
|
|
3638
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxAccordionPanel, isStandalone: true, selector: "[cngxAccordionPanel]", inputs: { panelId: { classPropertyName: "panelId", publicName: "panelId", isSignal: true, isRequired: true, transformFunction: null }, controls: { classPropertyName: "controls", publicName: "controls", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "handleClick()", "keydown": "handleKeydown($event)" }, properties: { "attr.aria-expanded": "expanded()", "attr.aria-controls": "controls() ?? null", "attr.aria-disabled": "disabled() || null", "attr.tabindex": "tabindex()" } }, exportAs: ["cngxAccordionPanel"], ngImport: i0 });
|
|
2954
3639
|
}
|
|
2955
3640
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAccordionPanel, decorators: [{
|
|
2956
3641
|
type: Directive,
|
|
@@ -2963,7 +3648,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2963
3648
|
'[attr.aria-controls]': 'controls() ?? null',
|
|
2964
3649
|
'[attr.aria-disabled]': 'disabled() || null',
|
|
2965
3650
|
'[attr.tabindex]': 'tabindex()',
|
|
2966
|
-
'(click)': '
|
|
3651
|
+
'(click)': 'handleClick()',
|
|
2967
3652
|
'(keydown)': 'handleKeydown($event)',
|
|
2968
3653
|
},
|
|
2969
3654
|
}]
|
|
@@ -3115,8 +3800,13 @@ const CNGX_BREADCRUMB_COLLAPSE_STRATEGY = new InjectionToken('CNGX_BREADCRUMB_CO
|
|
|
3115
3800
|
* <example-url>http://localhost:4200/#/common/interactive/breadcrumb/basic-trail</example-url>
|
|
3116
3801
|
*/
|
|
3117
3802
|
class CngxBreadcrumb {
|
|
3118
|
-
|
|
3119
|
-
|
|
3803
|
+
i18n = injectResolvedInteractiveI18n();
|
|
3804
|
+
/**
|
|
3805
|
+
* Accessible name of the navigation landmark. Unbound, it follows
|
|
3806
|
+
* `CNGX_INTERACTIVE_I18N.breadcrumb`, including a runtime language switch.
|
|
3807
|
+
*/
|
|
3808
|
+
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
3809
|
+
resolvedLabel = computed(() => this.label() ?? this.i18n().breadcrumb, ...(ngDevMode ? [{ debugName: "resolvedLabel" }] : /* istanbul ignore next */ []));
|
|
3120
3810
|
/** Maximum crumbs to show before the middle collapses. Unset = never collapse. */
|
|
3121
3811
|
maxVisible = input(undefined, ...(ngDevMode ? [{ debugName: "maxVisible" }] : /* istanbul ignore next */ []));
|
|
3122
3812
|
/** Swappable collapse rule; defaults to keep-first + last (max - 1). */
|
|
@@ -3146,7 +3836,7 @@ class CngxBreadcrumb {
|
|
|
3146
3836
|
return index !== undefined && this.collapsedIndices().has(index);
|
|
3147
3837
|
}
|
|
3148
3838
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBreadcrumb, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3149
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxBreadcrumb, isStandalone: true, selector: "[cngxBreadcrumb]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, maxVisible: { classPropertyName: "maxVisible", publicName: "maxVisible", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-label": "
|
|
3839
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxBreadcrumb, isStandalone: true, selector: "[cngxBreadcrumb]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, maxVisible: { classPropertyName: "maxVisible", publicName: "maxVisible", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-label": "resolvedLabel()" } }, providers: [{ provide: CNGX_BREADCRUMB, useExisting: CngxBreadcrumb }], queries: [{ propertyName: "items", predicate: CngxBreadcrumbItem, descendants: true, isSignal: true }], exportAs: ["cngxBreadcrumb"], ngImport: i0 });
|
|
3150
3840
|
}
|
|
3151
3841
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBreadcrumb, decorators: [{
|
|
3152
3842
|
type: Directive,
|
|
@@ -3156,7 +3846,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3156
3846
|
standalone: true,
|
|
3157
3847
|
providers: [{ provide: CNGX_BREADCRUMB, useExisting: CngxBreadcrumb }],
|
|
3158
3848
|
host: {
|
|
3159
|
-
'[attr.aria-label]': '
|
|
3849
|
+
'[attr.aria-label]': 'resolvedLabel()',
|
|
3160
3850
|
},
|
|
3161
3851
|
}]
|
|
3162
3852
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], maxVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxVisible", required: false }] }], items: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxBreadcrumbItem), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
@@ -3190,60 +3880,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3190
3880
|
}]
|
|
3191
3881
|
}] });
|
|
3192
3882
|
|
|
3193
|
-
/**
|
|
3194
|
-
* Default width tiers, matching the headless `responsive-collapse` recipe: 640px
|
|
3195
|
-
* and up shows 6, 440px and up shows 4, anything narrower shows 2. The `0` floor
|
|
3196
|
-
* guarantees a match for every non-negative width.
|
|
3197
|
-
*/
|
|
3198
|
-
const DEFAULT_BREADCRUMB_WIDTH_TIERS = [
|
|
3199
|
-
{ minWidth: 640, maxVisible: 6 },
|
|
3200
|
-
{ minWidth: 440, maxVisible: 4 },
|
|
3201
|
-
{ minWidth: 0, maxVisible: 2 },
|
|
3202
|
-
];
|
|
3203
|
-
/**
|
|
3204
|
-
* Pure width->count resolver: returns the `maxVisible` of the tier with the
|
|
3205
|
-
* highest `minWidth` that is still `<= width`. Order-independent - the tier list
|
|
3206
|
-
* is normalised (sorted by descending `minWidth`) before matching, so a consumer
|
|
3207
|
-
* may pass tiers in any order. When `width` sits below every tier's `minWidth`
|
|
3208
|
-
* the narrowest tier's `maxVisible` is the floor; an empty tier list yields
|
|
3209
|
-
* `Number.POSITIVE_INFINITY` (never collapse), leaving the trail intact.
|
|
3210
|
-
*
|
|
3211
|
-
* No DOM, no Angular - the width source (a `CngxResizeObserver`) lives in the
|
|
3212
|
-
* bar; this stays jsdom-testable and shared by the bar and the headless recipe.
|
|
3213
|
-
*
|
|
3214
|
-
* @category common/interactive/breadcrumb
|
|
3215
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/breadcrumb/breadcrumb-responsive.ts
|
|
3216
|
-
* @since 0.1.0
|
|
3217
|
-
* @relatedTo CngxBreadcrumb, CngxBreadcrumbWidthTier, DEFAULT_BREADCRUMB_WIDTH_TIERS
|
|
3218
|
-
*/
|
|
3219
|
-
function resolveBreadcrumbTier(width, tiers) {
|
|
3220
|
-
if (tiers.length === 0) {
|
|
3221
|
-
return Number.POSITIVE_INFINITY;
|
|
3222
|
-
}
|
|
3223
|
-
const sorted = [...tiers].sort((a, b) => b.minWidth - a.minWidth);
|
|
3224
|
-
for (const tier of sorted) {
|
|
3225
|
-
if (width >= tier.minWidth) {
|
|
3226
|
-
return tier.maxVisible;
|
|
3227
|
-
}
|
|
3228
|
-
}
|
|
3229
|
-
return sorted[sorted.length - 1].maxVisible;
|
|
3230
|
-
}
|
|
3231
|
-
|
|
3232
|
-
/**
|
|
3233
|
-
* DI token resolving to the nearest {@link CngxErrorAggregatorContract}
|
|
3234
|
-
* ancestor.
|
|
3235
|
-
*
|
|
3236
|
-
* Provided by {@link CngxErrorAggregator} via `useExisting`; descendant
|
|
3237
|
-
* `CngxErrorSource` directives inject with `{ optional: true }` so they
|
|
3238
|
-
* function as no-ops outside an aggregator.
|
|
3239
|
-
*
|
|
3240
|
-
* @category common/interactive/error
|
|
3241
|
-
* @wcag AA
|
|
3242
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/error-aggregator/error-aggregator.token.ts
|
|
3243
|
-
* @since 0.1.0
|
|
3244
|
-
*/
|
|
3245
|
-
const CNGX_ERROR_AGGREGATOR = new InjectionToken('CngxErrorAggregator');
|
|
3246
|
-
|
|
3247
3883
|
/**
|
|
3248
3884
|
* Single-value boolean switch with W3C `role="switch"` semantics. Click,
|
|
3249
3885
|
* Space, and Enter all flip `value`; the directive form (`[cngxToggle]`)
|
|
@@ -3355,18 +3991,16 @@ class CngxToggle {
|
|
|
3355
3991
|
this.hasProjectedLabelState.set(!!this.labelRef()?.nativeElement.textContent?.trim());
|
|
3356
3992
|
});
|
|
3357
3993
|
}
|
|
3994
|
+
groupHost = injectInteractiveGroupHost({
|
|
3995
|
+
uidPrefix: 'cngx-toggle-',
|
|
3996
|
+
invalid: this.invalid,
|
|
3997
|
+
});
|
|
3358
3998
|
/** Stable per-instance id used for `<label for>` wiring. */
|
|
3359
|
-
id =
|
|
3360
|
-
focusedState = signal(false, ...(ngDevMode ? [{ debugName: "focusedState" }] : /* istanbul ignore next */ []));
|
|
3999
|
+
id = this.groupHost.id;
|
|
3361
4000
|
/** Whether the host element currently has DOM focus. */
|
|
3362
|
-
focused = this.
|
|
4001
|
+
focused = this.groupHost.focused;
|
|
3363
4002
|
/** True when the toggle is `false` (off) - boolean atom semantics. */
|
|
3364
4003
|
empty = computed(() => this.value() === false, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
3365
|
-
fieldHost = inject(CNGX_FORM_FIELD_HOST, { optional: true });
|
|
3366
|
-
aggregator = inject(CNGX_ERROR_AGGREGATOR, {
|
|
3367
|
-
optional: true,
|
|
3368
|
-
skipSelf: true,
|
|
3369
|
-
});
|
|
3370
4004
|
/**
|
|
3371
4005
|
* Field-host→aggregator cascade. Inside `<cngx-form-field>` the
|
|
3372
4006
|
* presenter governs visibility (touched / strategy / scope). Outside
|
|
@@ -3374,7 +4008,7 @@ class CngxToggle {
|
|
|
3374
4008
|
* `shouldShow` (reveal-aware) wins. Outside both contexts the atom
|
|
3375
4009
|
* paints no error skin.
|
|
3376
4010
|
*/
|
|
3377
|
-
errorState =
|
|
4011
|
+
errorState = this.groupHost.errorState;
|
|
3378
4012
|
handleClick() {
|
|
3379
4013
|
if (this.disabled()) {
|
|
3380
4014
|
return;
|
|
@@ -3389,11 +4023,10 @@ class CngxToggle {
|
|
|
3389
4023
|
this.value.update((v) => !v);
|
|
3390
4024
|
}
|
|
3391
4025
|
handleFocusIn() {
|
|
3392
|
-
this.
|
|
4026
|
+
this.groupHost.handleFocusIn();
|
|
3393
4027
|
}
|
|
3394
4028
|
handleFocusOut() {
|
|
3395
|
-
this.
|
|
3396
|
-
this.fieldHost?.markAsTouched();
|
|
4029
|
+
this.groupHost.handleFocusOut();
|
|
3397
4030
|
}
|
|
3398
4031
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToggle, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3399
4032
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxToggle, isStandalone: true, selector: "[cngxToggle], cngx-toggle", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, disabledReason: { classPropertyName: "disabledReason", publicName: "disabledReason", isSignal: true, isRequired: false, transformFunction: null }, labelPosition: { classPropertyName: "labelPosition", publicName: "labelPosition", isSignal: true, isRequired: false, transformFunction: null }, thumbGlyph: { classPropertyName: "thumbGlyph", publicName: "thumbGlyph", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", invalid: "invalidChange" }, host: { attributes: { "role": "switch" }, listeners: { "click": "handleClick()", "keydown.space": "handleKeydown($event)", "keydown.enter": "handleKeydown($event)", "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-checked": "value() ? \"true\" : \"false\"", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-labelledby": "hasProjectedLabel() ? labelId : null", "attr.aria-describedby": "describedById()", "attr.tabindex": "disabled() ? -1 : 0", "class.cngx-toggle--checked": "value()", "class.cngx-toggle--disabled": "disabled()", "class.cngx-toggle--label-before": "labelPosition() === \"before\"" }, classAttribute: "cngx-toggle" }, providers: [
|
|
@@ -3416,7 +4049,7 @@ class CngxToggle {
|
|
|
3416
4049
|
[attr.aria-hidden]="disabled() && disabledReason() ? null : 'true'"
|
|
3417
4050
|
>{{ disabledReason() }}</span
|
|
3418
4051
|
>
|
|
3419
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-toggle-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-toggle-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-toggle-
|
|
4052
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-toggle-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-toggle-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-toggle-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-toggle-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-toggle-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}@property --cngx-toggle-transition{syntax: \"*\"; inherits: false; initial-value: .15s ease;}:where(.cngx-toggle,.cngx-toggle *){--cngx-toggle-transition: var(--cngx-duration-fast) ease}@property --cngx-toggle-track-width{syntax: \"*\"; inherits: false; initial-value: 2.25rem;}@property --cngx-toggle-track-height{syntax: \"*\"; inherits: false; initial-value: 1.25rem;}@property --cngx-toggle-track-radius{syntax: \"<length>\"; inherits: false; initial-value: 9999px;}@property --cngx-toggle-track-bg-off{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .25);}@property --cngx-toggle-track-bg-on{syntax: \"<color>\"; inherits: false; initial-value: oklch(.66 .19 50);}@property --cngx-toggle-thumb-inset{syntax: \"*\"; inherits: true; initial-value: .125rem;}@property --cngx-toggle-thumb-size{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-toggle-thumb-travel{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-toggle-thumb-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(1 0 0);}@property --cngx-toggle-thumb-shadow{syntax: \"*\"; inherits: false; initial-value: 0 1px 2px oklch(0 0 0 / .25);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-toggle-track-bg-off: oklch(1 0 0 / .25)}}[data-color-scheme=dark],.dark{--cngx-toggle-track-bg-off: oklch(1 0 0 / .25)}[data-color-scheme=light],.light{--cngx-toggle-track-bg-off: oklch(0 0 0 / .25)}}@layer cngx.components{@scope(.cngx-toggle){:scope{--cngx-toggle-gap: var(--cngx-space-sm);--cngx-toggle-thumb-inset: calc( (var(--cngx-toggle-track-height) - var(--cngx-toggle-thumb-size)) / 2 );display:inline-flex;align-items:center;gap:var(--cngx-toggle-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-toggle-color, inherit);min-block-size:var(--cngx-target-min, 0px)}:scope.cngx-toggle--label-before{flex-direction:row-reverse}:scope.cngx-toggle--disabled{cursor:not-allowed;color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope:focus-visible{outline:var(--cngx-toggle-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-toggle-focus-offset, 2px);border-radius:var(--cngx-toggle-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-toggle__track{position:relative;flex:0 0 auto;inline-size:var(--cngx-toggle-track-width, 2.25rem);block-size:var(--cngx-toggle-track-height, 1.25rem);border-radius:var(--cngx-toggle-track-radius, var(--cngx-radius-pill, 9999px));background:var(--cngx-toggle-track-bg-off, oklch(0 0 0 / .25));transition:background-color var(--cngx-toggle-transition, .15s ease)}:scope.cngx-toggle--checked .cngx-toggle__track{background:var(--cngx-toggle-track-bg-on, var(--cngx-color-primary, oklch(.66 .19 50)))}.cngx-toggle__thumb{position:absolute;inset-block-start:var(--cngx-toggle-thumb-inset, .125rem);inset-inline-start:var(--cngx-toggle-thumb-inset, .125rem);inline-size:var(--cngx-toggle-thumb-size, 1rem);block-size:var(--cngx-toggle-thumb-size, 1rem);display:inline-flex;align-items:center;justify-content:center;line-height:1;border-radius:50%;background:var(--cngx-toggle-thumb-bg, oklch(1 0 0));box-shadow:var(--cngx-toggle-thumb-shadow, 0 1px 2px oklch(0 0 0 / .25));transition:transform var(--cngx-toggle-transition, .15s ease)}.cngx-toggle__thumb:has(*){background:transparent;box-shadow:none;font-size:var(--cngx-toggle-thumb-size, 1rem);color:var(--cngx-toggle-thumb-bg, oklch(1 0 0))}:scope.cngx-toggle--checked .cngx-toggle__thumb{transform:translate(var(--cngx-toggle-thumb-travel, 1rem))}:scope.cngx-toggle--disabled .cngx-toggle__track{background:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 12%,transparent)}:scope.cngx-toggle--disabled.cngx-toggle--checked .cngx-toggle__track{background:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope.cngx-toggle--disabled .cngx-toggle__thumb{box-shadow:none}.cngx-toggle__label{flex:0 1 auto;min-inline-size:0}.cngx-toggle__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(prefers-reduced-motion:reduce){.cngx-toggle__track,.cngx-toggle__thumb{transition:none}}}}@media(forced-colors:active){.cngx-toggle__track{outline:1px solid ButtonBorder;outline-offset:-1px}.cngx-toggle__thumb{outline:1px solid ButtonText;outline-offset:-1px}.cngx-toggle.cngx-toggle--checked .cngx-toggle__track{background:Highlight!important}.cngx-toggle.cngx-toggle--disabled{color:GrayText}.cngx-toggle.cngx-toggle--disabled .cngx-toggle__track,.cngx-toggle.cngx-toggle--disabled .cngx-toggle__thumb{outline-color:GrayText}.cngx-toggle.cngx-toggle--disabled.cngx-toggle--checked .cngx-toggle__track{background:GrayText!important}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
3420
4053
|
}
|
|
3421
4054
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToggle, decorators: [{
|
|
3422
4055
|
type: Component,
|
|
@@ -3459,7 +4092,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3459
4092
|
[attr.aria-hidden]="disabled() && disabledReason() ? null : 'true'"
|
|
3460
4093
|
>{{ disabledReason() }}</span
|
|
3461
4094
|
>
|
|
3462
|
-
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-toggle-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-toggle-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-toggle-
|
|
4095
|
+
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-toggle-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-toggle-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-toggle-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-toggle-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-toggle-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}@property --cngx-toggle-transition{syntax: \"*\"; inherits: false; initial-value: .15s ease;}:where(.cngx-toggle,.cngx-toggle *){--cngx-toggle-transition: var(--cngx-duration-fast) ease}@property --cngx-toggle-track-width{syntax: \"*\"; inherits: false; initial-value: 2.25rem;}@property --cngx-toggle-track-height{syntax: \"*\"; inherits: false; initial-value: 1.25rem;}@property --cngx-toggle-track-radius{syntax: \"<length>\"; inherits: false; initial-value: 9999px;}@property --cngx-toggle-track-bg-off{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .25);}@property --cngx-toggle-track-bg-on{syntax: \"<color>\"; inherits: false; initial-value: oklch(.66 .19 50);}@property --cngx-toggle-thumb-inset{syntax: \"*\"; inherits: true; initial-value: .125rem;}@property --cngx-toggle-thumb-size{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-toggle-thumb-travel{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-toggle-thumb-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(1 0 0);}@property --cngx-toggle-thumb-shadow{syntax: \"*\"; inherits: false; initial-value: 0 1px 2px oklch(0 0 0 / .25);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-toggle-track-bg-off: oklch(1 0 0 / .25)}}[data-color-scheme=dark],.dark{--cngx-toggle-track-bg-off: oklch(1 0 0 / .25)}[data-color-scheme=light],.light{--cngx-toggle-track-bg-off: oklch(0 0 0 / .25)}}@layer cngx.components{@scope(.cngx-toggle){:scope{--cngx-toggle-gap: var(--cngx-space-sm);--cngx-toggle-thumb-inset: calc( (var(--cngx-toggle-track-height) - var(--cngx-toggle-thumb-size)) / 2 );display:inline-flex;align-items:center;gap:var(--cngx-toggle-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-toggle-color, inherit);min-block-size:var(--cngx-target-min, 0px)}:scope.cngx-toggle--label-before{flex-direction:row-reverse}:scope.cngx-toggle--disabled{cursor:not-allowed;color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope:focus-visible{outline:var(--cngx-toggle-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-toggle-focus-offset, 2px);border-radius:var(--cngx-toggle-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-toggle__track{position:relative;flex:0 0 auto;inline-size:var(--cngx-toggle-track-width, 2.25rem);block-size:var(--cngx-toggle-track-height, 1.25rem);border-radius:var(--cngx-toggle-track-radius, var(--cngx-radius-pill, 9999px));background:var(--cngx-toggle-track-bg-off, oklch(0 0 0 / .25));transition:background-color var(--cngx-toggle-transition, .15s ease)}:scope.cngx-toggle--checked .cngx-toggle__track{background:var(--cngx-toggle-track-bg-on, var(--cngx-color-primary, oklch(.66 .19 50)))}.cngx-toggle__thumb{position:absolute;inset-block-start:var(--cngx-toggle-thumb-inset, .125rem);inset-inline-start:var(--cngx-toggle-thumb-inset, .125rem);inline-size:var(--cngx-toggle-thumb-size, 1rem);block-size:var(--cngx-toggle-thumb-size, 1rem);display:inline-flex;align-items:center;justify-content:center;line-height:1;border-radius:50%;background:var(--cngx-toggle-thumb-bg, oklch(1 0 0));box-shadow:var(--cngx-toggle-thumb-shadow, 0 1px 2px oklch(0 0 0 / .25));transition:transform var(--cngx-toggle-transition, .15s ease)}.cngx-toggle__thumb:has(*){background:transparent;box-shadow:none;font-size:var(--cngx-toggle-thumb-size, 1rem);color:var(--cngx-toggle-thumb-bg, oklch(1 0 0))}:scope.cngx-toggle--checked .cngx-toggle__thumb{transform:translate(var(--cngx-toggle-thumb-travel, 1rem))}:scope.cngx-toggle--disabled .cngx-toggle__track{background:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 12%,transparent)}:scope.cngx-toggle--disabled.cngx-toggle--checked .cngx-toggle__track{background:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope.cngx-toggle--disabled .cngx-toggle__thumb{box-shadow:none}.cngx-toggle__label{flex:0 1 auto;min-inline-size:0}.cngx-toggle__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(prefers-reduced-motion:reduce){.cngx-toggle__track,.cngx-toggle__thumb{transition:none}}}}@media(forced-colors:active){.cngx-toggle__track{outline:1px solid ButtonBorder;outline-offset:-1px}.cngx-toggle__thumb{outline:1px solid ButtonText;outline-offset:-1px}.cngx-toggle.cngx-toggle--checked .cngx-toggle__track{background:Highlight!important}.cngx-toggle.cngx-toggle--disabled{color:GrayText}.cngx-toggle.cngx-toggle--disabled .cngx-toggle__track,.cngx-toggle.cngx-toggle--disabled .cngx-toggle__thumb{outline-color:GrayText}.cngx-toggle.cngx-toggle--disabled.cngx-toggle--checked .cngx-toggle__track{background:GrayText!important}}\n"] }]
|
|
3463
4096
|
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], disabledReason: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledReason", required: false }] }], labelPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelPosition", required: false }] }], thumbGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbGlyph", required: false }] }], labelRef: [{ type: i0.ViewChild, args: ['label', { isSignal: true }] }] } });
|
|
3464
4097
|
|
|
3465
4098
|
/**
|
|
@@ -3564,22 +4197,20 @@ class CngxCheckbox {
|
|
|
3564
4197
|
*/
|
|
3565
4198
|
hostTabindex = computed(() => this.rovingParent ? null : this.disabled() ? -1 : 0, ...(ngDevMode ? [{ debugName: "hostTabindex" }] : /* istanbul ignore next */ []));
|
|
3566
4199
|
ariaChecked = computed(() => this.indeterminate() ? 'mixed' : this.value() ? 'true' : 'false', ...(ngDevMode ? [{ debugName: "ariaChecked" }] : /* istanbul ignore next */ []));
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
4200
|
+
groupHost = injectInteractiveGroupHost({
|
|
4201
|
+
uidPrefix: 'cngx-checkbox-',
|
|
4202
|
+
invalid: this.invalid,
|
|
4203
|
+
});
|
|
4204
|
+
id = this.groupHost.id;
|
|
4205
|
+
focused = this.groupHost.focused;
|
|
3570
4206
|
/**
|
|
3571
4207
|
* Empty when value is `false` AND not in tri-state intermediate. An
|
|
3572
4208
|
* indeterminate checkbox carries user-visible state, so it does not
|
|
3573
4209
|
* count as empty for forms purposes.
|
|
3574
4210
|
*/
|
|
3575
4211
|
empty = computed(() => this.value() === false && !this.indeterminate(), ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
optional: true,
|
|
3579
|
-
skipSelf: true,
|
|
3580
|
-
});
|
|
3581
|
-
errorState = computed(() => this.fieldHost?.showError() ?? this.aggregator?.shouldShow() ?? false, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
3582
|
-
ariaInvalid = computed(() => this.invalid() || this.errorState(), ...(ngDevMode ? [{ debugName: "ariaInvalid" }] : /* istanbul ignore next */ []));
|
|
4212
|
+
errorState = this.groupHost.errorState;
|
|
4213
|
+
ariaInvalid = this.groupHost.ariaInvalid;
|
|
3583
4214
|
handleClick() {
|
|
3584
4215
|
this.advance();
|
|
3585
4216
|
}
|
|
@@ -3591,11 +4222,10 @@ class CngxCheckbox {
|
|
|
3591
4222
|
this.advance();
|
|
3592
4223
|
}
|
|
3593
4224
|
handleFocusIn() {
|
|
3594
|
-
this.
|
|
4225
|
+
this.groupHost.handleFocusIn();
|
|
3595
4226
|
}
|
|
3596
4227
|
handleFocusOut() {
|
|
3597
|
-
this.
|
|
3598
|
-
this.fieldHost?.markAsTouched();
|
|
4228
|
+
this.groupHost.handleFocusOut();
|
|
3599
4229
|
}
|
|
3600
4230
|
advance() {
|
|
3601
4231
|
if (this.disabled()) {
|
|
@@ -3630,7 +4260,7 @@ class CngxCheckbox {
|
|
|
3630
4260
|
[attr.aria-hidden]="disabled() && disabledReason() ? null : 'true'"
|
|
3631
4261
|
>{{ disabledReason() }}</span
|
|
3632
4262
|
>
|
|
3633
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-checkbox-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-checkbox-sibling-gap{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-checkbox-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-checkbox-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-checkbox-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-checkbox){:scope{--cngx-checkbox-gap: var(--cngx-space-sm);--cngx-checkbox-sibling-gap: var(--cngx-space-md);display:inline-flex;align-items:center;gap:var(--cngx-checkbox-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-checkbox-color, inherit);min-block-size:var(--cngx-target-min, 0px);min-inline-size:var(--cngx-target-min, 0px);vertical-align:middle}:scope.cngx-checkbox--disabled{cursor:not-allowed;
|
|
4263
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-checkbox-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-checkbox-sibling-gap{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-checkbox-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-checkbox-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-checkbox-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-checkbox){:scope{--cngx-checkbox-gap: var(--cngx-space-sm);--cngx-checkbox-sibling-gap: var(--cngx-space-md);display:inline-flex;align-items:center;gap:var(--cngx-checkbox-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-checkbox-color, inherit);min-block-size:var(--cngx-target-min, 0px);min-inline-size:var(--cngx-target-min, 0px);vertical-align:middle}:scope.cngx-checkbox--disabled{cursor:not-allowed;color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope:focus-visible{outline:var(--cngx-checkbox-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-checkbox-focus-offset, 2px);border-radius:var(--cngx-checkbox-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-checkbox__label{flex:0 1 auto;min-inline-size:0}.cngx-checkbox__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}.cngx-checkbox+.cngx-checkbox{margin-inline-start:var(--cngx-checkbox-sibling-gap, 1rem)}}@media(forced-colors:active){.cngx-checkbox.cngx-checkbox--disabled{color:GrayText}}\n"], dependencies: [{ kind: "component", type: CngxCheckboxIndicator, selector: "cngx-checkbox-indicator", inputs: ["variant", "checked", "indeterminate", "disabled", "size", "checkGlyph", "dashGlyph"], exportAs: ["cngxCheckboxIndicator"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
3634
4264
|
}
|
|
3635
4265
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCheckbox, decorators: [{
|
|
3636
4266
|
type: Component,
|
|
@@ -3678,7 +4308,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3678
4308
|
[attr.aria-hidden]="disabled() && disabledReason() ? null : 'true'"
|
|
3679
4309
|
>{{ disabledReason() }}</span
|
|
3680
4310
|
>
|
|
3681
|
-
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-checkbox-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-checkbox-sibling-gap{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-checkbox-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-checkbox-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-checkbox-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-checkbox){:scope{--cngx-checkbox-gap: var(--cngx-space-sm);--cngx-checkbox-sibling-gap: var(--cngx-space-md);display:inline-flex;align-items:center;gap:var(--cngx-checkbox-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-checkbox-color, inherit);min-block-size:var(--cngx-target-min, 0px);min-inline-size:var(--cngx-target-min, 0px);vertical-align:middle}:scope.cngx-checkbox--disabled{cursor:not-allowed;
|
|
4311
|
+
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-checkbox-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-checkbox-sibling-gap{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-checkbox-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-checkbox-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-checkbox-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-checkbox){:scope{--cngx-checkbox-gap: var(--cngx-space-sm);--cngx-checkbox-sibling-gap: var(--cngx-space-md);display:inline-flex;align-items:center;gap:var(--cngx-checkbox-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-checkbox-color, inherit);min-block-size:var(--cngx-target-min, 0px);min-inline-size:var(--cngx-target-min, 0px);vertical-align:middle}:scope.cngx-checkbox--disabled{cursor:not-allowed;color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope:focus-visible{outline:var(--cngx-checkbox-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-checkbox-focus-offset, 2px);border-radius:var(--cngx-checkbox-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-checkbox__label{flex:0 1 auto;min-inline-size:0}.cngx-checkbox__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}.cngx-checkbox+.cngx-checkbox{margin-inline-start:var(--cngx-checkbox-sibling-gap, 1rem)}}@media(forced-colors:active){.cngx-checkbox.cngx-checkbox--disabled{color:GrayText}}\n"] }]
|
|
3682
4312
|
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }, { type: i0.Output, args: ["indeterminateChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], disabledReason: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledReason", required: false }] }], checkGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkGlyph", required: false }] }], dashGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "dashGlyph", required: false }] }] } });
|
|
3683
4313
|
|
|
3684
4314
|
/**
|
|
@@ -3722,7 +4352,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3722
4352
|
* `[state]` is an optional `CngxAsyncState<unknown>` input; when bound,
|
|
3723
4353
|
* `aria-busy` reflects `state.status() === 'loading'` reactively so AT
|
|
3724
4354
|
* announces the busy moment without the consumer wiring the attribute
|
|
3725
|
-
* by hand.
|
|
4355
|
+
* by hand. Without an explicit binding the group discovers an ancestor
|
|
4356
|
+
* `CNGX_STATEFUL` provider as fallback - the input always wins when
|
|
4357
|
+
* both are present.
|
|
3726
4358
|
*
|
|
3727
4359
|
* ```html
|
|
3728
4360
|
* <cngx-checkbox-group
|
|
@@ -3772,8 +4404,20 @@ class CngxCheckboxGroup {
|
|
|
3772
4404
|
errorMessageId = input(null, ...(ngDevMode ? [{ debugName: "errorMessageId" }] : /* istanbul ignore next */ []));
|
|
3773
4405
|
orientation = input('vertical', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
3774
4406
|
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
4407
|
+
/**
|
|
4408
|
+
* Explicit `aria-labelledby` target id. Wins over the automatic
|
|
4409
|
+
* field-label reference applied inside a `cngx-form-field`.
|
|
4410
|
+
*/
|
|
4411
|
+
labelledBy = input(undefined, ...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
|
|
3775
4412
|
allValues = input(undefined, ...(ngDevMode ? [{ debugName: "allValues" }] : /* istanbul ignore next */ []));
|
|
3776
|
-
|
|
4413
|
+
/**
|
|
4414
|
+
* Optional async state driving `aria-busy`. An explicit binding wins;
|
|
4415
|
+
* when it is absent or `undefined`, an ancestor `CNGX_STATEFUL`
|
|
4416
|
+
* provider is discovered as fallback. A bare `state` attribute (empty
|
|
4417
|
+
* string) is treated as unset. `aria-busy` reflects
|
|
4418
|
+
* `status() === 'loading'`.
|
|
4419
|
+
*/
|
|
4420
|
+
state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), transform: (v) => (typeof v === 'string' ? undefined : v) });
|
|
3777
4421
|
keyFn = input((v) => v, ...(ngDevMode ? [{ debugName: "keyFn" }] : /* istanbul ignore next */ []));
|
|
3778
4422
|
controller = inject(CNGX_SELECTION_CONTROLLER_FACTORY)(this.selectedValues, {
|
|
3779
4423
|
keyFn: (v) => this.keyFn()(v),
|
|
@@ -3799,7 +4443,15 @@ class CngxCheckboxGroup {
|
|
|
3799
4443
|
return true;
|
|
3800
4444
|
}, ...(ngDevMode ? [{ debugName: "allSelected" }] : /* istanbul ignore next */ []));
|
|
3801
4445
|
someSelected = computed(() => this.selectedCount() > 0 && !this.allSelected(), ...(ngDevMode ? [{ debugName: "someSelected" }] : /* istanbul ignore next */ []));
|
|
3802
|
-
|
|
4446
|
+
groupHost = injectInteractiveGroupHost({
|
|
4447
|
+
uidPrefix: 'cngx-checkbox-group-',
|
|
4448
|
+
invalid: this.invalid,
|
|
4449
|
+
state: this.state,
|
|
4450
|
+
label: this.label,
|
|
4451
|
+
labelledBy: this.labelledBy,
|
|
4452
|
+
});
|
|
4453
|
+
ariaLabelledBy = this.groupHost.ariaLabelledBy;
|
|
4454
|
+
ariaBusy = this.groupHost.ariaBusy;
|
|
3803
4455
|
toggleAll() {
|
|
3804
4456
|
if (this.disabled()) {
|
|
3805
4457
|
return;
|
|
@@ -3825,27 +4477,20 @@ class CngxCheckboxGroup {
|
|
|
3825
4477
|
}
|
|
3826
4478
|
this.controller.deselect(value);
|
|
3827
4479
|
}
|
|
3828
|
-
id =
|
|
3829
|
-
|
|
3830
|
-
focused = this.focusedState.asReadonly();
|
|
4480
|
+
id = this.groupHost.id;
|
|
4481
|
+
focused = this.groupHost.focused;
|
|
3831
4482
|
/** Empty when no values selected. */
|
|
3832
4483
|
empty = computed(() => this.selectedValues().length === 0, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
optional: true,
|
|
3836
|
-
skipSelf: true,
|
|
3837
|
-
});
|
|
3838
|
-
errorState = computed(() => this.fieldHost?.showError() ?? this.aggregator?.shouldShow() ?? false, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
3839
|
-
ariaInvalid = computed(() => this.invalid() || this.errorState(), ...(ngDevMode ? [{ debugName: "ariaInvalid" }] : /* istanbul ignore next */ []));
|
|
4484
|
+
errorState = this.groupHost.errorState;
|
|
4485
|
+
ariaInvalid = this.groupHost.ariaInvalid;
|
|
3840
4486
|
handleFocusIn() {
|
|
3841
|
-
this.
|
|
4487
|
+
this.groupHost.handleFocusIn();
|
|
3842
4488
|
}
|
|
3843
4489
|
handleFocusOut() {
|
|
3844
|
-
this.
|
|
3845
|
-
this.fieldHost?.markAsTouched();
|
|
4490
|
+
this.groupHost.handleFocusOut();
|
|
3846
4491
|
}
|
|
3847
4492
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCheckboxGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3848
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxCheckboxGroup, isStandalone: true, selector: "cngx-checkbox-group, [cngxCheckboxGroup]", inputs: { selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, allValues: { classPropertyName: "allValues", publicName: "allValues", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, keyFn: { classPropertyName: "keyFn", publicName: "keyFn", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedValues: "selectedValuesChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "group" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "ariaInvalid() ? \"true\" : null", "attr.aria-errormessage": "ariaInvalid() ? errorMessageId() : null", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-checkbox-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-checkbox-group" }, providers: [
|
|
4493
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxCheckboxGroup, isStandalone: true, selector: "cngx-checkbox-group, [cngxCheckboxGroup]", inputs: { selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelledBy: { classPropertyName: "labelledBy", publicName: "labelledBy", isSignal: true, isRequired: false, transformFunction: null }, allValues: { classPropertyName: "allValues", publicName: "allValues", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, keyFn: { classPropertyName: "keyFn", publicName: "keyFn", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedValues: "selectedValuesChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "group" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "ariaInvalid() ? \"true\" : null", "attr.aria-errormessage": "ariaInvalid() ? errorMessageId() : null", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-checkbox-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-checkbox-group" }, providers: [
|
|
3849
4494
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxCheckboxGroup },
|
|
3850
4495
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxCheckboxGroup },
|
|
3851
4496
|
], exportAs: ["cngxCheckboxGroup"], hostDirectives: [{ directive: i1.CngxRovingTabindex, inputs: ["orientation", "orientation"] }], ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-checkbox-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-checkbox-group){:scope{--cngx-checkbox-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var(--cngx-checkbox-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-checkbox-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
@@ -3862,6 +4507,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3862
4507
|
role: 'group',
|
|
3863
4508
|
'[attr.id]': 'id()',
|
|
3864
4509
|
'[attr.aria-label]': 'label()',
|
|
4510
|
+
'[attr.aria-labelledby]': 'ariaLabelledBy()',
|
|
3865
4511
|
'[attr.aria-disabled]': 'disabled() ? "true" : null',
|
|
3866
4512
|
'[attr.aria-required]': 'required() ? "true" : null',
|
|
3867
4513
|
'[attr.aria-invalid]': 'ariaInvalid() ? "true" : null',
|
|
@@ -3874,7 +4520,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3874
4520
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxCheckboxGroup },
|
|
3875
4521
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxCheckboxGroup },
|
|
3876
4522
|
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-checkbox-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-checkbox-group){:scope{--cngx-checkbox-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var(--cngx-checkbox-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-checkbox-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"] }]
|
|
3877
|
-
}], ctorParameters: () => [], propDecorators: { selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], allValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "allValues", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }] } });
|
|
4523
|
+
}], ctorParameters: () => [], propDecorators: { selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], labelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelledBy", required: false }] }], allValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "allValues", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }] } });
|
|
3878
4524
|
|
|
3879
4525
|
/**
|
|
3880
4526
|
* DI token a `CngxButtonToggle` leaf injects to find its single-mode
|
|
@@ -3963,8 +4609,19 @@ class CngxButtonToggleGroup {
|
|
|
3963
4609
|
errorMessageId = input(null, ...(ngDevMode ? [{ debugName: "errorMessageId" }] : /* istanbul ignore next */ []));
|
|
3964
4610
|
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
3965
4611
|
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
3966
|
-
|
|
3967
|
-
|
|
4612
|
+
/**
|
|
4613
|
+
* Explicit `aria-labelledby` target id. Wins over the automatic
|
|
4614
|
+
* field-label reference applied inside a `cngx-form-field`.
|
|
4615
|
+
*/
|
|
4616
|
+
labelledBy = input(undefined, ...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
|
|
4617
|
+
/**
|
|
4618
|
+
* Optional async state driving `aria-busy`. An explicit binding wins;
|
|
4619
|
+
* when it is absent or `undefined`, an ancestor `CNGX_STATEFUL`
|
|
4620
|
+
* provider is discovered as fallback. A bare `state` attribute (empty
|
|
4621
|
+
* string) is treated as unset. `aria-busy` reflects
|
|
4622
|
+
* `status() === 'loading'`.
|
|
4623
|
+
*/
|
|
4624
|
+
state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), transform: (v) => (typeof v === 'string' ? undefined : v) });
|
|
3968
4625
|
roving = inject(CngxRovingTabindex, { host: true });
|
|
3969
4626
|
consumePendingArrowSelect(value) {
|
|
3970
4627
|
if (!this.roving.consumeNavigationKey()) {
|
|
@@ -3976,26 +4633,28 @@ class CngxButtonToggleGroup {
|
|
|
3976
4633
|
this.value.set(value);
|
|
3977
4634
|
return true;
|
|
3978
4635
|
}
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
4636
|
+
groupHost = injectInteractiveGroupHost({
|
|
4637
|
+
uidPrefix: 'cngx-button-toggle-group-',
|
|
4638
|
+
invalid: this.invalid,
|
|
4639
|
+
state: this.state,
|
|
4640
|
+
label: this.label,
|
|
4641
|
+
labelledBy: this.labelledBy,
|
|
4642
|
+
});
|
|
4643
|
+
ariaLabelledBy = this.groupHost.ariaLabelledBy;
|
|
4644
|
+
ariaBusy = this.groupHost.ariaBusy;
|
|
4645
|
+
id = this.groupHost.id;
|
|
4646
|
+
focused = this.groupHost.focused;
|
|
3982
4647
|
/** Empty when no toggle is selected. */
|
|
3983
4648
|
empty = computed(() => this.value() === undefined, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
3984
|
-
|
|
3985
|
-
aggregator = inject(CNGX_ERROR_AGGREGATOR, {
|
|
3986
|
-
optional: true,
|
|
3987
|
-
skipSelf: true,
|
|
3988
|
-
});
|
|
3989
|
-
errorState = computed(() => this.fieldHost?.showError() ?? this.aggregator?.shouldShow() ?? false, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
4649
|
+
errorState = this.groupHost.errorState;
|
|
3990
4650
|
handleFocusIn() {
|
|
3991
|
-
this.
|
|
4651
|
+
this.groupHost.handleFocusIn();
|
|
3992
4652
|
}
|
|
3993
4653
|
handleFocusOut() {
|
|
3994
|
-
this.
|
|
3995
|
-
this.fieldHost?.markAsTouched();
|
|
4654
|
+
this.groupHost.handleFocusOut();
|
|
3996
4655
|
}
|
|
3997
4656
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonToggleGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3998
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxButtonToggleGroup, isStandalone: true, selector: "cngx-button-toggle-group, [cngxButtonToggleGroup]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-orientation": "orientation()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-button-toggle-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-button-toggle-group" }, providers: [
|
|
4657
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxButtonToggleGroup, isStandalone: true, selector: "cngx-button-toggle-group, [cngxButtonToggleGroup]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelledBy: { classPropertyName: "labelledBy", publicName: "labelledBy", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-orientation": "orientation()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-button-toggle-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-button-toggle-group" }, providers: [
|
|
3999
4658
|
{ provide: CNGX_BUTTON_TOGGLE_GROUP, useExisting: CngxButtonToggleGroup },
|
|
4000
4659
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxButtonToggleGroup },
|
|
4001
4660
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxButtonToggleGroup },
|
|
@@ -4013,6 +4672,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4013
4672
|
role: 'radiogroup',
|
|
4014
4673
|
'[attr.id]': 'id()',
|
|
4015
4674
|
'[attr.aria-label]': 'label()',
|
|
4675
|
+
'[attr.aria-labelledby]': 'ariaLabelledBy()',
|
|
4016
4676
|
'[attr.aria-disabled]': 'disabled() ? "true" : null',
|
|
4017
4677
|
'[attr.aria-required]': 'required() ? "true" : null',
|
|
4018
4678
|
'[attr.aria-invalid]': '(invalid() || errorState()) ? "true" : null',
|
|
@@ -4027,7 +4687,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4027
4687
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxButtonToggleGroup },
|
|
4028
4688
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxButtonToggleGroup },
|
|
4029
4689
|
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-button-toggle-group-gap{syntax: \"*\"; inherits: false; initial-value: 0;}@property --cngx-button-toggle-group-radius{syntax: \"*\"; inherits: false; initial-value: .375rem;}}@layer cngx.components{@scope(.cngx-button-toggle-group,.cngx-button-multi-toggle-group){:scope{display:inline-flex;flex-direction:row;gap:var(--cngx-button-toggle-group-gap, 0);border-radius:var(--cngx-button-toggle-group-radius, var(--cngx-radius-md, .375rem))}:scope:not(.cngx-button-toggle-group--horizontal,.cngx-button-multi-toggle-group--horizontal){flex-direction:column}}}\n"] }]
|
|
4030
|
-
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }] } });
|
|
4690
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], labelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelledBy", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }] } });
|
|
4031
4691
|
|
|
4032
4692
|
/**
|
|
4033
4693
|
* DI token a `CngxButtonToggle` leaf injects to find its multi-mode
|
|
@@ -4116,9 +4776,20 @@ class CngxButtonMultiToggleGroup {
|
|
|
4116
4776
|
errorMessageId = input(null, ...(ngDevMode ? [{ debugName: "errorMessageId" }] : /* istanbul ignore next */ []));
|
|
4117
4777
|
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
4118
4778
|
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
4119
|
-
|
|
4779
|
+
/**
|
|
4780
|
+
* Explicit `aria-labelledby` target id. Wins over the automatic
|
|
4781
|
+
* field-label reference applied inside a `cngx-form-field`.
|
|
4782
|
+
*/
|
|
4783
|
+
labelledBy = input(undefined, ...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
|
|
4784
|
+
/**
|
|
4785
|
+
* Optional async state driving `aria-busy`. An explicit binding wins;
|
|
4786
|
+
* when it is absent or `undefined`, an ancestor `CNGX_STATEFUL`
|
|
4787
|
+
* provider is discovered as fallback. A bare `state` attribute (empty
|
|
4788
|
+
* string) is treated as unset. `aria-busy` reflects
|
|
4789
|
+
* `status() === 'loading'`.
|
|
4790
|
+
*/
|
|
4791
|
+
state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), transform: (v) => (typeof v === 'string' ? undefined : v) });
|
|
4120
4792
|
keyFn = input((v) => v, ...(ngDevMode ? [{ debugName: "keyFn" }] : /* istanbul ignore next */ []));
|
|
4121
|
-
ariaBusy = computed(() => this.state()?.status() === 'loading', ...(ngDevMode ? [{ debugName: "ariaBusy" }] : /* istanbul ignore next */ []));
|
|
4122
4793
|
controller = inject(CNGX_SELECTION_CONTROLLER_FACTORY)(this.selectedValues, {
|
|
4123
4794
|
keyFn: (v) => this.keyFn()(v),
|
|
4124
4795
|
});
|
|
@@ -4134,26 +4805,28 @@ class CngxButtonMultiToggleGroup {
|
|
|
4134
4805
|
}
|
|
4135
4806
|
this.controller.toggle(value);
|
|
4136
4807
|
}
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4808
|
+
groupHost = injectInteractiveGroupHost({
|
|
4809
|
+
uidPrefix: 'cngx-button-multi-toggle-group-',
|
|
4810
|
+
invalid: this.invalid,
|
|
4811
|
+
state: this.state,
|
|
4812
|
+
label: this.label,
|
|
4813
|
+
labelledBy: this.labelledBy,
|
|
4814
|
+
});
|
|
4815
|
+
ariaLabelledBy = this.groupHost.ariaLabelledBy;
|
|
4816
|
+
ariaBusy = this.groupHost.ariaBusy;
|
|
4817
|
+
id = this.groupHost.id;
|
|
4818
|
+
focused = this.groupHost.focused;
|
|
4140
4819
|
/** Empty when no toggles are selected. */
|
|
4141
4820
|
empty = computed(() => this.selectedValues().length === 0, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
4142
|
-
|
|
4143
|
-
aggregator = inject(CNGX_ERROR_AGGREGATOR, {
|
|
4144
|
-
optional: true,
|
|
4145
|
-
skipSelf: true,
|
|
4146
|
-
});
|
|
4147
|
-
errorState = computed(() => this.fieldHost?.showError() ?? this.aggregator?.shouldShow() ?? false, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
4821
|
+
errorState = this.groupHost.errorState;
|
|
4148
4822
|
handleFocusIn() {
|
|
4149
|
-
this.
|
|
4823
|
+
this.groupHost.handleFocusIn();
|
|
4150
4824
|
}
|
|
4151
4825
|
handleFocusOut() {
|
|
4152
|
-
this.
|
|
4153
|
-
this.fieldHost?.markAsTouched();
|
|
4826
|
+
this.groupHost.handleFocusOut();
|
|
4154
4827
|
}
|
|
4155
4828
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonMultiToggleGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4156
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxButtonMultiToggleGroup, isStandalone: true, selector: "cngx-button-multi-toggle-group, [cngxButtonMultiToggleGroup]", inputs: { selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, keyFn: { classPropertyName: "keyFn", publicName: "keyFn", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedValues: "selectedValuesChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "toolbar" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-orientation": "orientation()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-button-multi-toggle-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-button-multi-toggle-group" }, providers: [
|
|
4829
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxButtonMultiToggleGroup, isStandalone: true, selector: "cngx-button-multi-toggle-group, [cngxButtonMultiToggleGroup]", inputs: { selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelledBy: { classPropertyName: "labelledBy", publicName: "labelledBy", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, keyFn: { classPropertyName: "keyFn", publicName: "keyFn", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedValues: "selectedValuesChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "toolbar" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-orientation": "orientation()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-button-multi-toggle-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-button-multi-toggle-group" }, providers: [
|
|
4157
4830
|
{
|
|
4158
4831
|
provide: CNGX_BUTTON_MULTI_TOGGLE_GROUP,
|
|
4159
4832
|
useExisting: CngxButtonMultiToggleGroup,
|
|
@@ -4180,6 +4853,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4180
4853
|
role: 'toolbar',
|
|
4181
4854
|
'[attr.id]': 'id()',
|
|
4182
4855
|
'[attr.aria-label]': 'label()',
|
|
4856
|
+
'[attr.aria-labelledby]': 'ariaLabelledBy()',
|
|
4183
4857
|
'[attr.aria-disabled]': 'disabled() ? "true" : null',
|
|
4184
4858
|
'[attr.aria-required]': 'required() ? "true" : null',
|
|
4185
4859
|
'[attr.aria-invalid]': '(invalid() || errorState()) ? "true" : null',
|
|
@@ -4203,7 +4877,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4203
4877
|
useExisting: CngxButtonMultiToggleGroup,
|
|
4204
4878
|
},
|
|
4205
4879
|
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-button-toggle-group-gap{syntax: \"*\"; inherits: false; initial-value: 0;}@property --cngx-button-toggle-group-radius{syntax: \"*\"; inherits: false; initial-value: .375rem;}}@layer cngx.components{@scope(.cngx-button-toggle-group,.cngx-button-multi-toggle-group){:scope{display:inline-flex;flex-direction:row;gap:var(--cngx-button-toggle-group-gap, 0);border-radius:var(--cngx-button-toggle-group-radius, var(--cngx-radius-md, .375rem))}:scope:not(.cngx-button-toggle-group--horizontal,.cngx-button-multi-toggle-group--horizontal){flex-direction:column}}}\n"] }]
|
|
4206
|
-
}], ctorParameters: () => [], propDecorators: { selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }] } });
|
|
4880
|
+
}], ctorParameters: () => [], propDecorators: { selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], labelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelledBy", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }] } });
|
|
4207
4881
|
|
|
4208
4882
|
/**
|
|
4209
4883
|
* Button-toggle leaf. Restricted to `<button>` elements via the
|
|
@@ -4470,24 +5144,38 @@ class CngxRadioGroup {
|
|
|
4470
5144
|
errorMessageId = input(null, ...(ngDevMode ? [{ debugName: "errorMessageId" }] : /* istanbul ignore next */ []));
|
|
4471
5145
|
orientation = input('vertical', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
4472
5146
|
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
4473
|
-
|
|
5147
|
+
/**
|
|
5148
|
+
* Explicit `aria-labelledby` target id. Wins over the automatic
|
|
5149
|
+
* field-label reference applied inside a `cngx-form-field`.
|
|
5150
|
+
*/
|
|
5151
|
+
labelledBy = input(undefined, ...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
|
|
5152
|
+
/**
|
|
5153
|
+
* Optional async state driving `aria-busy`. An explicit binding wins;
|
|
5154
|
+
* when it is absent or `undefined`, an ancestor `CNGX_STATEFUL`
|
|
5155
|
+
* provider is discovered as fallback. A bare `state` attribute (empty
|
|
5156
|
+
* string) is treated as unset. `aria-busy` reflects
|
|
5157
|
+
* `status() === 'loading'`.
|
|
5158
|
+
*/
|
|
5159
|
+
state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), transform: (v) => (typeof v === 'string' ? undefined : v) });
|
|
4474
5160
|
nameInput = input(undefined, { ...(ngDevMode ? { debugName: "nameInput" } : /* istanbul ignore next */ {}), alias: 'name' });
|
|
4475
|
-
ariaBusy = computed(() => this.state()?.status() === 'loading', ...(ngDevMode ? [{ debugName: "ariaBusy" }] : /* istanbul ignore next */ []));
|
|
4476
5161
|
fallbackName = nextUid('cngx-radio-group');
|
|
4477
5162
|
name = computed(() => this.nameInput() ?? this.fallbackName, ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
4478
5163
|
registry = new Map();
|
|
4479
5164
|
roving = inject(CngxRovingTabindex, { host: true });
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
5165
|
+
groupHost = injectInteractiveGroupHost({
|
|
5166
|
+
uidPrefix: 'cngx-radio-group-',
|
|
5167
|
+
invalid: this.invalid,
|
|
5168
|
+
state: this.state,
|
|
5169
|
+
label: this.label,
|
|
5170
|
+
labelledBy: this.labelledBy,
|
|
5171
|
+
});
|
|
5172
|
+
ariaLabelledBy = this.groupHost.ariaLabelledBy;
|
|
5173
|
+
ariaBusy = this.groupHost.ariaBusy;
|
|
5174
|
+
id = this.groupHost.id;
|
|
5175
|
+
focused = this.groupHost.focused;
|
|
4483
5176
|
/** Empty when no radio is selected. */
|
|
4484
5177
|
empty = computed(() => this.value() === undefined, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
4485
|
-
|
|
4486
|
-
aggregator = inject(CNGX_ERROR_AGGREGATOR, {
|
|
4487
|
-
optional: true,
|
|
4488
|
-
skipSelf: true,
|
|
4489
|
-
});
|
|
4490
|
-
errorState = computed(() => this.fieldHost?.showError() ?? this.aggregator?.shouldShow() ?? false, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
5178
|
+
errorState = this.groupHost.errorState;
|
|
4491
5179
|
constructor() {
|
|
4492
5180
|
/* Per WAI-ARIA APG Radio Group, all four arrow keys navigate
|
|
4493
5181
|
regardless of the cosmetic group layout - the consumer-set
|
|
@@ -4514,14 +5202,13 @@ class CngxRadioGroup {
|
|
|
4514
5202
|
return true;
|
|
4515
5203
|
}
|
|
4516
5204
|
handleFocusIn() {
|
|
4517
|
-
this.
|
|
5205
|
+
this.groupHost.handleFocusIn();
|
|
4518
5206
|
}
|
|
4519
5207
|
handleFocusOut() {
|
|
4520
|
-
this.
|
|
4521
|
-
this.fieldHost?.markAsTouched();
|
|
5208
|
+
this.groupHost.handleFocusOut();
|
|
4522
5209
|
}
|
|
4523
5210
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRadioGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4524
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxRadioGroup, isStandalone: true, selector: "cngx-radio-group, [cngxRadioGroup]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, nameInput: { classPropertyName: "nameInput", publicName: "name", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-orientation": "orientation()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-radio-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-radio-group" }, providers: [
|
|
5211
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxRadioGroup, isStandalone: true, selector: "cngx-radio-group, [cngxRadioGroup]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelledBy: { classPropertyName: "labelledBy", publicName: "labelledBy", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, nameInput: { classPropertyName: "nameInput", publicName: "name", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-orientation": "orientation()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-radio-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-radio-group" }, providers: [
|
|
4525
5212
|
{ provide: CNGX_RADIO_GROUP, useExisting: CngxRadioGroup },
|
|
4526
5213
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxRadioGroup },
|
|
4527
5214
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxRadioGroup },
|
|
@@ -4534,6 +5221,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4534
5221
|
role: 'radiogroup',
|
|
4535
5222
|
'[attr.id]': 'id()',
|
|
4536
5223
|
'[attr.aria-label]': 'label()',
|
|
5224
|
+
'[attr.aria-labelledby]': 'ariaLabelledBy()',
|
|
4537
5225
|
'[attr.aria-disabled]': 'disabled() ? "true" : null',
|
|
4538
5226
|
'[attr.aria-required]': 'required() ? "true" : null',
|
|
4539
5227
|
'[attr.aria-invalid]': '(invalid() || errorState()) ? "true" : null',
|
|
@@ -4548,7 +5236,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4548
5236
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxRadioGroup },
|
|
4549
5237
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxRadioGroup },
|
|
4550
5238
|
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-radio-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-radio-group){:scope{--cngx-radio-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var(--cngx-radio-group-gap, var(--cngx-space-sm, .5rem));vertical-align:top}:scope.cngx-radio-group--horizontal{flex-direction:row}}}\n"] }]
|
|
4551
|
-
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], nameInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }] } });
|
|
5239
|
+
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], labelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelledBy", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], nameInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }] } });
|
|
4552
5240
|
|
|
4553
5241
|
/**
|
|
4554
5242
|
* Single radio leaf. Injects the parent group via `CNGX_RADIO_GROUP`
|
|
@@ -4663,7 +5351,7 @@ class CngxRadio {
|
|
|
4663
5351
|
[attr.aria-hidden]="radioDisabled() && disabledReason() ? null : 'true'"
|
|
4664
5352
|
>{{ disabledReason() }}</span
|
|
4665
5353
|
>
|
|
4666
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-radio-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-radio-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-radio-
|
|
5354
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-radio-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-radio-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-radio-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid oklch(.66 .19 50);}@property --cngx-radio-focus-offset{syntax: \"*\"; inherits: false; initial-value: 3px;}@property --cngx-radio-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-radio){:scope{--cngx-radio-gap: var(--cngx-space-sm);display:inline-flex;align-items:center;gap:var(--cngx-radio-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-radio-color, inherit);min-block-size:var(--cngx-target-min, 0px);min-inline-size:var(--cngx-target-min, 0px)}:scope.cngx-radio--disabled{cursor:not-allowed;color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope:focus-visible{outline:var( --cngx-radio-focus-outline, 2px solid var(--cngx-color-primary, oklch(.66 .19 50)) );outline-offset:var(--cngx-radio-focus-offset, 3px);border-radius:var(--cngx-radio-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-radio__label{flex:0 1 auto;min-inline-size:0}.cngx-radio__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}@media(forced-colors:active){.cngx-radio.cngx-radio--disabled{color:GrayText}}\n"], dependencies: [{ kind: "component", type: CngxRadioIndicator, selector: "cngx-radio-indicator", inputs: ["checked", "disabled", "size", "dotGlyph"], exportAs: ["cngxRadioIndicator"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
4667
5355
|
}
|
|
4668
5356
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRadio, decorators: [{
|
|
4669
5357
|
type: Component,
|
|
@@ -4700,7 +5388,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
4700
5388
|
[attr.aria-hidden]="radioDisabled() && disabledReason() ? null : 'true'"
|
|
4701
5389
|
>{{ disabledReason() }}</span
|
|
4702
5390
|
>
|
|
4703
|
-
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-radio-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-radio-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-radio-
|
|
5391
|
+
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-radio-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-radio-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-radio-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid oklch(.66 .19 50);}@property --cngx-radio-focus-offset{syntax: \"*\"; inherits: false; initial-value: 3px;}@property --cngx-radio-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-radio){:scope{--cngx-radio-gap: var(--cngx-space-sm);display:inline-flex;align-items:center;gap:var(--cngx-radio-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-radio-color, inherit);min-block-size:var(--cngx-target-min, 0px);min-inline-size:var(--cngx-target-min, 0px)}:scope.cngx-radio--disabled{cursor:not-allowed;color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope:focus-visible{outline:var( --cngx-radio-focus-outline, 2px solid var(--cngx-color-primary, oklch(.66 .19 50)) );outline-offset:var(--cngx-radio-focus-offset, 3px);border-radius:var(--cngx-radio-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-radio__label{flex:0 1 auto;min-inline-size:0}.cngx-radio__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}@media(forced-colors:active){.cngx-radio.cngx-radio--disabled{color:GrayText}}\n"] }]
|
|
4704
5392
|
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], disabledReason: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledReason", required: false }] }], dotGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "dotGlyph", required: false }] }] } });
|
|
4705
5393
|
|
|
4706
5394
|
/**
|
|
@@ -4866,17 +5554,15 @@ class CngxChipInteraction {
|
|
|
4866
5554
|
}
|
|
4867
5555
|
return this.describedBy();
|
|
4868
5556
|
}, ...(ngDevMode ? [{ debugName: "resolvedDescribedBy" }] : /* istanbul ignore next */ []));
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
5557
|
+
groupHost = injectInteractiveGroupHost({
|
|
5558
|
+
uidPrefix: 'cngx-chip-',
|
|
5559
|
+
invalid: this.invalid,
|
|
5560
|
+
});
|
|
5561
|
+
id = this.groupHost.id;
|
|
5562
|
+
focused = this.groupHost.focused;
|
|
4872
5563
|
/** Empty when the chip is unselected - boolean atom semantics. */
|
|
4873
5564
|
empty = computed(() => this.value() === false, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
4874
|
-
|
|
4875
|
-
errorAggregator = inject(CNGX_ERROR_AGGREGATOR, {
|
|
4876
|
-
optional: true,
|
|
4877
|
-
skipSelf: true,
|
|
4878
|
-
});
|
|
4879
|
-
errorState = computed(() => this.fieldHost?.showError() ?? this.errorAggregator?.shouldShow() ?? false, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
5565
|
+
errorState = this.groupHost.errorState;
|
|
4880
5566
|
constructor() {
|
|
4881
5567
|
const hostEl = inject(ElementRef).nativeElement;
|
|
4882
5568
|
const renderer = inject(Renderer2);
|
|
@@ -4950,11 +5636,10 @@ class CngxChipInteraction {
|
|
|
4950
5636
|
this.removeRequest.emit();
|
|
4951
5637
|
}
|
|
4952
5638
|
handleFocusIn() {
|
|
4953
|
-
this.
|
|
5639
|
+
this.groupHost.handleFocusIn();
|
|
4954
5640
|
}
|
|
4955
5641
|
handleFocusOut() {
|
|
4956
|
-
this.
|
|
4957
|
-
this.fieldHost?.markAsTouched();
|
|
5642
|
+
this.groupHost.handleFocusOut();
|
|
4958
5643
|
}
|
|
4959
5644
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChipInteraction, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
4960
5645
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxChipInteraction, isStandalone: true, selector: "[cngxChipInteraction]", inputs: { chipValue: { classPropertyName: "chipValue", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "selected", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, disabledReason: { classPropertyName: "disabledReason", publicName: "disabledReason", isSignal: true, isRequired: false, transformFunction: null }, describedBy: { classPropertyName: "describedBy", publicName: "cngxDescribedBy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "selectedChange", disabled: "disabledChange", invalid: "invalidChange", removeRequest: "removeRequest" }, host: { attributes: { "role": "option" }, listeners: { "click": "handleClick($event)", "keydown.space": "handleKeydown($event)", "keydown.enter": "handleKeydown($event)", "keydown.delete": "handleRemoveKeydown($event)", "keydown.backspace": "handleRemoveKeydown($event)", "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-selected": "value() ? \"true\" : \"false\"", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-describedby": "resolvedDescribedBy()", "attr.tabindex": "disabled() ? -1 : 0", "class.cngx-chip-interaction--selected": "value()", "class.cngx-chip-interaction--disabled": "disabled()" }, classAttribute: "cngx-chip-interaction" }, providers: [
|
|
@@ -5225,10 +5910,30 @@ class CngxChipGroup {
|
|
|
5225
5910
|
errorMessageId = input(null, ...(ngDevMode ? [{ debugName: "errorMessageId" }] : /* istanbul ignore next */ []));
|
|
5226
5911
|
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
5227
5912
|
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
5228
|
-
|
|
5913
|
+
/**
|
|
5914
|
+
* Explicit `aria-labelledby` target id. Wins over the automatic
|
|
5915
|
+
* field-label reference applied inside a `cngx-form-field`.
|
|
5916
|
+
*/
|
|
5917
|
+
labelledBy = input(undefined, ...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
|
|
5918
|
+
/**
|
|
5919
|
+
* Optional async state driving `aria-busy`. An explicit binding wins;
|
|
5920
|
+
* when it is absent or `undefined`, an ancestor `CNGX_STATEFUL`
|
|
5921
|
+
* provider is discovered as fallback. A bare `state` attribute (empty
|
|
5922
|
+
* string) is treated as unset. `aria-busy` reflects
|
|
5923
|
+
* `status() === 'loading'`.
|
|
5924
|
+
*/
|
|
5925
|
+
state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), transform: (v) => (typeof v === 'string' ? undefined : v) });
|
|
5229
5926
|
/** CngxChipGroupHost - leaf-side cascade source. */
|
|
5230
5927
|
isDisabled = this.disabled;
|
|
5231
|
-
|
|
5928
|
+
groupHost = injectInteractiveGroupHost({
|
|
5929
|
+
uidPrefix: 'cngx-chip-group-',
|
|
5930
|
+
invalid: this.invalid,
|
|
5931
|
+
state: this.state,
|
|
5932
|
+
label: this.label,
|
|
5933
|
+
labelledBy: this.labelledBy,
|
|
5934
|
+
});
|
|
5935
|
+
ariaLabelledBy = this.groupHost.ariaLabelledBy;
|
|
5936
|
+
ariaBusy = this.groupHost.ariaBusy;
|
|
5232
5937
|
isSelected(value) {
|
|
5233
5938
|
return Object.is(this.selected(), value);
|
|
5234
5939
|
}
|
|
@@ -5250,26 +5955,19 @@ class CngxChipGroup {
|
|
|
5250
5955
|
this.selected.set(undefined);
|
|
5251
5956
|
}
|
|
5252
5957
|
}
|
|
5253
|
-
id =
|
|
5254
|
-
|
|
5255
|
-
focused = this.focusedState.asReadonly();
|
|
5958
|
+
id = this.groupHost.id;
|
|
5959
|
+
focused = this.groupHost.focused;
|
|
5256
5960
|
/** Empty when no chip is selected. */
|
|
5257
5961
|
empty = computed(() => this.selected() === undefined, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
5258
|
-
|
|
5259
|
-
errorAggregator = inject(CNGX_ERROR_AGGREGATOR, {
|
|
5260
|
-
optional: true,
|
|
5261
|
-
skipSelf: true,
|
|
5262
|
-
});
|
|
5263
|
-
errorState = computed(() => this.fieldHost?.showError() ?? this.errorAggregator?.shouldShow() ?? false, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
5962
|
+
errorState = this.groupHost.errorState;
|
|
5264
5963
|
handleFocusIn() {
|
|
5265
|
-
this.
|
|
5964
|
+
this.groupHost.handleFocusIn();
|
|
5266
5965
|
}
|
|
5267
5966
|
handleFocusOut() {
|
|
5268
|
-
this.
|
|
5269
|
-
this.fieldHost?.markAsTouched();
|
|
5967
|
+
this.groupHost.handleFocusOut();
|
|
5270
5968
|
}
|
|
5271
5969
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChipGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
5272
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxChipGroup, isStandalone: true, selector: "cngx-chip-group, [cngxChipGroup]", inputs: { selected: { classPropertyName: "selected", publicName: "selected", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selectedChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "listbox" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-chip-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-chip-group" }, providers: [
|
|
5970
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxChipGroup, isStandalone: true, selector: "cngx-chip-group, [cngxChipGroup]", inputs: { selected: { classPropertyName: "selected", publicName: "selected", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelledBy: { classPropertyName: "labelledBy", publicName: "labelledBy", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selectedChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "listbox" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-chip-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-chip-group" }, providers: [
|
|
5273
5971
|
{ provide: CNGX_CHIP_GROUP_HOST, useExisting: CngxChipGroup },
|
|
5274
5972
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxChipGroup },
|
|
5275
5973
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxChipGroup },
|
|
@@ -5287,6 +5985,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5287
5985
|
role: 'listbox',
|
|
5288
5986
|
'[attr.id]': 'id()',
|
|
5289
5987
|
'[attr.aria-label]': 'label()',
|
|
5988
|
+
'[attr.aria-labelledby]': 'ariaLabelledBy()',
|
|
5290
5989
|
'[attr.aria-disabled]': 'disabled() ? "true" : null',
|
|
5291
5990
|
'[attr.aria-required]': 'required() ? "true" : null',
|
|
5292
5991
|
'[attr.aria-invalid]': '(invalid() || errorState()) ? "true" : null',
|
|
@@ -5300,7 +5999,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5300
5999
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxChipGroup },
|
|
5301
6000
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxChipGroup },
|
|
5302
6001
|
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-chip-group){:scope{--cngx-chip-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:max(var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem)),var(--cngx-target-gap, 0px))}:scope.cngx-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"] }]
|
|
5303
|
-
}], propDecorators: { selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: false }] }, { type: i0.Output, args: ["selectedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }] } });
|
|
6002
|
+
}], propDecorators: { selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: false }] }, { type: i0.Output, args: ["selectedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], labelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelledBy", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }] } });
|
|
5304
6003
|
|
|
5305
6004
|
/**
|
|
5306
6005
|
* Multi-select chip group. Owns a `selectedValues = model<T[]>([])`
|
|
@@ -5403,14 +6102,34 @@ class CngxMultiChipGroup {
|
|
|
5403
6102
|
errorMessageId = input(null, ...(ngDevMode ? [{ debugName: "errorMessageId" }] : /* istanbul ignore next */ []));
|
|
5404
6103
|
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
5405
6104
|
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
5406
|
-
|
|
6105
|
+
/**
|
|
6106
|
+
* Explicit `aria-labelledby` target id. Wins over the automatic
|
|
6107
|
+
* field-label reference applied inside a `cngx-form-field`.
|
|
6108
|
+
*/
|
|
6109
|
+
labelledBy = input(undefined, ...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
|
|
6110
|
+
/**
|
|
6111
|
+
* Optional async state driving `aria-busy`. An explicit binding wins;
|
|
6112
|
+
* when it is absent or `undefined`, an ancestor `CNGX_STATEFUL`
|
|
6113
|
+
* provider is discovered as fallback. A bare `state` attribute (empty
|
|
6114
|
+
* string) is treated as unset. `aria-busy` reflects
|
|
6115
|
+
* `status() === 'loading'`.
|
|
6116
|
+
*/
|
|
6117
|
+
state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), transform: (v) => (typeof v === 'string' ? undefined : v) });
|
|
5407
6118
|
keyFn = input((v) => v, ...(ngDevMode ? [{ debugName: "keyFn" }] : /* istanbul ignore next */ []));
|
|
5408
6119
|
/** CngxChipGroupHost - leaf-side cascade source. */
|
|
5409
6120
|
isDisabled = this.disabled;
|
|
5410
6121
|
controller = inject(CNGX_SELECTION_CONTROLLER_FACTORY)(this.selectedValues, {
|
|
5411
6122
|
keyFn: (v) => this.keyFn()(v),
|
|
5412
6123
|
});
|
|
5413
|
-
|
|
6124
|
+
groupHost = injectInteractiveGroupHost({
|
|
6125
|
+
uidPrefix: 'cngx-multi-chip-group-',
|
|
6126
|
+
invalid: this.invalid,
|
|
6127
|
+
state: this.state,
|
|
6128
|
+
label: this.label,
|
|
6129
|
+
labelledBy: this.labelledBy,
|
|
6130
|
+
});
|
|
6131
|
+
ariaLabelledBy = this.groupHost.ariaLabelledBy;
|
|
6132
|
+
ariaBusy = this.groupHost.ariaBusy;
|
|
5414
6133
|
/** Public membership count - useful for label hints + announcements. */
|
|
5415
6134
|
selectedCount = this.controller.selectedCount;
|
|
5416
6135
|
constructor() {
|
|
@@ -5431,26 +6150,19 @@ class CngxMultiChipGroup {
|
|
|
5431
6150
|
}
|
|
5432
6151
|
this.controller.deselect(value);
|
|
5433
6152
|
}
|
|
5434
|
-
id =
|
|
5435
|
-
|
|
5436
|
-
focused = this.focusedState.asReadonly();
|
|
6153
|
+
id = this.groupHost.id;
|
|
6154
|
+
focused = this.groupHost.focused;
|
|
5437
6155
|
/** Empty when no chips are selected. */
|
|
5438
6156
|
empty = computed(() => this.selectedValues().length === 0, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
5439
|
-
|
|
5440
|
-
errorAggregator = inject(CNGX_ERROR_AGGREGATOR, {
|
|
5441
|
-
optional: true,
|
|
5442
|
-
skipSelf: true,
|
|
5443
|
-
});
|
|
5444
|
-
errorState = computed(() => this.fieldHost?.showError() ?? this.errorAggregator?.shouldShow() ?? false, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
6157
|
+
errorState = this.groupHost.errorState;
|
|
5445
6158
|
handleFocusIn() {
|
|
5446
|
-
this.
|
|
6159
|
+
this.groupHost.handleFocusIn();
|
|
5447
6160
|
}
|
|
5448
6161
|
handleFocusOut() {
|
|
5449
|
-
this.
|
|
5450
|
-
this.fieldHost?.markAsTouched();
|
|
6162
|
+
this.groupHost.handleFocusOut();
|
|
5451
6163
|
}
|
|
5452
6164
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMultiChipGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
5453
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxMultiChipGroup, isStandalone: true, selector: "cngx-multi-chip-group, [cngxMultiChipGroup]", inputs: { selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, keyFn: { classPropertyName: "keyFn", publicName: "keyFn", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedValues: "selectedValuesChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "listbox", "aria-multiselectable": "true" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-multi-chip-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-multi-chip-group" }, providers: [
|
|
6165
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxMultiChipGroup, isStandalone: true, selector: "cngx-multi-chip-group, [cngxMultiChipGroup]", inputs: { selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelledBy: { classPropertyName: "labelledBy", publicName: "labelledBy", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, keyFn: { classPropertyName: "keyFn", publicName: "keyFn", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedValues: "selectedValuesChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "listbox", "aria-multiselectable": "true" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-multi-chip-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-multi-chip-group" }, providers: [
|
|
5454
6166
|
{ provide: CNGX_CHIP_GROUP_HOST, useExisting: CngxMultiChipGroup },
|
|
5455
6167
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxMultiChipGroup },
|
|
5456
6168
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxMultiChipGroup },
|
|
@@ -5469,6 +6181,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5469
6181
|
'aria-multiselectable': 'true',
|
|
5470
6182
|
'[attr.id]': 'id()',
|
|
5471
6183
|
'[attr.aria-label]': 'label()',
|
|
6184
|
+
'[attr.aria-labelledby]': 'ariaLabelledBy()',
|
|
5472
6185
|
'[attr.aria-disabled]': 'disabled() ? "true" : null',
|
|
5473
6186
|
'[attr.aria-required]': 'required() ? "true" : null',
|
|
5474
6187
|
'[attr.aria-invalid]': '(invalid() || errorState()) ? "true" : null',
|
|
@@ -5482,7 +6195,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
5482
6195
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxMultiChipGroup },
|
|
5483
6196
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxMultiChipGroup },
|
|
5484
6197
|
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-multi-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-multi-chip-group){:scope{--cngx-multi-chip-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:max(var(--cngx-multi-chip-group-gap, var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem))),var(--cngx-target-gap, 0px))}:scope.cngx-multi-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"] }]
|
|
5485
|
-
}], ctorParameters: () => [], propDecorators: { selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }] } });
|
|
6198
|
+
}], ctorParameters: () => [], propDecorators: { selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], labelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelledBy", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }] } });
|
|
5486
6199
|
|
|
5487
6200
|
/**
|
|
5488
6201
|
* Tokenizing input that turns user-entered strings into emitted
|
|
@@ -5886,11 +6599,31 @@ function createTreeController(opts) {
|
|
|
5886
6599
|
// id → FlatTreeNode, value-key → source CngxTreeNode, parentId →
|
|
5887
6600
|
// first-child FlatTreeNode. All lookups are O(1); the old linear
|
|
5888
6601
|
// scan in firstChildOf is gone.
|
|
6602
|
+
// Error once per offending id/key, not once per recompute - indexes()
|
|
6603
|
+
// rebuilds on every expand/collapse and a persistent duplicate would
|
|
6604
|
+
// otherwise flood the console.
|
|
6605
|
+
const reportedDuplicates = new Set();
|
|
5889
6606
|
const indexes = computed(() => {
|
|
5890
6607
|
const byId = new Map();
|
|
5891
6608
|
const byValue = new Map();
|
|
5892
6609
|
const firstChildById = new Map();
|
|
5893
6610
|
for (const n of flatNodes()) {
|
|
6611
|
+
if (isDevMode()) {
|
|
6612
|
+
// A colliding id/key silently shadows the earlier node in every
|
|
6613
|
+
// O(1) lookup (expansion, selection, focus) - surface the
|
|
6614
|
+
// authoring error instead of dropping nodes.
|
|
6615
|
+
if (byId.has(n.id) && !reportedDuplicates.has(`id:${n.id}`)) {
|
|
6616
|
+
reportedDuplicates.add(`id:${n.id}`);
|
|
6617
|
+
console.error(`createTreeController: duplicate node id "${n.id}" from nodeIdFn - ` +
|
|
6618
|
+
'the earlier node is shadowed in id lookups. Ids must be unique.');
|
|
6619
|
+
}
|
|
6620
|
+
const key = keyFn(n.value);
|
|
6621
|
+
if (byValue.has(key) && !reportedDuplicates.has(`key:${String(key)}`)) {
|
|
6622
|
+
reportedDuplicates.add(`key:${String(key)}`);
|
|
6623
|
+
console.error(`createTreeController: duplicate selection key "${String(key)}" from keyFn - ` +
|
|
6624
|
+
'the earlier node is shadowed in selection lookups. Keys must be unique.');
|
|
6625
|
+
}
|
|
6626
|
+
}
|
|
5894
6627
|
byId.set(n.id, n);
|
|
5895
6628
|
byValue.set(keyFn(n.value), n);
|
|
5896
6629
|
const pids = n.parentIds;
|
|
@@ -6012,6 +6745,27 @@ function createTreeController(opts) {
|
|
|
6012
6745
|
expand(id);
|
|
6013
6746
|
}
|
|
6014
6747
|
};
|
|
6748
|
+
const reveal = (id) => {
|
|
6749
|
+
// parentIds already carries the full ancestor chain root -> parent;
|
|
6750
|
+
// no walk needed. untracked keeps the index read out of caller graphs
|
|
6751
|
+
// (mutator contract, same as peekExpanded).
|
|
6752
|
+
const node = untracked(() => indexes().byId.get(id));
|
|
6753
|
+
if (!node || node.parentIds.length === 0) {
|
|
6754
|
+
return;
|
|
6755
|
+
}
|
|
6756
|
+
const current = peekExpanded();
|
|
6757
|
+
const missing = node.parentIds.filter((pid) => !current.has(pid));
|
|
6758
|
+
if (missing.length === 0) {
|
|
6759
|
+
return;
|
|
6760
|
+
}
|
|
6761
|
+
expandedIdsWritable.update((s) => {
|
|
6762
|
+
const next = new Set(s);
|
|
6763
|
+
for (const pid of missing) {
|
|
6764
|
+
next.add(pid);
|
|
6765
|
+
}
|
|
6766
|
+
return next;
|
|
6767
|
+
});
|
|
6768
|
+
};
|
|
6015
6769
|
const setsEqual = (a, b) => {
|
|
6016
6770
|
if (a === b) {
|
|
6017
6771
|
return true;
|
|
@@ -6056,6 +6810,7 @@ function createTreeController(opts) {
|
|
|
6056
6810
|
expand,
|
|
6057
6811
|
collapse,
|
|
6058
6812
|
toggle,
|
|
6813
|
+
reveal,
|
|
6059
6814
|
expandAll,
|
|
6060
6815
|
collapseAll,
|
|
6061
6816
|
findById,
|
|
@@ -6362,7 +7117,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
6362
7117
|
* Composes naturally with `CngxAsyncClick` and `CngxActionButton`:
|
|
6363
7118
|
*
|
|
6364
7119
|
* ```typescript
|
|
6365
|
-
* const [saveWithRetry, retryState] =
|
|
7120
|
+
* const [saveWithRetry, retryState] = createRetry(
|
|
6366
7121
|
* () => this.http.post('/api/save', data),
|
|
6367
7122
|
* { maxAttempts: 3, delay: 1000, backoff: 'exponential' }
|
|
6368
7123
|
* );
|
|
@@ -6375,7 +7130,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
6375
7130
|
*
|
|
6376
7131
|
* @category common/interactive/retry
|
|
6377
7132
|
*/
|
|
6378
|
-
function
|
|
7133
|
+
function createRetry(action, config) {
|
|
6379
7134
|
const maxAttempts = config?.maxAttempts ?? 3;
|
|
6380
7135
|
const baseDelay = config?.delay ?? 1000;
|
|
6381
7136
|
const backoff = config?.backoff ?? 'exponential';
|
|
@@ -6401,6 +7156,9 @@ function withRetry(action, config) {
|
|
|
6401
7156
|
data: computed(() => undefined),
|
|
6402
7157
|
error: lastErrorState.asReadonly(),
|
|
6403
7158
|
});
|
|
7159
|
+
// Generation counter cancels any in-flight retry loop on re-invocation
|
|
7160
|
+
// (and on reset - a stale loop must not overwrite freshly reset state).
|
|
7161
|
+
let generation = 0;
|
|
6404
7162
|
const retryState = {
|
|
6405
7163
|
attempt: attemptState.asReadonly(),
|
|
6406
7164
|
maxAttempts: computed(() => maxAttempts),
|
|
@@ -6409,6 +7167,7 @@ function withRetry(action, config) {
|
|
|
6409
7167
|
lastError: lastErrorState.asReadonly(),
|
|
6410
7168
|
state: asyncState,
|
|
6411
7169
|
reset() {
|
|
7170
|
+
generation++;
|
|
6412
7171
|
attemptState.set(0);
|
|
6413
7172
|
retryingState.set(false);
|
|
6414
7173
|
exhaustedState.set(false);
|
|
@@ -6416,8 +7175,6 @@ function withRetry(action, config) {
|
|
|
6416
7175
|
lastErrorState.set(undefined);
|
|
6417
7176
|
},
|
|
6418
7177
|
};
|
|
6419
|
-
// Generation counter cancels any in-flight retry loop on re-invocation.
|
|
6420
|
-
let generation = 0;
|
|
6421
7178
|
const retryableAction = async () => {
|
|
6422
7179
|
const thisGeneration = ++generation;
|
|
6423
7180
|
attemptState.set(0);
|
|
@@ -6466,6 +7223,14 @@ function withRetry(action, config) {
|
|
|
6466
7223
|
};
|
|
6467
7224
|
return [retryableAction, retryState];
|
|
6468
7225
|
}
|
|
7226
|
+
/**
|
|
7227
|
+
* Alias of {@link createRetry} under the pre-convention name.
|
|
7228
|
+
*
|
|
7229
|
+
* @deprecated Use `createRetry` - this name is removed at the v1.0 cut
|
|
7230
|
+
* (`with*` is reserved for provider feature functions).
|
|
7231
|
+
* @category common/interactive/retry
|
|
7232
|
+
*/
|
|
7233
|
+
const withRetry = createRetry;
|
|
6469
7234
|
|
|
6470
7235
|
/**
|
|
6471
7236
|
* Creates an optimistic update function for a signal.
|
|
@@ -6478,7 +7243,7 @@ function withRetry(action, config) {
|
|
|
6478
7243
|
*
|
|
6479
7244
|
* ```typescript
|
|
6480
7245
|
* readonly name = signal('Alice');
|
|
6481
|
-
* readonly [updateName, nameState] =
|
|
7246
|
+
* readonly [updateName, nameState] = createOptimistic(
|
|
6482
7247
|
* this.name,
|
|
6483
7248
|
* (value) => this.http.put('/api/name', { name: value })
|
|
6484
7249
|
* );
|
|
@@ -6500,7 +7265,7 @@ function withRetry(action, config) {
|
|
|
6500
7265
|
*
|
|
6501
7266
|
* @category common/interactive/optimistic
|
|
6502
7267
|
*/
|
|
6503
|
-
function
|
|
7268
|
+
function createOptimistic(current, action) {
|
|
6504
7269
|
const rolledBackState = signal(false, ...(ngDevMode ? [{ debugName: "rolledBackState" }] : /* istanbul ignore next */ []));
|
|
6505
7270
|
const errorState = signal(undefined, ...(ngDevMode ? [{ debugName: "errorState" }] : /* istanbul ignore next */ []));
|
|
6506
7271
|
const statusState = signal('idle', ...(ngDevMode ? [{ debugName: "statusState" }] : /* istanbul ignore next */ []));
|
|
@@ -6545,6 +7310,14 @@ function optimistic(current, action) {
|
|
|
6545
7310
|
};
|
|
6546
7311
|
return [apply, state];
|
|
6547
7312
|
}
|
|
7313
|
+
/**
|
|
7314
|
+
* Alias of {@link createOptimistic} under the pre-convention name.
|
|
7315
|
+
*
|
|
7316
|
+
* @deprecated Use `createOptimistic` - this name is removed at the
|
|
7317
|
+
* v1.0 cut (exported factories carry the `create` prefix).
|
|
7318
|
+
* @category common/interactive/optimistic
|
|
7319
|
+
*/
|
|
7320
|
+
const optimistic = createOptimistic;
|
|
6548
7321
|
|
|
6549
7322
|
/**
|
|
6550
7323
|
* Detects long-press gestures via Pointer Events.
|
|
@@ -6629,6 +7402,64 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
6629
7402
|
}]
|
|
6630
7403
|
}], ctorParameters: () => [], propDecorators: { threshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "threshold", required: false }] }], enabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "enabled", required: false }] }], moveThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "moveThreshold", required: false }] }], longPressed: [{ type: i0.Output, args: ["longPressed"] }] } });
|
|
6631
7404
|
|
|
7405
|
+
/**
|
|
7406
|
+
* Shared pointer-gesture engine behind `CngxSwipe` and `CngxSwipeDismiss`.
|
|
7407
|
+
*
|
|
7408
|
+
* Owns the full hardening set so both directives stay in parity: pointer
|
|
7409
|
+
* capture on the host, a `pointercancel` arm, per-gesture `pointerId`
|
|
7410
|
+
* filtering on the document-level streams, and `takeUntilDestroyed`
|
|
7411
|
+
* teardown. Must be called in an injection context.
|
|
7412
|
+
*
|
|
7413
|
+
* @internal
|
|
7414
|
+
*/
|
|
7415
|
+
function createSwipeEngine(el, doc, hooks) {
|
|
7416
|
+
const pointerDown$ = fromEvent(el, 'pointerdown');
|
|
7417
|
+
const pointerMove$ = fromEvent(doc, 'pointermove');
|
|
7418
|
+
const pointerUp$ = fromEvent(doc, 'pointerup');
|
|
7419
|
+
// pointercancel fires when the browser takes the pointer back (system
|
|
7420
|
+
// gesture, popup, JS-triggered focus loss). Without an explicit arm the
|
|
7421
|
+
// in-flight state would stay stuck because pointerup never arrives.
|
|
7422
|
+
const pointerCancel$ = fromEvent(doc, 'pointercancel');
|
|
7423
|
+
pointerDown$
|
|
7424
|
+
.pipe(filter(() => hooks.enabled()), switchMap((start) => {
|
|
7425
|
+
const startX = start.clientX;
|
|
7426
|
+
const startY = start.clientY;
|
|
7427
|
+
const pointerId = start.pointerId;
|
|
7428
|
+
// Document streams see every pointer; a second finger or a stylus
|
|
7429
|
+
// hovering mid-gesture must not steer this gesture's deltas.
|
|
7430
|
+
const samePointer = (e) => e.pointerId === pointerId;
|
|
7431
|
+
// Capture the pointer on the host so subsequent move / up events
|
|
7432
|
+
// route here even when the cursor leaves the original element
|
|
7433
|
+
// (real mouse drags drift off the panel into the page chrome).
|
|
7434
|
+
try {
|
|
7435
|
+
el.setPointerCapture(pointerId);
|
|
7436
|
+
}
|
|
7437
|
+
catch {
|
|
7438
|
+
// setPointerCapture throws if pointerId is invalid (e.g.
|
|
7439
|
+
// synthetic event in some test envs) - safe to ignore.
|
|
7440
|
+
}
|
|
7441
|
+
const release = () => {
|
|
7442
|
+
try {
|
|
7443
|
+
el.releasePointerCapture(pointerId);
|
|
7444
|
+
}
|
|
7445
|
+
catch {
|
|
7446
|
+
// releasePointerCapture throws when the pointer is no longer
|
|
7447
|
+
// captured (e.g. the browser already released it before firing
|
|
7448
|
+
// pointercancel) - safe to ignore.
|
|
7449
|
+
}
|
|
7450
|
+
};
|
|
7451
|
+
const settle$ = merge(pointerUp$.pipe(filter(samePointer), map((end) => ({
|
|
7452
|
+
dx: end.clientX - startX,
|
|
7453
|
+
dy: end.clientY - startY,
|
|
7454
|
+
}))), pointerCancel$.pipe(filter(samePointer), map(() => null)));
|
|
7455
|
+
return pointerMove$.pipe(filter(samePointer), tap((move) => hooks.onMove(move.clientX - startX, move.clientY - startY)), takeUntil(settle$.pipe(tap((settle) => {
|
|
7456
|
+
release();
|
|
7457
|
+
hooks.onSettle(settle);
|
|
7458
|
+
}))));
|
|
7459
|
+
}), takeUntilDestroyed())
|
|
7460
|
+
.subscribe();
|
|
7461
|
+
}
|
|
7462
|
+
|
|
6632
7463
|
/**
|
|
6633
7464
|
* Detects directional swipe gestures via Pointer Events and reports the
|
|
6634
7465
|
* resolved direction.
|
|
@@ -6704,64 +7535,28 @@ class CngxSwipe {
|
|
|
6704
7535
|
constructor() {
|
|
6705
7536
|
const nativeEl = inject((ElementRef)).nativeElement;
|
|
6706
7537
|
const doc = inject(DOCUMENT);
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
// (system gesture, popup, JS-triggered focus loss). Without an
|
|
6712
|
-
// explicit arm the in-flight state would stay stuck at
|
|
6713
|
-
// `swiping = true` because pointerup never arrives.
|
|
6714
|
-
const pointerCancel$ = fromEvent(doc, 'pointercancel');
|
|
6715
|
-
const resetState = (pointerId) => {
|
|
6716
|
-
if (pointerId !== undefined) {
|
|
6717
|
-
try {
|
|
6718
|
-
nativeEl.releasePointerCapture(pointerId);
|
|
6719
|
-
}
|
|
6720
|
-
catch {
|
|
6721
|
-
// releasePointerCapture throws when the pointer is no
|
|
6722
|
-
// longer captured (e.g. the browser already released it
|
|
6723
|
-
// before firing pointercancel) - safe to ignore.
|
|
6724
|
-
}
|
|
6725
|
-
}
|
|
6726
|
-
this.swipingState.set(false);
|
|
6727
|
-
this.swipeProgressState.set(0);
|
|
6728
|
-
this.swipeDirectionState.set(null);
|
|
6729
|
-
};
|
|
6730
|
-
pointerDown$
|
|
6731
|
-
.pipe(filter(() => this.enabled()), switchMap((start) => {
|
|
6732
|
-
const startX = start.clientX;
|
|
6733
|
-
const startY = start.clientY;
|
|
6734
|
-
const pointerId = start.pointerId;
|
|
6735
|
-
// Capture the pointer on the swipe host so subsequent
|
|
6736
|
-
// move / up events route here even when the cursor leaves
|
|
6737
|
-
// the original element (real mouse drags drift off the
|
|
6738
|
-
// panel into the strip / page chrome and would otherwise
|
|
6739
|
-
// skip the directive).
|
|
6740
|
-
try {
|
|
6741
|
-
nativeEl.setPointerCapture(pointerId);
|
|
6742
|
-
}
|
|
6743
|
-
catch {
|
|
6744
|
-
// setPointerCapture throws if pointerId is invalid (e.g.
|
|
6745
|
-
// synthetic event in some test envs) - safe to ignore.
|
|
6746
|
-
}
|
|
6747
|
-
const settle$ = merge(pointerUp$.pipe(map((end) => ({
|
|
6748
|
-
reading: this.read(startX, startY, end.clientX, end.clientY),
|
|
6749
|
-
}))), pointerCancel$.pipe(map(() => ({ reading: null }))));
|
|
6750
|
-
return pointerMove$.pipe(tap((move) => {
|
|
6751
|
-
const reading = this.read(startX, startY, move.clientX, move.clientY);
|
|
7538
|
+
createSwipeEngine(nativeEl, doc, {
|
|
7539
|
+
enabled: () => this.enabled(),
|
|
7540
|
+
onMove: (dx, dy) => {
|
|
7541
|
+
const reading = this.read(dx, dy);
|
|
6752
7542
|
if (reading) {
|
|
6753
7543
|
this.swipingState.set(true);
|
|
6754
7544
|
this.swipeDirectionState.set(reading.direction);
|
|
6755
7545
|
this.swipeProgressState.set(Math.min(1, reading.distance / this.threshold()));
|
|
6756
7546
|
}
|
|
6757
|
-
}
|
|
6758
|
-
|
|
6759
|
-
|
|
7547
|
+
},
|
|
7548
|
+
onSettle: (settle) => {
|
|
7549
|
+
if (settle) {
|
|
7550
|
+
const reading = this.read(settle.dx, settle.dy);
|
|
7551
|
+
if (reading && reading.distance >= this.threshold()) {
|
|
7552
|
+
this.swiped.emit(reading.direction);
|
|
7553
|
+
}
|
|
6760
7554
|
}
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
7555
|
+
this.swipingState.set(false);
|
|
7556
|
+
this.swipeProgressState.set(0);
|
|
7557
|
+
this.swipeDirectionState.set(null);
|
|
7558
|
+
},
|
|
7559
|
+
});
|
|
6765
7560
|
}
|
|
6766
7561
|
/**
|
|
6767
7562
|
* Resolve the swipe direction + distance for a pointer delta.
|
|
@@ -6777,9 +7572,7 @@ class CngxSwipe {
|
|
|
6777
7572
|
* pointer before pointerup, so a clean cycle reaching here is already
|
|
6778
7573
|
* the intended direction. `both` keeps the dominant-axis heuristic.
|
|
6779
7574
|
*/
|
|
6780
|
-
read(
|
|
6781
|
-
const dx = endX - startX;
|
|
6782
|
-
const dy = endY - startY;
|
|
7575
|
+
read(dx, dy) {
|
|
6783
7576
|
const axis = this.axis();
|
|
6784
7577
|
if (axis === 'x') {
|
|
6785
7578
|
return { direction: dx < 0 ? 'left' : 'right', distance: Math.abs(dx) };
|
|
@@ -6865,47 +7658,57 @@ class CngxSwipeDismiss {
|
|
|
6865
7658
|
swiping = this.swipingState.asReadonly();
|
|
6866
7659
|
/** Progress of the current swipe from 0 to 1 (clamped). */
|
|
6867
7660
|
swipeProgress = this.swipeProgressState.asReadonly();
|
|
7661
|
+
/**
|
|
7662
|
+
* The `touch-action` the host should advertise, derived from the dismiss
|
|
7663
|
+
* direction: a horizontal dismiss hands vertical panning back to native
|
|
7664
|
+
* scrolling and vice versa. No value is written while disabled.
|
|
7665
|
+
*/
|
|
7666
|
+
touchAction = computed(() => {
|
|
7667
|
+
if (!this.enabled()) {
|
|
7668
|
+
return null;
|
|
7669
|
+
}
|
|
7670
|
+
const dir = this.direction();
|
|
7671
|
+
return dir === 'left' || dir === 'right' ? 'pan-y' : 'pan-x';
|
|
7672
|
+
}, ...(ngDevMode ? [{ debugName: "touchAction" }] : /* istanbul ignore next */ []));
|
|
6868
7673
|
constructor() {
|
|
6869
7674
|
const nativeEl = inject((ElementRef)).nativeElement;
|
|
6870
7675
|
const doc = inject(DOCUMENT);
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
.pipe(filter(() => this.enabled()), switchMap((start) => {
|
|
6876
|
-
const startX = start.clientX;
|
|
6877
|
-
const startY = start.clientY;
|
|
6878
|
-
return pointerMove$.pipe(tap((move) => {
|
|
6879
|
-
const delta = this.getDelta(startX, startY, move.clientX, move.clientY);
|
|
7676
|
+
createSwipeEngine(nativeEl, doc, {
|
|
7677
|
+
enabled: () => this.enabled(),
|
|
7678
|
+
onMove: (dx, dy) => {
|
|
7679
|
+
const delta = this.getDelta(dx, dy);
|
|
6880
7680
|
if (delta > 0) {
|
|
6881
7681
|
this.swipingState.set(true);
|
|
6882
7682
|
this.swipeProgressState.set(Math.min(1, delta / this.threshold()));
|
|
6883
7683
|
}
|
|
6884
|
-
}
|
|
6885
|
-
|
|
6886
|
-
|
|
7684
|
+
},
|
|
7685
|
+
onSettle: (settle) => {
|
|
7686
|
+
if (settle) {
|
|
7687
|
+
const delta = this.getDelta(settle.dx, settle.dy);
|
|
7688
|
+
if (delta >= this.threshold()) {
|
|
7689
|
+
this.swiped.emit();
|
|
7690
|
+
}
|
|
6887
7691
|
}
|
|
6888
7692
|
this.swipingState.set(false);
|
|
6889
7693
|
this.swipeProgressState.set(0);
|
|
6890
|
-
}
|
|
6891
|
-
})
|
|
6892
|
-
.subscribe();
|
|
7694
|
+
},
|
|
7695
|
+
});
|
|
6893
7696
|
}
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
switch (
|
|
7697
|
+
/** Signed delta along the dismiss direction; movement away from it is negative. */
|
|
7698
|
+
getDelta(dx, dy) {
|
|
7699
|
+
switch (this.direction()) {
|
|
6897
7700
|
case 'left':
|
|
6898
|
-
return
|
|
7701
|
+
return -dx;
|
|
6899
7702
|
case 'right':
|
|
6900
|
-
return
|
|
7703
|
+
return dx;
|
|
6901
7704
|
case 'up':
|
|
6902
|
-
return
|
|
7705
|
+
return -dy;
|
|
6903
7706
|
case 'down':
|
|
6904
|
-
return
|
|
7707
|
+
return dy;
|
|
6905
7708
|
}
|
|
6906
7709
|
}
|
|
6907
7710
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSwipeDismiss, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
6908
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxSwipeDismiss, isStandalone: true, selector: "[cngxSwipeDismiss]", inputs: { direction: { classPropertyName: "direction", publicName: "cngxSwipeDismiss", isSignal: true, isRequired: true, transformFunction: null }, threshold: { classPropertyName: "threshold", publicName: "threshold", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { swiped: "swiped" }, exportAs: ["cngxSwipeDismiss"], ngImport: i0 });
|
|
7711
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxSwipeDismiss, isStandalone: true, selector: "[cngxSwipeDismiss]", inputs: { direction: { classPropertyName: "direction", publicName: "cngxSwipeDismiss", isSignal: true, isRequired: true, transformFunction: null }, threshold: { classPropertyName: "threshold", publicName: "threshold", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { swiped: "swiped" }, host: { properties: { "style.touch-action": "touchAction()", "style.user-select": "swiping() ? 'none' : null", "style.-webkit-user-select": "swiping() ? 'none' : null" } }, exportAs: ["cngxSwipeDismiss"], ngImport: i0 });
|
|
6909
7712
|
}
|
|
6910
7713
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSwipeDismiss, decorators: [{
|
|
6911
7714
|
type: Directive,
|
|
@@ -6913,6 +7716,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
6913
7716
|
selector: '[cngxSwipeDismiss]',
|
|
6914
7717
|
exportAs: 'cngxSwipeDismiss',
|
|
6915
7718
|
standalone: true,
|
|
7719
|
+
host: {
|
|
7720
|
+
// Advertise the gesture's axis so the browser never claims the swipe
|
|
7721
|
+
// as a scroll; the orthogonal axis stays native (mirrors CngxSwipe).
|
|
7722
|
+
'[style.touch-action]': 'touchAction()',
|
|
7723
|
+
// Suppress text selection only while a gesture is in flight - a bare
|
|
7724
|
+
// user-select:none would kill selection even when the user is reading.
|
|
7725
|
+
'[style.user-select]': "swiping() ? 'none' : null",
|
|
7726
|
+
'[style.-webkit-user-select]': "swiping() ? 'none' : null",
|
|
7727
|
+
},
|
|
6916
7728
|
}]
|
|
6917
7729
|
}], ctorParameters: () => [], propDecorators: { direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxSwipeDismiss", required: true }] }], threshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "threshold", required: false }] }], enabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "enabled", required: false }] }], swiped: [{ type: i0.Output, args: ["swiped"] }] } });
|
|
6918
7730
|
|
|
@@ -6944,7 +7756,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
6944
7756
|
* <span class="chip-strip" [cngxReorder]="values" (reordered)="apply($event)">
|
|
6945
7757
|
* @for (v of values(); track v; let i = $index) {
|
|
6946
7758
|
* <span class="chip" [attr.data-reorder-index]="i">
|
|
6947
|
-
* <button cngxReorderHandle aria-label="
|
|
7759
|
+
* <button cngxReorderHandle aria-label="Move item">⋮⋮</button>
|
|
6948
7760
|
* {{ v.label }}
|
|
6949
7761
|
* </span>
|
|
6950
7762
|
* }
|
|
@@ -7032,10 +7844,23 @@ class CngxReorder {
|
|
|
7032
7844
|
doc = inject(DOCUMENT);
|
|
7033
7845
|
direction = injectDirection();
|
|
7034
7846
|
destroyRef = inject(DestroyRef);
|
|
7847
|
+
/**
|
|
7848
|
+
* Cleanups of click suppressors whose window is still open. Routed
|
|
7849
|
+
* through ONE destroy hook (below) instead of a fresh
|
|
7850
|
+
* `DestroyRef.onDestroy` registration per completed drag - those
|
|
7851
|
+
* registrations were never released and accumulated over the
|
|
7852
|
+
* directive's lifetime.
|
|
7853
|
+
*/
|
|
7854
|
+
pendingSuppressorCleanups = new Set();
|
|
7035
7855
|
constructor() {
|
|
7036
7856
|
this.wirePointer();
|
|
7037
7857
|
this.wireKeyboard();
|
|
7038
7858
|
this.wireDevModeCheck();
|
|
7859
|
+
this.destroyRef.onDestroy(() => {
|
|
7860
|
+
for (const cleanup of [...this.pendingSuppressorCleanups]) {
|
|
7861
|
+
cleanup();
|
|
7862
|
+
}
|
|
7863
|
+
});
|
|
7039
7864
|
}
|
|
7040
7865
|
wirePointer() {
|
|
7041
7866
|
const down$ = fromEvent(this.hostEl, 'pointerdown');
|
|
@@ -7239,7 +8064,7 @@ class CngxReorder {
|
|
|
7239
8064
|
if (from < 0 || from >= current.length) {
|
|
7240
8065
|
return;
|
|
7241
8066
|
}
|
|
7242
|
-
const clampedTo =
|
|
8067
|
+
const clampedTo = clamp$1(to, 0, current.length - 1);
|
|
7243
8068
|
if (clampedTo === from) {
|
|
7244
8069
|
return;
|
|
7245
8070
|
}
|
|
@@ -7259,8 +8084,8 @@ class CngxReorder {
|
|
|
7259
8084
|
* itself after the first event, after a short watchdog timeout if
|
|
7260
8085
|
* no click ever fires (browsers skip the click when mouse travel
|
|
7261
8086
|
* exceeds the platform drag threshold), and on directive destroy
|
|
7262
|
-
*
|
|
7263
|
-
* iterations.
|
|
8087
|
+
* (via the routed `pendingSuppressorCleanups` set) so test fixtures
|
|
8088
|
+
* never leak a document-level handler across iterations.
|
|
7264
8089
|
*/
|
|
7265
8090
|
installClickSuppressor() {
|
|
7266
8091
|
let cleaned = false;
|
|
@@ -7275,6 +8100,7 @@ class CngxReorder {
|
|
|
7275
8100
|
return;
|
|
7276
8101
|
}
|
|
7277
8102
|
cleaned = true;
|
|
8103
|
+
this.pendingSuppressorCleanups.delete(cleanup);
|
|
7278
8104
|
this.doc.removeEventListener('click', handler, true);
|
|
7279
8105
|
clearTimeout(watchdog);
|
|
7280
8106
|
};
|
|
@@ -7283,7 +8109,7 @@ class CngxReorder {
|
|
|
7283
8109
|
// 50ms covers queuing quirks without lingering past the user's
|
|
7284
8110
|
// next real click.
|
|
7285
8111
|
const watchdog = setTimeout(cleanup, 50);
|
|
7286
|
-
this.
|
|
8112
|
+
this.pendingSuppressorCleanups.add(cleanup);
|
|
7287
8113
|
}
|
|
7288
8114
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxReorder, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
7289
8115
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxReorder, isStandalone: true, selector: "[cngxReorder]", inputs: { items: { classPropertyName: "items", publicName: "cngxReorder", isSignal: true, isRequired: true, transformFunction: null }, handleSelector: { classPropertyName: "handleSelector", publicName: "handleSelector", isSignal: true, isRequired: false, transformFunction: null }, itemSelector: { classPropertyName: "itemSelector", publicName: "itemSelector", isSignal: true, isRequired: false, transformFunction: null }, ignoreSelector: { classPropertyName: "ignoreSelector", publicName: "ignoreSelector", isSignal: true, isRequired: false, transformFunction: null }, keyboardModifier: { classPropertyName: "keyboardModifier", publicName: "keyboardModifier", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { reordered: "reordered", dragStart: "dragStart", dragEnd: "dragEnd" }, host: { properties: { "class.cngx-reorder-container": "true", "class.cngx-reorder-dragging": "dragging()" } }, exportAs: ["cngxReorder"], ngImport: i0 });
|
|
@@ -7372,10 +8198,13 @@ function createChipStripRoving(opts) {
|
|
|
7372
8198
|
let nextIdx;
|
|
7373
8199
|
switch (event.key) {
|
|
7374
8200
|
case 'ArrowUp':
|
|
7375
|
-
|
|
8201
|
+
// Clamp semantics: a boundary step keeps the current index. The
|
|
8202
|
+
// shrink-clamp effect maintains `current` inside [0, count), so
|
|
8203
|
+
// `?? current` is exactly the previous Math.max/Math.min clamp.
|
|
8204
|
+
nextIdx = resolveStepFrom(current, -1, { count }) ?? current;
|
|
7376
8205
|
break;
|
|
7377
8206
|
case 'ArrowDown':
|
|
7378
|
-
nextIdx =
|
|
8207
|
+
nextIdx = resolveStepFrom(current, 1, { count }) ?? current;
|
|
7379
8208
|
break;
|
|
7380
8209
|
case 'ArrowLeft':
|
|
7381
8210
|
case 'ArrowRight': {
|
|
@@ -7384,7 +8213,7 @@ function createChipStripRoving(opts) {
|
|
|
7384
8213
|
if (step === null) {
|
|
7385
8214
|
return;
|
|
7386
8215
|
}
|
|
7387
|
-
nextIdx =
|
|
8216
|
+
nextIdx = resolveStepFrom(current, step, { count }) ?? current;
|
|
7388
8217
|
break;
|
|
7389
8218
|
}
|
|
7390
8219
|
case 'Home':
|
|
@@ -7736,12 +8565,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
7736
8565
|
* ```
|
|
7737
8566
|
*
|
|
7738
8567
|
* @param isDirty - Callback that returns `true` when there are unsaved changes.
|
|
7739
|
-
* @param message - Confirmation message.
|
|
8568
|
+
* @param message - Confirmation message. Unset, it reads `unsavedChanges` of
|
|
8569
|
+
* `CNGX_INTERACTIVE_I18N` (English `'You have unsaved changes. Leave anyway?'`)
|
|
8570
|
+
* when the guard runs, so it follows the active language.
|
|
7740
8571
|
* @returns A functional guard compatible with Angular's `canDeactivate`.
|
|
7741
8572
|
*
|
|
7742
8573
|
* @category common/interactive/guard
|
|
7743
8574
|
*/
|
|
7744
|
-
function canDeactivateWhenClean(isDirty, message
|
|
8575
|
+
function canDeactivateWhenClean(isDirty, message) {
|
|
7745
8576
|
return () => {
|
|
7746
8577
|
if (!isDirty()) {
|
|
7747
8578
|
return true;
|
|
@@ -7751,7 +8582,7 @@ function canDeactivateWhenClean(isDirty, message = 'You have unsaved changes. Le
|
|
|
7751
8582
|
if (!win) {
|
|
7752
8583
|
return true;
|
|
7753
8584
|
}
|
|
7754
|
-
return win.confirm(message);
|
|
8585
|
+
return win.confirm(message ?? injectResolvedInteractiveI18n()().unsavedChanges);
|
|
7755
8586
|
};
|
|
7756
8587
|
}
|
|
7757
8588
|
|
|
@@ -7831,7 +8662,7 @@ class CngxCloseButton {
|
|
|
7831
8662
|
}
|
|
7832
8663
|
</ng-content>
|
|
7833
8664
|
</button>
|
|
7834
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-close-button-bg{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-border{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-size{syntax: \"<length>\"; inherits: false; initial-value: 32px;}@property --cngx-close-button-padding{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-close-button-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-close-button-
|
|
8665
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-close-button-bg{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-border{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-size{syntax: \"<length>\"; inherits: false; initial-value: 32px;}@property --cngx-close-button-padding{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-close-button-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-close-button-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-close-button-transition{syntax: \"<time>\"; inherits: false; initial-value: .15s;}:where(.cngx-close-button,.cngx-close-button *){--cngx-close-button-transition: var(--cngx-duration-fast)}:where(.cngx-close-button){--cngx-close-button-color: var(--cngx-color-text-muted, oklch(.5 .01 250))}@property --cngx-close-button-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .04);}@property --cngx-close-button-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-close-button-focus-offset{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-close-button-icon-size{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-close-button-hover-bg: oklch(1 0 0 / .06)}}[data-color-scheme=dark],.dark{--cngx-close-button-hover-bg: oklch(1 0 0 / .06)}[data-color-scheme=light],.light{--cngx-close-button-hover-bg: oklch(0 0 0 / .04)}}@layer cngx.components{@scope(.cngx-close-button){:scope{--cngx-close-button-padding: var(--cngx-space-sm);display:inline-flex;align-items:center;justify-content:center;vertical-align:middle}.cngx-close-button__btn{display:inline-flex;align-items:center;justify-content:center;appearance:none;background:var(--cngx-close-button-bg, none);border:var(--cngx-close-button-border, none);min-width:max(var(--cngx-close-button-size, 32px),var(--cngx-target-min, 0px));min-height:max(var(--cngx-close-button-size, 32px),var(--cngx-target-min, 0px));padding:var(--cngx-close-button-padding, var(--cngx-space-sm, 8px));cursor:pointer;color:var(--cngx-close-button-color, inherit);border-radius:var(--cngx-close-button-radius, var(--cngx-radius-sm, 4px));transition:color var(--cngx-close-button-transition, .15s) ease}.cngx-close-button__btn:hover{color:inherit;background:var(--cngx-close-button-hover-bg, oklch(0 0 0 / .04))}.cngx-close-button__btn:focus-visible{outline:var(--cngx-close-button-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-close-button-focus-offset, 2px);color:inherit}.cngx-close-button__btn:active{color:color-mix(in oklab,currentColor 80%,transparent)}.cngx-close-button__icon{width:var(--cngx-close-button-icon-size, 16px);height:var(--cngx-close-button-icon-size, 16px);flex-shrink:0}}}\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
7835
8666
|
}
|
|
7836
8667
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCloseButton, decorators: [{
|
|
7837
8668
|
type: Component,
|
|
@@ -7859,7 +8690,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
7859
8690
|
}
|
|
7860
8691
|
</ng-content>
|
|
7861
8692
|
</button>
|
|
7862
|
-
`, styles: ["@layer cngx.tokens{@property --cngx-close-button-bg{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-border{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-size{syntax: \"<length>\"; inherits: false; initial-value: 32px;}@property --cngx-close-button-padding{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-close-button-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-close-button-
|
|
8693
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-close-button-bg{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-border{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-size{syntax: \"<length>\"; inherits: false; initial-value: 32px;}@property --cngx-close-button-padding{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-close-button-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-close-button-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-close-button-transition{syntax: \"<time>\"; inherits: false; initial-value: .15s;}:where(.cngx-close-button,.cngx-close-button *){--cngx-close-button-transition: var(--cngx-duration-fast)}:where(.cngx-close-button){--cngx-close-button-color: var(--cngx-color-text-muted, oklch(.5 .01 250))}@property --cngx-close-button-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .04);}@property --cngx-close-button-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-close-button-focus-offset{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-close-button-icon-size{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-close-button-hover-bg: oklch(1 0 0 / .06)}}[data-color-scheme=dark],.dark{--cngx-close-button-hover-bg: oklch(1 0 0 / .06)}[data-color-scheme=light],.light{--cngx-close-button-hover-bg: oklch(0 0 0 / .04)}}@layer cngx.components{@scope(.cngx-close-button){:scope{--cngx-close-button-padding: var(--cngx-space-sm);display:inline-flex;align-items:center;justify-content:center;vertical-align:middle}.cngx-close-button__btn{display:inline-flex;align-items:center;justify-content:center;appearance:none;background:var(--cngx-close-button-bg, none);border:var(--cngx-close-button-border, none);min-width:max(var(--cngx-close-button-size, 32px),var(--cngx-target-min, 0px));min-height:max(var(--cngx-close-button-size, 32px),var(--cngx-target-min, 0px));padding:var(--cngx-close-button-padding, var(--cngx-space-sm, 8px));cursor:pointer;color:var(--cngx-close-button-color, inherit);border-radius:var(--cngx-close-button-radius, var(--cngx-radius-sm, 4px));transition:color var(--cngx-close-button-transition, .15s) ease}.cngx-close-button__btn:hover{color:inherit;background:var(--cngx-close-button-hover-bg, oklch(0 0 0 / .04))}.cngx-close-button__btn:focus-visible{outline:var(--cngx-close-button-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-close-button-focus-offset, 2px);color:inherit}.cngx-close-button__btn:active{color:color-mix(in oklab,currentColor 80%,transparent)}.cngx-close-button__icon{width:var(--cngx-close-button-icon-size, 16px);height:var(--cngx-close-button-icon-size, 16px);flex-shrink:0}}}\n"] }]
|
|
7863
8694
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }] } });
|
|
7864
8695
|
|
|
7865
8696
|
/**
|
|
@@ -7869,8 +8700,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
7869
8700
|
*
|
|
7870
8701
|
* Designed as a `hostDirective` composition primitive - attach it to
|
|
7871
8702
|
* components that need hover state without implementing their own
|
|
7872
|
-
* mouseenter/mouseleave logic.
|
|
7873
|
-
*
|
|
8703
|
+
* mouseenter/mouseleave logic. Host components read the read-only
|
|
8704
|
+
* `hovered` signal via `inject(CngxHoverable, { host: true })`; the
|
|
8705
|
+
* pointer events are the only writers.
|
|
7874
8706
|
*
|
|
7875
8707
|
* Used internally by `CngxTreetableRow` for row highlight-on-hover.
|
|
7876
8708
|
*
|
|
@@ -7898,10 +8730,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
7898
8730
|
* @relatedTo CngxPressable, CngxRipple
|
|
7899
8731
|
*/
|
|
7900
8732
|
class CngxHoverable {
|
|
8733
|
+
/** Backing state for {@link hovered}. */
|
|
8734
|
+
hoveredState = signal(false, ...(ngDevMode ? [{ debugName: "hoveredState" }] : /* istanbul ignore next */ []));
|
|
7901
8735
|
/** `true` while the pointer is over the host element. */
|
|
7902
|
-
hovered =
|
|
8736
|
+
hovered = this.hoveredState.asReadonly();
|
|
8737
|
+
handleMouseEnter() {
|
|
8738
|
+
this.hoveredState.set(true);
|
|
8739
|
+
}
|
|
8740
|
+
handleMouseLeave() {
|
|
8741
|
+
this.hoveredState.set(false);
|
|
8742
|
+
}
|
|
7903
8743
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxHoverable, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
7904
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxHoverable, isStandalone: true, selector: "[cngxHoverable]", host: { listeners: { "mouseenter": "
|
|
8744
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxHoverable, isStandalone: true, selector: "[cngxHoverable]", host: { listeners: { "mouseenter": "handleMouseEnter()", "mouseleave": "handleMouseLeave()" } }, exportAs: ["cngxHoverable"], ngImport: i0 });
|
|
7905
8745
|
}
|
|
7906
8746
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxHoverable, decorators: [{
|
|
7907
8747
|
type: Directive,
|
|
@@ -7910,12 +8750,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
7910
8750
|
standalone: true,
|
|
7911
8751
|
exportAs: 'cngxHoverable',
|
|
7912
8752
|
host: {
|
|
7913
|
-
'(mouseenter)': '
|
|
7914
|
-
'(mouseleave)': '
|
|
8753
|
+
'(mouseenter)': 'handleMouseEnter()',
|
|
8754
|
+
'(mouseleave)': 'handleMouseLeave()',
|
|
7915
8755
|
},
|
|
7916
8756
|
}]
|
|
7917
8757
|
}] });
|
|
7918
8758
|
|
|
8759
|
+
/** Angular's `LOCALE_ID` when the app provides none. */
|
|
8760
|
+
const IMPLICIT_LOCALE_ID = 'en-US';
|
|
7919
8761
|
/**
|
|
7920
8762
|
* Headless text-to-speech directive using the browser's SpeechSynthesis API.
|
|
7921
8763
|
*
|
|
@@ -7977,14 +8819,36 @@ class CngxSpeak {
|
|
|
7977
8819
|
pitch = input(1, ...(ngDevMode ? [{ debugName: "pitch" }] : /* istanbul ignore next */ []));
|
|
7978
8820
|
/** Speech volume (0–1, default 1). */
|
|
7979
8821
|
volume = input(1, ...(ngDevMode ? [{ debugName: "volume" }] : /* istanbul ignore next */ []));
|
|
7980
|
-
/**
|
|
8822
|
+
/**
|
|
8823
|
+
* BCP 47 language tag (e.g. `'de-DE'`). Empty string uses the app locale,
|
|
8824
|
+
* in the order cngx formatters read it: a provided `CNGX_LOCALE`
|
|
8825
|
+
* (`provideLocale`, `provideCngxI18n`), else a `LOCALE_ID` other than
|
|
8826
|
+
* `'en-US'`, else `<html lang>`, else the browser's default voice language.
|
|
8827
|
+
*
|
|
8828
|
+
* `'en-US'` is Angular's implicit `LOCALE_ID` when an app sets none, and an
|
|
8829
|
+
* explicit `'en-US'` cannot be told apart from it. A voice is chosen by its
|
|
8830
|
+
* language, so treating that default as a choice would read German page
|
|
8831
|
+
* text with an English voice; it falls through to `<html lang>` instead.
|
|
8832
|
+
* An app that wants American English speech says so with `provideLocale`,
|
|
8833
|
+
* `<html lang>` or this input.
|
|
8834
|
+
*/
|
|
7981
8835
|
lang = input('', ...(ngDevMode ? [{ debugName: "lang" }] : /* istanbul ignore next */ []));
|
|
8836
|
+
appLocale = inject(CNGX_LOCALE, { optional: true });
|
|
8837
|
+
// Without a provided CNGX_LOCALE this reads the nearest LOCALE_ID.
|
|
8838
|
+
locale = injectLocale();
|
|
8839
|
+
documentElement = inject(DOCUMENT).documentElement;
|
|
7982
8840
|
/** Controls auto-speak on text changes. Does NOT affect `speak()` or `cancel()`. */
|
|
7983
8841
|
enabled = input(true, ...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
|
|
7984
8842
|
speakingState = signal(false, ...(ngDevMode ? [{ debugName: "speakingState" }] : /* istanbul ignore next */ []));
|
|
7985
8843
|
supportedState;
|
|
7986
8844
|
synth;
|
|
7987
8845
|
initialized = signal(false, ...(ngDevMode ? [{ debugName: "initialized" }] : /* istanbul ignore next */ []));
|
|
8846
|
+
// Retains the in-flight utterance: Chrome garbage-collects unreferenced
|
|
8847
|
+
// utterances mid-speech and then never fires their onend/onerror, which
|
|
8848
|
+
// would leave `speaking` stuck at true. Also the ownership marker for
|
|
8849
|
+
// cancel - synth.cancel() clears the GLOBAL queue, so it may only fire
|
|
8850
|
+
// while an utterance of THIS directive is live.
|
|
8851
|
+
activeUtterance = null;
|
|
7988
8852
|
/** Whether the browser supports the SpeechSynthesis API. */
|
|
7989
8853
|
supported;
|
|
7990
8854
|
/** `true` while an utterance is being spoken. */
|
|
@@ -8000,9 +8864,11 @@ class CngxSpeak {
|
|
|
8000
8864
|
if (!this.initialized() || !value || !this.enabled() || !this.synth) {
|
|
8001
8865
|
return;
|
|
8002
8866
|
}
|
|
8003
|
-
|
|
8867
|
+
// untracked: rate/pitch/volume/lang are per-utterance parameters read
|
|
8868
|
+
// inside performSpeak - a parameter change must not re-speak the text.
|
|
8869
|
+
untracked(() => this.performSpeak(value));
|
|
8004
8870
|
});
|
|
8005
|
-
inject(DestroyRef).onDestroy(() => this.
|
|
8871
|
+
inject(DestroyRef).onDestroy(() => this.cancelOwn());
|
|
8006
8872
|
}
|
|
8007
8873
|
/** Speak arbitrary text. Always works regardless of `enabled`. */
|
|
8008
8874
|
speak(text) {
|
|
@@ -8010,10 +8876,14 @@ class CngxSpeak {
|
|
|
8010
8876
|
this.performSpeak(text);
|
|
8011
8877
|
}
|
|
8012
8878
|
}
|
|
8013
|
-
/**
|
|
8879
|
+
/**
|
|
8880
|
+
* Cancel this directive's ongoing speech. A no-op while no own utterance
|
|
8881
|
+
* is live, so an idle instance never clears the shared synthesis queue.
|
|
8882
|
+
* (Starting a new utterance still interrupts whatever is playing -
|
|
8883
|
+
* `SpeechSynthesis` is a single audio channel.)
|
|
8884
|
+
*/
|
|
8014
8885
|
cancel() {
|
|
8015
|
-
this.
|
|
8016
|
-
this.speakingState.set(false);
|
|
8886
|
+
this.cancelOwn();
|
|
8017
8887
|
}
|
|
8018
8888
|
/** Toggle speech: speak text if idle, cancel if speaking. */
|
|
8019
8889
|
toggle() {
|
|
@@ -8027,6 +8897,17 @@ class CngxSpeak {
|
|
|
8027
8897
|
}
|
|
8028
8898
|
}
|
|
8029
8899
|
}
|
|
8900
|
+
resolveAppLanguage() {
|
|
8901
|
+
const provided = this.appLocale?.();
|
|
8902
|
+
if (provided) {
|
|
8903
|
+
return provided;
|
|
8904
|
+
}
|
|
8905
|
+
const localeId = this.locale();
|
|
8906
|
+
if (localeId !== IMPLICIT_LOCALE_ID) {
|
|
8907
|
+
return localeId;
|
|
8908
|
+
}
|
|
8909
|
+
return this.documentElement.lang;
|
|
8910
|
+
}
|
|
8030
8911
|
performSpeak(text) {
|
|
8031
8912
|
const synth = this.synth;
|
|
8032
8913
|
// Chrome silently drops the next speak() when cancel() runs on an
|
|
@@ -8039,15 +8920,35 @@ class CngxSpeak {
|
|
|
8039
8920
|
utterance.rate = this.rate();
|
|
8040
8921
|
utterance.pitch = this.pitch();
|
|
8041
8922
|
utterance.volume = this.volume();
|
|
8042
|
-
const lang = this.lang();
|
|
8923
|
+
const lang = this.lang() || this.resolveAppLanguage();
|
|
8043
8924
|
if (lang) {
|
|
8044
8925
|
utterance.lang = lang;
|
|
8045
8926
|
}
|
|
8046
|
-
utterance.onstart = () =>
|
|
8047
|
-
|
|
8048
|
-
|
|
8927
|
+
utterance.onstart = () => {
|
|
8928
|
+
if (this.activeUtterance === utterance) {
|
|
8929
|
+
this.speakingState.set(true);
|
|
8930
|
+
}
|
|
8931
|
+
};
|
|
8932
|
+
utterance.onend = () => this.finishUtterance(utterance);
|
|
8933
|
+
utterance.onerror = () => this.finishUtterance(utterance);
|
|
8934
|
+
this.activeUtterance = utterance;
|
|
8049
8935
|
synth.speak(utterance);
|
|
8050
8936
|
}
|
|
8937
|
+
cancelOwn() {
|
|
8938
|
+
if (this.activeUtterance) {
|
|
8939
|
+
this.activeUtterance = null;
|
|
8940
|
+
this.synth?.cancel();
|
|
8941
|
+
}
|
|
8942
|
+
this.speakingState.set(false);
|
|
8943
|
+
}
|
|
8944
|
+
/** Ignores stale callbacks of a replaced utterance so a new one keeps `speaking` intact. */
|
|
8945
|
+
finishUtterance(utterance) {
|
|
8946
|
+
if (this.activeUtterance !== utterance) {
|
|
8947
|
+
return;
|
|
8948
|
+
}
|
|
8949
|
+
this.activeUtterance = null;
|
|
8950
|
+
this.speakingState.set(false);
|
|
8951
|
+
}
|
|
8051
8952
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSpeak, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
8052
8953
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxSpeak, isStandalone: true, selector: "[cngxSpeak]", inputs: { text: { classPropertyName: "text", publicName: "cngxSpeak", isSignal: true, isRequired: true, transformFunction: null }, rate: { classPropertyName: "rate", publicName: "rate", isSignal: true, isRequired: false, transformFunction: null }, pitch: { classPropertyName: "pitch", publicName: "pitch", isSignal: true, isRequired: false, transformFunction: null }, volume: { classPropertyName: "volume", publicName: "volume", isSignal: true, isRequired: false, transformFunction: null }, lang: { classPropertyName: "lang", publicName: "lang", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxSpeak"], ngImport: i0 });
|
|
8053
8954
|
}
|
|
@@ -8202,7 +9103,8 @@ class CngxOption {
|
|
|
8202
9103
|
isSelected = this.selectedState.asReadonly();
|
|
8203
9104
|
/**
|
|
8204
9105
|
* Reactive visibility derived from the optional `CNGX_OPTION_FILTER_HOST`
|
|
8205
|
-
* host's `searchTerm` and `matches` policy
|
|
9106
|
+
* host's `searchTerm` and `matches` policy (called with this option as the
|
|
9107
|
+
* fourth argument). `false` when no host is
|
|
8206
9108
|
* provided or the term is empty; `true` only when the host's policy
|
|
8207
9109
|
* explicitly rejects the option for the current term.
|
|
8208
9110
|
*
|
|
@@ -8217,7 +9119,7 @@ class CngxOption {
|
|
|
8217
9119
|
if (!term) {
|
|
8218
9120
|
return false;
|
|
8219
9121
|
}
|
|
8220
|
-
return !host.matches(this.value(), this.label(), term);
|
|
9122
|
+
return !host.matches(this.value(), this.label(), term, this);
|
|
8221
9123
|
}, ...(ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []));
|
|
8222
9124
|
/**
|
|
8223
9125
|
* Resolved label as a Signal - explicit `label` input wins, falling back to
|
|
@@ -8406,7 +9308,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
8406
9308
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/listbox/listbox.directive.ts
|
|
8407
9309
|
* @since 0.1.0
|
|
8408
9310
|
* @relatedTo CngxListboxSearch, CngxListboxTrigger, CngxOption, CngxOptionGroup, CngxActiveDescendant
|
|
8409
|
-
*
|
|
9311
|
+
* <example-url>http://localhost:4200/#/common/interactive/listbox/base/synced-listboxes</example-url>
|
|
8410
9312
|
* <example-url>http://localhost:4200/#/common/interactive/listbox/search/command-palette</example-url>
|
|
8411
9313
|
* <example-url>http://localhost:4200/#/common/interactive/listbox/trigger/select-dropdown</example-url>
|
|
8412
9314
|
* <example-url>http://localhost:4200/#/common/interactive/listbox/base/multi-select</example-url>
|
|
@@ -8633,7 +9535,7 @@ class CngxListbox {
|
|
|
8633
9535
|
}
|
|
8634
9536
|
}
|
|
8635
9537
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListbox, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
8636
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxListbox, isStandalone: true, selector: "[cngxListbox]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "compareWith", isSignal: true, isRequired: false, transformFunction: null }, cngxSearchRef: { classPropertyName: "cngxSearchRef", publicName: "cngxSearchRef", isSignal: true, isRequired: false, transformFunction: null }, externalActivation: { classPropertyName: "externalActivation", publicName: "externalActivation", isSignal: true, isRequired: false, transformFunction: null }, explicitOptions: { classPropertyName: "explicitOptions", publicName: "explicitOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", selectedValues: "selectedValuesChange" }, host: { attributes: { "role": "listbox" }, properties: { "attr.aria-label": "label()", "attr.aria-multiselectable": "multiple() ? \"true\" : null" } }, queries: [{ propertyName: "contentOptions", predicate: CngxOption, descendants: true, isSignal: true }], exportAs: ["cngxListbox"], hostDirectives: [{ directive: i1.CngxActiveDescendant, inputs: ["items", "items", "orientation", "orientation", "loop", "loop", "typeahead", "typeahead", "autoHighlightFirst", "autoHighlightFirst", "virtualCount", "virtualCount", "windowStart", "windowStart"] }], ngImport: i0 });
|
|
9538
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxListbox, isStandalone: true, selector: "[cngxListbox]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "compareWith", isSignal: true, isRequired: false, transformFunction: null }, cngxSearchRef: { classPropertyName: "cngxSearchRef", publicName: "cngxSearchRef", isSignal: true, isRequired: false, transformFunction: null }, externalActivation: { classPropertyName: "externalActivation", publicName: "externalActivation", isSignal: true, isRequired: false, transformFunction: null }, explicitOptions: { classPropertyName: "explicitOptions", publicName: "explicitOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", selectedValues: "selectedValuesChange" }, host: { attributes: { "role": "listbox" }, properties: { "attr.aria-label": "label()", "attr.aria-multiselectable": "multiple() ? \"true\" : null" } }, queries: [{ propertyName: "contentOptions", predicate: CngxOption, descendants: true, isSignal: true }], exportAs: ["cngxListbox"], hostDirectives: [{ directive: i1.CngxActiveDescendant, inputs: ["items", "items", "orientation", "orientation", "loop", "loop", "typeahead", "typeahead", "autoHighlightFirst", "autoHighlightFirst", "virtualCount", "virtualCount", "windowStart", "windowStart"], outputs: ["activated", "activated"] }], ngImport: i0 });
|
|
8637
9539
|
}
|
|
8638
9540
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListbox, decorators: [{
|
|
8639
9541
|
type: Directive,
|
|
@@ -8653,6 +9555,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
8653
9555
|
'virtualCount',
|
|
8654
9556
|
'windowStart',
|
|
8655
9557
|
],
|
|
9558
|
+
// `activated` fires on EVERY pick (click / Enter / Space), including a
|
|
9559
|
+
// re-pick of the already-selected value - unlike `valueChange`, which
|
|
9560
|
+
// stays silent when the model value does not change. Close-on-select
|
|
9561
|
+
// compositions (paginator dropdowns) bind this instead of `valueChange`.
|
|
9562
|
+
outputs: ['activated'],
|
|
8656
9563
|
},
|
|
8657
9564
|
],
|
|
8658
9565
|
host: {
|
|
@@ -8663,13 +9570,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
8663
9570
|
}]
|
|
8664
9571
|
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], compareWith: [{ type: i0.Input, args: [{ isSignal: true, alias: "compareWith", required: false }] }], cngxSearchRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxSearchRef", required: false }] }], externalActivation: [{ type: i0.Input, args: [{ isSignal: true, alias: "externalActivation", required: false }] }], explicitOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "explicitOptions", required: false }] }], contentOptions: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxOption), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
8665
9572
|
|
|
8666
|
-
/**
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
9573
|
+
/**
|
|
9574
|
+
* The default listbox matcher: an accent- and case-tolerant substring match
|
|
9575
|
+
* of `option.label` against the term in the locale `locale` holds, built on
|
|
9576
|
+
* {@link createLabelMatcher}. It accepts any object with a `label`, so the
|
|
9577
|
+
* same function serves as a `ListboxMatchFn` and as a select-family matcher
|
|
9578
|
+
* over stable option definitions. The option object is the cache key, so each
|
|
9579
|
+
* label is folded once per label text and locale; the cache is a `WeakMap`
|
|
9580
|
+
* owned by the returned function and never outlives the options. An empty
|
|
9581
|
+
* term matches every option.
|
|
9582
|
+
*
|
|
9583
|
+
* Reach for it when a component filters `ActiveDescendantItem`s and wants the
|
|
9584
|
+
* same match a `CngxListboxSearch` applies by default, e.g. as the last arm
|
|
9585
|
+
* of an `input() ?? config ?? default` cascade. Create it once per host in an
|
|
9586
|
+
* injection context (field initializer) so the cache lives as long as the host.
|
|
9587
|
+
*
|
|
9588
|
+
* ```typescript
|
|
9589
|
+
* private readonly labelMatch = createListboxLabelMatch(injectLocale());
|
|
9590
|
+
* protected readonly matchFn = computed(() => this.matchFnInput() ?? this.labelMatch);
|
|
9591
|
+
* ```
|
|
9592
|
+
*
|
|
9593
|
+
* @category common/interactive
|
|
9594
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/listbox/listbox-search.directive.ts
|
|
9595
|
+
* @since 0.1.0
|
|
9596
|
+
* @relatedTo createLabelMatcher, CngxListboxSearch
|
|
9597
|
+
*/
|
|
9598
|
+
function createListboxLabelMatch(locale) {
|
|
9599
|
+
const matches = createLabelMatcher(locale);
|
|
9600
|
+
return (option, term) => matches(option.label, term, option);
|
|
9601
|
+
}
|
|
8673
9602
|
/**
|
|
8674
9603
|
* Search input for a `CngxListbox`.
|
|
8675
9604
|
*
|
|
@@ -8687,8 +9616,11 @@ const defaultLabelMatch = (option, term) => {
|
|
|
8687
9616
|
* <example-url>http://localhost:4200/#/common/interactive/listbox/search/command-palette</example-url>
|
|
8688
9617
|
*/
|
|
8689
9618
|
class CngxListboxSearch {
|
|
8690
|
-
/**
|
|
8691
|
-
|
|
9619
|
+
/**
|
|
9620
|
+
* Custom matcher. Defaults to a substring match on `label` that ignores
|
|
9621
|
+
* case and accents in the app locale.
|
|
9622
|
+
*/
|
|
9623
|
+
matchFn = input(createListboxLabelMatch(injectLocale()), ...(ngDevMode ? [{ debugName: "matchFn" }] : /* istanbul ignore next */ []));
|
|
8692
9624
|
search = inject(CngxSearch, { self: true, host: true });
|
|
8693
9625
|
/** Current debounced search term (proxied from CngxSearch). */
|
|
8694
9626
|
term = this.search.term;
|
|
@@ -8733,329 +9665,142 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
8733
9665
|
* | open | Enter / Space | activate; close if `closeOnSelect()` |
|
|
8734
9666
|
* | any | Escape | close and restore focus to trigger |
|
|
8735
9667
|
*
|
|
8736
|
-
* @category common/interactive/listbox
|
|
8737
|
-
* @docsKind primary
|
|
8738
|
-
* @wcag AA
|
|
8739
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/listbox/listbox-trigger.directive.ts
|
|
8740
|
-
* @since 0.1.0
|
|
8741
|
-
* @relatedTo CngxListbox, CngxListboxSearch, CngxPopoverTrigger, CngxActiveDescendant
|
|
8742
|
-
* <example-url>http://localhost:4200/#/common/interactive/listbox/trigger/select-dropdown</example-url>
|
|
8743
|
-
*/
|
|
8744
|
-
class CngxListboxTrigger {
|
|
8745
|
-
/** Listbox controlled by this trigger. */
|
|
8746
|
-
listbox = input.required({ ...(ngDevMode ? { debugName: "listbox" } : /* istanbul ignore next */ {}), alias: 'cngxListboxTrigger' });
|
|
8747
|
-
/** Popover that wraps the listbox panel. */
|
|
8748
|
-
popover = input.required(...(ngDevMode ? [{ debugName: "popover" }] : /* istanbul ignore next */ []));
|
|
8749
|
-
/** Whether activating an option closes the popover. */
|
|
8750
|
-
closeOnSelect = input(true, ...(ngDevMode ? [{ debugName: "closeOnSelect" }] : /* istanbul ignore next */ []));
|
|
8751
|
-
/** Mirrors `CngxPopover.isVisible()` for host binding and external read. */
|
|
8752
|
-
isOpen = computed(() => this.popover().isVisible(), ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
8753
|
-
/**
|
|
8754
|
-
* Fires when the user presses Backspace on an empty input. Only
|
|
8755
|
-
* emitted when the host element is an `<input>` with a co-located
|
|
8756
|
-
* `CngxListboxSearch` - the tag-input convention "Backspace on empty
|
|
8757
|
-
* deletes the trailing chip" lives at the trigger, so consumers only
|
|
8758
|
-
* wire one subscription to own the delete path. On non-input hosts
|
|
8759
|
-
* (classic button triggers) the event never fires.
|
|
8760
|
-
*/
|
|
8761
|
-
backspaceOnEmpty = output();
|
|
8762
|
-
/**
|
|
8763
|
-
* When a `CngxListboxSearch` is attached to the same host element, we
|
|
8764
|
-
* suppress the printable-character typeahead forwarding: the keystroke
|
|
8765
|
-
* must reach the native `<input>` value so the search directive's
|
|
8766
|
-
* debounced term picks it up. Without this guard every printable char
|
|
8767
|
-
* would be `preventDefault()`'d and the input would never receive text.
|
|
8768
|
-
*
|
|
8769
|
-
* Injected as optional + self so only co-located search declarations
|
|
8770
|
-
* flip the behaviour. Combobox-style triggers (where the focusable
|
|
8771
|
-
* element IS an `<input cngxListboxSearch cngxListboxTrigger>`) opt in
|
|
8772
|
-
* automatically; classic button triggers keep native-`<select>` parity.
|
|
8773
|
-
*/
|
|
8774
|
-
search = inject(CngxListboxSearch, { optional: true, self: true });
|
|
8775
|
-
el = inject(ElementRef);
|
|
8776
|
-
handleKeydown(event) {
|
|
8777
|
-
// Never hijack browser/app shortcuts: Ctrl/Cmd/Alt combos pass through
|
|
8778
|
-
// untouched - the same guard the nav strategies apply. Without it,
|
|
8779
|
-
// Ctrl+ArrowDown on a trigger would navigate and swallow the event.
|
|
8780
|
-
if (event.ctrlKey || event.metaKey || event.altKey) {
|
|
8781
|
-
return;
|
|
8782
|
-
}
|
|
8783
|
-
const key = event.key;
|
|
8784
|
-
const ad = this.listbox().ad;
|
|
8785
|
-
// Tag-input convention: Backspace on an empty co-located search input
|
|
8786
|
-
// emits backspaceOnEmpty for the parent composite (CngxCombobox, …)
|
|
8787
|
-
// to delete the trailing chip. Consolidated here so the trigger owns
|
|
8788
|
-
// the only keydown handler on the element. Non-input triggers skip
|
|
8789
|
-
// this path via the co-located-search guard.
|
|
8790
|
-
if (key === 'Backspace' && this.search) {
|
|
8791
|
-
const host = this.el.nativeElement;
|
|
8792
|
-
if (host instanceof HTMLInputElement && host.value === '') {
|
|
8793
|
-
this.backspaceOnEmpty.emit();
|
|
8794
|
-
// No preventDefault - the consumer's chip-remove path owns DOM impact.
|
|
8795
|
-
}
|
|
8796
|
-
}
|
|
8797
|
-
if (!this.isOpen()) {
|
|
8798
|
-
if (key === 'ArrowDown' || key === 'Enter' || key === ' ') {
|
|
8799
|
-
event.preventDefault();
|
|
8800
|
-
this.popover().show();
|
|
8801
|
-
ad.highlightFirst();
|
|
8802
|
-
return;
|
|
8803
|
-
}
|
|
8804
|
-
if (key === 'ArrowUp') {
|
|
8805
|
-
event.preventDefault();
|
|
8806
|
-
this.popover().show();
|
|
8807
|
-
ad.highlightLast();
|
|
8808
|
-
return;
|
|
8809
|
-
}
|
|
8810
|
-
return;
|
|
8811
|
-
}
|
|
8812
|
-
switch (key) {
|
|
8813
|
-
case 'Escape':
|
|
8814
|
-
event.preventDefault();
|
|
8815
|
-
this.popover().hide();
|
|
8816
|
-
return;
|
|
8817
|
-
case 'ArrowDown':
|
|
8818
|
-
event.preventDefault();
|
|
8819
|
-
ad.highlightNext();
|
|
8820
|
-
return;
|
|
8821
|
-
case 'ArrowUp':
|
|
8822
|
-
event.preventDefault();
|
|
8823
|
-
ad.highlightPrev();
|
|
8824
|
-
return;
|
|
8825
|
-
case 'Home':
|
|
8826
|
-
event.preventDefault();
|
|
8827
|
-
ad.highlightFirst();
|
|
8828
|
-
return;
|
|
8829
|
-
case 'End':
|
|
8830
|
-
event.preventDefault();
|
|
8831
|
-
ad.highlightLast();
|
|
8832
|
-
return;
|
|
8833
|
-
case 'Enter':
|
|
8834
|
-
case ' ':
|
|
8835
|
-
if (!ad.activeItem()) {
|
|
8836
|
-
return;
|
|
8837
|
-
}
|
|
8838
|
-
event.preventDefault();
|
|
8839
|
-
ad.activateCurrent();
|
|
8840
|
-
if (this.closeOnSelect()) {
|
|
8841
|
-
this.popover().hide();
|
|
8842
|
-
}
|
|
8843
|
-
return;
|
|
8844
|
-
}
|
|
8845
|
-
if (this.search) {
|
|
8846
|
-
// Let the keystroke reach the <input> for CngxListboxSearch debounce.
|
|
8847
|
-
return;
|
|
8848
|
-
}
|
|
8849
|
-
if (key.length === 1 && /\S/.exec(key) !== null) {
|
|
8850
|
-
// Native <select> parity: printable chars drive AD typeahead while
|
|
8851
|
-
// focus stays on the trigger.
|
|
8852
|
-
event.preventDefault();
|
|
8853
|
-
ad.typeaheadChar(key);
|
|
8854
|
-
}
|
|
8855
|
-
}
|
|
8856
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListboxTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
8857
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxListboxTrigger, isStandalone: true, selector: "[cngxListboxTrigger]", inputs: { listbox: { classPropertyName: "listbox", publicName: "cngxListboxTrigger", isSignal: true, isRequired: true, transformFunction: null }, popover: { classPropertyName: "popover", publicName: "popover", isSignal: true, isRequired: true, transformFunction: null }, closeOnSelect: { classPropertyName: "closeOnSelect", publicName: "closeOnSelect", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { backspaceOnEmpty: "backspaceOnEmpty" }, host: { listeners: { "keydown": "handleKeydown($event)" }, properties: { "attr.aria-haspopup": "\"listbox\"", "attr.aria-expanded": "isOpen()" } }, exportAs: ["cngxListboxTrigger"], ngImport: i0 });
|
|
8858
|
-
}
|
|
8859
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListboxTrigger, decorators: [{
|
|
8860
|
-
type: Directive,
|
|
8861
|
-
args: [{
|
|
8862
|
-
selector: '[cngxListboxTrigger]',
|
|
8863
|
-
exportAs: 'cngxListboxTrigger',
|
|
8864
|
-
standalone: true,
|
|
8865
|
-
host: {
|
|
8866
|
-
'[attr.aria-haspopup]': '"listbox"',
|
|
8867
|
-
'[attr.aria-expanded]': 'isOpen()',
|
|
8868
|
-
'(keydown)': 'handleKeydown($event)',
|
|
8869
|
-
},
|
|
8870
|
-
}]
|
|
8871
|
-
}], propDecorators: { listbox: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxListboxTrigger", required: true }] }], popover: [{ type: i0.Input, args: [{ isSignal: true, alias: "popover", required: true }] }], closeOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnSelect", required: false }] }], backspaceOnEmpty: [{ type: i0.Output, args: ["backspaceOnEmpty"] }] } });
|
|
8872
|
-
|
|
8873
|
-
/**
|
|
8874
|
-
* Global polite live-region announcer for the menu family. Delegates to
|
|
8875
|
-
* the shared {@link CngxLiveAnnouncer}, announcing menu state transitions
|
|
8876
|
-
* (submenu open/close, item activation) through its polite region.
|
|
8877
|
-
*
|
|
8878
|
-
* Scoped `providedIn: 'root'` so every menu in the app shares the same
|
|
8879
|
-
* region; the announcer clears then re-sets one frame later so screen
|
|
8880
|
-
* readers treat repeated identical messages as fresh events.
|
|
8881
|
-
*
|
|
8882
|
-
* Default factory output for {@link CNGX_MENU_ANNOUNCER_FACTORY}.
|
|
8883
|
-
* Consumers obtain the announcer via the factory token, never by
|
|
8884
|
-
* `inject(CngxMenuAnnouncer)` directly, so a swap is enterprise-wide.
|
|
8885
|
-
*
|
|
8886
|
-
* @category common/interactive/menu
|
|
8887
|
-
* @wcag AA
|
|
8888
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/menu/menu-announcer.ts
|
|
8889
|
-
* @since 0.1.0
|
|
8890
|
-
* @relatedTo CngxMenu, CngxMenuTrigger, CngxMenuItemSubmenu
|
|
8891
|
-
*/
|
|
8892
|
-
class CngxMenuAnnouncer {
|
|
8893
|
-
announcer = inject(CngxLiveAnnouncer);
|
|
8894
|
-
/**
|
|
8895
|
-
* Announce a message via the polite live region. Empty messages are
|
|
8896
|
-
* ignored. The region is cleared ~16ms before being repopulated so AT
|
|
8897
|
-
* picks up identical-text repeats as a new event.
|
|
8898
|
-
*/
|
|
8899
|
-
announce(message) {
|
|
8900
|
-
if (!message) {
|
|
8901
|
-
return;
|
|
8902
|
-
}
|
|
8903
|
-
this.announcer.announce(message, 'polite');
|
|
8904
|
-
}
|
|
8905
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMenuAnnouncer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
8906
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMenuAnnouncer, providedIn: 'root' });
|
|
8907
|
-
}
|
|
8908
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMenuAnnouncer, decorators: [{
|
|
8909
|
-
type: Injectable,
|
|
8910
|
-
args: [{ providedIn: 'root' }]
|
|
8911
|
-
}] });
|
|
8912
|
-
/**
|
|
8913
|
-
* Default factory that hands out the root-scoped {@link CngxMenuAnnouncer}
|
|
8914
|
-
* singleton. Consumers wire a custom announcer by replacing
|
|
8915
|
-
* {@link CNGX_MENU_ANNOUNCER_FACTORY}.
|
|
8916
|
-
*
|
|
8917
|
-
* Must run inside an injection context.
|
|
8918
|
-
*
|
|
8919
|
-
* @category common/interactive/menu
|
|
8920
|
-
*/
|
|
8921
|
-
function createMenuAnnouncer() {
|
|
8922
|
-
return inject(CngxMenuAnnouncer);
|
|
8923
|
-
}
|
|
8924
|
-
/**
|
|
8925
|
-
* DI token carrying the factory that yields the menu family's announcer.
|
|
8926
|
-
* Defaults to {@link createMenuAnnouncer} returning the root-scoped
|
|
8927
|
-
* {@link CngxMenuAnnouncer} singleton. Override via `providers` /
|
|
8928
|
-
* `viewProviders` for telemetry-wrapping, locale-aware, or test-doubled
|
|
8929
|
-
* announcers without forking the menu module. Symmetric to
|
|
8930
|
-
* `CNGX_COMMIT_ERROR_ANNOUNCER_FACTORY` from the select family.
|
|
8931
|
-
*
|
|
8932
|
-
* ```ts
|
|
8933
|
-
* bootstrapApplication(AppComponent, {
|
|
8934
|
-
* providers: [
|
|
8935
|
-
* {
|
|
8936
|
-
* provide: CNGX_MENU_ANNOUNCER_FACTORY,
|
|
8937
|
-
* useValue: () => ({ announce: (msg) => myTelemetry.log(msg) }),
|
|
8938
|
-
* },
|
|
8939
|
-
* ],
|
|
8940
|
-
* });
|
|
8941
|
-
* ```
|
|
8942
|
-
*
|
|
8943
|
-
* @category common/interactive/menu
|
|
8944
|
-
* @wcag AA
|
|
8945
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/menu/menu-announcer.ts
|
|
8946
|
-
* @since 0.1.0
|
|
8947
|
-
*/
|
|
8948
|
-
const CNGX_MENU_ANNOUNCER_FACTORY = new InjectionToken('CNGX_MENU_ANNOUNCER_FACTORY', { providedIn: 'root', factory: () => createMenuAnnouncer });
|
|
8949
|
-
/**
|
|
8950
|
-
* Resolve the {@link CngxMenuAnnouncerLike} from the current injection
|
|
8951
|
-
* scope via the factory token. Must run inside an injection context.
|
|
8952
|
-
*
|
|
8953
|
-
* @category common/interactive/menu
|
|
8954
|
-
*/
|
|
8955
|
-
function injectMenuAnnouncer() {
|
|
8956
|
-
return inject(CNGX_MENU_ANNOUNCER_FACTORY)();
|
|
8957
|
-
}
|
|
8958
|
-
|
|
8959
|
-
/**
|
|
8960
|
-
* Internal helper that brands a config-mutator function with the `_target`
|
|
8961
|
-
* discriminator. Every `with*` feature returns one of these.
|
|
8962
|
-
*
|
|
8963
|
-
* @internal
|
|
8964
|
-
*/
|
|
8965
|
-
function defineMenuConfigFeature(fn) {
|
|
8966
|
-
return Object.assign(fn, { _target: 'config' });
|
|
8967
|
-
}
|
|
8968
|
-
/**
|
|
8969
|
-
* Library-default menu configuration. **English-only** - German (or any
|
|
8970
|
-
* other locale) is consumer-supplied via `withAriaLabels` per the
|
|
8971
|
-
* `feedback_en_default_locale` rule.
|
|
8972
|
-
*
|
|
8973
|
-
* @category common/interactive/menu
|
|
8974
|
-
*/
|
|
8975
|
-
const DEFAULT_MENU_CONFIG = {
|
|
8976
|
-
ariaLabels: {
|
|
8977
|
-
submenuOpened: 'Submenu opened',
|
|
8978
|
-
submenuClosed: 'Submenu closed',
|
|
8979
|
-
itemActivated: 'Item activated',
|
|
8980
|
-
itemDisabled: 'Item disabled',
|
|
8981
|
-
menuDismissed: 'Menu dismissed',
|
|
8982
|
-
},
|
|
8983
|
-
typeaheadDebounce: 300,
|
|
8984
|
-
submenuOpenDelay: 0,
|
|
8985
|
-
submenuCloseDelay: 150,
|
|
8986
|
-
closeOnSelect: true,
|
|
8987
|
-
dismissOnOutsideClick: true,
|
|
8988
|
-
dismissOnScroll: false,
|
|
8989
|
-
dismissOnBlur: true,
|
|
8990
|
-
};
|
|
8991
|
-
/**
|
|
8992
|
-
* DI token carrying the resolved {@link CngxMenuConfig}. Defaults to
|
|
8993
|
-
* {@link DEFAULT_MENU_CONFIG} at root; override via {@link provideMenuConfig}
|
|
8994
|
-
* (app-wide) or {@link provideMenuConfigAt} (component scope via
|
|
8995
|
-
* `viewProviders`).
|
|
8996
|
-
*
|
|
8997
|
-
* @category common/interactive/menu
|
|
8998
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/menu/menu-config.ts
|
|
8999
|
-
* @since 0.1.0
|
|
9000
|
-
*/
|
|
9001
|
-
const CNGX_MENU_CONFIG = new InjectionToken('CngxMenuConfig', {
|
|
9002
|
-
providedIn: 'root',
|
|
9003
|
-
factory: () => DEFAULT_MENU_CONFIG,
|
|
9004
|
-
});
|
|
9005
|
-
/** @internal */
|
|
9006
|
-
function applyFeatures(base, features) {
|
|
9007
|
-
return features.reduce((cfg, feature) => feature(cfg), base);
|
|
9008
|
-
}
|
|
9009
|
-
/**
|
|
9010
|
-
* Provide a menu configuration at app root. Each feature is a partial
|
|
9011
|
-
* override produced by `with*` helpers (see `menu-config-features.ts`).
|
|
9012
|
-
*
|
|
9013
|
-
* ```ts
|
|
9014
|
-
* bootstrapApplication(AppComponent, {
|
|
9015
|
-
* providers: [
|
|
9016
|
-
* provideMenuConfig(
|
|
9017
|
-
* withAriaLabels({ submenuOpened: 'Untermenü geöffnet' }),
|
|
9018
|
-
* withTypeaheadDebounce(500),
|
|
9019
|
-
* ),
|
|
9020
|
-
* ],
|
|
9021
|
-
* });
|
|
9022
|
-
* ```
|
|
9023
|
-
*
|
|
9024
|
-
* @category common/interactive/menu
|
|
9025
|
-
*/
|
|
9026
|
-
function provideMenuConfig(...features) {
|
|
9027
|
-
return makeEnvironmentProviders([
|
|
9028
|
-
{
|
|
9029
|
-
provide: CNGX_MENU_CONFIG,
|
|
9030
|
-
useFactory: () => applyFeatures(DEFAULT_MENU_CONFIG, features),
|
|
9031
|
-
},
|
|
9032
|
-
]);
|
|
9033
|
-
}
|
|
9034
|
-
/**
|
|
9035
|
-
* Component-scoped menu configuration override. Pass into a directive or
|
|
9036
|
-
* component's `viewProviders`; features merge on top of the parent
|
|
9037
|
-
* config (root or an enclosing scope).
|
|
9038
|
-
*
|
|
9039
|
-
* @category common/interactive/menu
|
|
9040
|
-
*/
|
|
9041
|
-
function provideMenuConfigAt(...features) {
|
|
9042
|
-
return [
|
|
9043
|
-
{
|
|
9044
|
-
provide: CNGX_MENU_CONFIG,
|
|
9045
|
-
useFactory: (parent) => applyFeatures(parent ?? DEFAULT_MENU_CONFIG, features),
|
|
9046
|
-
deps: [[new SkipSelf(), new Optional(), CNGX_MENU_CONFIG]],
|
|
9047
|
-
},
|
|
9048
|
-
];
|
|
9049
|
-
}
|
|
9050
|
-
/**
|
|
9051
|
-
* Resolves the {@link CngxMenuConfig} from the current injection scope.
|
|
9052
|
-
* Must run inside an injection context.
|
|
9053
|
-
*
|
|
9054
|
-
* @category common/interactive/menu
|
|
9668
|
+
* @category common/interactive/listbox
|
|
9669
|
+
* @docsKind primary
|
|
9670
|
+
* @wcag AA
|
|
9671
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/listbox/listbox-trigger.directive.ts
|
|
9672
|
+
* @since 0.1.0
|
|
9673
|
+
* @relatedTo CngxListbox, CngxListboxSearch, CngxPopoverTrigger, CngxActiveDescendant
|
|
9674
|
+
* <example-url>http://localhost:4200/#/common/interactive/listbox/trigger/select-dropdown</example-url>
|
|
9055
9675
|
*/
|
|
9056
|
-
|
|
9057
|
-
|
|
9676
|
+
class CngxListboxTrigger {
|
|
9677
|
+
/** Listbox controlled by this trigger. */
|
|
9678
|
+
listbox = input.required({ ...(ngDevMode ? { debugName: "listbox" } : /* istanbul ignore next */ {}), alias: 'cngxListboxTrigger' });
|
|
9679
|
+
/** Popover that wraps the listbox panel. */
|
|
9680
|
+
popover = input.required(...(ngDevMode ? [{ debugName: "popover" }] : /* istanbul ignore next */ []));
|
|
9681
|
+
/** Whether activating an option closes the popover. */
|
|
9682
|
+
closeOnSelect = input(true, ...(ngDevMode ? [{ debugName: "closeOnSelect" }] : /* istanbul ignore next */ []));
|
|
9683
|
+
/** Mirrors `CngxPopover.isVisible()` for host binding and external read. */
|
|
9684
|
+
isOpen = computed(() => this.popover().isVisible(), ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
9685
|
+
/**
|
|
9686
|
+
* Fires when the user presses Backspace on an empty input. Only
|
|
9687
|
+
* emitted when the host element is an `<input>` with a co-located
|
|
9688
|
+
* `CngxListboxSearch` - the tag-input convention "Backspace on empty
|
|
9689
|
+
* deletes the trailing chip" lives at the trigger, so consumers only
|
|
9690
|
+
* wire one subscription to own the delete path. On non-input hosts
|
|
9691
|
+
* (classic button triggers) the event never fires.
|
|
9692
|
+
*/
|
|
9693
|
+
backspaceOnEmpty = output();
|
|
9694
|
+
/**
|
|
9695
|
+
* When a `CngxListboxSearch` is attached to the same host element, we
|
|
9696
|
+
* suppress the printable-character typeahead forwarding: the keystroke
|
|
9697
|
+
* must reach the native `<input>` value so the search directive's
|
|
9698
|
+
* debounced term picks it up. Without this guard every printable char
|
|
9699
|
+
* would be `preventDefault()`'d and the input would never receive text.
|
|
9700
|
+
*
|
|
9701
|
+
* Injected as optional + self so only co-located search declarations
|
|
9702
|
+
* flip the behaviour. Combobox-style triggers (where the focusable
|
|
9703
|
+
* element IS an `<input cngxListboxSearch cngxListboxTrigger>`) opt in
|
|
9704
|
+
* automatically; classic button triggers keep native-`<select>` parity.
|
|
9705
|
+
*/
|
|
9706
|
+
search = inject(CngxListboxSearch, { optional: true, self: true });
|
|
9707
|
+
el = inject(ElementRef);
|
|
9708
|
+
handleKeydown(event) {
|
|
9709
|
+
// Never hijack browser/app shortcuts: Ctrl/Cmd/Alt combos pass through
|
|
9710
|
+
// untouched - the same guard the nav strategies apply. Without it,
|
|
9711
|
+
// Ctrl+ArrowDown on a trigger would navigate and swallow the event.
|
|
9712
|
+
if (event.ctrlKey || event.metaKey || event.altKey) {
|
|
9713
|
+
return;
|
|
9714
|
+
}
|
|
9715
|
+
const key = event.key;
|
|
9716
|
+
const ad = this.listbox().ad;
|
|
9717
|
+
// Tag-input convention: Backspace on an empty co-located search input
|
|
9718
|
+
// emits backspaceOnEmpty for the parent composite (CngxCombobox, …)
|
|
9719
|
+
// to delete the trailing chip. Consolidated here so the trigger owns
|
|
9720
|
+
// the only keydown handler on the element. Non-input triggers skip
|
|
9721
|
+
// this path via the co-located-search guard.
|
|
9722
|
+
if (key === 'Backspace' && this.search) {
|
|
9723
|
+
const host = this.el.nativeElement;
|
|
9724
|
+
if (host instanceof HTMLInputElement && host.value === '') {
|
|
9725
|
+
this.backspaceOnEmpty.emit();
|
|
9726
|
+
// No preventDefault - the consumer's chip-remove path owns DOM impact.
|
|
9727
|
+
}
|
|
9728
|
+
}
|
|
9729
|
+
if (!this.isOpen()) {
|
|
9730
|
+
if (key === 'ArrowDown' || key === 'Enter' || key === ' ') {
|
|
9731
|
+
event.preventDefault();
|
|
9732
|
+
this.popover().show();
|
|
9733
|
+
ad.highlightFirst();
|
|
9734
|
+
return;
|
|
9735
|
+
}
|
|
9736
|
+
if (key === 'ArrowUp') {
|
|
9737
|
+
event.preventDefault();
|
|
9738
|
+
this.popover().show();
|
|
9739
|
+
ad.highlightLast();
|
|
9740
|
+
return;
|
|
9741
|
+
}
|
|
9742
|
+
return;
|
|
9743
|
+
}
|
|
9744
|
+
switch (key) {
|
|
9745
|
+
case 'Escape':
|
|
9746
|
+
event.preventDefault();
|
|
9747
|
+
this.popover().hide();
|
|
9748
|
+
return;
|
|
9749
|
+
case 'ArrowDown':
|
|
9750
|
+
event.preventDefault();
|
|
9751
|
+
ad.highlightNext();
|
|
9752
|
+
return;
|
|
9753
|
+
case 'ArrowUp':
|
|
9754
|
+
event.preventDefault();
|
|
9755
|
+
ad.highlightPrev();
|
|
9756
|
+
return;
|
|
9757
|
+
case 'Home':
|
|
9758
|
+
event.preventDefault();
|
|
9759
|
+
ad.highlightFirst();
|
|
9760
|
+
return;
|
|
9761
|
+
case 'End':
|
|
9762
|
+
event.preventDefault();
|
|
9763
|
+
ad.highlightLast();
|
|
9764
|
+
return;
|
|
9765
|
+
case 'Enter':
|
|
9766
|
+
case ' ':
|
|
9767
|
+
if (!ad.activeItem()) {
|
|
9768
|
+
return;
|
|
9769
|
+
}
|
|
9770
|
+
event.preventDefault();
|
|
9771
|
+
ad.activateCurrent();
|
|
9772
|
+
if (this.closeOnSelect()) {
|
|
9773
|
+
this.popover().hide();
|
|
9774
|
+
}
|
|
9775
|
+
return;
|
|
9776
|
+
}
|
|
9777
|
+
if (this.search) {
|
|
9778
|
+
// Let the keystroke reach the <input> for CngxListboxSearch debounce.
|
|
9779
|
+
return;
|
|
9780
|
+
}
|
|
9781
|
+
if (key.length === 1 && /\S/.exec(key) !== null) {
|
|
9782
|
+
// Native <select> parity: printable chars drive AD typeahead while
|
|
9783
|
+
// focus stays on the trigger.
|
|
9784
|
+
event.preventDefault();
|
|
9785
|
+
ad.typeaheadChar(key);
|
|
9786
|
+
}
|
|
9787
|
+
}
|
|
9788
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListboxTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
9789
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxListboxTrigger, isStandalone: true, selector: "[cngxListboxTrigger]", inputs: { listbox: { classPropertyName: "listbox", publicName: "cngxListboxTrigger", isSignal: true, isRequired: true, transformFunction: null }, popover: { classPropertyName: "popover", publicName: "popover", isSignal: true, isRequired: true, transformFunction: null }, closeOnSelect: { classPropertyName: "closeOnSelect", publicName: "closeOnSelect", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { backspaceOnEmpty: "backspaceOnEmpty" }, host: { listeners: { "keydown": "handleKeydown($event)" }, properties: { "attr.aria-haspopup": "\"listbox\"", "attr.aria-expanded": "isOpen()" } }, exportAs: ["cngxListboxTrigger"], ngImport: i0 });
|
|
9058
9790
|
}
|
|
9791
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxListboxTrigger, decorators: [{
|
|
9792
|
+
type: Directive,
|
|
9793
|
+
args: [{
|
|
9794
|
+
selector: '[cngxListboxTrigger]',
|
|
9795
|
+
exportAs: 'cngxListboxTrigger',
|
|
9796
|
+
standalone: true,
|
|
9797
|
+
host: {
|
|
9798
|
+
'[attr.aria-haspopup]': '"listbox"',
|
|
9799
|
+
'[attr.aria-expanded]': 'isOpen()',
|
|
9800
|
+
'(keydown)': 'handleKeydown($event)',
|
|
9801
|
+
},
|
|
9802
|
+
}]
|
|
9803
|
+
}], propDecorators: { listbox: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxListboxTrigger", required: true }] }], popover: [{ type: i0.Input, args: [{ isSignal: true, alias: "popover", required: true }] }], closeOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnSelect", required: false }] }], backspaceOnEmpty: [{ type: i0.Output, args: ["backspaceOnEmpty"] }] } });
|
|
9059
9804
|
|
|
9060
9805
|
/**
|
|
9061
9806
|
* DI token a menu host provides for sub-component composers (e.g. an
|
|
@@ -9101,7 +9846,7 @@ class CngxMenu {
|
|
|
9101
9846
|
ad = inject(CngxActiveDescendant, { self: true, host: true });
|
|
9102
9847
|
elementRef = inject(ElementRef);
|
|
9103
9848
|
announcer = inject(CNGX_MENU_ANNOUNCER_FACTORY)();
|
|
9104
|
-
|
|
9849
|
+
ariaLabels = coerceSignal(injectMenuConfig().ariaLabels);
|
|
9105
9850
|
/** Internal registry backing {@link submenuItems}. */
|
|
9106
9851
|
_submenuItems = signal([], { ...(ngDevMode ? { debugName: "_submenuItems" } : /* istanbul ignore next */ {}), equal: sameSubmenuItems });
|
|
9107
9852
|
/**
|
|
@@ -9130,7 +9875,7 @@ class CngxMenu {
|
|
|
9130
9875
|
.pipe(takeUntilDestroyed())
|
|
9131
9876
|
.subscribe(() => {
|
|
9132
9877
|
untracked(() => {
|
|
9133
|
-
this.announcer.announce(this.
|
|
9878
|
+
this.announcer.announce(this.ariaLabels().itemActivated);
|
|
9134
9879
|
});
|
|
9135
9880
|
});
|
|
9136
9881
|
}
|
|
@@ -9230,37 +9975,19 @@ class CngxMenuItem {
|
|
|
9230
9975
|
value = input(undefined, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
9231
9976
|
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
9232
9977
|
labelInput = input(undefined, { ...(ngDevMode ? { debugName: "labelInput" } : /* istanbul ignore next */ {}), alias: 'label' });
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
if (explicit) {
|
|
9242
|
-
return explicit;
|
|
9243
|
-
}
|
|
9244
|
-
const el = this.elementRef.nativeElement;
|
|
9245
|
-
return (el.textContent ?? '').trim();
|
|
9246
|
-
};
|
|
9978
|
+
core = injectMenuItemCore({
|
|
9979
|
+
value: this.value,
|
|
9980
|
+
disabled: this.disabled,
|
|
9981
|
+
labelInput: this.labelInput,
|
|
9982
|
+
});
|
|
9983
|
+
id = this.core.id;
|
|
9984
|
+
isHighlighted = this.core.isHighlighted;
|
|
9985
|
+
label = () => this.core.label();
|
|
9247
9986
|
handleClick() {
|
|
9248
|
-
|
|
9249
|
-
this.announcer.announce(this.menuConfig.ariaLabels.itemDisabled);
|
|
9250
|
-
return;
|
|
9251
|
-
}
|
|
9252
|
-
const ad = this.ad;
|
|
9253
|
-
if (!ad) {
|
|
9254
|
-
return;
|
|
9255
|
-
}
|
|
9256
|
-
ad.highlightByValue(this.value());
|
|
9257
|
-
ad.activateCurrent();
|
|
9987
|
+
this.core.handleClick();
|
|
9258
9988
|
}
|
|
9259
9989
|
handlePointerEnter() {
|
|
9260
|
-
|
|
9261
|
-
return;
|
|
9262
|
-
}
|
|
9263
|
-
this.ad?.highlightByValue(this.value());
|
|
9990
|
+
this.core.handlePointerEnter();
|
|
9264
9991
|
}
|
|
9265
9992
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMenuItem, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
9266
9993
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxMenuItem, isStandalone: true, selector: "[cngxMenuItem]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, labelInput: { classPropertyName: "labelInput", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "menuitem" }, listeners: { "click": "handleClick()", "pointerenter": "handlePointerEnter()" }, properties: { "id": "id", "class.cngx-menu-item--highlighted": "isHighlighted()", "class.cngx-menu-item--disabled": "disabled()", "attr.aria-disabled": "disabled() || null", "attr.tabindex": "-1" } }, providers: [{ provide: CNGX_AD_ITEM, useExisting: CngxMenuItem }], exportAs: ["cngxMenuItem"], ngImport: i0 });
|
|
@@ -9453,7 +10180,7 @@ class CngxMenuItemSubmenu {
|
|
|
9453
10180
|
menuHost = inject(CNGX_MENU_HOST, { optional: true });
|
|
9454
10181
|
wiring = inject(CNGX_MENU_SUBMENU_WIRING, { optional: true });
|
|
9455
10182
|
announcer = inject(CNGX_MENU_ANNOUNCER_FACTORY)();
|
|
9456
|
-
|
|
10183
|
+
ariaLabels = coerceSignal(injectMenuConfig().ariaLabels);
|
|
9457
10184
|
destroyRef = inject(DestroyRef);
|
|
9458
10185
|
ownId = nextUid('cngx-menu-submenu');
|
|
9459
10186
|
/** Popover resolved from the input, else the DI wiring fallback. */
|
|
@@ -9490,7 +10217,7 @@ class CngxMenuItemSubmenu {
|
|
|
9490
10217
|
if (!popover) {
|
|
9491
10218
|
return;
|
|
9492
10219
|
}
|
|
9493
|
-
popover.
|
|
10220
|
+
popover.setAnchorElement(this.elementRef.nativeElement);
|
|
9494
10221
|
if (!popover.isVisible()) {
|
|
9495
10222
|
popover.show();
|
|
9496
10223
|
}
|
|
@@ -9544,10 +10271,10 @@ class CngxMenuItemSubmenu {
|
|
|
9544
10271
|
}
|
|
9545
10272
|
untracked(() => {
|
|
9546
10273
|
if (current) {
|
|
9547
|
-
this.announcer.announce(this.
|
|
10274
|
+
this.announcer.announce(this.ariaLabels().submenuOpened);
|
|
9548
10275
|
}
|
|
9549
10276
|
else {
|
|
9550
|
-
this.announcer.announce(this.
|
|
10277
|
+
this.announcer.announce(this.ariaLabels().submenuClosed);
|
|
9551
10278
|
}
|
|
9552
10279
|
});
|
|
9553
10280
|
});
|
|
@@ -9723,38 +10450,20 @@ class CngxMenuItemCheckbox {
|
|
|
9723
10450
|
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
9724
10451
|
labelInput = input(undefined, { ...(ngDevMode ? { debugName: "labelInput" } : /* istanbul ignore next */ {}), alias: 'label' });
|
|
9725
10452
|
checked = model(false, ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
return explicit;
|
|
9736
|
-
}
|
|
9737
|
-
const el = this.elementRef.nativeElement;
|
|
9738
|
-
return (el.textContent ?? '').trim();
|
|
9739
|
-
};
|
|
10453
|
+
core = injectMenuItemCore({
|
|
10454
|
+
value: this.value,
|
|
10455
|
+
disabled: this.disabled,
|
|
10456
|
+
labelInput: this.labelInput,
|
|
10457
|
+
onActivate: () => this.checked.update((c) => !c),
|
|
10458
|
+
});
|
|
10459
|
+
id = this.core.id;
|
|
10460
|
+
isHighlighted = this.core.isHighlighted;
|
|
10461
|
+
label = () => this.core.label();
|
|
9740
10462
|
handleClick() {
|
|
9741
|
-
|
|
9742
|
-
this.announcer.announce(this.menuConfig.ariaLabels.itemDisabled);
|
|
9743
|
-
return;
|
|
9744
|
-
}
|
|
9745
|
-
const ad = this.ad;
|
|
9746
|
-
if (!ad) {
|
|
9747
|
-
return;
|
|
9748
|
-
}
|
|
9749
|
-
ad.highlightByValue(this.value());
|
|
9750
|
-
this.checked.update((c) => !c);
|
|
9751
|
-
ad.activateCurrent();
|
|
10463
|
+
this.core.handleClick();
|
|
9752
10464
|
}
|
|
9753
10465
|
handlePointerEnter() {
|
|
9754
|
-
|
|
9755
|
-
return;
|
|
9756
|
-
}
|
|
9757
|
-
this.ad?.highlightByValue(this.value());
|
|
10466
|
+
this.core.handlePointerEnter();
|
|
9758
10467
|
}
|
|
9759
10468
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMenuItemCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
9760
10469
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxMenuItemCheckbox, isStandalone: true, selector: "[cngxMenuItemCheckbox]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, labelInput: { classPropertyName: "labelInput", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange" }, host: { attributes: { "role": "menuitemcheckbox" }, listeners: { "click": "handleClick()", "pointerenter": "handlePointerEnter()" }, properties: { "id": "id", "attr.aria-checked": "checked()", "attr.aria-disabled": "disabled() || null", "class.cngx-menu-item--highlighted": "isHighlighted()", "class.cngx-menu-item--disabled": "disabled()", "class.cngx-menu-item--checked": "checked()", "attr.tabindex": "-1" } }, providers: [{ provide: CNGX_AD_ITEM, useExisting: CngxMenuItemCheckbox }], exportAs: ["cngxMenuItemCheckbox"], ngImport: i0 });
|
|
@@ -9825,13 +10534,15 @@ class CngxMenuItemRadio {
|
|
|
9825
10534
|
value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
9826
10535
|
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
9827
10536
|
labelInput = input(undefined, { ...(ngDevMode ? { debugName: "labelInput" } : /* istanbul ignore next */ {}), alias: 'label' });
|
|
9828
|
-
id = nextUid('cngx-menu-item');
|
|
9829
|
-
elementRef = inject((ElementRef));
|
|
9830
|
-
ad = inject(CngxActiveDescendant, { optional: true });
|
|
9831
10537
|
group = inject(CNGX_MENU_RADIO_GROUP, { optional: true });
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
10538
|
+
core = injectMenuItemCore({
|
|
10539
|
+
value: this.value,
|
|
10540
|
+
disabled: this.disabled,
|
|
10541
|
+
labelInput: this.labelInput,
|
|
10542
|
+
onActivate: () => this.group?.select(this.value()),
|
|
10543
|
+
});
|
|
10544
|
+
id = this.core.id;
|
|
10545
|
+
isHighlighted = this.core.isHighlighted;
|
|
9835
10546
|
/** Whether this radio is the currently selected value in its group. */
|
|
9836
10547
|
checked = computed(() => {
|
|
9837
10548
|
const group = this.group;
|
|
@@ -9840,32 +10551,12 @@ class CngxMenuItemRadio {
|
|
|
9840
10551
|
}
|
|
9841
10552
|
return Object.is(group.selectedValue(), this.value());
|
|
9842
10553
|
}, ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
9843
|
-
label = () =>
|
|
9844
|
-
const explicit = this.labelInput();
|
|
9845
|
-
if (explicit) {
|
|
9846
|
-
return explicit;
|
|
9847
|
-
}
|
|
9848
|
-
const el = this.elementRef.nativeElement;
|
|
9849
|
-
return (el.textContent ?? '').trim();
|
|
9850
|
-
};
|
|
10554
|
+
label = () => this.core.label();
|
|
9851
10555
|
handleClick() {
|
|
9852
|
-
|
|
9853
|
-
this.announcer.announce(this.menuConfig.ariaLabels.itemDisabled);
|
|
9854
|
-
return;
|
|
9855
|
-
}
|
|
9856
|
-
const ad = this.ad;
|
|
9857
|
-
if (!ad) {
|
|
9858
|
-
return;
|
|
9859
|
-
}
|
|
9860
|
-
ad.highlightByValue(this.value());
|
|
9861
|
-
this.group?.select(this.value());
|
|
9862
|
-
ad.activateCurrent();
|
|
10556
|
+
this.core.handleClick();
|
|
9863
10557
|
}
|
|
9864
10558
|
handlePointerEnter() {
|
|
9865
|
-
|
|
9866
|
-
return;
|
|
9867
|
-
}
|
|
9868
|
-
this.ad?.highlightByValue(this.value());
|
|
10559
|
+
this.core.handlePointerEnter();
|
|
9869
10560
|
}
|
|
9870
10561
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMenuItemRadio, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
9871
10562
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxMenuItemRadio, isStandalone: true, selector: "[cngxMenuItemRadio]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, labelInput: { classPropertyName: "labelInput", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "menuitemradio" }, listeners: { "click": "handleClick()", "pointerenter": "handlePointerEnter()" }, properties: { "id": "id", "attr.aria-checked": "checked()", "attr.aria-disabled": "disabled() || null", "class.cngx-menu-item--highlighted": "isHighlighted()", "class.cngx-menu-item--disabled": "disabled()", "class.cngx-menu-item--checked": "checked()", "attr.tabindex": "-1" } }, providers: [{ provide: CNGX_AD_ITEM, useExisting: CngxMenuItemRadio }], exportAs: ["cngxMenuItemRadio"], ngImport: i0 });
|
|
@@ -10104,6 +10795,9 @@ function createMenuFocusStack(deps) {
|
|
|
10104
10795
|
target.focus();
|
|
10105
10796
|
});
|
|
10106
10797
|
},
|
|
10798
|
+
discardFocus() {
|
|
10799
|
+
savedFocus = null;
|
|
10800
|
+
},
|
|
10107
10801
|
handleEscape(event) {
|
|
10108
10802
|
event.preventDefault();
|
|
10109
10803
|
if (submenuStack().length > 0) {
|
|
@@ -10286,7 +10980,7 @@ const CNGX_MENU_FOCUS_STACK_FACTORY = new InjectionToken('CNGX_MENU_FOCUS_STACK_
|
|
|
10286
10980
|
function withAriaLabels(partial) {
|
|
10287
10981
|
return defineMenuConfigFeature((cfg) => ({
|
|
10288
10982
|
...cfg,
|
|
10289
|
-
ariaLabels:
|
|
10983
|
+
ariaLabels: createOverrideMerge(cfg.ariaLabels, partial),
|
|
10290
10984
|
}));
|
|
10291
10985
|
}
|
|
10292
10986
|
/**
|
|
@@ -10556,6 +11250,7 @@ const DEFAULT_RESOLVE_OPEN = () => ({
|
|
|
10556
11250
|
open: true,
|
|
10557
11251
|
context: undefined,
|
|
10558
11252
|
});
|
|
11253
|
+
const DEFAULT_RESOLVE_KEYBOARD_OPEN = DEFAULT_RESOLVE_OPEN;
|
|
10559
11254
|
/**
|
|
10560
11255
|
* Build a {@link CngxContextMenuTriggerCore} from its dependencies. Pure
|
|
10561
11256
|
* factory - no Angular DI; the caller resolves collaborators and passes
|
|
@@ -10567,6 +11262,8 @@ const DEFAULT_RESOLVE_OPEN = () => ({
|
|
|
10567
11262
|
*/
|
|
10568
11263
|
function createContextMenuTriggerCore(deps) {
|
|
10569
11264
|
const resolveOpen = deps.resolveOpen ?? DEFAULT_RESOLVE_OPEN;
|
|
11265
|
+
const resolveKeyboardOpen = deps.resolveKeyboardOpen ?? DEFAULT_RESOLVE_KEYBOARD_OPEN;
|
|
11266
|
+
const ariaLabels = coerceSignal(deps.menuConfig.ariaLabels);
|
|
10570
11267
|
// Shared submenu focus-stack model - identical W3C APG keyboard contract to
|
|
10571
11268
|
// CngxMenuTrigger. The core owns the ArrowRight/ArrowLeft/Escape routing;
|
|
10572
11269
|
// whoever forwards keydown into `handleKeydown` (the trigger host, and the
|
|
@@ -10582,7 +11279,7 @@ function createContextMenuTriggerCore(deps) {
|
|
|
10582
11279
|
hostElement: deps.hostElement,
|
|
10583
11280
|
menuConfig: deps.menuConfig,
|
|
10584
11281
|
factory: deps.dismissFactory,
|
|
10585
|
-
onDismiss: () => deps.announcer.announce(
|
|
11282
|
+
onDismiss: () => deps.announcer.announce(ariaLabels().menuDismissed),
|
|
10586
11283
|
});
|
|
10587
11284
|
let virtualAnchor = null;
|
|
10588
11285
|
const ensureVirtualAnchor = () => {
|
|
@@ -10612,7 +11309,7 @@ function createContextMenuTriggerCore(deps) {
|
|
|
10612
11309
|
anchor.style.left = `${x}px`;
|
|
10613
11310
|
anchor.style.top = `${y}px`;
|
|
10614
11311
|
anchor.style.setProperty('anchor-name', `--cngx-pop-${deps.popover().id()}`);
|
|
10615
|
-
deps.popover().
|
|
11312
|
+
deps.popover().setAnchorElement(anchor);
|
|
10616
11313
|
if (!deps.popover().isVisible()) {
|
|
10617
11314
|
deps.popover().show();
|
|
10618
11315
|
}
|
|
@@ -10649,7 +11346,12 @@ function createContextMenuTriggerCore(deps) {
|
|
|
10649
11346
|
return;
|
|
10650
11347
|
}
|
|
10651
11348
|
if (event.key === 'F10' && event.shiftKey) {
|
|
11349
|
+
const decision = resolveKeyboardOpen(event);
|
|
11350
|
+
if (!decision.open) {
|
|
11351
|
+
return;
|
|
11352
|
+
}
|
|
10652
11353
|
event.preventDefault();
|
|
11354
|
+
deps.commitContext?.(decision.context);
|
|
10653
11355
|
const rect = deps.hostElement.getBoundingClientRect();
|
|
10654
11356
|
openAt(rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
10655
11357
|
return;
|
|
@@ -10704,6 +11406,11 @@ function createContextMenuTriggerCore(deps) {
|
|
|
10704
11406
|
focusStack.restoreFocus();
|
|
10705
11407
|
}
|
|
10706
11408
|
},
|
|
11409
|
+
standDown() {
|
|
11410
|
+
dismissBinding.detach();
|
|
11411
|
+
focusStack.reset();
|
|
11412
|
+
focusStack.discardFocus?.();
|
|
11413
|
+
},
|
|
10707
11414
|
destroy() {
|
|
10708
11415
|
removeVirtualAnchor();
|
|
10709
11416
|
dismissBinding.detach();
|
|
@@ -10730,7 +11437,7 @@ function createContextMenuTriggerCore(deps) {
|
|
|
10730
11437
|
* the always-open, always-`preventDefault` behaviour.
|
|
10731
11438
|
*
|
|
10732
11439
|
* Anchoring uses a transient zero-size DOM element positioned at the
|
|
10733
|
-
* pointer coords,
|
|
11440
|
+
* pointer coords, installed via the popover's `setAnchorElement` - virtual
|
|
10734
11441
|
* `getBoundingClientRect` objects are not yet supported as anchors, so
|
|
10735
11442
|
* the transient div is the workaround.
|
|
10736
11443
|
*
|
|
@@ -10911,6 +11618,7 @@ class CngxMenuTrigger {
|
|
|
10911
11618
|
direction = injectDirection();
|
|
10912
11619
|
hostElRef = inject(ElementRef);
|
|
10913
11620
|
menuConfig = injectMenuConfig();
|
|
11621
|
+
ariaLabels = coerceSignal(this.menuConfig.ariaLabels);
|
|
10914
11622
|
announcer = inject(CNGX_MENU_ANNOUNCER_FACTORY)();
|
|
10915
11623
|
/**
|
|
10916
11624
|
* Submenu focus-stack model - the active submenu chain, the saved-focus
|
|
@@ -10929,7 +11637,7 @@ class CngxMenuTrigger {
|
|
|
10929
11637
|
hostElement: this.hostElRef.nativeElement,
|
|
10930
11638
|
menuConfig: this.menuConfig,
|
|
10931
11639
|
factory: inject(CNGX_MENU_DISMISS_HANDLER_FACTORY),
|
|
10932
|
-
onDismiss: () => this.announcer.announce(this.
|
|
11640
|
+
onDismiss: () => this.announcer.announce(this.ariaLabels().menuDismissed),
|
|
10933
11641
|
});
|
|
10934
11642
|
/**
|
|
10935
11643
|
* The dismissal source that closed the menu most recently. `null`
|
|
@@ -11225,16 +11933,18 @@ function errorSourceMapEqual(a, b) {
|
|
|
11225
11933
|
* test harnesses) can inspect or drive form-error state without traversing
|
|
11226
11934
|
* the DOM. Directives with `cngxErrorScopeName` / `cngxErrorAggregatorName`
|
|
11227
11935
|
* inputs auto-register here when the registry is provided in the host
|
|
11228
|
-
* environment
|
|
11936
|
+
* environment via {@link provideErrorRegistry}.
|
|
11229
11937
|
*
|
|
11230
11938
|
* Not `providedIn: 'root'` - consumers opt in by including
|
|
11231
11939
|
* `provideErrorRegistry()` in their `bootstrapApplication` providers. When
|
|
11232
11940
|
* the registry is absent, the directives skip registration and keep their
|
|
11233
11941
|
* pure DOM behaviour.
|
|
11234
11942
|
*
|
|
11235
|
-
* @
|
|
11236
|
-
*
|
|
11237
|
-
*
|
|
11943
|
+
* @category common/interactive/error
|
|
11944
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/error-registry/error-registry.ts
|
|
11945
|
+
* @since 0.1.0
|
|
11946
|
+
* @relatedTo CngxErrorScope, CngxErrorAggregator, CngxErrorSource
|
|
11947
|
+
* <example-url>http://localhost:4200/#/common/interactive/error/registry/provider-and-reveal-features</example-url>
|
|
11238
11948
|
*/
|
|
11239
11949
|
class CngxErrorRegistry {
|
|
11240
11950
|
scopesState = signal(new Map(), { ...(ngDevMode ? { debugName: "scopesState" } : /* istanbul ignore next */ {}), equal: mapKeySetEqual });
|
|
@@ -11285,14 +11995,22 @@ class CngxErrorRegistry {
|
|
|
11285
11995
|
if (current.get(name) === scope) {
|
|
11286
11996
|
return;
|
|
11287
11997
|
}
|
|
11998
|
+
if (isDevMode() && current.has(name)) {
|
|
11999
|
+
console.warn(`CngxErrorRegistry: a scope named "${name}" is already registered. ` +
|
|
12000
|
+
'The existing instance stays live (swap-is-noop); unregister it first for a true swap.');
|
|
12001
|
+
}
|
|
11288
12002
|
const next = new Map(current);
|
|
11289
12003
|
next.set(name, scope);
|
|
11290
12004
|
this.scopesState.set(next);
|
|
11291
12005
|
}
|
|
11292
|
-
/**
|
|
11293
|
-
|
|
12006
|
+
/**
|
|
12007
|
+
* Removes the named scope, but only when `scope` is the stored instance.
|
|
12008
|
+
* No-op if absent or if a different instance holds the name - a late
|
|
12009
|
+
* destroy of a swap-absorbed duplicate must not evict the live winner.
|
|
12010
|
+
*/
|
|
12011
|
+
unregisterScope(name, scope) {
|
|
11294
12012
|
const current = this.scopesState();
|
|
11295
|
-
if (
|
|
12013
|
+
if (current.get(name) !== scope) {
|
|
11296
12014
|
return;
|
|
11297
12015
|
}
|
|
11298
12016
|
const next = new Map(current);
|
|
@@ -11319,14 +12037,22 @@ class CngxErrorRegistry {
|
|
|
11319
12037
|
if (current.get(name) === aggregator) {
|
|
11320
12038
|
return;
|
|
11321
12039
|
}
|
|
12040
|
+
if (isDevMode() && current.has(name)) {
|
|
12041
|
+
console.warn(`CngxErrorRegistry: an aggregator named "${name}" is already registered. ` +
|
|
12042
|
+
'The existing instance stays live (swap-is-noop); unregister it first for a true swap.');
|
|
12043
|
+
}
|
|
11322
12044
|
const next = new Map(current);
|
|
11323
12045
|
next.set(name, aggregator);
|
|
11324
12046
|
this.aggregatorsState.set(next);
|
|
11325
12047
|
}
|
|
11326
|
-
/**
|
|
11327
|
-
|
|
12048
|
+
/**
|
|
12049
|
+
* Removes the named aggregator, but only when `aggregator` is the stored
|
|
12050
|
+
* instance. No-op if absent or if a different instance holds the name - a
|
|
12051
|
+
* late destroy of a swap-absorbed duplicate must not evict the live winner.
|
|
12052
|
+
*/
|
|
12053
|
+
unregisterAggregator(name, aggregator) {
|
|
11328
12054
|
const current = this.aggregatorsState();
|
|
11329
|
-
if (
|
|
12055
|
+
if (current.get(name) !== aggregator) {
|
|
11330
12056
|
return;
|
|
11331
12057
|
}
|
|
11332
12058
|
const next = new Map(current);
|
|
@@ -11416,13 +12142,30 @@ class CngxErrorScope {
|
|
|
11416
12142
|
return;
|
|
11417
12143
|
}
|
|
11418
12144
|
const destroyRef = inject(DestroyRef);
|
|
12145
|
+
const injector = inject(Injector);
|
|
12146
|
+
// Registration reacts to name changes: a renamed scope unregisters its
|
|
12147
|
+
// old key and registers the new one. Deferred behind afterNextRender so
|
|
12148
|
+
// registration stays browser-only.
|
|
11419
12149
|
afterNextRender(() => {
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
12150
|
+
let registered = null;
|
|
12151
|
+
effect(() => {
|
|
12152
|
+
const name = this.scopeName();
|
|
12153
|
+
untracked(() => {
|
|
12154
|
+
if (registered && registered !== name) {
|
|
12155
|
+
registry.unregisterScope(registered, this);
|
|
12156
|
+
registered = null;
|
|
12157
|
+
}
|
|
12158
|
+
if (name && registered !== name) {
|
|
12159
|
+
registry.registerScope(name, this);
|
|
12160
|
+
registered = name;
|
|
12161
|
+
}
|
|
12162
|
+
});
|
|
12163
|
+
}, { injector });
|
|
12164
|
+
destroyRef.onDestroy(() => {
|
|
12165
|
+
if (registered) {
|
|
12166
|
+
registry.unregisterScope(registered, this);
|
|
12167
|
+
}
|
|
12168
|
+
});
|
|
11426
12169
|
});
|
|
11427
12170
|
}
|
|
11428
12171
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxErrorScope, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
@@ -11513,8 +12256,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
11513
12256
|
}]
|
|
11514
12257
|
}], ctorParameters: () => [], propDecorators: { cngxErrorSource: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxErrorSource", required: true }] }], when: [{ type: i0.Input, args: [{ isSignal: true, alias: "when", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
|
|
11515
12258
|
|
|
11516
|
-
|
|
11517
|
-
|
|
12259
|
+
const ERROR_LIST_FORMAT_CACHE_LIMIT = 32;
|
|
12260
|
+
/**
|
|
12261
|
+
* @internal - one `Intl.ListFormat` per locale for the announcement joiner.
|
|
12262
|
+
* The `unit` / `short` style joins without a conjunction in en-US
|
|
12263
|
+
* (`A, B, C`, identical to the former `', '` join); de-DE reads
|
|
12264
|
+
* `A, B und C`.
|
|
12265
|
+
*/
|
|
12266
|
+
const errorListFormatFor = memoize((locale) => new Intl.ListFormat(locale, { type: 'unit', style: 'short' }), { cacheLimit: ERROR_LIST_FORMAT_CACHE_LIMIT });
|
|
11518
12267
|
/**
|
|
11519
12268
|
* Builds the canonical error-aggregator computed graph (six derived
|
|
11520
12269
|
* signals + `addSource`/`removeSource` mutators) over a caller-owned
|
|
@@ -11523,7 +12272,10 @@ const ERROR_LABEL_JOINER = ', ';
|
|
|
11523
12272
|
* Single source of truth for the aggregator surface: `CngxErrorAggregator`
|
|
11524
12273
|
* (directive form, ARIA host bindings) and `injectErrorAggregator`
|
|
11525
12274
|
* (programmatic form, no DOM host) both delegate to this helper so the
|
|
11526
|
-
* two surfaces stay field-for-field equivalent without manual
|
|
12275
|
+
* two CONTRACT surfaces stay field-for-field equivalent without manual
|
|
12276
|
+
* sync. Registry registration sits outside this equivalence: the directive
|
|
12277
|
+
* re-registers reactively when its name input changes, the factory's
|
|
12278
|
+
* static name registers once.
|
|
11527
12279
|
*
|
|
11528
12280
|
* Returns a fresh `CngxErrorAggregatorContract` each call - every
|
|
11529
12281
|
* `computed` is freshly bound to the supplied `sourcesState`/`scope`
|
|
@@ -11578,7 +12330,15 @@ function createErrorAggregatorContract(deps) {
|
|
|
11578
12330
|
const resolved = scope();
|
|
11579
12331
|
return resolved ? resolved.showErrors() : true;
|
|
11580
12332
|
}, ...(ngDevMode ? [{ debugName: "shouldShow" }] : /* istanbul ignore next */ []));
|
|
11581
|
-
|
|
12333
|
+
// Live-region text: the locale is read untracked, so a locale flip never
|
|
12334
|
+
// re-speaks a shown announcement; the next error change speaks it.
|
|
12335
|
+
const announcement = computed(() => {
|
|
12336
|
+
if (!shouldShow()) {
|
|
12337
|
+
return '';
|
|
12338
|
+
}
|
|
12339
|
+
const labels = errorLabels();
|
|
12340
|
+
return untracked(() => errorListFormatFor(deps.locale()).format(labels));
|
|
12341
|
+
}, ...(ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []));
|
|
11582
12342
|
return {
|
|
11583
12343
|
hasError,
|
|
11584
12344
|
errorCount,
|
|
@@ -11587,7 +12347,12 @@ function createErrorAggregatorContract(deps) {
|
|
|
11587
12347
|
shouldShow,
|
|
11588
12348
|
announcement,
|
|
11589
12349
|
addSource(entry) {
|
|
11590
|
-
const
|
|
12350
|
+
const current = sourcesState();
|
|
12351
|
+
if (isDevMode() && current.has(entry.key) && current.get(entry.key) !== entry) {
|
|
12352
|
+
console.warn(`CngxErrorAggregator: an error source with key "${entry.key}" is already ` +
|
|
12353
|
+
'registered; the new entry replaces it (last-wins). Use unique keys per source.');
|
|
12354
|
+
}
|
|
12355
|
+
const next = new Map(current);
|
|
11591
12356
|
next.set(entry.key, entry);
|
|
11592
12357
|
sourcesState.set(next);
|
|
11593
12358
|
},
|
|
@@ -11688,6 +12453,7 @@ class CngxErrorAggregator {
|
|
|
11688
12453
|
contract = createErrorAggregatorContract({
|
|
11689
12454
|
sourcesState: this.sourcesState,
|
|
11690
12455
|
scope: this.effectiveScope,
|
|
12456
|
+
locale: injectLocale(),
|
|
11691
12457
|
});
|
|
11692
12458
|
hasError = this.contract.hasError;
|
|
11693
12459
|
errorCount = this.contract.errorCount;
|
|
@@ -11754,13 +12520,30 @@ class CngxErrorAggregator {
|
|
|
11754
12520
|
if (!registry) {
|
|
11755
12521
|
return;
|
|
11756
12522
|
}
|
|
12523
|
+
const injector = inject(Injector);
|
|
12524
|
+
// Registration reacts to name changes: a renamed aggregator unregisters
|
|
12525
|
+
// its old key and registers the new one. Deferred behind afterNextRender
|
|
12526
|
+
// so registration stays browser-only.
|
|
11757
12527
|
afterNextRender(() => {
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
12528
|
+
let registered = null;
|
|
12529
|
+
effect(() => {
|
|
12530
|
+
const name = this.aggregatorName();
|
|
12531
|
+
untracked(() => {
|
|
12532
|
+
if (registered && registered !== name) {
|
|
12533
|
+
registry.unregisterAggregator(registered, this);
|
|
12534
|
+
registered = null;
|
|
12535
|
+
}
|
|
12536
|
+
if (name && registered !== name) {
|
|
12537
|
+
registry.registerAggregator(name, this);
|
|
12538
|
+
registered = name;
|
|
12539
|
+
}
|
|
12540
|
+
});
|
|
12541
|
+
}, { injector });
|
|
12542
|
+
destroyRef.onDestroy(() => {
|
|
12543
|
+
if (registered) {
|
|
12544
|
+
registry.unregisterAggregator(registered, this);
|
|
12545
|
+
}
|
|
12546
|
+
});
|
|
11764
12547
|
});
|
|
11765
12548
|
}
|
|
11766
12549
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxErrorAggregator, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
@@ -11793,9 +12576,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
11793
12576
|
* Must be called in an injection context (constructor, factory provider,
|
|
11794
12577
|
* `runInInjectionContext`).
|
|
11795
12578
|
*
|
|
11796
|
-
* @
|
|
11797
|
-
*
|
|
11798
|
-
*
|
|
12579
|
+
* @category common/interactive/error
|
|
12580
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/error-registry/inject-error-scope.ts
|
|
12581
|
+
* @since 0.1.0
|
|
12582
|
+
* @relatedTo CngxErrorScope
|
|
12583
|
+
* <example-url>http://localhost:4200/#/common/interactive/error/registry/inject-error-scope-programmatic</example-url>
|
|
11799
12584
|
*/
|
|
11800
12585
|
function injectErrorScope(name) {
|
|
11801
12586
|
const showErrorsState = signal(false, ...(ngDevMode ? [{ debugName: "showErrorsState" }] : /* istanbul ignore next */ []));
|
|
@@ -11811,7 +12596,7 @@ function injectErrorScope(name) {
|
|
|
11811
12596
|
if (registry) {
|
|
11812
12597
|
const destroyRef = inject(DestroyRef);
|
|
11813
12598
|
registry.registerScope(name, contract);
|
|
11814
|
-
destroyRef.onDestroy(() => registry.unregisterScope(name));
|
|
12599
|
+
destroyRef.onDestroy(() => registry.unregisterScope(name, contract));
|
|
11815
12600
|
}
|
|
11816
12601
|
}
|
|
11817
12602
|
return contract;
|
|
@@ -11843,9 +12628,11 @@ function injectErrorScope(name) {
|
|
|
11843
12628
|
* ({@link `@cngx/common/interactive`#CngxErrorAggregator}) and the
|
|
11844
12629
|
* function form share a single source of truth.
|
|
11845
12630
|
*
|
|
11846
|
-
* @
|
|
11847
|
-
*
|
|
11848
|
-
*
|
|
12631
|
+
* @category common/interactive/error
|
|
12632
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/error-registry/inject-error-aggregator.ts
|
|
12633
|
+
* @since 0.1.0
|
|
12634
|
+
* @relatedTo CngxErrorAggregator
|
|
12635
|
+
* <example-url>http://localhost:4200/#/common/interactive/error/registry/inject-error-aggregator-programmatic</example-url>
|
|
11849
12636
|
*/
|
|
11850
12637
|
function injectErrorAggregator(name, sources, scope, labels) {
|
|
11851
12638
|
const sourcesState = signal(buildInitialSources(sources, labels), { ...(ngDevMode ? { debugName: "sourcesState" } : /* istanbul ignore next */ {}), equal: errorSourceMapEqual });
|
|
@@ -11853,13 +12640,14 @@ function injectErrorAggregator(name, sources, scope, labels) {
|
|
|
11853
12640
|
const contract = createErrorAggregatorContract({
|
|
11854
12641
|
sourcesState,
|
|
11855
12642
|
scope: scopeSignal.asReadonly(),
|
|
12643
|
+
locale: injectLocale(),
|
|
11856
12644
|
});
|
|
11857
12645
|
if (name) {
|
|
11858
12646
|
const registry = inject(CngxErrorRegistry, { optional: true });
|
|
11859
12647
|
if (registry) {
|
|
11860
12648
|
const destroyRef = inject(DestroyRef);
|
|
11861
12649
|
registry.registerAggregator(name, contract);
|
|
11862
|
-
destroyRef.onDestroy(() => registry.unregisterAggregator(name));
|
|
12650
|
+
destroyRef.onDestroy(() => registry.unregisterAggregator(name, contract));
|
|
11863
12651
|
}
|
|
11864
12652
|
}
|
|
11865
12653
|
return contract;
|
|
@@ -11899,9 +12687,11 @@ function buildInitialSources(sources, labels) {
|
|
|
11899
12687
|
* });
|
|
11900
12688
|
* ```
|
|
11901
12689
|
*
|
|
11902
|
-
* @
|
|
11903
|
-
*
|
|
11904
|
-
*
|
|
12690
|
+
* @category common/interactive/error
|
|
12691
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/error-registry/provide-error-registry.ts
|
|
12692
|
+
* @since 0.1.0
|
|
12693
|
+
* @relatedTo CngxErrorScope, CngxErrorAggregator
|
|
12694
|
+
* <example-url>http://localhost:4200/#/common/interactive/error/registry/provider-and-reveal-features</example-url>
|
|
11905
12695
|
*/
|
|
11906
12696
|
function provideErrorRegistry(...features) {
|
|
11907
12697
|
let config = {};
|
|
@@ -11952,9 +12742,10 @@ function provideErrorRegistry(...features) {
|
|
|
11952
12742
|
* instead - the scope-name registration path stays available without
|
|
11953
12743
|
* the global listener.
|
|
11954
12744
|
*
|
|
11955
|
-
* @
|
|
11956
|
-
*
|
|
11957
|
-
*
|
|
12745
|
+
* @category common/interactive/error
|
|
12746
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/error-registry/provide-error-registry.ts
|
|
12747
|
+
* @since 0.1.0
|
|
12748
|
+
* <example-url>http://localhost:4200/#/common/interactive/error/registry/provider-and-reveal-features</example-url>
|
|
11958
12749
|
*/
|
|
11959
12750
|
function withGlobalRevealOnSubmit() {
|
|
11960
12751
|
return { _apply: (c) => ({ ...c, revealOnSubmit: true }) };
|
|
@@ -11972,9 +12763,10 @@ function withGlobalRevealOnSubmit() {
|
|
|
11972
12763
|
* the common pattern (reveal-all on attempted navigation) but surface
|
|
11973
12764
|
* the implication when wiring a guard that cancels based on form errors.
|
|
11974
12765
|
*
|
|
11975
|
-
* @
|
|
11976
|
-
*
|
|
11977
|
-
*
|
|
12766
|
+
* @category common/interactive/error
|
|
12767
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/error-registry/provide-error-registry.ts
|
|
12768
|
+
* @since 0.1.0
|
|
12769
|
+
* <example-url>http://localhost:4200/#/common/interactive/error/registry/provider-and-reveal-features</example-url>
|
|
11978
12770
|
*/
|
|
11979
12771
|
function withRevealOnNavigate() {
|
|
11980
12772
|
return { _apply: (c) => ({ ...c, revealOnNavigate: true }) };
|
|
@@ -11988,5 +12780,5 @@ function withRevealOnNavigate() {
|
|
|
11988
12780
|
* Generated bundle index. Do not edit.
|
|
11989
12781
|
*/
|
|
11990
12782
|
|
|
11991
|
-
export { CNGX_ACCORDION, CNGX_BREADCRUMB, CNGX_BREADCRUMB_COLLAPSE_STRATEGY, CNGX_BUTTON_MULTI_TOGGLE_GROUP, CNGX_BUTTON_TOGGLE_GROUP, CNGX_CHIP_GROUP_HOST, CNGX_CHIP_STRIP_ROVING_FACTORY, CNGX_CLOSE_ICON, CNGX_CONTROL_VALUE, CNGX_ERROR_AGGREGATOR, CNGX_ERROR_SCOPE, CNGX_HIERARCHICAL_NAV_STRATEGY, CNGX_HOVER_INTENT_DEFAULTS, CNGX_MENU_ANNOUNCER_FACTORY, CNGX_MENU_CONFIG, CNGX_MENU_DISMISS_HANDLER_FACTORY, CNGX_MENU_FOCUS_STACK_FACTORY, CNGX_MENU_HOST, CNGX_MENU_NAV_STRATEGY, CNGX_MENU_RADIO_GROUP, CNGX_MENU_SUBMENU_ITEM, CNGX_MENU_SUBMENU_WIRING, CNGX_NAV_CONFIG, CNGX_OPTION_CONTAINER, CNGX_OPTION_FILTER_HOST, CNGX_OPTION_INTERACTION_HOST, CNGX_OPTION_STATUS_HOST, CNGX_RADIO_GROUP, CNGX_SLIDER_RANGE, CNGX_SUBMENU_TRY_FALLBACKS, CNGX_TREE_CONFIG, CNGX_TREE_CONTROLLER_FACTORY, CngxAccordion, CngxAccordionPanel, CngxAsyncClick, CngxAsyncStatus, CngxBeforeUnload, CngxBreadcrumb, CngxBreadcrumbItem, CngxBreadcrumbSeparator, CngxButtonMultiToggleGroup, CngxButtonToggle, CngxButtonToggleGroup, CngxCheckbox, CngxCheckboxGroup, CngxChipGroup, CngxChipInGroup, CngxChipInput, CngxChipInteraction, CngxClickOutside, CngxCloseButton, CngxContextMenuTrigger, CngxCopyBlock, CngxCopyText, CngxDisclosure, CngxErrorAggregator, CngxErrorRegistry, CngxErrorScope, CngxErrorSource, CngxErrorState, CngxExpandable, CngxFailed, CngxHierarchicalNav, CngxHoverIntent, CngxHoverable, CngxKeyboardShortcut, CngxListbox, CngxListboxSearch, CngxListboxTrigger, CngxLongPress, CngxMenu, CngxMenuAnnouncer, CngxMenuGroup, CngxMenuItem, CngxMenuItemCheckbox, CngxMenuItemIcon, CngxMenuItemKbd, CngxMenuItemLabel, CngxMenuItemRadio, CngxMenuItemSubmenu, CngxMenuItemSuffix, CngxMenuSeparator, CngxMenuTrigger, CngxMultiChipGroup, CngxNavBadge, CngxNavGroup, CngxNavGroupRegistry, CngxNavLabel, CngxNavLink, CngxOption, CngxOptionGroup, CngxPending, CngxPressRipple, CngxPressable, CngxRadio, CngxRadioGroup, CngxRangeSlider, CngxRangeSliderTrack, CngxReorder, CngxRipple, CngxSearch, CngxSlider, CngxSliderThumb, CngxSliderTrack, CngxSpeak, CngxSucceeded, CngxSwipe, CngxSwipeDismiss, CngxToggle,
|
|
12783
|
+
export { CNGX_ACCORDION, CNGX_BREADCRUMB, CNGX_BREADCRUMB_COLLAPSE_STRATEGY, CNGX_BUTTON_MULTI_TOGGLE_GROUP, CNGX_BUTTON_TOGGLE_GROUP, CNGX_CHIP_GROUP_HOST, CNGX_CHIP_STRIP_ROVING_FACTORY, CNGX_CLOSE_ICON, CNGX_CONTROL_VALUE, CNGX_ERROR_AGGREGATOR, CNGX_ERROR_SCOPE, CNGX_HIERARCHICAL_NAV_STRATEGY, CNGX_HOVER_INTENT_DEFAULTS, CNGX_INTERACTIVE_I18N, CNGX_INTERACTIVE_LANGUAGE_EN, CNGX_MENU_ANNOUNCER_FACTORY, CNGX_MENU_CONFIG, CNGX_MENU_DISMISS_HANDLER_FACTORY, CNGX_MENU_FOCUS_STACK_FACTORY, CNGX_MENU_HOST, CNGX_MENU_LANGUAGE_EN, CNGX_MENU_NAV_STRATEGY, CNGX_MENU_RADIO_GROUP, CNGX_MENU_SUBMENU_ITEM, CNGX_MENU_SUBMENU_WIRING, CNGX_NAV_CONFIG, CNGX_OPTION_CONTAINER, CNGX_OPTION_FILTER_HOST, CNGX_OPTION_INTERACTION_HOST, CNGX_OPTION_STATUS_HOST, CNGX_RADIO_GROUP, CNGX_SLIDER_RANGE, CNGX_SUBMENU_TRY_FALLBACKS, CNGX_TREE_CONFIG, CNGX_TREE_CONTROLLER_FACTORY, CngxAccordion, CngxAccordionPanel, CngxAsyncClick, CngxAsyncStatus, CngxBeforeUnload, CngxBreadcrumb, CngxBreadcrumbItem, CngxBreadcrumbSeparator, CngxButtonMultiToggleGroup, CngxButtonToggle, CngxButtonToggleGroup, CngxCheckbox, CngxCheckboxGroup, CngxChipGroup, CngxChipInGroup, CngxChipInput, CngxChipInteraction, CngxClickOutside, CngxCloseButton, CngxContextMenuTrigger, CngxCopyBlock, CngxCopyText, CngxDisclosure, CngxErrorAggregator, CngxErrorRegistry, CngxErrorScope, CngxErrorSource, CngxErrorState, CngxExpandable, CngxFailed, CngxHierarchicalNav, CngxHoverIntent, CngxHoverable, CngxKeyboardShortcut, CngxListbox, CngxListboxSearch, CngxListboxTrigger, CngxLongPress, CngxMenu, CngxMenuAnnouncer, CngxMenuGroup, CngxMenuItem, CngxMenuItemCheckbox, CngxMenuItemIcon, CngxMenuItemKbd, CngxMenuItemLabel, CngxMenuItemRadio, CngxMenuItemSubmenu, CngxMenuItemSuffix, CngxMenuSeparator, CngxMenuTrigger, CngxMultiChipGroup, CngxNavBadge, CngxNavGroup, CngxNavGroupRegistry, CngxNavLabel, CngxNavLink, CngxOption, CngxOptionGroup, CngxPending, CngxPressRipple, CngxPressable, CngxRadio, CngxRadioGroup, CngxRangeSlider, CngxRangeSliderTrack, CngxReorder, CngxRipple, CngxSearch, CngxSlider, CngxSliderThumb, CngxSliderTrack, CngxSpeak, CngxSucceeded, CngxSwipe, CngxSwipeDismiss, CngxToggle, DEFAULT_MENU_CONFIG, canDeactivateWhenClean, connectSubmenuHoverToFocusStack, createAccordionKeyboardNav, createBreadcrumbCollapse, createChipStripRoving, createContextMenuTriggerCore, createListboxLabelMatch, createMenuAnnouncer, createMenuDismissHandler, createMenuFocusStack, createMenuRadioController, createMenuTriggerDismissBinding, createOptimistic, createRetry, createSliderCore, createTreeAdItems, createTreeController, createW3CMenuStrategy, createW3CTreeStrategy, injectErrorAggregator, injectErrorScope, injectInteractiveGroupHost, injectInteractiveI18n, injectMenuAnnouncer, injectMenuConfig, injectMenuItemCore, injectNavConfig, injectTreeConfig, optimistic, provideCngxMenu, provideErrorRegistry, provideInteractiveI18n, provideMenuConfig, provideMenuConfigAt, provideNavConfig, provideNavConfigAt, provideTreeConfig, provideTreeConfigAt, reflectAsyncDisplayStatus, withAriaLabels, withCloseOnSelect, withDefaultInitiallyExpanded, withDefaultKeyFn, withDefaultLabelFn, withDefaultNodeIdFn, withDismissOnBlur, withDismissOnOutsideClick, withDismissOnScroll, withGlobalRevealOnSubmit, withInteractiveI18nLabels, withNavAnimation, withNavIndent, withRetry, withRevealOnNavigate, withSingleAccordion, withSubmenuCloseDelay, withSubmenuOpenDelay, withTreeCacheLimit, withTypeaheadDebounce };
|
|
11992
12784
|
//# sourceMappingURL=cngx-common-interactive.mjs.map
|