@cngx/common 0.1.0-rc.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/README.md +15 -2
- package/button/README.md +258 -0
- package/command/README.md +42 -2
- package/data/README.md +15 -12
- package/fesm2022/cngx-common-a11y.mjs +1076 -319
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +99 -77
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-button.mjs +1084 -0
- package/fesm2022/cngx-common-button.mjs.map +1 -0
- package/fesm2022/cngx-common-card.mjs +138 -78
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +799 -327
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +101 -25
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +861 -423
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +198 -160
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +693 -329
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +7303 -2774
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +2174 -442
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-menu-button.mjs +557 -0
- package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
- package/fesm2022/cngx-common-popover.mjs +2109 -557
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +548 -419
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +442 -331
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +44 -71
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +10 -10
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +30 -19
- package/layout/README.md +17 -1
- package/menu-button/README.md +234 -0
- package/package.json +31 -8
- package/popover/README.md +81 -4
- package/popover/tooltip-indicator.scss +52 -0
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +96 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +5 -5
- package/theming/components/cngx-accordion.css +36 -7
- package/theming/components/cngx-async.css +185 -37
- package/theming/components/cngx-backdrop.css +3 -1
- package/theming/components/cngx-badge.css +20 -5
- package/theming/components/cngx-bottom-sheet.css +2 -0
- package/theming/components/cngx-breadcrumb.css +3 -1
- package/theming/components/cngx-button-group.css +325 -0
- package/theming/components/cngx-button-toggle.css +55 -23
- package/theming/components/cngx-button.css +975 -0
- package/theming/components/cngx-data-grid.css +2 -0
- package/theming/components/cngx-dialog.css +3 -1
- package/theming/components/cngx-divider.css +24 -9
- package/theming/components/cngx-drawer.css +153 -0
- package/theming/components/cngx-icon-glyph.css +76 -0
- package/theming/components/cngx-listbox.css +79 -25
- package/theming/components/cngx-menu.css +112 -52
- package/theming/components/cngx-nav.css +1220 -0
- package/theming/components/cngx-popover-sheet.css +434 -0
- package/theming/components/cngx-popover.css +37 -9
- package/theming/components/cngx-recycler-placeholder.css +2 -0
- package/theming/components/cngx-ripple.css +74 -16
- package/theming/components/cngx-sidebar.css +71 -0
- package/theming/components/cngx-slider.css +3 -1
- package/theming/components/cngx-tooltip.css +2 -0
- package/timeline/README.md +2 -2
- package/types/cngx-common-a11y.d.ts +488 -112
- package/types/cngx-common-audio.d.ts +60 -88
- package/types/cngx-common-button.d.ts +698 -0
- package/types/cngx-common-card.d.ts +104 -78
- package/types/cngx-common-chart.d.ts +677 -389
- package/types/cngx-common-command.d.ts +55 -41
- package/types/cngx-common-data.d.ts +506 -360
- package/types/cngx-common-dialog.d.ts +94 -127
- package/types/cngx-common-display.d.ts +475 -300
- package/types/cngx-common-interactive.d.ts +4383 -1721
- package/types/cngx-common-layout.d.ts +1399 -288
- package/types/cngx-common-menu-button.d.ts +382 -0
- package/types/cngx-common-popover.d.ts +990 -268
- package/types/cngx-common-stepper.d.ts +374 -465
- package/types/cngx-common-tabs.d.ts +309 -403
- package/types/cngx-common-timeline.d.ts +50 -109
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, computed, makeEnvironmentProviders, model, input, Injector, output, signal, Directive, TemplateRef, contentChild, DestroyRef, Renderer2, ElementRef, effect, afterNextRender, untracked,
|
|
3
|
-
import { CNGX_COMMIT_CONTROLLER_FACTORY } from '@cngx/common/data';
|
|
2
|
+
import { InjectionToken, inject, computed, makeEnvironmentProviders, model, input, Injector, output, signal, Directive, TemplateRef, contentChild, DestroyRef, Renderer2, ElementRef, effect, afterRenderEffect, afterNextRender, untracked, linkedSignal, runInInjectionContext } from '@angular/core';
|
|
3
|
+
import { CNGX_COMMIT_CONTROLLER_FACTORY, createRefusedPhrase } from '@cngx/common/data';
|
|
4
4
|
import { createOverrideMerge, createTransitionTracker, CNGX_STATEFUL, nextUid, coerceSignal, createAnnouncementPhrase } from '@cngx/core/utils';
|
|
5
|
-
import { recordEqual, arrayEqual } from '@cngx/utils';
|
|
5
|
+
import { recordEqual, CngxRuntimeError, CNGX_ICON_ALERT, cngxDevWarn, arrayEqual } from '@cngx/utils';
|
|
6
6
|
import { createLanguageSection, formatMessage, createSectionBundle } from '@cngx/core/i18n';
|
|
7
7
|
import { isObservable, Observable } from 'rxjs';
|
|
8
|
-
import { PRIMARY_OUTLET, Router,
|
|
8
|
+
import { PRIMARY_OUTLET, Router, ActivatedRoute, NavigationEnd } from '@angular/router';
|
|
9
|
+
import { createIconSvgElement } from '@cngx/common/display';
|
|
9
10
|
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
10
11
|
import { filter } from 'rxjs/operators';
|
|
11
|
-
import { resolveInlineStep } from '@cngx/core';
|
|
12
|
+
import { resolveInlineStep, injectEffectiveMotion } from '@cngx/core';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* DI fallback the presenter reads when its `[commitAction]` input is
|
|
@@ -17,9 +18,8 @@ import { resolveInlineStep } from '@cngx/core';
|
|
|
17
18
|
* exposes a non-null `action()`, its `mode()` wins over the
|
|
18
19
|
* `[commitMode]` input.
|
|
19
20
|
*
|
|
20
|
-
* @category common/tabs
|
|
21
21
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/commit-action.token.ts
|
|
22
|
-
* @since 0.
|
|
22
|
+
* @since 0.3.0
|
|
23
23
|
*/
|
|
24
24
|
const CNGX_TABS_COMMIT_ACTION = new InjectionToken('CngxTabsCommitAction');
|
|
25
25
|
|
|
@@ -27,12 +27,10 @@ const CNGX_TABS_COMMIT_ACTION = new InjectionToken('CngxTabsCommitAction');
|
|
|
27
27
|
* The English tabs section: the single source of the tabs' English copy.
|
|
28
28
|
* `CNGX_TABS_I18N` and the `CNGX_TABS_CONFIG` labels default to it.
|
|
29
29
|
*
|
|
30
|
-
* @
|
|
31
|
-
* @since 0.1.0
|
|
30
|
+
* @since 0.3.0
|
|
32
31
|
* @relatedTo CNGX_TABS_I18N, CNGX_TABS_CONFIG
|
|
33
32
|
*/
|
|
34
33
|
const CNGX_TABS_LANGUAGE_EN = {
|
|
35
|
-
tabsRegion: 'Tabs',
|
|
36
34
|
tabsLabel: 'Tabs',
|
|
37
35
|
tabRoleDescription: 'tab list',
|
|
38
36
|
tabPanelRoleDescription: 'tab panel',
|
|
@@ -41,6 +39,7 @@ const CNGX_TABS_LANGUAGE_EN = {
|
|
|
41
39
|
tabHasErrors: { one: '{count} error', other: '{count} errors' },
|
|
42
40
|
moreTabsLabel: '{count} more',
|
|
43
41
|
unlabeledTab: 'Tab {position}',
|
|
42
|
+
unlabeledTabOfCount: 'Tab {position} of {count}',
|
|
44
43
|
previousTab: 'Previous tab: {tab}',
|
|
45
44
|
nextTab: 'Next tab: {tab}',
|
|
46
45
|
closeTab: 'Close "{label}"',
|
|
@@ -50,6 +49,8 @@ const CNGX_TABS_LANGUAGE_EN = {
|
|
|
50
49
|
commitFailedRetry: 'Could not switch tab - retry?',
|
|
51
50
|
commitInFlight: 'Switching tab…',
|
|
52
51
|
commitRolledBackTo: 'Could not save changes - reverted to "{origin}".',
|
|
52
|
+
commitRefused: 'Tab switch not allowed - stayed on "{origin}".',
|
|
53
|
+
commitRefusedGeneric: 'Tab switch not allowed.',
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
/**
|
|
@@ -66,6 +67,7 @@ function tabsBundleFrom(section, locale) {
|
|
|
66
67
|
tabHasErrors: (count) => formatMessage(section.tabHasErrors, { count }, locale),
|
|
67
68
|
moreTabsLabel: (count) => formatMessage(section.moreTabsLabel, { count }, locale),
|
|
68
69
|
unlabeledTab: (position) => formatMessage(section.unlabeledTab, { position }, locale),
|
|
70
|
+
unlabeledTabOfCount: (position, count) => formatMessage(section.unlabeledTabOfCount, { position, count }, locale),
|
|
69
71
|
previousTab: (tab) => formatMessage(section.previousTab, { tab }, locale),
|
|
70
72
|
nextTab: (tab) => formatMessage(section.nextTab, { tab }, locale),
|
|
71
73
|
closeTab: (label) => formatMessage(section.closeTab, { label }, locale),
|
|
@@ -74,6 +76,8 @@ function tabsBundleFrom(section, locale) {
|
|
|
74
76
|
commitFailedRetry: section.commitFailedRetry,
|
|
75
77
|
commitInFlight: section.commitInFlight,
|
|
76
78
|
commitRolledBackTo: (origin) => formatMessage(section.commitRolledBackTo, { origin }, locale),
|
|
79
|
+
commitRefused: (origin) => formatMessage(section.commitRefused, { origin }, locale),
|
|
80
|
+
commitRefusedGeneric: section.commitRefusedGeneric,
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
/** @internal The tabs section of the active pack over English. */
|
|
@@ -92,10 +96,9 @@ const tabsBundle = createSectionBundle({
|
|
|
92
96
|
* for the app locale. Provide it through {@link provideTabsI18n}; a
|
|
93
97
|
* `{ provide, useValue }` entry must supply a `Signal<CngxTabsI18n>`.
|
|
94
98
|
*
|
|
95
|
-
* @category common/tabs/i18n
|
|
96
99
|
* @wcag AA
|
|
97
100
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/i18n/tabs-i18n.ts
|
|
98
|
-
* @since 0.
|
|
101
|
+
* @since 0.3.0
|
|
99
102
|
*/
|
|
100
103
|
const CNGX_TABS_I18N = new InjectionToken('CngxTabsI18n', {
|
|
101
104
|
providedIn: 'root',
|
|
@@ -111,11 +114,10 @@ function defineTabsI18nFeature(fn) {
|
|
|
111
114
|
}
|
|
112
115
|
/**
|
|
113
116
|
* Override i18n labels via a partial bundle - unset keys keep the
|
|
114
|
-
* language pack's copy, or the English default. Same shape as
|
|
115
|
-
* `withTabsFallbackLabels
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* @category common/tabs/i18n
|
|
117
|
+
* language pack's copy, or the English default. Same shape as
|
|
118
|
+
* `withTabsFallbackLabels`, so `provideCngxTabs` composes the i18n and
|
|
119
|
+
* the config feature uniformly. Pass a `Signal` to switch the language
|
|
120
|
+
* at runtime.
|
|
119
121
|
*/
|
|
120
122
|
function withTabsI18nLabels(overrides) {
|
|
121
123
|
return defineTabsI18nFeature((bundle) => createOverrideMerge(bundle, overrides));
|
|
@@ -134,8 +136,6 @@ function withTabsI18nLabels(overrides) {
|
|
|
134
136
|
* ],
|
|
135
137
|
* });
|
|
136
138
|
* ```
|
|
137
|
-
*
|
|
138
|
-
* @category common/tabs/i18n
|
|
139
139
|
*/
|
|
140
140
|
function provideTabsI18n(...features) {
|
|
141
141
|
return {
|
|
@@ -146,8 +146,6 @@ function provideTabsI18n(...features) {
|
|
|
146
146
|
/**
|
|
147
147
|
* Inject the resolved tabs i18n bundle. Read it inside a `computed()`,
|
|
148
148
|
* template or handler so a language switch reaches the label.
|
|
149
|
-
*
|
|
150
|
-
* @category common/tabs/i18n
|
|
151
149
|
*/
|
|
152
150
|
function injectTabsI18n() {
|
|
153
151
|
return tabsBundle.resolve(inject(CNGX_TABS_I18N));
|
|
@@ -168,9 +166,6 @@ const TABS_CONFIG_DEFAULTS = {
|
|
|
168
166
|
// for both organisms, and pinning one here would silently flip the
|
|
169
167
|
// other. linkAriaCurrent defaults at the link, not here.
|
|
170
168
|
linkAriaCurrent: 'page',
|
|
171
|
-
ariaLabels: {
|
|
172
|
-
tabsRegion: CNGX_TABS_LANGUAGE_EN.tabsRegion,
|
|
173
|
-
},
|
|
174
169
|
fallbackLabels: {
|
|
175
170
|
// W3C ARIA tablist convention - kept distinct from
|
|
176
171
|
// `i18n.tabsLabel` so AT doesn't read the same string twice
|
|
@@ -187,10 +182,9 @@ const TABS_CONFIG_DEFAULTS = {
|
|
|
187
182
|
* `providedIn: 'root'` with the library defaults; override via {@link provideTabsConfig}
|
|
188
183
|
* (root) or {@link provideTabsConfigAt} (component scope).
|
|
189
184
|
*
|
|
190
|
-
* @category common/tabs
|
|
191
185
|
* @wcag AA
|
|
192
186
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tabs-config.ts
|
|
193
|
-
* @since 0.
|
|
187
|
+
* @since 0.3.0
|
|
194
188
|
*/
|
|
195
189
|
const CNGX_TABS_CONFIG = new InjectionToken('CngxTabsConfig', {
|
|
196
190
|
providedIn: 'root',
|
|
@@ -210,8 +204,6 @@ function defineTabsConfigFeature(fn) {
|
|
|
210
204
|
/**
|
|
211
205
|
* Override the default orientation. Per-instance `[orientation]`
|
|
212
206
|
* still wins; this changes the cascade default only.
|
|
213
|
-
*
|
|
214
|
-
* @category common/tabs
|
|
215
207
|
*/
|
|
216
208
|
function withTabsDefaultOrientation(orientation) {
|
|
217
209
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -224,15 +216,11 @@ function withTabsDefaultOrientation(orientation) {
|
|
|
224
216
|
* collides with the stepper family's identical symbol when both libs
|
|
225
217
|
* are auto-imported. The alias stays for one minor release before
|
|
226
218
|
* removal.
|
|
227
|
-
*
|
|
228
|
-
* @category common/tabs
|
|
229
219
|
*/
|
|
230
220
|
const withDefaultOrientation = withTabsDefaultOrientation;
|
|
231
221
|
/**
|
|
232
222
|
* Override whether roving-tabindex navigation loops from last back to
|
|
233
223
|
* first (and vice versa). Per-instance `[loop]` Input still wins.
|
|
234
|
-
*
|
|
235
|
-
* @category common/tabs
|
|
236
224
|
*/
|
|
237
225
|
function withTabsRovingLoop(loop) {
|
|
238
226
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, defaultLoop: loop }));
|
|
@@ -242,8 +230,6 @@ function withTabsRovingLoop(loop) {
|
|
|
242
230
|
* `'optimistic'` activates the tab on action dispatch and rolls back
|
|
243
231
|
* on error; `'pessimistic'` waits for success. Per-instance
|
|
244
232
|
* `[commitMode]` Input still wins.
|
|
245
|
-
*
|
|
246
|
-
* @category common/tabs
|
|
247
233
|
*/
|
|
248
234
|
function withTabsCommitMode(mode) {
|
|
249
235
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -259,8 +245,6 @@ function withTabsCommitMode(mode) {
|
|
|
259
245
|
*
|
|
260
246
|
* Not to be confused with `[cngxTabsRouteSync]`, the router-outlet
|
|
261
247
|
* integration - this feature configures fragment deep-linking only.
|
|
262
|
-
*
|
|
263
|
-
* @category common/tabs
|
|
264
248
|
*/
|
|
265
249
|
function withTabsFragmentSync(mode, param = 'tab') {
|
|
266
250
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -281,8 +265,6 @@ function withTabsFragmentSync(mode, param = 'tab') {
|
|
|
281
265
|
*
|
|
282
266
|
* Changes which policy runs, not the policies themselves - swap those via
|
|
283
267
|
* {@link CNGX_TAB_URL_MATCH_STRATEGY}.
|
|
284
|
-
*
|
|
285
|
-
* @category common/tabs
|
|
286
268
|
*/
|
|
287
269
|
function withTabsRouteMatch(mode) {
|
|
288
270
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, routeMatch: mode }));
|
|
@@ -297,8 +279,6 @@ function withTabsRouteMatch(mode) {
|
|
|
297
279
|
* `provideTabsConfigAt` in that component's `viewProviders` rather than
|
|
298
280
|
* setting it app-wide, unless every nav in the app is section-shaped.
|
|
299
281
|
* Per-link `[ariaCurrent]` still wins.
|
|
300
|
-
*
|
|
301
|
-
* @category common/tabs
|
|
302
282
|
*/
|
|
303
283
|
function withTabsLinkAriaCurrent(token) {
|
|
304
284
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, linkAriaCurrent: token }));
|
|
@@ -308,8 +288,6 @@ function withTabsLinkAriaCurrent(token) {
|
|
|
308
288
|
* with the new `[cngxTabsRouteSync]` router-outlet directive; this
|
|
309
289
|
* feature only ever configured fragment / query-param deep-linking. The
|
|
310
290
|
* alias stays for one minor release before removal.
|
|
311
|
-
*
|
|
312
|
-
* @category common/tabs
|
|
313
291
|
*/
|
|
314
292
|
const withTabsRouterSync = withTabsFragmentSync;
|
|
315
293
|
/**
|
|
@@ -318,8 +296,6 @@ const withTabsRouterSync = withTabsFragmentSync;
|
|
|
318
296
|
* the cascade default. Structure, slots, ARIA, and keyboard behaviour
|
|
319
297
|
* are identical across skins - only the `[data-skin]` host attribute
|
|
320
298
|
* changes the CSS layer. The Material twin (`[cngxMatTabs]`) ignores it.
|
|
321
|
-
*
|
|
322
|
-
* @category common/tabs
|
|
323
299
|
*/
|
|
324
300
|
function withTabsSkin(skin) {
|
|
325
301
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, skin }));
|
|
@@ -329,8 +305,6 @@ function withTabsSkin(skin) {
|
|
|
329
305
|
* Default`'start'`. Per-instance `[iconLayout]` Input still wins. Orthogonal to
|
|
330
306
|
* skin and orientation - only the `[data-icon-layout]` host attribute
|
|
331
307
|
* changes.
|
|
332
|
-
*
|
|
333
|
-
* @category common/tabs
|
|
334
308
|
*/
|
|
335
309
|
function withTabsIconLayout(layout) {
|
|
336
310
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, iconLayout: layout }));
|
|
@@ -345,8 +319,6 @@ function withTabsIconLayout(layout) {
|
|
|
345
319
|
*
|
|
346
320
|
* Under `'lazy'`, a deep link mounts only the panel it names: both sync
|
|
347
321
|
* directives seed the active tab before the first panel render.
|
|
348
|
-
*
|
|
349
|
-
* @category common/tabs
|
|
350
322
|
*/
|
|
351
323
|
function withTabsPanelMode(mode) {
|
|
352
324
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, panelMode: mode }));
|
|
@@ -356,8 +328,6 @@ function withTabsPanelMode(mode) {
|
|
|
356
328
|
* (horizontal only). \
|
|
357
329
|
* Default `false`. Per-instance `[fitted]` Input still
|
|
358
330
|
* wins. No effect under `orientation="vertical"`.
|
|
359
|
-
*
|
|
360
|
-
* @category common/tabs
|
|
361
331
|
*/
|
|
362
332
|
function withTabsFitted(fitted) {
|
|
363
333
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, fitted }));
|
|
@@ -366,8 +336,6 @@ function withTabsFitted(fitted) {
|
|
|
366
336
|
* Set the app-wide default tab-cluster alignment (horizontal only). \
|
|
367
337
|
* Default `'start'`. Per-instance `[tabAlign]` Input still wins. Ignored
|
|
368
338
|
* under `orientation="vertical"` and when the group is `fitted`.
|
|
369
|
-
*
|
|
370
|
-
* @category common/tabs
|
|
371
339
|
*/
|
|
372
340
|
function withTabsAlign(align) {
|
|
373
341
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, tabAlign: align }));
|
|
@@ -376,8 +344,6 @@ function withTabsAlign(align) {
|
|
|
376
344
|
* Set the app-wide default for whether tabs render a close affordance. \
|
|
377
345
|
* Default `false`. Per-instance `[closable]` Input wins; a per-`CngxTab`
|
|
378
346
|
* `[closable]` override wins over both.
|
|
379
|
-
*
|
|
380
|
-
* @category common/tabs
|
|
381
347
|
*/
|
|
382
348
|
function withTabsClosable(closable) {
|
|
383
349
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, closable }));
|
|
@@ -386,33 +352,16 @@ function withTabsClosable(closable) {
|
|
|
386
352
|
* Set the app-wide default for whether the group renders an add-tab
|
|
387
353
|
* button. \
|
|
388
354
|
* Default `false`. Per-instance `[addable]` Input wins.
|
|
389
|
-
*
|
|
390
|
-
* @category common/tabs
|
|
391
355
|
*/
|
|
392
356
|
function withTabsAddable(addable) {
|
|
393
357
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, addable }));
|
|
394
358
|
}
|
|
395
359
|
/** @internal - shared empty base, so label merges over an unset key memoize. */
|
|
396
360
|
const NO_LABELS = {};
|
|
397
|
-
/**
|
|
398
|
-
* Merge ARIA labels into the cascade. Keys not provided keep their
|
|
399
|
-
* library defaults; per-instance overrides on the tab group still win.
|
|
400
|
-
* Pass a `Signal` to switch the language at runtime.
|
|
401
|
-
*
|
|
402
|
-
* @category common/tabs
|
|
403
|
-
*/
|
|
404
|
-
function withTabsAriaLabels(labels) {
|
|
405
|
-
return defineTabsConfigFeature((cfg) => ({
|
|
406
|
-
...cfg,
|
|
407
|
-
ariaLabels: createOverrideMerge(cfg.ariaLabels ?? NO_LABELS, labels),
|
|
408
|
-
}));
|
|
409
|
-
}
|
|
410
361
|
/**
|
|
411
362
|
* Merge the tablist / tab-panel `aria-roledescription` fallbacks into the
|
|
412
363
|
* cascade. Keys not provided keep their library defaults. Pass a `Signal`
|
|
413
364
|
* to switch the language at runtime.
|
|
414
|
-
*
|
|
415
|
-
* @category common/tabs
|
|
416
365
|
*/
|
|
417
366
|
function withTabsFallbackLabels(labels) {
|
|
418
367
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -423,8 +372,6 @@ function withTabsFallbackLabels(labels) {
|
|
|
423
372
|
/**
|
|
424
373
|
* Override the IO-debounce window (ms). See
|
|
425
374
|
* {@link CngxTabsConfig.overflowStabilizeMs}.
|
|
426
|
-
*
|
|
427
|
-
* @category common/tabs
|
|
428
375
|
*/
|
|
429
376
|
function withTabOverflowStabilizeMs(ms) {
|
|
430
377
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -435,8 +382,6 @@ function withTabOverflowStabilizeMs(ms) {
|
|
|
435
382
|
/**
|
|
436
383
|
* Override the worst-case staleness ceiling on the visibility-map
|
|
437
384
|
* commit. See {@link CngxTabsConfig.overflowMaxDeferMs}.
|
|
438
|
-
*
|
|
439
|
-
* @category common/tabs
|
|
440
385
|
*/
|
|
441
386
|
function withTabOverflowMaxDeferMs(ms) {
|
|
442
387
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -456,8 +401,6 @@ function withTabOverflowMaxDeferMs(ms) {
|
|
|
456
401
|
*
|
|
457
402
|
* providers: [provideTabsConfig(withTabOverflowTriggerTemplate(this.moreTrigger()))]
|
|
458
403
|
* ```
|
|
459
|
-
*
|
|
460
|
-
* @category common/tabs
|
|
461
404
|
*/
|
|
462
405
|
function withTabOverflowTriggerTemplate(template) {
|
|
463
406
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -468,8 +411,6 @@ function withTabOverflowTriggerTemplate(template) {
|
|
|
468
411
|
/**
|
|
469
412
|
* App-wide override for each row inside the overflow popover. \
|
|
470
413
|
* Middle tier; per-instance `*cngxTabOverflowItem` still wins.
|
|
471
|
-
*
|
|
472
|
-
* @category common/tabs
|
|
473
414
|
*/
|
|
474
415
|
function withTabOverflowItemTemplate(template) {
|
|
475
416
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -481,8 +422,6 @@ function withTabOverflowItemTemplate(template) {
|
|
|
481
422
|
* App-wide override for the error-badge decoration. Middle tier;
|
|
482
423
|
* per-instance `*cngxTabErrorBadge` still wins. Sibling of the
|
|
483
424
|
* stepper family's `withStepBadgeTemplate`.
|
|
484
|
-
*
|
|
485
|
-
* @category common/tabs
|
|
486
425
|
*/
|
|
487
426
|
function withTabErrorBadgeTemplate(template) {
|
|
488
427
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -495,8 +434,6 @@ function withTabErrorBadgeTemplate(template) {
|
|
|
495
434
|
* tier; \
|
|
496
435
|
* per-instance `*cngxTabRejectionIcon` still wins. Sibling
|
|
497
436
|
* of {@link withStepRejectionTemplate}.
|
|
498
|
-
*
|
|
499
|
-
* @category common/tabs
|
|
500
437
|
*/
|
|
501
438
|
function withTabRejectionIconTemplate(template) {
|
|
502
439
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -508,8 +445,6 @@ function withTabRejectionIconTemplate(template) {
|
|
|
508
445
|
* App-wide override for the commit-pending busy-spinner overlay.
|
|
509
446
|
* Middle tier; per-instance `*cngxTabBusySpinner` still wins.
|
|
510
447
|
* Sibling of {@link withStepBusySpinnerTemplate}.
|
|
511
|
-
*
|
|
512
|
-
* @category common/tabs
|
|
513
448
|
*/
|
|
514
449
|
function withTabBusySpinnerTemplate(template) {
|
|
515
450
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -521,8 +456,6 @@ function withTabBusySpinnerTemplate(template) {
|
|
|
521
456
|
* App-wide override for the tab-icon slot. Middle tier of the 3-stage
|
|
522
457
|
* cascade; per-instance `*cngxTabIcon` still wins. Sibling of
|
|
523
458
|
* {@link withStepIndicatorTemplate}.
|
|
524
|
-
*
|
|
525
|
-
* @category common/tabs
|
|
526
459
|
*/
|
|
527
460
|
function withTabIconTemplate(template) {
|
|
528
461
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -533,8 +466,6 @@ function withTabIconTemplate(template) {
|
|
|
533
466
|
/**
|
|
534
467
|
* App-wide override for a tab's close-button glyph. Middle tier;
|
|
535
468
|
* per-instance `*cngxTabCloseIcon` still wins.
|
|
536
|
-
*
|
|
537
|
-
* @category common/tabs
|
|
538
469
|
*/
|
|
539
470
|
function withTabCloseIconTemplate(template) {
|
|
540
471
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -545,8 +476,6 @@ function withTabCloseIconTemplate(template) {
|
|
|
545
476
|
/**
|
|
546
477
|
* App-wide override for the add-tab button glyph. Middle tier;
|
|
547
478
|
* per-instance `*cngxTabAddIcon` still wins.
|
|
548
|
-
*
|
|
549
|
-
* @category common/tabs
|
|
550
479
|
*/
|
|
551
480
|
function withTabAddIconTemplate(template) {
|
|
552
481
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -562,7 +491,6 @@ function tabsConfigDefaultsFromPack() {
|
|
|
562
491
|
const language = injectTabsLanguage();
|
|
563
492
|
return {
|
|
564
493
|
...TABS_CONFIG_DEFAULTS,
|
|
565
|
-
ariaLabels: computed(() => ({ tabsRegion: language().tabsRegion }), { equal: recordEqual }),
|
|
566
494
|
fallbackLabels: computed(() => ({
|
|
567
495
|
tabRoleDescription: language().tabRoleDescription,
|
|
568
496
|
tabPanelRoleDescription: language().tabPanelRoleDescription,
|
|
@@ -577,8 +505,6 @@ function resolveFeatures(features) {
|
|
|
577
505
|
* Root-level provider. Apply once in `bootstrapApplication` /
|
|
578
506
|
* `appConfig.providers`. Returns {@link EnvironmentProviders} per
|
|
579
507
|
* the canonical cngx config-cascade signature.
|
|
580
|
-
*
|
|
581
|
-
* @category common/tabs
|
|
582
508
|
*/
|
|
583
509
|
function provideTabsConfig(...features) {
|
|
584
510
|
return makeEnvironmentProviders([
|
|
@@ -596,16 +522,12 @@ function provideTabsConfig(...features) {
|
|
|
596
522
|
* viewProviders: [...provideTabsConfigAt(withTabsDefaultOrientation('vertical'))],
|
|
597
523
|
* })
|
|
598
524
|
* ```
|
|
599
|
-
*
|
|
600
|
-
* @category common/tabs
|
|
601
525
|
*/
|
|
602
526
|
function provideTabsConfigAt(...features) {
|
|
603
527
|
return [{ provide: CNGX_TABS_CONFIG, useFactory: () => resolveFeatures(features) }];
|
|
604
528
|
}
|
|
605
529
|
/**
|
|
606
530
|
* Inject the resolved tabs config in an injection context.
|
|
607
|
-
*
|
|
608
|
-
* @category common/tabs
|
|
609
531
|
*/
|
|
610
532
|
function injectTabsConfig() {
|
|
611
533
|
return inject(CNGX_TABS_CONFIG);
|
|
@@ -613,10 +535,10 @@ function injectTabsConfig() {
|
|
|
613
535
|
|
|
614
536
|
/**
|
|
615
537
|
* Wraps a {@link CngxCommitController} with the action-shape adapter
|
|
616
|
-
* that
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
538
|
+
* that resolves `Observable<boolean>` / `Promise<boolean>` / `boolean`
|
|
539
|
+
* returns into one {@link CngxTabsCommitResolution}: `true` accepts,
|
|
540
|
+
* `false` refuses (the controller settles to `'idle'` and stores no
|
|
541
|
+
* error), a throw fails.
|
|
620
542
|
*/
|
|
621
543
|
function createTabsCommitHandler(opts) {
|
|
622
544
|
const { controller } = opts;
|
|
@@ -624,8 +546,9 @@ function createTabsCommitHandler(opts) {
|
|
|
624
546
|
isCommitting: controller.isCommitting,
|
|
625
547
|
beginTransition(fromIndex, toIndex, action, onResolve) {
|
|
626
548
|
controller.begin((handlers) => runTabsAction(action, fromIndex, toIndex, handlers), toIndex, fromIndex, {
|
|
627
|
-
onSuccess: () => onResolve(
|
|
628
|
-
onError: () => onResolve(
|
|
549
|
+
onSuccess: () => onResolve('accepted'),
|
|
550
|
+
onError: () => onResolve('failed'),
|
|
551
|
+
onRefused: () => onResolve('refused'),
|
|
629
552
|
});
|
|
630
553
|
},
|
|
631
554
|
cancel() {
|
|
@@ -644,7 +567,7 @@ function runTabsAction(action, fromIndex, toIndex, handlers) {
|
|
|
644
567
|
handlers.onSuccess(toIndex);
|
|
645
568
|
}
|
|
646
569
|
else {
|
|
647
|
-
handlers.
|
|
570
|
+
handlers.onRefused();
|
|
648
571
|
}
|
|
649
572
|
};
|
|
650
573
|
const safeError = (err) => {
|
|
@@ -692,7 +615,9 @@ function runTabsAction(action, fromIndex, toIndex, handlers) {
|
|
|
692
615
|
// EMPTY-style sources complete without emitting; without this arm
|
|
693
616
|
// the commit stays 'pending' forever and busy() latches true.
|
|
694
617
|
if (!done) {
|
|
695
|
-
safeError(new
|
|
618
|
+
safeError(new CngxRuntimeError('CNGX1059', typeof ngDevMode !== 'undefined' &&
|
|
619
|
+
ngDevMode &&
|
|
620
|
+
'[cngxTabGroup] commitAction completed without emitting true or false.'));
|
|
696
621
|
}
|
|
697
622
|
},
|
|
698
623
|
});
|
|
@@ -723,9 +648,8 @@ function runTabsAction(action, fromIndex, toIndex, handlers) {
|
|
|
723
648
|
* - `CNGX_ARRAY_COMMIT_HANDLER_FACTORY` (select) and
|
|
724
649
|
* - `CNGX_STEPPER_COMMIT_HANDLER_FACTORY`.
|
|
725
650
|
*
|
|
726
|
-
* @category common/tabs
|
|
727
651
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/commit-handler.ts
|
|
728
|
-
* @since 0.
|
|
652
|
+
* @since 0.3.0
|
|
729
653
|
*/
|
|
730
654
|
const CNGX_TABS_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxTabsCommitHandlerFactory', {
|
|
731
655
|
providedIn: 'root',
|
|
@@ -739,12 +663,29 @@ const CNGX_TABS_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxTabsCommitHandl
|
|
|
739
663
|
* `select()`, roving stop derived from `activeId`) through
|
|
740
664
|
* `createTabKeyboardNav`.
|
|
741
665
|
*
|
|
742
|
-
* @category common/tabs
|
|
743
666
|
* @wcag AA
|
|
744
667
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-group-host.token.ts
|
|
745
|
-
* @since 0.
|
|
668
|
+
* @since 0.3.0
|
|
746
669
|
*/
|
|
747
670
|
const CNGX_TAB_GROUP_HOST = new InjectionToken('CngxTabGroupHost');
|
|
671
|
+
/**
|
|
672
|
+
* Inject the {@link CNGX_TAB_GROUP_HOST} for a tab add-on directive, from
|
|
673
|
+
* its own element or an ancestor in the same template. Throws a
|
|
674
|
+
* `CngxRuntimeError` with code `CNGX1055` when there is none, in development
|
|
675
|
+
* and production alike. `selector` names the add-on in the development
|
|
676
|
+
* message.
|
|
677
|
+
*
|
|
678
|
+
* @internal
|
|
679
|
+
*/
|
|
680
|
+
function injectTabGroupHost(selector) {
|
|
681
|
+
const group = inject(CNGX_TAB_GROUP_HOST, { host: true, optional: true });
|
|
682
|
+
if (!group) {
|
|
683
|
+
throw new CngxRuntimeError('CNGX1055', typeof ngDevMode !== 'undefined' &&
|
|
684
|
+
ngDevMode &&
|
|
685
|
+
`[${selector}] must be placed on or inside an element with [cngxTabGroup], such as <cngx-tab-group> or <cngx-tab-nav>.`);
|
|
686
|
+
}
|
|
687
|
+
return group;
|
|
688
|
+
}
|
|
748
689
|
|
|
749
690
|
/**
|
|
750
691
|
* Tab-group presenter - brain of every CNGX tab flow. \
|
|
@@ -758,26 +699,31 @@ const CNGX_TAB_GROUP_HOST = new InjectionToken('CngxTabGroupHost');
|
|
|
758
699
|
* Directive-only - organisms compose via `hostDirectives`, consumers attach
|
|
759
700
|
* `[cngxTabGroup]` directly.
|
|
760
701
|
*
|
|
761
|
-
* @category common/tabs
|
|
762
|
-
* @docsKind primary
|
|
763
702
|
* @wcag AA
|
|
764
703
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/presenter.directive.ts
|
|
765
|
-
* @since 0.
|
|
704
|
+
* @since 0.3.0
|
|
766
705
|
* @relatedTo CngxTab, CngxTabContent, CngxTabLabel, CngxTabsFragmentSync
|
|
767
|
-
* <example-url
|
|
706
|
+
* <example-url>/#/ui/tabs/tab-commit-action/optimistic-pessimistic-commits-with-bridge-directives</example-url>
|
|
768
707
|
*/
|
|
769
708
|
class CngxTabGroupPresenter {
|
|
770
709
|
config = injectTabsConfig();
|
|
710
|
+
/**
|
|
711
|
+
* Zero-based index of the active tab, two-way bindable as `[(activeIndex)]`. Defaults to `0`. The
|
|
712
|
+
* presenter writes it on navigation, so with a `commitAction` in `'pessimistic'` mode it changes only
|
|
713
|
+
* after the action resolves `true`; `activeId` reads it clamped to the registered tab count.
|
|
714
|
+
*/
|
|
771
715
|
activeIndex = model(0, ...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
772
716
|
/**
|
|
773
|
-
*
|
|
774
|
-
* the resolved
|
|
717
|
+
* Axis of the tab list: `'horizontal'` or `'vertical'`, bound as `[orientation]`. The tab organisms
|
|
718
|
+
* reflect the resolved value as `aria-orientation` and `data-orientation`. Unbound, the
|
|
719
|
+
* {@link orientation} computed falls back to the tabs config `defaultOrientation`, then `'horizontal'`.
|
|
775
720
|
*/
|
|
776
721
|
orientationInput = input(undefined, { ...(ngDevMode ? { debugName: "orientationInput" } : /* istanbul ignore next */ {}), alias: 'orientation' });
|
|
777
722
|
orientation = computed(() => this.orientationInput() ?? this.config.defaultOrientation ?? 'horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
778
723
|
/**
|
|
779
|
-
*
|
|
780
|
-
*
|
|
724
|
+
* Whether `selectNext` and `selectPrevious` wrap from the last enabled tab to the first and back,
|
|
725
|
+
* bound as `[loop]`. Unbound, the {@link loop} computed falls back to the tabs config `defaultLoop`,
|
|
726
|
+
* then `true`.
|
|
781
727
|
*/
|
|
782
728
|
loopInput = input(undefined, { ...(ngDevMode ? { debugName: "loopInput" } : /* istanbul ignore next */ {}), alias: 'loop' });
|
|
783
729
|
loop = computed(() => this.loopInput() ?? this.config.defaultLoop ?? true, ...(ngDevMode ? [{ debugName: "loop" }] : /* istanbul ignore next */ []));
|
|
@@ -788,19 +734,19 @@ class CngxTabGroupPresenter {
|
|
|
788
734
|
* semantics come from the commit-controller - a rapid second
|
|
789
735
|
* `select(...)` cancels the in-flight runner.
|
|
790
736
|
*
|
|
791
|
-
* @
|
|
792
|
-
* the
|
|
737
|
+
* Bound as `[commitAction]`. The {@link commitAction} computed resolves the input first, then the
|
|
738
|
+
* `CNGX_TABS_COMMIT_ACTION` DI fallback used by the router sync, then `null`; there is no config
|
|
739
|
+
* tier.
|
|
793
740
|
*/
|
|
794
741
|
commitActionInput = input(null, { ...(ngDevMode ? { debugName: "commitActionInput" } : /* istanbul ignore next */ {}), alias: 'commitAction' });
|
|
795
742
|
/**
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
* action to confirm.
|
|
743
|
+
* Whether a tab change lands before (`'optimistic'`) or after (`'pessimistic'`) the commit action
|
|
744
|
+
* resolves, bound as `[commitMode]`. A tab change is navigation, not a save, so the default is
|
|
745
|
+
* `'optimistic'`; choose `'pessimistic'` when the new tab must wait for the action to confirm.
|
|
800
746
|
*
|
|
801
|
-
* @
|
|
802
|
-
* the
|
|
803
|
-
*
|
|
747
|
+
* The {@link commitMode} computed lets the mode of an active `CNGX_TABS_COMMIT_ACTION` DI fallback
|
|
748
|
+
* win (the routed path pins `'pessimistic'`); otherwise it resolves the input, then the tabs config
|
|
749
|
+
* `defaultCommitMode`, then `'optimistic'`.
|
|
804
750
|
*/
|
|
805
751
|
commitModeInput = input(undefined, { ...(ngDevMode ? { debugName: "commitModeInput" } : /* istanbul ignore next */ {}), alias: 'commitMode' });
|
|
806
752
|
injector = inject(Injector);
|
|
@@ -871,12 +817,24 @@ class CngxTabGroupPresenter {
|
|
|
871
817
|
* the tracker's `linkedSignal` is allocated once per presenter.
|
|
872
818
|
*/
|
|
873
819
|
commitTransition = createTransitionTracker(() => this.commitController.state.status());
|
|
874
|
-
// Persistence-of-
|
|
875
|
-
// and `originIndexDuringCommit` for the contract.
|
|
876
|
-
|
|
820
|
+
// Persistence-of-rejection surface - see `CngxTabGroupHost.lastOutcome`,
|
|
821
|
+
// `lastFailedIndex` and `originIndexDuringCommit` for the contract. Two
|
|
822
|
+
// event sources, never synced: the settle record and the sequence whose
|
|
823
|
+
// visual marker was cleared. `lastFailedIndex` derives from both, so
|
|
824
|
+
// clearing the marker never touches the announcement record.
|
|
825
|
+
lastOutcomeState = signal(undefined, ...(ngDevMode ? [{ debugName: "lastOutcomeState" }] : /* istanbul ignore next */ []));
|
|
826
|
+
clearedSequenceState = signal(undefined, ...(ngDevMode ? [{ debugName: "clearedSequenceState" }] : /* istanbul ignore next */ []));
|
|
827
|
+
// Bumped once per settled refusal or failure. Plain field - only read
|
|
828
|
+
// inside the resolve handler.
|
|
829
|
+
outcomeSequence = 0;
|
|
877
830
|
originIndexDuringCommitState = signal(undefined, ...(ngDevMode ? [{ debugName: "originIndexDuringCommitState" }] : /* istanbul ignore next */ []));
|
|
831
|
+
/** {@inheritDoc CngxTabGroupHost.lastOutcome} */
|
|
832
|
+
lastOutcome = this.lastOutcomeState.asReadonly();
|
|
878
833
|
/** {@inheritDoc CngxTabGroupHost.lastFailedIndex} */
|
|
879
|
-
lastFailedIndex =
|
|
834
|
+
lastFailedIndex = computed(() => {
|
|
835
|
+
const outcome = this.lastOutcomeState();
|
|
836
|
+
return outcome && outcome.sequence !== this.clearedSequenceState() ? outcome.index : undefined;
|
|
837
|
+
}, ...(ngDevMode ? [{ debugName: "lastFailedIndex" }] : /* istanbul ignore next */ []));
|
|
880
838
|
/** {@inheritDoc CngxTabGroupHost.originIndexDuringCommit} */
|
|
881
839
|
originIndexDuringCommit = this.originIndexDuringCommitState.asReadonly();
|
|
882
840
|
tabsState = signal([], { ...(ngDevMode ? { debugName: "tabsState" } : /* istanbul ignore next */ {}), equal: tabsEqual });
|
|
@@ -889,6 +847,11 @@ class CngxTabGroupPresenter {
|
|
|
889
847
|
return Math.max(0, Math.min(this.activeIndex(), count - 1));
|
|
890
848
|
}, ...(ngDevMode ? [{ debugName: "clampedIndex" }] : /* istanbul ignore next */ []));
|
|
891
849
|
activeId = computed(() => this.tabs()[this.clampedIndex()]?.id ?? null, { ...(ngDevMode ? { debugName: "activeId" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
850
|
+
/**
|
|
851
|
+
* `CngxTabGroupHost` contract, called by `CngxTab` in its `ngOnInit` and by `CngxTabLink`. Appends the
|
|
852
|
+
* handle to the tab list in registration order; a second call with a known id replaces the stored
|
|
853
|
+
* handle and keeps its position.
|
|
854
|
+
*/
|
|
892
855
|
register(handle) {
|
|
893
856
|
const current = this.tabsState();
|
|
894
857
|
const idx = current.findIndex((h) => h.id === handle.id);
|
|
@@ -900,6 +863,11 @@ class CngxTabGroupPresenter {
|
|
|
900
863
|
}
|
|
901
864
|
this.tabsState.set([...current, handle]);
|
|
902
865
|
}
|
|
866
|
+
/**
|
|
867
|
+
* `CngxTabGroupHost` contract, called from the destroy hook of `CngxTab` and `CngxTabLink`. Removes the
|
|
868
|
+
* tab from the list; when `handle` is passed and is no longer the stored one (it was replaced by a
|
|
869
|
+
* re-register), the call does nothing.
|
|
870
|
+
*/
|
|
903
871
|
unregister(id, handle) {
|
|
904
872
|
const current = this.tabsState();
|
|
905
873
|
const entry = current.find((h) => h.id === id);
|
|
@@ -915,8 +883,13 @@ class CngxTabGroupPresenter {
|
|
|
915
883
|
}
|
|
916
884
|
/** {@inheritDoc CngxTabGroupHost.clearLastFailed} */
|
|
917
885
|
clearLastFailed() {
|
|
918
|
-
this.
|
|
886
|
+
this.clearedSequenceState.set(this.lastOutcomeState()?.sequence);
|
|
919
887
|
}
|
|
888
|
+
/**
|
|
889
|
+
* Activates the tab at the given index, clamped to the registered range. Does nothing when the target is
|
|
890
|
+
* the active tab or is disabled. Without a `commitAction` the change is synchronous; with one, it follows
|
|
891
|
+
* `commitMode`, and a newer call supersedes the pending one.
|
|
892
|
+
*/
|
|
920
893
|
select(index) {
|
|
921
894
|
const tabs = this.tabs();
|
|
922
895
|
if (tabs.length === 0) {
|
|
@@ -936,8 +909,8 @@ class CngxTabGroupPresenter {
|
|
|
936
909
|
// untouched, so a stale origin can never leak into the
|
|
937
910
|
// live-region announcement.
|
|
938
911
|
this.activeIndex.set(target);
|
|
939
|
-
if (this.
|
|
940
|
-
this.
|
|
912
|
+
if (this.lastFailedIndex() === target) {
|
|
913
|
+
this.clearLastFailed();
|
|
941
914
|
}
|
|
942
915
|
return;
|
|
943
916
|
}
|
|
@@ -948,31 +921,38 @@ class CngxTabGroupPresenter {
|
|
|
948
921
|
if (mode === 'optimistic') {
|
|
949
922
|
this.activeIndex.set(target);
|
|
950
923
|
}
|
|
951
|
-
this.commitHandler.beginTransition(previous, target, action, (
|
|
952
|
-
if (
|
|
924
|
+
this.commitHandler.beginTransition(previous, target, action, (outcome) => {
|
|
925
|
+
if (outcome === 'accepted') {
|
|
953
926
|
// Window closes on success - origin label no longer needed;
|
|
954
|
-
// clear the rejection
|
|
955
|
-
// target successfully.
|
|
927
|
+
// clear the rejection marker if the user re-picked the
|
|
928
|
+
// rejected target successfully.
|
|
956
929
|
this.originIndexDuringCommitState.set(undefined);
|
|
957
|
-
if (this.
|
|
958
|
-
this.
|
|
930
|
+
if (this.lastFailedIndex() === target) {
|
|
931
|
+
this.clearLastFailed();
|
|
959
932
|
}
|
|
960
933
|
if (mode === 'pessimistic') {
|
|
961
934
|
this.activeIndex.set(target);
|
|
962
935
|
}
|
|
936
|
+
return;
|
|
963
937
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
938
|
+
// Refused or failed - record the outcome on the target; RETAIN the
|
|
939
|
+
// origin so the announcements can resolve the origin label for the
|
|
940
|
+
// rich phrase. Both kinds roll back: optimistic returns to the
|
|
941
|
+
// origin, pessimistic never moved.
|
|
942
|
+
this.lastOutcomeState.set({
|
|
943
|
+
kind: outcome,
|
|
944
|
+
index: target,
|
|
945
|
+
sequence: ++this.outcomeSequence,
|
|
946
|
+
});
|
|
947
|
+
if (mode === 'optimistic') {
|
|
948
|
+
this.activeIndex.set(previous);
|
|
973
949
|
}
|
|
974
950
|
});
|
|
975
951
|
}
|
|
952
|
+
/**
|
|
953
|
+
* Activates the next enabled tab after the active one, through `select`. At the end of the list it wraps
|
|
954
|
+
* to the first enabled tab when `loop` is on, otherwise it does nothing.
|
|
955
|
+
*/
|
|
976
956
|
selectNext() {
|
|
977
957
|
const tabs = this.tabs();
|
|
978
958
|
if (tabs.length === 0) {
|
|
@@ -996,6 +976,10 @@ class CngxTabGroupPresenter {
|
|
|
996
976
|
}
|
|
997
977
|
}
|
|
998
978
|
}
|
|
979
|
+
/**
|
|
980
|
+
* Activates the previous enabled tab before the active one, through `select`. At the start of the list it
|
|
981
|
+
* wraps to the last enabled tab when `loop` is on, otherwise it does nothing.
|
|
982
|
+
*/
|
|
999
983
|
selectPrevious() {
|
|
1000
984
|
const tabs = this.tabs();
|
|
1001
985
|
if (tabs.length === 0) {
|
|
@@ -1019,6 +1003,9 @@ class CngxTabGroupPresenter {
|
|
|
1019
1003
|
}
|
|
1020
1004
|
}
|
|
1021
1005
|
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Activates the tab registered under the given id, through `select`. Unknown ids are ignored.
|
|
1008
|
+
*/
|
|
1022
1009
|
selectById(id) {
|
|
1023
1010
|
const tabs = this.tabs();
|
|
1024
1011
|
const idx = tabs.findIndex((h) => h.id === id);
|
|
@@ -1026,6 +1013,12 @@ class CngxTabGroupPresenter {
|
|
|
1026
1013
|
this.select(idx);
|
|
1027
1014
|
}
|
|
1028
1015
|
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Asks to close the tab with the given id: when an earlier tab closes it shifts `activeIndex` and the
|
|
1018
|
+
* rejection markers so the same tab stays active; closing the active tab hands over to its neighbour.
|
|
1019
|
+
* Then emits `tabClose` with the id and index. It does not remove the tab; the consumer
|
|
1020
|
+
* drops it from its own data in the `(tabClose)` handler. Unknown ids are ignored.
|
|
1021
|
+
*/
|
|
1029
1022
|
requestClose(id) {
|
|
1030
1023
|
const tabs = this.tabs();
|
|
1031
1024
|
const index = tabs.findIndex((h) => h.id === id);
|
|
@@ -1052,12 +1045,17 @@ class CngxTabGroupPresenter {
|
|
|
1052
1045
|
// The rejection markers are flat indices into the same registry, so a
|
|
1053
1046
|
// close before them drifts the decoration onto the wrong tab (reachable
|
|
1054
1047
|
// only via the dismissable affordance the organism layers on top). Shift
|
|
1055
|
-
// them the same way `activeIndex` shifts, and drop the
|
|
1056
|
-
// when its own tab is the one closed.
|
|
1057
|
-
|
|
1048
|
+
// them the same way `activeIndex` shifts, and drop the outcome outright
|
|
1049
|
+
// when its own tab is the one closed. A shift copies the sequence, so
|
|
1050
|
+
// nothing downstream treats it as a new outcome.
|
|
1051
|
+
this.lastOutcomeState.update((outcome) => shiftOutcomeOnClose(outcome, index));
|
|
1058
1052
|
this.originIndexDuringCommitState.update((origin) => shiftIndexOnClose(origin, index));
|
|
1059
1053
|
this.tabClose.emit({ id, index });
|
|
1060
1054
|
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Emits `tabAdd`. The presenter creates no tab; the consumer appends one to its own data in the
|
|
1057
|
+
* `(tabAdd)` handler.
|
|
1058
|
+
*/
|
|
1061
1059
|
requestAdd() {
|
|
1062
1060
|
this.tabAdd.emit();
|
|
1063
1061
|
}
|
|
@@ -1094,6 +1092,23 @@ function shiftIndexOnClose(stored, removed) {
|
|
|
1094
1092
|
}
|
|
1095
1093
|
return removed < stored ? stored - 1 : stored;
|
|
1096
1094
|
}
|
|
1095
|
+
/**
|
|
1096
|
+
* {@link shiftIndexOnClose} for a settle record: the same object when the
|
|
1097
|
+
* index stays put (no re-emission), a copy with the shifted index and the
|
|
1098
|
+
* SAME sequence when it moves, `undefined` when its own tab is closed.
|
|
1099
|
+
*
|
|
1100
|
+
* @internal
|
|
1101
|
+
*/
|
|
1102
|
+
function shiftOutcomeOnClose(outcome, removed) {
|
|
1103
|
+
if (outcome === undefined) {
|
|
1104
|
+
return undefined;
|
|
1105
|
+
}
|
|
1106
|
+
const index = shiftIndexOnClose(outcome.index, removed);
|
|
1107
|
+
if (index === undefined) {
|
|
1108
|
+
return undefined;
|
|
1109
|
+
}
|
|
1110
|
+
return index === outcome.index ? outcome : { ...outcome, index };
|
|
1111
|
+
}
|
|
1097
1112
|
/**
|
|
1098
1113
|
* Registry equality for the tab registry signal: element-wise reference
|
|
1099
1114
|
* identity, not structural comparison. Two arrays are equal only when
|
|
@@ -1131,10 +1146,9 @@ function tabsEqual(a, b) {
|
|
|
1131
1146
|
* The overflow molecule and consumer-authored skin sub-components inject this
|
|
1132
1147
|
* instead of the concrete component class.
|
|
1133
1148
|
*
|
|
1134
|
-
* @category common/tabs
|
|
1135
1149
|
* @wcag AA
|
|
1136
1150
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-panel-host.token.ts
|
|
1137
|
-
* @since 0.
|
|
1151
|
+
* @since 0.3.0
|
|
1138
1152
|
*/
|
|
1139
1153
|
const CNGX_TAB_PANEL_HOST = new InjectionToken('CngxTabPanelHost');
|
|
1140
1154
|
|
|
@@ -1173,10 +1187,9 @@ const CNGX_TAB_PANEL_HOST = new InjectionToken('CngxTabPanelHost');
|
|
|
1173
1187
|
* export class MySectionNav {}
|
|
1174
1188
|
* ```
|
|
1175
1189
|
*
|
|
1176
|
-
* @category common/tabs
|
|
1177
1190
|
* @wcag AA
|
|
1178
1191
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-nav-host.token.ts
|
|
1179
|
-
* @since 0.
|
|
1192
|
+
* @since 0.3.0
|
|
1180
1193
|
* @relatedTo CngxTabsRouteSync, CNGX_TAB_GROUP_HOST, CngxTabNav, CngxMatTabNav
|
|
1181
1194
|
*/
|
|
1182
1195
|
const CNGX_TAB_NAV_HOST = new InjectionToken('CngxTabNavHost');
|
|
@@ -1287,8 +1300,6 @@ function resolveByPrefix(ctx) {
|
|
|
1287
1300
|
*
|
|
1288
1301
|
* Pure: no injection context, no signal reads. The directive resolves the
|
|
1289
1302
|
* mode cascade and the tab registry, then hands both in.
|
|
1290
|
-
*
|
|
1291
|
-
* @category common/tabs
|
|
1292
1303
|
*/
|
|
1293
1304
|
function createTabUrlMatch() {
|
|
1294
1305
|
return {
|
|
@@ -1311,10 +1322,9 @@ function createTabUrlMatch() {
|
|
|
1311
1322
|
* navigation a tab switch performs is already swappable, so the read that
|
|
1312
1323
|
* mirrors navigation back onto `activeIndex` should be too.
|
|
1313
1324
|
*
|
|
1314
|
-
* @category common/tabs
|
|
1315
1325
|
* @wcag AA
|
|
1316
1326
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/url-match.ts
|
|
1317
|
-
* @since 0.
|
|
1327
|
+
* @since 0.3.0
|
|
1318
1328
|
* @relatedTo CngxTabsRouteSync, createTabUrlMatch, createTabRouterCommit
|
|
1319
1329
|
*/
|
|
1320
1330
|
const CNGX_TAB_URL_MATCH_STRATEGY = new InjectionToken('CngxTabUrlMatchStrategy', {
|
|
@@ -1335,10 +1345,9 @@ const CNGX_TAB_URL_MATCH_STRATEGY = new InjectionToken('CngxTabUrlMatchStrategy'
|
|
|
1335
1345
|
* </div>
|
|
1336
1346
|
* ```
|
|
1337
1347
|
*
|
|
1338
|
-
* @category common/tabs
|
|
1339
1348
|
* @wcag AA
|
|
1340
1349
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-content.directive.ts
|
|
1341
|
-
* @since 0.
|
|
1350
|
+
* @since 0.3.0
|
|
1342
1351
|
* @relatedTo CngxTab, CngxTabLabel
|
|
1343
1352
|
*/
|
|
1344
1353
|
class CngxTabContent {
|
|
@@ -1367,10 +1376,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1367
1376
|
* </div>
|
|
1368
1377
|
* ```
|
|
1369
1378
|
*
|
|
1370
|
-
* @category common/tabs
|
|
1371
1379
|
* @wcag AA
|
|
1372
1380
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-label.directive.ts
|
|
1373
|
-
* @since 0.
|
|
1381
|
+
* @since 0.3.0
|
|
1374
1382
|
* @relatedTo CngxTab, CngxTabContent
|
|
1375
1383
|
*/
|
|
1376
1384
|
class CngxTabLabel {
|
|
@@ -1404,12 +1412,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1404
1412
|
* </div>
|
|
1405
1413
|
* ```
|
|
1406
1414
|
*
|
|
1407
|
-
* @category common/tabs/slots
|
|
1408
1415
|
* @wcag AA
|
|
1409
1416
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-sub-label.directive.ts
|
|
1410
|
-
* @since 0.
|
|
1417
|
+
* @since 0.3.0
|
|
1411
1418
|
* @relatedTo CngxTab, CngxTabLabel, CngxTabContent
|
|
1412
|
-
* <example-url
|
|
1419
|
+
* <example-url>/#/ui/tabs/tab-sub-label/label-with-count</example-url>
|
|
1413
1420
|
*/
|
|
1414
1421
|
class CngxTabSubLabel {
|
|
1415
1422
|
/**
|
|
@@ -1445,19 +1452,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1445
1452
|
* ... content templates here ...
|
|
1446
1453
|
* </div>
|
|
1447
1454
|
* ```
|
|
1448
|
-
* @category common/tabs
|
|
1449
|
-
* @docsKind primary
|
|
1450
1455
|
* @wcag AA
|
|
1451
1456
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab.directive.ts
|
|
1452
|
-
* @since 0.
|
|
1457
|
+
* @since 0.3.0
|
|
1453
1458
|
* @relatedTo CngxTabGroupPresenter, CngxTabLabel, CngxTabContent, CngxTabErrorBadge
|
|
1454
1459
|
* @slot cngxTabLabel The tab's own header label.
|
|
1455
1460
|
* @slot cngxTabSubLabel Secondary line under the label, e.g. a count or status.
|
|
1456
1461
|
* @slot cngxTabContent The panel body, rendered lazily when the tab activates.
|
|
1457
1462
|
*/
|
|
1458
1463
|
class CngxTab {
|
|
1464
|
+
/**
|
|
1465
|
+
* Identifier the tab registers under with its group. Defaults to an auto-generated `cngx-tab-` uid.
|
|
1466
|
+
* It is captured once in `ngOnInit`, so a later rebind does not re-register; `selectById`, the
|
|
1467
|
+
* `(tabClose)` event and the fragment-sync deep link match against it.
|
|
1468
|
+
*/
|
|
1459
1469
|
id = input(nextUid('cngx-tab-'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
1470
|
+
/**
|
|
1471
|
+
* Marks the tab as not selectable. Defaults to `false`. A disabled tab is skipped by next/previous
|
|
1472
|
+
* navigation and refused by `select`, and the strip header reflects it through `aria-disabled`.
|
|
1473
|
+
*/
|
|
1460
1474
|
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
1475
|
+
/**
|
|
1476
|
+
* Header text of the tab, shown in the strip. Defaults to `undefined`; the `*cngxTabLabel` slot
|
|
1477
|
+
* provides richer content.
|
|
1478
|
+
*/
|
|
1461
1479
|
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
1462
1480
|
/**
|
|
1463
1481
|
* Optional secondary text line under the primary label (a count, a
|
|
@@ -1466,6 +1484,11 @@ class CngxTab {
|
|
|
1466
1484
|
* richer content. Folds into the tab's accessible name.
|
|
1467
1485
|
*/
|
|
1468
1486
|
subLabel = input(undefined, ...(ngDevMode ? [{ debugName: "subLabel" }] : /* istanbul ignore next */ []));
|
|
1487
|
+
/**
|
|
1488
|
+
* Optional error aggregator for forms with several error sources. Defaults to `undefined`. The tab
|
|
1489
|
+
* counts as errored when the aggregator's `shouldShow()` is `true`, so a deferred-reveal validation stays
|
|
1490
|
+
* silent until it is revealed; it composes with `[error]`, either one errors the tab.
|
|
1491
|
+
*/
|
|
1469
1492
|
errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
|
|
1470
1493
|
/**
|
|
1471
1494
|
* Direct error flag for the common "this tab is invalid" case - no
|
|
@@ -1516,7 +1539,9 @@ class CngxTab {
|
|
|
1516
1539
|
selected = computed(() => this.host?.activeId() === this.id(), { ...(ngDevMode ? { debugName: "selected" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
1517
1540
|
constructor() {
|
|
1518
1541
|
if (!this.host) {
|
|
1519
|
-
throw new
|
|
1542
|
+
throw new CngxRuntimeError('CNGX1045', typeof ngDevMode !== 'undefined' &&
|
|
1543
|
+
ngDevMode &&
|
|
1544
|
+
'[cngxTab] must be placed inside <cngx-tab-group> or an element with [cngxTabGroup].');
|
|
1520
1545
|
}
|
|
1521
1546
|
}
|
|
1522
1547
|
ngOnInit() {
|
|
@@ -1570,8 +1595,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1570
1595
|
* There is no `select()` call - invoking it would re-enter the commit path the
|
|
1571
1596
|
* routed-nav model deliberately keeps dormant.
|
|
1572
1597
|
*
|
|
1573
|
-
* **Error communication is reactive:** `aria-invalid` plus
|
|
1574
|
-
*
|
|
1598
|
+
* **Error communication is reactive:** `aria-invalid` plus a leading
|
|
1599
|
+
* `aria-hidden` alert icon (`.cngx-tab-link__error-icon`, built from the
|
|
1600
|
+
* shared icon data) signal the state, and an injected screen-reader
|
|
1575
1601
|
* descriptor span (referenced by a permanent `aria-describedby`) carries the
|
|
1576
1602
|
* direct `[error]` message string so assistive tech reads *why* the link is
|
|
1577
1603
|
* invalid.
|
|
@@ -1583,11 +1609,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1583
1609
|
* </cngx-tab-nav>
|
|
1584
1610
|
* ```
|
|
1585
1611
|
*
|
|
1586
|
-
* @category common/tabs
|
|
1587
|
-
* @docsKind primary
|
|
1588
1612
|
* @wcag AA
|
|
1589
1613
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-link.directive.ts
|
|
1590
|
-
* @since 0.
|
|
1614
|
+
* @since 0.3.0
|
|
1591
1615
|
* @relatedTo CngxTabNav, CngxTabsRouteSync, CngxTab, CngxMatTabLink
|
|
1592
1616
|
*/
|
|
1593
1617
|
class CngxTabLink {
|
|
@@ -1664,9 +1688,13 @@ class CngxTabLink {
|
|
|
1664
1688
|
descriptorId = computed(() => `${this.id()}-desc`, ...(ngDevMode ? [{ debugName: "descriptorId" }] : /* istanbul ignore next */ []));
|
|
1665
1689
|
/** The injected descriptor `<span>`, created in {@link ngOnInit}. */
|
|
1666
1690
|
descriptorEl = null;
|
|
1691
|
+
/** The leading alert icon, present while {@link hasError} holds. */
|
|
1692
|
+
errorIconEl = null;
|
|
1667
1693
|
constructor() {
|
|
1668
1694
|
if (!this.host) {
|
|
1669
|
-
throw new
|
|
1695
|
+
throw new CngxRuntimeError('CNGX1045', typeof ngDevMode !== 'undefined' &&
|
|
1696
|
+
ngDevMode &&
|
|
1697
|
+
'[cngxTabLink] must be placed inside <cngx-tab-nav> or an element with [cngxTabGroup].');
|
|
1670
1698
|
}
|
|
1671
1699
|
// Mirror the direct-error message into the describedby span. DOM side
|
|
1672
1700
|
// effect only - no signal writes. Guards until the span exists (created
|
|
@@ -1677,6 +1705,11 @@ class CngxTabLink {
|
|
|
1677
1705
|
this.syncDescriptor(el);
|
|
1678
1706
|
}
|
|
1679
1707
|
});
|
|
1708
|
+
// The anchor is consumer DOM, so the alert icon is built here rather
|
|
1709
|
+
// than templated: leading child, `aria-hidden`, so the link's name and
|
|
1710
|
+
// its textContent stay the label alone. An after-render effect never
|
|
1711
|
+
// runs on the server, so hydration meets the template's own DOM.
|
|
1712
|
+
afterRenderEffect({ write: () => this.syncErrorIcon(this.hasError()) });
|
|
1680
1713
|
}
|
|
1681
1714
|
ngOnInit() {
|
|
1682
1715
|
// Register in ngOnInit, NOT the constructor: a dynamically-bound `[id]`
|
|
@@ -1713,6 +1746,30 @@ class CngxTabLink {
|
|
|
1713
1746
|
}
|
|
1714
1747
|
});
|
|
1715
1748
|
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Insert or remove the leading `aria-hidden` alert icon. The svg is
|
|
1751
|
+
* legible bare (see `createIconSvgElement`); a styled tab organism sizes
|
|
1752
|
+
* it through the `.cngx-tab-link__error-icon` hook.
|
|
1753
|
+
*/
|
|
1754
|
+
syncErrorIcon(show) {
|
|
1755
|
+
if (!show) {
|
|
1756
|
+
if (this.errorIconEl) {
|
|
1757
|
+
this.renderer.removeChild(this.hostEl, this.errorIconEl);
|
|
1758
|
+
this.errorIconEl = null;
|
|
1759
|
+
}
|
|
1760
|
+
return;
|
|
1761
|
+
}
|
|
1762
|
+
if (this.errorIconEl) {
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
const span = this.renderer.createElement('span');
|
|
1766
|
+
this.renderer.addClass(span, 'cngx-tab-link__error-icon');
|
|
1767
|
+
this.renderer.setAttribute(span, 'aria-hidden', 'true');
|
|
1768
|
+
const svg = createIconSvgElement(this.renderer, CNGX_ICON_ALERT, 'cngx-tab-link__icon-svg');
|
|
1769
|
+
this.renderer.appendChild(span, svg.element);
|
|
1770
|
+
this.renderer.insertBefore(this.hostEl, span, this.hostEl.firstChild);
|
|
1771
|
+
this.errorIconEl = span;
|
|
1772
|
+
}
|
|
1716
1773
|
/**
|
|
1717
1774
|
* Write the current direct-error message into the descriptor span and
|
|
1718
1775
|
* toggle its `aria-hidden` so a clear link exposes no description. Keeps
|
|
@@ -1760,8 +1817,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1760
1817
|
*
|
|
1761
1818
|
* @internal
|
|
1762
1819
|
*/
|
|
1763
|
-
function warnTabsRouterAbsent(
|
|
1764
|
-
|
|
1820
|
+
function warnTabsRouterAbsent(selector, enables) {
|
|
1821
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1824
|
+
cngxDevWarn('CNGX1031', `[${selector}] no Router / ActivatedRoute available - the URL sync is a no-op. ` +
|
|
1765
1825
|
`Provide @angular/router via provideRouter(...) to enable ${enables}.`);
|
|
1766
1826
|
}
|
|
1767
1827
|
|
|
@@ -1796,19 +1856,29 @@ function warnTabsRouterAbsent(directive, enables) {
|
|
|
1796
1856
|
* </cngx-tab-group>
|
|
1797
1857
|
* ```
|
|
1798
1858
|
*
|
|
1799
|
-
* @category common/tabs
|
|
1800
|
-
* @docsKind primary
|
|
1801
1859
|
* @wcag AA
|
|
1802
1860
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/router-sync.directive.ts
|
|
1803
|
-
* @since 0.
|
|
1861
|
+
* @since 0.3.0
|
|
1804
1862
|
* @relatedTo CngxTabGroupPresenter, CngxTab
|
|
1863
|
+
* @axis level organism
|
|
1805
1864
|
*/
|
|
1806
1865
|
class CngxTabsFragmentSync {
|
|
1807
1866
|
// Default undefined so the cascade resolves through CNGX_TABS_CONFIG.
|
|
1808
|
-
//
|
|
1809
|
-
//
|
|
1810
|
-
//
|
|
1867
|
+
// The resolved mode / param are read on every URL write and read, not
|
|
1868
|
+
// only at init; changing either after init applies to the next one and
|
|
1869
|
+
// leaves the previous key behind in the URL.
|
|
1870
|
+
/**
|
|
1871
|
+
* Binding `[mode]`: where the active tab id is kept in the URL, `'fragment'` (`#tab=settings`) or
|
|
1872
|
+
* `'queryParam'` (`?tab=settings`). Unset, it resolves through `fragmentSyncMode` of the tabs config and
|
|
1873
|
+
* then `'fragment'`. A change after init applies to the next URL write or read and leaves the previous
|
|
1874
|
+
* key in the URL.
|
|
1875
|
+
*/
|
|
1811
1876
|
modeInput = input(undefined, { ...(ngDevMode ? { debugName: "modeInput" } : /* istanbul ignore next */ {}), alias: 'mode' });
|
|
1877
|
+
/**
|
|
1878
|
+
* Binding `[paramName]`: name of the fragment or query key that carries the tab id. Unset, it resolves
|
|
1879
|
+
* through `fragmentSyncParam` of the tabs config and then `'tab'`. A change after init applies to the next URL write or read and leaves the previous
|
|
1880
|
+
* key in the URL.
|
|
1881
|
+
*/
|
|
1812
1882
|
paramNameInput = input(undefined, { ...(ngDevMode ? { debugName: "paramNameInput" } : /* istanbul ignore next */ {}), alias: 'paramName' });
|
|
1813
1883
|
config = injectTabsConfig();
|
|
1814
1884
|
mode = computed(() => this.modeInput() ?? this.config.fragmentSyncMode ?? 'fragment', ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
|
|
@@ -1824,7 +1894,7 @@ class CngxTabsFragmentSync {
|
|
|
1824
1894
|
* history entry.
|
|
1825
1895
|
*/
|
|
1826
1896
|
replaceUrl = input(true, ...(ngDevMode ? [{ debugName: "replaceUrl" }] : /* istanbul ignore next */ []));
|
|
1827
|
-
host =
|
|
1897
|
+
host = injectTabGroupHost('cngxTabsFragmentSync');
|
|
1828
1898
|
router = inject(Router, { optional: true });
|
|
1829
1899
|
/**
|
|
1830
1900
|
* Latched once the URL seed has reached a registered tab, so the
|
|
@@ -1840,8 +1910,13 @@ class CngxTabsFragmentSync {
|
|
|
1840
1910
|
*/
|
|
1841
1911
|
seeded = false;
|
|
1842
1912
|
constructor() {
|
|
1843
|
-
|
|
1844
|
-
|
|
1913
|
+
// Router is providedIn: 'root' and resolves without provideRouter(...);
|
|
1914
|
+
// ActivatedRoute does not, so it is the "router is set up" signal.
|
|
1915
|
+
const route = inject(ActivatedRoute, { optional: true });
|
|
1916
|
+
if (!this.router || !route) {
|
|
1917
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1918
|
+
afterNextRender(() => warnTabsRouterAbsent('cngxTabsFragmentSync', 'deep-linking'));
|
|
1919
|
+
}
|
|
1845
1920
|
return;
|
|
1846
1921
|
}
|
|
1847
1922
|
const router = this.router;
|
|
@@ -1995,9 +2070,17 @@ const cngxDefaultTabRoute = (handle) => [handle.id];
|
|
|
1995
2070
|
* resolves on this navigation's own `navigate()` promise:
|
|
1996
2071
|
*
|
|
1997
2072
|
* - resolved `true` (`NavigationEnd`) → `true` (commit the switch)
|
|
2073
|
+
* - resolved `null` (a skipped same-URL navigation, the route is
|
|
2074
|
+
* already active) → `true`
|
|
1998
2075
|
* - resolved `false` (`NavigationCancel` - a `CanDeactivate` guard
|
|
1999
|
-
* blocked, or a newer navigation superseded this one) → `false
|
|
2000
|
-
*
|
|
2076
|
+
* blocked, or a newer navigation superseded this one) → `false`, a
|
|
2077
|
+
* refused switch: nothing failed, the commit state stores no error
|
|
2078
|
+
* - rejected (`NavigationError` - a guard or resolver threw) → the
|
|
2079
|
+
* observable errors with the router's original error, a failed
|
|
2080
|
+
* switch: the commit state goes to `'error'` and keeps that error
|
|
2081
|
+
*
|
|
2082
|
+
* This is the router's own model: a guard answering `false` cancels,
|
|
2083
|
+
* only a throw is an error.
|
|
2001
2084
|
*
|
|
2002
2085
|
* Routed tabs reuse the presenter's commit lifecycle verbatim - the
|
|
2003
2086
|
* router navigation is simply the async op. \
|
|
@@ -2009,9 +2092,8 @@ const cngxDefaultTabRoute = (handle) => [handle.id];
|
|
|
2009
2092
|
* late promise resolution lands on the closed subscriber and is
|
|
2010
2093
|
* dropped by RxJS itself.
|
|
2011
2094
|
*
|
|
2012
|
-
* @category common/tabs
|
|
2013
2095
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/router-commit.ts
|
|
2014
|
-
* @since 0.
|
|
2096
|
+
* @since 0.3.0
|
|
2015
2097
|
*/
|
|
2016
2098
|
function createTabRouterCommit(opts) {
|
|
2017
2099
|
const routeFor = opts.routeFor ?? cngxDefaultTabRoute;
|
|
@@ -2032,9 +2114,11 @@ function createTabRouterCommit(opts) {
|
|
|
2032
2114
|
// already active, which commits.
|
|
2033
2115
|
subscriber.next(result !== false);
|
|
2034
2116
|
subscriber.complete();
|
|
2035
|
-
}, () => {
|
|
2036
|
-
|
|
2037
|
-
|
|
2117
|
+
}, (err) => {
|
|
2118
|
+
// A guard or resolver threw (`NavigationError`): a failure,
|
|
2119
|
+
// not a refusal. Hand the router's own error on so the commit
|
|
2120
|
+
// state stores what actually went wrong.
|
|
2121
|
+
subscriber.error(err);
|
|
2038
2122
|
});
|
|
2039
2123
|
});
|
|
2040
2124
|
}
|
|
@@ -2133,11 +2217,9 @@ function createTabRouterCommit(opts) {
|
|
|
2133
2217
|
* <router-outlet></router-outlet>
|
|
2134
2218
|
* ```
|
|
2135
2219
|
*
|
|
2136
|
-
* @category common/tabs
|
|
2137
|
-
* @docsKind primary
|
|
2138
2220
|
* @wcag AA
|
|
2139
2221
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/route-sync.directive.ts
|
|
2140
|
-
* @since 0.
|
|
2222
|
+
* @since 0.3.0
|
|
2141
2223
|
* @relatedTo CngxTabGroupPresenter, CngxTabsFragmentSync, createTabRouterCommit, CngxTabNav, CngxTabLink
|
|
2142
2224
|
*/
|
|
2143
2225
|
class CngxTabsRouteSync {
|
|
@@ -2167,7 +2249,7 @@ class CngxTabsRouteSync {
|
|
|
2167
2249
|
* replaces the policies themselves.
|
|
2168
2250
|
*/
|
|
2169
2251
|
match = input(undefined, ...(ngDevMode ? [{ debugName: "match" }] : /* istanbul ignore next */ []));
|
|
2170
|
-
host =
|
|
2252
|
+
host = injectTabGroupHost('cngxTabsRouteSync');
|
|
2171
2253
|
router = inject(Router, { optional: true });
|
|
2172
2254
|
navHost = inject(CNGX_TAB_NAV_HOST, { optional: true, host: true });
|
|
2173
2255
|
config = injectTabsConfig();
|
|
@@ -2183,13 +2265,13 @@ class CngxTabsRouteSync {
|
|
|
2183
2265
|
mode = signal('pessimistic', ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
|
|
2184
2266
|
/**
|
|
2185
2267
|
* Router commit-action read by the presenter via the DI fallback.
|
|
2186
|
-
* `null` when
|
|
2268
|
+
* `null` when the router is not set up (graceful no-op). Rebuilt only
|
|
2187
2269
|
* when `routeFor` changes; the navigation gate itself is the async
|
|
2188
2270
|
* op inside the action.
|
|
2189
2271
|
*/
|
|
2190
2272
|
action = computed(() => {
|
|
2191
2273
|
const router = this.router;
|
|
2192
|
-
if (!router) {
|
|
2274
|
+
if (!router || !this.activatedRoute) {
|
|
2193
2275
|
return null;
|
|
2194
2276
|
}
|
|
2195
2277
|
return createTabRouterCommit({
|
|
@@ -2199,8 +2281,12 @@ class CngxTabsRouteSync {
|
|
|
2199
2281
|
});
|
|
2200
2282
|
}, ...(ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []));
|
|
2201
2283
|
constructor() {
|
|
2202
|
-
|
|
2203
|
-
|
|
2284
|
+
// Router is providedIn: 'root' and resolves without provideRouter(...);
|
|
2285
|
+
// ActivatedRoute does not, so it is the "router is set up" signal.
|
|
2286
|
+
if (!this.router || !this.activatedRoute) {
|
|
2287
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
2288
|
+
afterNextRender(() => warnTabsRouterAbsent('cngxTabsRouteSync', 'routed tabs'));
|
|
2289
|
+
}
|
|
2204
2290
|
return;
|
|
2205
2291
|
}
|
|
2206
2292
|
const router = this.router;
|
|
@@ -2306,7 +2392,7 @@ function createTabsHostAttrs(inputs) {
|
|
|
2306
2392
|
};
|
|
2307
2393
|
}
|
|
2308
2394
|
|
|
2309
|
-
function partitionFeatures(features) {
|
|
2395
|
+
function partitionFeatures(features, caller) {
|
|
2310
2396
|
const config = [];
|
|
2311
2397
|
const i18n = [];
|
|
2312
2398
|
for (const feat of features) {
|
|
@@ -2321,11 +2407,17 @@ function partitionFeatures(features) {
|
|
|
2321
2407
|
// Unbranded feature - runtime escape from the `_target` type.
|
|
2322
2408
|
// Drop with dev-warn so an i18n-shaped override never lands
|
|
2323
2409
|
// silently in `CNGX_TABS_CONFIG`.
|
|
2324
|
-
if (
|
|
2325
|
-
|
|
2326
|
-
'
|
|
2327
|
-
|
|
2328
|
-
|
|
2410
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
2411
|
+
if (caller === 'provideCngxTabsAt') {
|
|
2412
|
+
cngxDevWarn('CNGX1041', 'provideCngxTabsAt(): dropped feature without a `_target` ' +
|
|
2413
|
+
'discriminator. Pass config through the `with*` helpers of @cngx/common/tabs ' +
|
|
2414
|
+
'and labels through `withTabsI18nLabels(...)`.');
|
|
2415
|
+
}
|
|
2416
|
+
else {
|
|
2417
|
+
cngxDevWarn('CNGX1041', 'provideCngxTabs(): dropped feature without a `_target` ' +
|
|
2418
|
+
'discriminator. Pass config through the `with*` helpers of @cngx/common/tabs ' +
|
|
2419
|
+
'and labels through `withTabsI18nLabels(...)`.');
|
|
2420
|
+
}
|
|
2329
2421
|
}
|
|
2330
2422
|
}
|
|
2331
2423
|
return { config, i18n };
|
|
@@ -2346,7 +2438,6 @@ function partitionFeatures(features) {
|
|
|
2346
2438
|
* providers: [
|
|
2347
2439
|
* provideCngxTabs(
|
|
2348
2440
|
* withTabsDefaultOrientation('vertical'),
|
|
2349
|
-
* withTabsAriaLabels({ tabsRegion: 'Bereiche' }),
|
|
2350
2441
|
* withTabsI18nLabels({ tabsLabel: 'Bereiche', moreTabsLabel: (n) => `${n} mehr` }),
|
|
2351
2442
|
* withTabOverflowStabilizeMs(150),
|
|
2352
2443
|
* ),
|
|
@@ -2354,13 +2445,12 @@ function partitionFeatures(features) {
|
|
|
2354
2445
|
* });
|
|
2355
2446
|
* ```
|
|
2356
2447
|
*
|
|
2357
|
-
* @category common/tabs
|
|
2358
2448
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/provide-cngx-tabs.ts
|
|
2359
|
-
* @since 0.
|
|
2449
|
+
* @since 0.3.0
|
|
2360
2450
|
* @relatedTo CngxTabGroup, CngxTabsConfig, provideCngxTabsAt
|
|
2361
2451
|
*/
|
|
2362
2452
|
function provideCngxTabs(...features) {
|
|
2363
|
-
const { config, i18n } = partitionFeatures(features);
|
|
2453
|
+
const { config, i18n } = partitionFeatures(features, 'provideCngxTabs');
|
|
2364
2454
|
return makeEnvironmentProviders([
|
|
2365
2455
|
provideTabsConfig(...config),
|
|
2366
2456
|
...(i18n.length > 0 ? [provideTabsI18n(...i18n)] : []),
|
|
@@ -2382,13 +2472,12 @@ function provideCngxTabs(...features) {
|
|
|
2382
2472
|
* })
|
|
2383
2473
|
* ```
|
|
2384
2474
|
*
|
|
2385
|
-
* @category common/tabs
|
|
2386
2475
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/provide-cngx-tabs.ts
|
|
2387
|
-
* @since 0.
|
|
2476
|
+
* @since 0.3.0
|
|
2388
2477
|
* @relatedTo CngxTabGroup, CngxTabsConfig, provideCngxTabs
|
|
2389
2478
|
*/
|
|
2390
2479
|
function provideCngxTabsAt(...features) {
|
|
2391
|
-
const { config, i18n } = partitionFeatures(features);
|
|
2480
|
+
const { config, i18n } = partitionFeatures(features, 'provideCngxTabsAt');
|
|
2392
2481
|
return [
|
|
2393
2482
|
// Gate like i18n: an i18n-only call must not plant an empty config
|
|
2394
2483
|
// at this injector level and shadow an app-wide provideTabsConfig.
|
|
@@ -2401,8 +2490,6 @@ function provideCngxTabsAt(...features) {
|
|
|
2401
2490
|
* Default adapter for the cngx-native `<cngx-tab-group>` strip: \
|
|
2402
2491
|
* walks `host.closest('.cngx-tabs__strip-wrapper')` for the IO root,
|
|
2403
2492
|
* then `[id="${handle.id}-header"]` for each button.
|
|
2404
|
-
*
|
|
2405
|
-
* @category common/tabs/overflow
|
|
2406
2493
|
*/
|
|
2407
2494
|
function createCngxTabOverflowDefaultDomAdapter() {
|
|
2408
2495
|
return {
|
|
@@ -2422,9 +2509,8 @@ function createCngxTabOverflowDefaultDomAdapter() {
|
|
|
2422
2509
|
* forking the molecule. Defaults to
|
|
2423
2510
|
* {@link createCngxTabOverflowDefaultDomAdapter}.
|
|
2424
2511
|
*
|
|
2425
|
-
* @category common/tabs/overflow
|
|
2426
2512
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/dom-adapter.ts
|
|
2427
|
-
* @since 0.
|
|
2513
|
+
* @since 0.3.0
|
|
2428
2514
|
*/
|
|
2429
2515
|
const CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY = new InjectionToken('CngxTabOverflowDomAdapterFactory', {
|
|
2430
2516
|
providedIn: 'root',
|
|
@@ -2459,8 +2545,6 @@ const CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY = new InjectionToken('CngxTabOverflo
|
|
|
2459
2545
|
* afterNextRender(() => retry.start());
|
|
2460
2546
|
* destroyRef.onDestroy(() => retry.cancel());
|
|
2461
2547
|
* ```
|
|
2462
|
-
*
|
|
2463
|
-
* @category common/tabs/overflow
|
|
2464
2548
|
*/
|
|
2465
2549
|
function createDomAnchorRetry(options) {
|
|
2466
2550
|
let attempts = 0;
|
|
@@ -2523,9 +2607,8 @@ function createDomAnchorRetry(options) {
|
|
|
2523
2607
|
* - `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY`, and
|
|
2524
2608
|
* - `CNGX_TABS_COMMIT_HANDLER_FACTORY`.
|
|
2525
2609
|
*
|
|
2526
|
-
* @category common/tabs/overflow
|
|
2527
2610
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/dom-anchor-retry.ts
|
|
2528
|
-
* @since 0.
|
|
2611
|
+
* @since 0.3.0
|
|
2529
2612
|
*/
|
|
2530
2613
|
const CNGX_DOM_ANCHOR_RETRY_FACTORY = new InjectionToken('CngxDomAnchorRetryFactory', {
|
|
2531
2614
|
providedIn: 'root',
|
|
@@ -2546,10 +2629,9 @@ const CNGX_DOM_ANCHOR_RETRY_FACTORY = new InjectionToken('CngxDomAnchorRetryFact
|
|
|
2546
2629
|
* </cngx-tab-overflow>
|
|
2547
2630
|
* ```
|
|
2548
2631
|
*
|
|
2549
|
-
* @category common/tabs/overflow
|
|
2550
2632
|
* @wcag AA
|
|
2551
2633
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/tab-overflow-trigger.directive.ts
|
|
2552
|
-
* @since 0.
|
|
2634
|
+
* @since 0.3.0
|
|
2553
2635
|
* @relatedTo CngxTabOverflowItem, CngxTab
|
|
2554
2636
|
*/
|
|
2555
2637
|
class CngxTabOverflowTrigger {
|
|
@@ -2582,10 +2664,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2582
2664
|
* </cngx-tab-overflow>
|
|
2583
2665
|
* ```
|
|
2584
2666
|
*
|
|
2585
|
-
* @category common/tabs/overflow
|
|
2586
2667
|
* @wcag AA
|
|
2587
2668
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/tab-overflow-item.directive.ts
|
|
2588
|
-
* @since 0.
|
|
2669
|
+
* @since 0.3.0
|
|
2589
2670
|
* @relatedTo CngxTabOverflowTrigger, CngxTab
|
|
2590
2671
|
*/
|
|
2591
2672
|
class CngxTabOverflowItem {
|
|
@@ -2606,7 +2687,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2606
2687
|
* Structural slot for the error-badge template. 3-stage cascade:
|
|
2607
2688
|
* per-instance directive >
|
|
2608
2689
|
* `CNGX_TABS_CONFIG.templates.errorBadge` >
|
|
2609
|
-
*
|
|
2690
|
+
* the default alert icon.
|
|
2610
2691
|
*
|
|
2611
2692
|
* ```html
|
|
2612
2693
|
* <cngx-tab-group>
|
|
@@ -2618,12 +2699,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2618
2699
|
* </cngx-tab-group>
|
|
2619
2700
|
* ```
|
|
2620
2701
|
*
|
|
2621
|
-
* @category common/tabs/slots
|
|
2622
2702
|
* @wcag AA
|
|
2623
2703
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-error-badge.directive.ts
|
|
2624
|
-
* @since 0.
|
|
2704
|
+
* @since 0.3.0
|
|
2625
2705
|
* @relatedTo CngxTabRejectionIcon, CngxTabBusySpinner, CngxTab
|
|
2626
|
-
* <example-url
|
|
2706
|
+
* <example-url>/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
2627
2707
|
*/
|
|
2628
2708
|
class CngxTabErrorBadge {
|
|
2629
2709
|
templateRef = inject(TemplateRef);
|
|
@@ -2643,7 +2723,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2643
2723
|
* Structural slot for the rejection-decoration template. 3-stage
|
|
2644
2724
|
* cascade: per-instance directive >
|
|
2645
2725
|
* `CNGX_TABS_CONFIG.templates.rejectionIcon` >
|
|
2646
|
-
*
|
|
2726
|
+
* the default alert icon (a failed commit) or ban icon (a refused
|
|
2727
|
+
* one).
|
|
2647
2728
|
*
|
|
2648
2729
|
* ```html
|
|
2649
2730
|
* <cngx-tab-group>
|
|
@@ -2660,12 +2741,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2660
2741
|
* </cngx-tab-group>
|
|
2661
2742
|
* ```
|
|
2662
2743
|
*
|
|
2663
|
-
* @category common/tabs/slots
|
|
2664
2744
|
* @wcag AA
|
|
2665
2745
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-rejection-icon.directive.ts
|
|
2666
|
-
* @since 0.
|
|
2746
|
+
* @since 0.3.0
|
|
2667
2747
|
* @relatedTo CngxTabErrorBadge, CngxTabBusySpinner, CngxTab
|
|
2668
|
-
* <example-url
|
|
2748
|
+
* <example-url>/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
2669
2749
|
*/
|
|
2670
2750
|
class CngxTabRejectionIcon {
|
|
2671
2751
|
templateRef = inject(TemplateRef);
|
|
@@ -2694,12 +2774,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2694
2774
|
* </cngx-tab-group>
|
|
2695
2775
|
* ```
|
|
2696
2776
|
*
|
|
2697
|
-
* @category common/tabs/slots
|
|
2698
2777
|
* @wcag AA
|
|
2699
2778
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-busy-spinner.directive.ts
|
|
2700
|
-
* @since 0.
|
|
2779
|
+
* @since 0.3.0
|
|
2701
2780
|
* @relatedTo CngxTabErrorBadge, CngxTabRejectionIcon, CngxTab
|
|
2702
|
-
* <example-url
|
|
2781
|
+
* <example-url>/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
2703
2782
|
*/
|
|
2704
2783
|
class CngxTabBusySpinner {
|
|
2705
2784
|
templateRef = inject(TemplateRef);
|
|
@@ -2727,16 +2806,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2727
2806
|
* </ng-template>
|
|
2728
2807
|
* ```
|
|
2729
2808
|
*
|
|
2730
|
-
* @category common/tabs/slots
|
|
2731
2809
|
* @wcag AA
|
|
2732
2810
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-icon.directive.ts
|
|
2733
|
-
* @since 0.
|
|
2811
|
+
* @since 0.3.0
|
|
2734
2812
|
* @relatedTo CngxTabErrorBadge, CngxTab, CngxTabGroup
|
|
2735
|
-
* <example-url
|
|
2736
|
-
* <example-url
|
|
2737
|
-
* <example-url
|
|
2738
|
-
* <example-url
|
|
2739
|
-
* <example-url
|
|
2813
|
+
* <example-url>/#/ui/tabs/tab-icons/icon-end</example-url>
|
|
2814
|
+
* <example-url>/#/ui/tabs/tab-icons/icon-only</example-url>
|
|
2815
|
+
* <example-url>/#/ui/tabs/tab-icons/icon-start</example-url>
|
|
2816
|
+
* <example-url>/#/ui/tabs/tab-icons/icon-top</example-url>
|
|
2817
|
+
* <example-url>/#/ui/tabs/tab-icons/icon-vertical-sidebar</example-url>
|
|
2740
2818
|
*/
|
|
2741
2819
|
class CngxTabIcon {
|
|
2742
2820
|
templateRef = inject(TemplateRef);
|
|
@@ -2755,7 +2833,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2755
2833
|
/**
|
|
2756
2834
|
* Structural slot for a tab's close-button glyph. 3-stage cascade:
|
|
2757
2835
|
* per-instance directive > `CNGX_TABS_CONFIG.templates.closeIcon` >
|
|
2758
|
-
*
|
|
2836
|
+
* the default close icon.
|
|
2759
2837
|
*
|
|
2760
2838
|
* ```html
|
|
2761
2839
|
* <cngx-tab-group closable (tabClose)="remove($event.id)">
|
|
@@ -2764,12 +2842,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2764
2842
|
* </cngx-tab-group>
|
|
2765
2843
|
* ```
|
|
2766
2844
|
*
|
|
2767
|
-
* @category common/tabs/slots
|
|
2768
2845
|
* @wcag AA
|
|
2769
2846
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-close-icon.directive.ts
|
|
2770
|
-
* @since 0.
|
|
2847
|
+
* @since 0.3.0
|
|
2771
2848
|
* @relatedTo CngxTabAddIcon, CngxTabGroup
|
|
2772
|
-
* <example-url
|
|
2849
|
+
* <example-url>/#/ui/tabs/tab-dismissable/dismissable-and-addable</example-url>
|
|
2773
2850
|
*/
|
|
2774
2851
|
class CngxTabCloseIcon {
|
|
2775
2852
|
templateRef = inject(TemplateRef);
|
|
@@ -2788,7 +2865,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2788
2865
|
/**
|
|
2789
2866
|
* Structural slot for the add-tab button glyph. 3-stage cascade:
|
|
2790
2867
|
* per-instance directive > `CNGX_TABS_CONFIG.templates.addIcon` >
|
|
2791
|
-
*
|
|
2868
|
+
* the default plus icon. The button owns its `aria-label`; the
|
|
2792
2869
|
* template paints only the glyph, so its context is `void`.
|
|
2793
2870
|
*
|
|
2794
2871
|
* ```html
|
|
@@ -2798,13 +2875,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2798
2875
|
* </cngx-tab-group>
|
|
2799
2876
|
* ```
|
|
2800
2877
|
*
|
|
2801
|
-
* @category common/tabs/slots
|
|
2802
2878
|
* @wcag AA
|
|
2803
2879
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-add-icon.directive.ts
|
|
2804
|
-
* @since 0.
|
|
2880
|
+
* @since 0.3.0
|
|
2805
2881
|
* @relatedTo CngxTabCloseIcon, CngxTabGroup
|
|
2806
|
-
* <example-url
|
|
2807
|
-
* <example-url
|
|
2882
|
+
* <example-url>/#/ui/tabs/tab-dismissable/dismissable-and-addable</example-url>
|
|
2883
|
+
* <example-url>/#/ui/tabs/tab-group/addable-tabs</example-url>
|
|
2808
2884
|
*/
|
|
2809
2885
|
class CngxTabAddIcon {
|
|
2810
2886
|
templateRef = inject(TemplateRef);
|
|
@@ -2854,9 +2930,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2854
2930
|
* dismiss.handleAdd(); // routes through presenter.requestAdd
|
|
2855
2931
|
* ```
|
|
2856
2932
|
*
|
|
2857
|
-
* @category common/tabs
|
|
2858
2933
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/dismissals/tab-dismissals.ts
|
|
2859
|
-
* @since 0.
|
|
2934
|
+
* @since 0.3.0
|
|
2860
2935
|
* @relatedTo CngxTabGroup, CngxTabCloseIcon, CngxTabAddIcon
|
|
2861
2936
|
*/
|
|
2862
2937
|
function createTabDismissals(opts) {
|
|
@@ -3003,9 +3078,8 @@ function createTabDismissals(opts) {
|
|
|
3003
3078
|
* activation the focused tab is always the active one, so the clamped
|
|
3004
3079
|
* active index is the correct origin.
|
|
3005
3080
|
*
|
|
3006
|
-
* @category common/tabs
|
|
3007
3081
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/keyboard/tab-keyboard-nav.ts
|
|
3008
|
-
* @since 0.
|
|
3082
|
+
* @since 0.3.0
|
|
3009
3083
|
* @relatedTo CngxTabGroupPresenter, CngxTabGroup, createTabGroupAnnouncements
|
|
3010
3084
|
*/
|
|
3011
3085
|
function createTabKeyboardNav(opts) {
|
|
@@ -3077,8 +3151,13 @@ function createTabKeyboardNav(opts) {
|
|
|
3077
3151
|
buttons.find((button) => button.getAttribute('data-tab-id') === id)?.focus();
|
|
3078
3152
|
};
|
|
3079
3153
|
if (opts.injector) {
|
|
3154
|
+
// Keyed on the outcome sequence, not the commit status: a refusal
|
|
3155
|
+
// settles to 'idle' and never reaches 'error'. A number compares with
|
|
3156
|
+
// `Object.is`, so the close shift (index moved, sequence copied) never
|
|
3157
|
+
// re-runs the release, and a cleared outcome (`undefined`) is ignored.
|
|
3158
|
+
const outcomeSequence = computed(() => opts.host.lastOutcome()?.sequence, ...(ngDevMode ? [{ debugName: "outcomeSequence" }] : /* istanbul ignore next */ []));
|
|
3080
3159
|
effect(() => {
|
|
3081
|
-
if (
|
|
3160
|
+
if (outcomeSequence() === undefined) {
|
|
3082
3161
|
return;
|
|
3083
3162
|
}
|
|
3084
3163
|
untracked(() => {
|
|
@@ -3157,7 +3236,7 @@ function createTabKeyboardNav(opts) {
|
|
|
3157
3236
|
* `null`.
|
|
3158
3237
|
*
|
|
3159
3238
|
* `null` means the organism renders its built-in default - a default
|
|
3160
|
-
* span for the state decorations, the
|
|
3239
|
+
* span for the state decorations, the default icon for
|
|
3161
3240
|
* `closeIcon` / `addIcon`, and nothing for `icon`.
|
|
3162
3241
|
*
|
|
3163
3242
|
* Pure - no DI, no side effects. Safe in field-init. Sibling to
|
|
@@ -3177,10 +3256,9 @@ function createTabKeyboardNav(opts) {
|
|
|
3177
3256
|
* - An unbound `icon` slot resolves to nothing, which is correct - the
|
|
3178
3257
|
* icon is decorative and the label carries the accessible name.
|
|
3179
3258
|
*
|
|
3180
|
-
* @category common/tabs/slots
|
|
3181
3259
|
* @wcag AA
|
|
3182
3260
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-group-template-cascade.ts
|
|
3183
|
-
* @since 0.
|
|
3261
|
+
* @since 0.3.0
|
|
3184
3262
|
* @relatedTo CngxTabGroup, CngxTabErrorBadge, CngxTabBusySpinner, CngxTabRejectionIcon
|
|
3185
3263
|
*/
|
|
3186
3264
|
function createTabGroupTemplateBindings(opts) {
|
|
@@ -3222,10 +3300,9 @@ function createTabGroupTemplateBindings(opts) {
|
|
|
3222
3300
|
* always in the DOM; `statusPhrase` only fills its content, keeping the
|
|
3223
3301
|
* `aria-describedby` reference stable.
|
|
3224
3302
|
*
|
|
3225
|
-
* @category common/tabs/announcements
|
|
3226
3303
|
* @wcag AA
|
|
3227
3304
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/announcements/tab-group-announcements.ts
|
|
3228
|
-
* @since 0.
|
|
3305
|
+
* @since 0.3.0
|
|
3229
3306
|
* @relatedTo CngxTabGroup, CngxLiveRegion, createTabKeyboardNav
|
|
3230
3307
|
*/
|
|
3231
3308
|
function createTabGroupAnnouncements(options) {
|
|
@@ -3233,7 +3310,6 @@ function createTabGroupAnnouncements(options) {
|
|
|
3233
3310
|
const closedAnnouncement = options.closedAnnouncement ?? (() => '');
|
|
3234
3311
|
const fallbackLabels = coerceSignal(config.fallbackLabels);
|
|
3235
3312
|
const defaultFallbackLabels = coerceSignal(TABS_CONFIG_DEFAULTS.fallbackLabels);
|
|
3236
|
-
const ariaLabels = coerceSignal(config.ariaLabels);
|
|
3237
3313
|
const tabsRoleDescription = computed(() => fallbackLabels()?.tabRoleDescription ?? defaultFallbackLabels().tabRoleDescription, ...(ngDevMode ? [{ debugName: "tabsRoleDescription" }] : /* istanbul ignore next */ []));
|
|
3238
3314
|
const tabPanelRoleDescription = computed(() => fallbackLabels()?.tabPanelRoleDescription ??
|
|
3239
3315
|
defaultFallbackLabels().tabPanelRoleDescription, ...(ngDevMode ? [{ debugName: "tabPanelRoleDescription" }] : /* istanbul ignore next */ []));
|
|
@@ -3241,7 +3317,7 @@ function createTabGroupAnnouncements(options) {
|
|
|
3241
3317
|
if (ariaLabelledBy()) {
|
|
3242
3318
|
return null;
|
|
3243
3319
|
}
|
|
3244
|
-
return ariaLabel() ??
|
|
3320
|
+
return ariaLabel() ?? i18n().tabsLabel;
|
|
3245
3321
|
}, ...(ngDevMode ? [{ debugName: "resolvedAriaLabel" }] : /* istanbul ignore next */ []));
|
|
3246
3322
|
// `prev?.source` = source value before the most recent change -
|
|
3247
3323
|
// prior activeIndex without an `effect`-driven slot (Pillar 1).
|
|
@@ -3252,44 +3328,85 @@ function createTabGroupAnnouncements(options) {
|
|
|
3252
3328
|
// Close phrase with commit-activity expiry: a NEW phrase (re)arms; a
|
|
3253
3329
|
// commit status change while armed spends the phrase, so a later
|
|
3254
3330
|
// return to idle re-renders '' instead of re-announcing the stale
|
|
3255
|
-
// close.
|
|
3331
|
+
// close. A new refused or failed outcome spends it too: a synchronous
|
|
3332
|
+
// refusal never changes the status, and the close phrase must not
|
|
3333
|
+
// resurface once the refused phrase is spent. Mount seeds with the
|
|
3334
|
+
// current phrase (never empty-coerced).
|
|
3256
3335
|
const closedPhrase = createAnnouncementPhrase({
|
|
3257
3336
|
source: () => ({
|
|
3258
3337
|
phrase: closedAnnouncement(),
|
|
3259
3338
|
status: presenter.commitTransition.current(),
|
|
3339
|
+
sequence: presenter.lastOutcome()?.sequence,
|
|
3260
3340
|
}),
|
|
3261
3341
|
arm: (curr, prev) => (curr.phrase !== prev.phrase ? curr.phrase : null),
|
|
3262
|
-
spend: (curr, prev) => curr.status !== prev.status,
|
|
3342
|
+
spend: (curr, prev) => curr.status !== prev.status || curr.sequence !== prev.sequence,
|
|
3263
3343
|
seed: (src) => src.phrase,
|
|
3264
3344
|
});
|
|
3345
|
+
// A refusal leaves the commit status at 'idle', so no status edge can
|
|
3346
|
+
// voice it. The phrase arms on each new refused outcome (a new
|
|
3347
|
+
// sequence) and is spent by the next commit activity, an active-index
|
|
3348
|
+
// move, a cleared outcome (its own tab closed) or a new close phrase,
|
|
3349
|
+
// so closing another tab after a refusal is announced. Arm wins over
|
|
3350
|
+
// spend in the same flush, so an optimistic rollback still arms.
|
|
3351
|
+
const refusedPhrase = createRefusedPhrase({
|
|
3352
|
+
outcome: () => presenter.lastOutcome(),
|
|
3353
|
+
status: () => presenter.commitTransition.current(),
|
|
3354
|
+
activeIndex: () => presenter.activeIndex(),
|
|
3355
|
+
copy: refusedCopy,
|
|
3356
|
+
extraSpend: () => closedAnnouncement(),
|
|
3357
|
+
});
|
|
3358
|
+
function refusedCopy() {
|
|
3359
|
+
const originIdx = presenter.originIndexDuringCommit();
|
|
3360
|
+
const origin = originIdx !== undefined ? presenter.tabs()[originIdx] : undefined;
|
|
3361
|
+
const copy = i18n();
|
|
3362
|
+
// An origin index past the end names a removed tab: the generic copy.
|
|
3363
|
+
if (!origin || originIdx === undefined) {
|
|
3364
|
+
return copy.commitRefusedGeneric;
|
|
3365
|
+
}
|
|
3366
|
+
return copy.commitRefused(originName(origin, originIdx, copy));
|
|
3367
|
+
}
|
|
3368
|
+
// A label-less origin is named by its position.
|
|
3369
|
+
function originName(origin, originIdx, copy) {
|
|
3370
|
+
const label = origin.label();
|
|
3371
|
+
if (label) {
|
|
3372
|
+
return label;
|
|
3373
|
+
}
|
|
3374
|
+
return copy.unlabeledTab(originIdx + 1);
|
|
3375
|
+
}
|
|
3265
3376
|
// Copy and tab labels (which a consumer may translate) are read untracked
|
|
3266
3377
|
// in the live region: a language switch must not re-speak the last phrase;
|
|
3267
3378
|
// the next transition speaks the new language.
|
|
3268
3379
|
const liveAnnouncement = computed(() => {
|
|
3269
|
-
// Read
|
|
3270
|
-
//
|
|
3271
|
-
//
|
|
3272
|
-
|
|
3380
|
+
// Read both phrases EAGERLY: linkedSignal only observes snapshots it
|
|
3381
|
+
// is actually read under, so a lazy read behind an earlier arm would
|
|
3382
|
+
// skip the intermediate 'pending' and never spend the phrase.
|
|
3383
|
+
const refused = refusedPhrase();
|
|
3273
3384
|
const closeConfirmation = closedPhrase();
|
|
3385
|
+
if (refused) {
|
|
3386
|
+
return refused;
|
|
3387
|
+
}
|
|
3274
3388
|
const current = presenter.commitTransition.current();
|
|
3275
3389
|
if (current === 'pending') {
|
|
3276
3390
|
return untracked(() => i18n().commitInFlight);
|
|
3277
3391
|
}
|
|
3278
3392
|
if (current === 'error') {
|
|
3279
|
-
// No `previous === 'pending'` guard - sync
|
|
3393
|
+
// No `previous === 'pending'` guard - sync failures collapse
|
|
3280
3394
|
// pending → error in one flush, so the tracker captures
|
|
3281
3395
|
// `previous = 'idle'` and an unguarded read keeps the
|
|
3282
|
-
// announcement reachable for
|
|
3396
|
+
// announcement reachable for a synchronously throwing
|
|
3397
|
+
// `commitAction`. A `false` answer never reaches this arm: it
|
|
3398
|
+
// settles to 'idle' as a refusal.
|
|
3283
3399
|
const failedIdx = presenter.lastFailedIndex();
|
|
3284
3400
|
const originIdx = presenter.originIndexDuringCommit();
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
return untracked(() => i18n().commitRolledBackTo(originLabel));
|
|
3290
|
-
}
|
|
3401
|
+
const origin = failedIdx !== undefined && originIdx !== undefined ? presenter.tabs()[originIdx] : undefined;
|
|
3402
|
+
// No origin, or an origin index past the end (a removed tab): retry copy.
|
|
3403
|
+
if (!origin || originIdx === undefined) {
|
|
3404
|
+
return untracked(() => i18n().commitFailedRetry);
|
|
3291
3405
|
}
|
|
3292
|
-
return untracked(() =>
|
|
3406
|
+
return untracked(() => {
|
|
3407
|
+
const copy = i18n();
|
|
3408
|
+
return copy.commitRolledBackTo(originName(origin, originIdx, copy));
|
|
3409
|
+
});
|
|
3293
3410
|
}
|
|
3294
3411
|
if (current === 'success') {
|
|
3295
3412
|
const tabs = presenter.tabs();
|
|
@@ -3303,7 +3420,9 @@ function createTabGroupAnnouncements(options) {
|
|
|
3303
3420
|
const prevIdx = priorActiveIndex();
|
|
3304
3421
|
return untracked(() => {
|
|
3305
3422
|
const copy = i18n();
|
|
3306
|
-
const positionPhrase =
|
|
3423
|
+
const positionPhrase = label
|
|
3424
|
+
? copy.selectedTab(label, idx + 1, count)
|
|
3425
|
+
: copy.unlabeledTabOfCount(idx + 1, count);
|
|
3307
3426
|
if (idx > prevIdx) {
|
|
3308
3427
|
return copy.nextTab(positionPhrase);
|
|
3309
3428
|
}
|
|
@@ -3334,12 +3453,31 @@ function createTabGroupAnnouncements(options) {
|
|
|
3334
3453
|
}
|
|
3335
3454
|
function tabAriaLabel(tab, position) {
|
|
3336
3455
|
const tabs = presenter.tabs();
|
|
3337
|
-
const label = tab.label()
|
|
3456
|
+
const label = tab.label();
|
|
3338
3457
|
const detail = tab.subLabel();
|
|
3339
3458
|
const copy = i18n();
|
|
3459
|
+
if (!label) {
|
|
3460
|
+
const positionName = copy.unlabeledTabOfCount(position, tabs.length);
|
|
3461
|
+
return detail ? copy.tabLabelWithDetail(positionName, detail) : positionName;
|
|
3462
|
+
}
|
|
3340
3463
|
const labelPart = detail ? copy.tabLabelWithDetail(label, detail) : label;
|
|
3341
3464
|
return copy.selectedTab(labelPart, position, tabs.length);
|
|
3342
3465
|
}
|
|
3466
|
+
function tabLabelId(tab) {
|
|
3467
|
+
return `${tab.id}-label`;
|
|
3468
|
+
}
|
|
3469
|
+
function tabSubLabelId(tab) {
|
|
3470
|
+
return `${tab.id}-sublabel`;
|
|
3471
|
+
}
|
|
3472
|
+
function tabLabelledBy(tab, hasLabelTemplate, hasSubLabelTemplate) {
|
|
3473
|
+
if (tab.label() || !hasLabelTemplate) {
|
|
3474
|
+
return null;
|
|
3475
|
+
}
|
|
3476
|
+
if (hasSubLabelTemplate || tab.subLabel()) {
|
|
3477
|
+
return `${tabLabelId(tab)} ${tabSubLabelId(tab)}`;
|
|
3478
|
+
}
|
|
3479
|
+
return tabLabelId(tab);
|
|
3480
|
+
}
|
|
3343
3481
|
// Eager seed - `linkedSignal` is lazy and the success arm doesn't
|
|
3344
3482
|
// touch the tracker at construction (commitTransition is `idle`),
|
|
3345
3483
|
// so without this read `prev?.source` is undefined on the first
|
|
@@ -3352,6 +3490,9 @@ function createTabGroupAnnouncements(options) {
|
|
|
3352
3490
|
liveAnnouncement,
|
|
3353
3491
|
statusPhrase,
|
|
3354
3492
|
tabAriaLabel,
|
|
3493
|
+
tabLabelledBy,
|
|
3494
|
+
tabLabelId,
|
|
3495
|
+
tabSubLabelId,
|
|
3355
3496
|
};
|
|
3356
3497
|
}
|
|
3357
3498
|
|
|
@@ -3382,10 +3523,9 @@ function createTabGroupAnnouncements(options) {
|
|
|
3382
3523
|
* point instead of as the first announcement. Returning to a section
|
|
3383
3524
|
* that was active at mount still announces.
|
|
3384
3525
|
*
|
|
3385
|
-
* @category common/tabs/announcements
|
|
3386
3526
|
* @wcag AA
|
|
3387
3527
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/announcements/tab-nav-announcement.ts
|
|
3388
|
-
* @since 0.
|
|
3528
|
+
* @since 0.3.0
|
|
3389
3529
|
* @relatedTo CngxTabNav, CngxLiveRegion, createTabGroupAnnouncements
|
|
3390
3530
|
*/
|
|
3391
3531
|
function createTabNavAnnouncement(options) {
|
|
@@ -3421,36 +3561,11 @@ function createTabNavAnnouncement(options) {
|
|
|
3421
3561
|
return { liveAnnouncement };
|
|
3422
3562
|
}
|
|
3423
3563
|
|
|
3424
|
-
/**
|
|
3425
|
-
* Default glyph fallbacks for `<cngx-tab-group>` skin slots. Read by
|
|
3426
|
-
* the organism when neither a per-instance slot directive nor
|
|
3427
|
-
* `CNGX_TABS_CONFIG.templates.<key>` is bound. Sibling to
|
|
3428
|
-
* `CNGX_SELECT_GLYPHS` and `CNGX_STEPPER_GLYPHS`. Exported because
|
|
3429
|
-
* Sheriff forbids deep-relative imports across library boundaries;
|
|
3430
|
-
* `@internal` enforces consumer intent. Consumers customise via slot
|
|
3431
|
-
* directives or `withTab*Template` config features.
|
|
3432
|
-
*
|
|
3433
|
-
* @internal
|
|
3434
|
-
* @category common/tabs
|
|
3435
|
-
*/
|
|
3436
|
-
const CNGX_TABS_GLYPHS = {
|
|
3437
|
-
/** Default visual for `*cngxTabErrorBadge` when no override is bound. */
|
|
3438
|
-
errorBadge: '!',
|
|
3439
|
-
/** Default visual for `*cngxTabRejectionIcon` when no override is bound. */
|
|
3440
|
-
rejectionIcon: '!',
|
|
3441
|
-
/** Default visual for a tab's close button when no override is bound. */
|
|
3442
|
-
closeIcon: '×',
|
|
3443
|
-
/** Default visual for the add-tab button when no override is bound. */
|
|
3444
|
-
addIcon: '+',
|
|
3445
|
-
};
|
|
3446
|
-
|
|
3447
3564
|
/**
|
|
3448
3565
|
* DOM `id` for a hidden-tab option row in the overflow listbox. \
|
|
3449
3566
|
* Stable across CD passes so `aria-activedescendant` resolves to
|
|
3450
3567
|
* the same `<li>`. `-overflow-option` suffix avoids collision with
|
|
3451
3568
|
* the strip-button (`-header`) and per-tab descriptor (`-desc`).
|
|
3452
|
-
*
|
|
3453
|
-
* @category common/tabs/overflow
|
|
3454
3569
|
*/
|
|
3455
3570
|
function tabOverflowOptionId(tab) {
|
|
3456
3571
|
return `${tab.id}-overflow-option`;
|
|
@@ -3499,8 +3614,6 @@ function adItemsEqual(a, b) {
|
|
|
3499
3614
|
* Pure - no DI, no side effects, no destroy hooks. Safe to call
|
|
3500
3615
|
* from a component's field-init block. Mirrors the select-family
|
|
3501
3616
|
* `createTemplateRegistry` pattern.
|
|
3502
|
-
*
|
|
3503
|
-
* @category common/tabs/overflow
|
|
3504
3617
|
*/
|
|
3505
3618
|
function createTabOverflowTemplateBindings(opts) {
|
|
3506
3619
|
const triggerTemplate = computed(() => opts.triggerSlot()?.templateRef ?? opts.config.templates?.overflowTrigger ?? null, ...(ngDevMode ? [{ debugName: "triggerTemplate" }] : /* istanbul ignore next */ []));
|
|
@@ -3573,7 +3686,6 @@ function createTabOverflowTemplateBindings(opts) {
|
|
|
3573
3686
|
* `aria-activedescendant` while real focus stays on the trigger (APG
|
|
3574
3687
|
* menu-button); the rows are never tab stops.
|
|
3575
3688
|
*
|
|
3576
|
-
* @category common/tabs/overflow
|
|
3577
3689
|
* @wcag AA
|
|
3578
3690
|
*/
|
|
3579
3691
|
function createOverflowPopoverHighlightSync(popover, ad) {
|
|
@@ -3595,9 +3707,8 @@ function createOverflowPopoverHighlightSync(popover, ad) {
|
|
|
3595
3707
|
* - `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY` and
|
|
3596
3708
|
* - `CNGX_TABS_COMMIT_HANDLER_FACTORY`.
|
|
3597
3709
|
*
|
|
3598
|
-
* @category common/tabs/overflow
|
|
3599
3710
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/overflow-template-cascade.ts
|
|
3600
|
-
* @since 0.
|
|
3711
|
+
* @since 0.3.0
|
|
3601
3712
|
*/
|
|
3602
3713
|
const CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY = new InjectionToken('CngxOverflowPopoverHighlightSyncFactory', {
|
|
3603
3714
|
providedIn: 'root',
|
|
@@ -3626,9 +3737,10 @@ const DEFAULT_SCROLL_OPTIONS = {
|
|
|
3626
3737
|
* popover scrolls it back into the strip, and the overflow recompute
|
|
3627
3738
|
* then self-trims - keyboard navigation and the overflow list stay in
|
|
3628
3739
|
* sync.
|
|
3629
|
-
* -
|
|
3630
|
-
*
|
|
3631
|
-
*
|
|
3740
|
+
* - The default is smooth-center along the inline axis, instant under
|
|
3741
|
+
* reduced motion (the in-app `CNGX_MOTION` pick or the OS query, via
|
|
3742
|
+
* `injectEffectiveMotion`); pass `scrollOptions` to replace it, for
|
|
3743
|
+
* example to scroll vertically.
|
|
3632
3744
|
*
|
|
3633
3745
|
* ```ts
|
|
3634
3746
|
* // Install once from the organism's field-init (needs an injection context).
|
|
@@ -3641,22 +3753,25 @@ const DEFAULT_SCROLL_OPTIONS = {
|
|
|
3641
3753
|
* });
|
|
3642
3754
|
* ```
|
|
3643
3755
|
*
|
|
3644
|
-
* @category common/tabs/scroll-sync
|
|
3645
3756
|
* @wcag AA
|
|
3646
3757
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/scroll-sync/organism-scroll-sync.ts
|
|
3647
|
-
* @since 0.
|
|
3758
|
+
* @since 0.3.0
|
|
3648
3759
|
* @relatedTo CngxTabGroup, CngxTabOverflow, CNGX_ORGANISM_SCROLL_SYNC_FACTORY
|
|
3649
3760
|
*/
|
|
3650
3761
|
function createOrganismScrollSync(opts) {
|
|
3651
3762
|
const { activeId, hostElement, scrollOptions, injector } = opts;
|
|
3652
|
-
const resolvedOptions = scrollOptions ?? DEFAULT_SCROLL_OPTIONS;
|
|
3653
3763
|
runInInjectionContext(injector, () => {
|
|
3764
|
+
const motion = scrollOptions ? undefined : injectEffectiveMotion();
|
|
3654
3765
|
effect(() => {
|
|
3655
3766
|
const id = activeId();
|
|
3656
3767
|
if (!id) {
|
|
3657
3768
|
return;
|
|
3658
3769
|
}
|
|
3659
3770
|
untracked(() => {
|
|
3771
|
+
const resolvedOptions = scrollOptions ?? {
|
|
3772
|
+
...DEFAULT_SCROLL_OPTIONS,
|
|
3773
|
+
behavior: motion?.() === 'reduced' ? 'auto' : DEFAULT_SCROLL_OPTIONS.behavior,
|
|
3774
|
+
};
|
|
3660
3775
|
const button = hostElement.querySelector(`[id="${id}-header"]`);
|
|
3661
3776
|
button?.scrollIntoView?.(resolvedOptions);
|
|
3662
3777
|
});
|
|
@@ -3679,7 +3794,7 @@ function createOrganismScrollSync(opts) {
|
|
|
3679
3794
|
* - `CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY`.
|
|
3680
3795
|
*
|
|
3681
3796
|
* ```ts
|
|
3682
|
-
* //
|
|
3797
|
+
* // Always scroll instantly, motion preference or not:
|
|
3683
3798
|
* providers: [
|
|
3684
3799
|
* {
|
|
3685
3800
|
* provide: CNGX_ORGANISM_SCROLL_SYNC_FACTORY,
|
|
@@ -3690,10 +3805,9 @@ function createOrganismScrollSync(opts) {
|
|
|
3690
3805
|
* // Or disable scroll-into-view entirely: useValue: () => {}
|
|
3691
3806
|
* ```
|
|
3692
3807
|
*
|
|
3693
|
-
* @category common/tabs/scroll-sync
|
|
3694
3808
|
* @wcag AA
|
|
3695
3809
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/scroll-sync/organism-scroll-sync.ts
|
|
3696
|
-
* @since 0.
|
|
3810
|
+
* @since 0.3.0
|
|
3697
3811
|
* @relatedTo createOrganismScrollSync, CngxOrganismScrollSyncFactory
|
|
3698
3812
|
*/
|
|
3699
3813
|
const CNGX_ORGANISM_SCROLL_SYNC_FACTORY = new InjectionToken('CngxOrganismScrollSyncFactory', {
|
|
@@ -3726,8 +3840,6 @@ function directiveMapEqual(a, b) {
|
|
|
3726
3840
|
* directives keyed by `id()`. Structural equal prevents cascade when
|
|
3727
3841
|
* `contentChildren` re-emits an unchanged child set. Shared by
|
|
3728
3842
|
* `<cngx-tab-group>`, `<cngx-stepper>`, and `<cngx-mat-stepper>`.
|
|
3729
|
-
*
|
|
3730
|
-
* @category common/tabs/registry
|
|
3731
3843
|
*/
|
|
3732
3844
|
function createDirectiveByIdMap(opts) {
|
|
3733
3845
|
return computed(() => {
|
|
@@ -3746,9 +3858,8 @@ function createDirectiveByIdMap(opts) {
|
|
|
3746
3858
|
* - `CNGX_DOM_ANCHOR_RETRY_FACTORY` and
|
|
3747
3859
|
* - `CNGX_ORGANISM_SCROLL_SYNC_FACTORY`.
|
|
3748
3860
|
*
|
|
3749
|
-
* @category common/tabs/registry
|
|
3750
3861
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/registry/directive-by-id-map.ts
|
|
3751
|
-
* @since 0.
|
|
3862
|
+
* @since 0.3.0
|
|
3752
3863
|
*/
|
|
3753
3864
|
const CNGX_DIRECTIVE_BY_ID_MAP_FACTORY = new InjectionToken('CngxDirectiveByIdMapFactory', {
|
|
3754
3865
|
providedIn: 'root',
|
|
@@ -3756,12 +3867,12 @@ const CNGX_DIRECTIVE_BY_ID_MAP_FACTORY = new InjectionToken('CngxDirectiveByIdMa
|
|
|
3756
3867
|
});
|
|
3757
3868
|
|
|
3758
3869
|
/**
|
|
3759
|
-
* @module
|
|
3870
|
+
* @module `@cngx/common/tabs`
|
|
3760
3871
|
*/
|
|
3761
3872
|
|
|
3762
3873
|
/**
|
|
3763
3874
|
* Generated bundle index. Do not edit.
|
|
3764
3875
|
*/
|
|
3765
3876
|
|
|
3766
|
-
export { CNGX_DIRECTIVE_BY_ID_MAP_FACTORY, CNGX_DOM_ANCHOR_RETRY_FACTORY, CNGX_ORGANISM_SCROLL_SYNC_FACTORY, CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY, CNGX_TABS_COMMIT_ACTION, CNGX_TABS_COMMIT_HANDLER_FACTORY, CNGX_TABS_CONFIG,
|
|
3877
|
+
export { CNGX_DIRECTIVE_BY_ID_MAP_FACTORY, CNGX_DOM_ANCHOR_RETRY_FACTORY, CNGX_ORGANISM_SCROLL_SYNC_FACTORY, CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY, CNGX_TABS_COMMIT_ACTION, CNGX_TABS_COMMIT_HANDLER_FACTORY, CNGX_TABS_CONFIG, CNGX_TABS_I18N, CNGX_TABS_LANGUAGE_EN, CNGX_TAB_GROUP_HOST, CNGX_TAB_NAV_HOST, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY, CNGX_TAB_PANEL_HOST, CNGX_TAB_URL_MATCH_STRATEGY, CngxTab, CngxTabAddIcon, CngxTabBusySpinner, CngxTabCloseIcon, CngxTabContent, CngxTabErrorBadge, CngxTabGroupPresenter, CngxTabIcon, CngxTabLabel, CngxTabLink, CngxTabOverflowItem, CngxTabOverflowTrigger, CngxTabRejectionIcon, CngxTabSubLabel, CngxTabsFragmentSync, CngxTabsRouteSync, createCngxTabOverflowDefaultDomAdapter, createDirectiveByIdMap, createDomAnchorRetry, createOrganismScrollSync, createOverflowPopoverHighlightSync, createTabDismissals, createTabGroupAnnouncements, createTabGroupTemplateBindings, createTabKeyboardNav, createTabNavAnnouncement, createTabOverflowTemplateBindings, createTabRouterCommit, createTabUrlMatch, createTabsCommitHandler, createTabsHostAttrs, injectTabsConfig, injectTabsI18n, provideCngxTabs, provideCngxTabsAt, provideTabsConfig, provideTabsConfigAt, provideTabsI18n, tabOverflowOptionId, withDefaultOrientation, withTabAddIconTemplate, withTabBusySpinnerTemplate, withTabCloseIconTemplate, withTabErrorBadgeTemplate, withTabIconTemplate, withTabOverflowItemTemplate, withTabOverflowMaxDeferMs, withTabOverflowStabilizeMs, withTabOverflowTriggerTemplate, withTabRejectionIconTemplate, withTabsAddable, withTabsAlign, withTabsClosable, withTabsCommitMode, withTabsDefaultOrientation, withTabsFallbackLabels, withTabsFitted, withTabsFragmentSync, withTabsI18nLabels, withTabsIconLayout, withTabsLinkAriaCurrent, withTabsPanelMode, withTabsRouteMatch, withTabsRouterSync, withTabsRovingLoop, withTabsSkin };
|
|
3767
3878
|
//# sourceMappingURL=cngx-common-tabs.mjs.map
|