@cngx/ui 0.0.1-rc.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.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +550 -0
  3. package/action-button/README.md +98 -0
  4. package/empty-state/README.md +103 -0
  5. package/feedback/README.md +33 -0
  6. package/fesm2022/cngx-ui-action-button.mjs +319 -0
  7. package/fesm2022/cngx-ui-action-button.mjs.map +1 -0
  8. package/fesm2022/cngx-ui-empty-state.mjs +138 -0
  9. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -0
  10. package/fesm2022/cngx-ui-feedback.mjs +2962 -0
  11. package/fesm2022/cngx-ui-feedback.mjs.map +1 -0
  12. package/fesm2022/cngx-ui-layout.mjs +89 -0
  13. package/fesm2022/cngx-ui-layout.mjs.map +1 -0
  14. package/fesm2022/cngx-ui-mat-stepper.mjs +567 -0
  15. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -0
  16. package/fesm2022/cngx-ui-mat-tabs.mjs +1405 -0
  17. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -0
  18. package/fesm2022/cngx-ui-material.mjs +79 -0
  19. package/fesm2022/cngx-ui-material.mjs.map +1 -0
  20. package/fesm2022/cngx-ui-overlay.mjs +91 -0
  21. package/fesm2022/cngx-ui-overlay.mjs.map +1 -0
  22. package/fesm2022/cngx-ui-sidenav.mjs +521 -0
  23. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -0
  24. package/fesm2022/cngx-ui-skeleton.mjs +158 -0
  25. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -0
  26. package/fesm2022/cngx-ui-speak.mjs +112 -0
  27. package/fesm2022/cngx-ui-speak.mjs.map +1 -0
  28. package/fesm2022/cngx-ui-stepper.mjs +312 -0
  29. package/fesm2022/cngx-ui-stepper.mjs.map +1 -0
  30. package/fesm2022/cngx-ui-tabs.mjs +507 -0
  31. package/fesm2022/cngx-ui-tabs.mjs.map +1 -0
  32. package/fesm2022/cngx-ui.mjs +45 -0
  33. package/fesm2022/cngx-ui.mjs.map +1 -0
  34. package/layout/README.md +133 -0
  35. package/mat-stepper/README.md +34 -0
  36. package/mat-tabs/README.md +163 -0
  37. package/mat-tabs/styles/mat-tabs.css +233 -0
  38. package/material/README.md +90 -0
  39. package/overlay/README.md +99 -0
  40. package/package.json +98 -0
  41. package/sidenav/README.md +127 -0
  42. package/skeleton/README.md +98 -0
  43. package/speak/README.md +93 -0
  44. package/speak/speak-button-theme.scss +78 -0
  45. package/stepper/README.md +40 -0
  46. package/tabs/README.md +28 -0
  47. package/types/cngx-ui-action-button.d.ts +126 -0
  48. package/types/cngx-ui-empty-state.d.ts +41 -0
  49. package/types/cngx-ui-feedback.d.ts +1174 -0
  50. package/types/cngx-ui-layout.d.ts +56 -0
  51. package/types/cngx-ui-mat-stepper.d.ts +234 -0
  52. package/types/cngx-ui-mat-tabs.d.ts +664 -0
  53. package/types/cngx-ui-material.d.ts +36 -0
  54. package/types/cngx-ui-overlay.d.ts +57 -0
  55. package/types/cngx-ui-sidenav.d.ts +209 -0
  56. package/types/cngx-ui-skeleton.d.ts +97 -0
  57. package/types/cngx-ui-speak.d.ts +31 -0
  58. package/types/cngx-ui-stepper.d.ts +129 -0
  59. package/types/cngx-ui-tabs.d.ts +165 -0
  60. package/types/cngx-ui.d.ts +18 -0
@@ -0,0 +1,507 @@
1
+ import { NgTemplateOutlet } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { input, inject, ElementRef, Injector, contentChildren, contentChild, ChangeDetectionStrategy, Component, viewChild, DestroyRef, linkedSignal, computed, isDevMode, afterNextRender, effect, untracked } from '@angular/core';
4
+ import * as i2 from '@cngx/common/a11y';
5
+ import { CngxLiveRegion, CngxRovingItem, CngxRovingTabindex, CngxFocusRestore, CngxActiveDescendant } from '@cngx/common/a11y';
6
+ import * as i1 from '@cngx/common/tabs';
7
+ import { CNGX_TAB_GROUP_HOST, injectTabsI18n, injectTabsConfig, CNGX_TABS_GLYPHS, CngxTab, CngxTabErrorBadge, CngxTabRejectionIcon, CngxTabBusySpinner, createTabGroupAnnouncements, CNGX_ORGANISM_SCROLL_SYNC_FACTORY, CNGX_DIRECTIVE_BY_ID_MAP_FACTORY, createTabGroupTemplateBindings, CNGX_TAB_PANEL_HOST, CngxTabGroupPresenter, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY, tabOverflowOptionId, CngxTabOverflowTrigger, CngxTabOverflowItem, createTabOverflowTemplateBindings, CNGX_DOM_ANCHOR_RETRY_FACTORY, CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY } from '@cngx/common/tabs';
8
+ import { CngxClickOutside } from '@cngx/common/interactive';
9
+ import { CngxPopover, CngxPopoverTrigger } from '@cngx/common/popover';
10
+
11
+ /**
12
+ * CNGX tab-group organism. Thin shell over {@link CngxTabGroupPresenter}
13
+ * + `CngxRovingTabindex` + `CngxFocusRestore` via `hostDirectives`.
14
+ * Material variant lives at `[cngxMatTabs]` in `@cngx/ui/mat-tabs`.
15
+ *
16
+ * All ARIA attrs are signal-driven — never one-shot bindings.
17
+ * `CngxLiveRegion` is mounted as a child `<span>` rather than a
18
+ * host directive: its `role="status"` would clobber the wrapper's
19
+ * `role="group"` landmark.
20
+ */
21
+ class CngxTabGroup {
22
+ ariaLabel = input(undefined, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
23
+ ariaLabelledBy = input(undefined, { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: 'aria-labelledby' });
24
+ presenter = inject(CNGX_TAB_GROUP_HOST);
25
+ i18n = injectTabsI18n();
26
+ config = injectTabsConfig();
27
+ /** Default-glyph table for the template's fallback spans. Pillar 1. */
28
+ glyphs = CNGX_TABS_GLYPHS;
29
+ hostElement = inject(ElementRef).nativeElement;
30
+ injector = inject(Injector);
31
+ tabDirectives = contentChildren(CngxTab, { ...(ngDevMode ? { debugName: "tabDirectives" } : /* istanbul ignore next */ {}), descendants: true });
32
+ /**
33
+ * Per-instance skin slots. Resolved via 3-stage cascade in {@link templates}:
34
+ * `*cngxTab*` directive > `CNGX_TABS_CONFIG.templates.<key>` > built-in.
35
+ * AOT (NG8110) requires `contentChild()` to be a direct field initialiser
36
+ * on the variant — cascade resolution is delegated to the factory.
37
+ */
38
+ errorBadgeSlot = contentChild(CngxTabErrorBadge, ...(ngDevMode ? [{ debugName: "errorBadgeSlot" }] : /* istanbul ignore next */ []));
39
+ rejectionIconSlot = contentChild(CngxTabRejectionIcon, ...(ngDevMode ? [{ debugName: "rejectionIconSlot" }] : /* istanbul ignore next */ []));
40
+ busySpinnerSlot = contentChild(CngxTabBusySpinner, ...(ngDevMode ? [{ debugName: "busySpinnerSlot" }] : /* istanbul ignore next */ []));
41
+ /**
42
+ * AT-announcement bundle from `@cngx/common/tabs/announcements/`.
43
+ * Owns role descriptions, resolved aria-label, live-region phrasing,
44
+ * and the prior-active-index `linkedSignal` driving the success-arm
45
+ * direction prefix.
46
+ */
47
+ announcements = createTabGroupAnnouncements({
48
+ presenter: this.presenter,
49
+ i18n: this.i18n,
50
+ config: this.config,
51
+ ariaLabel: this.ariaLabel,
52
+ ariaLabelledBy: this.ariaLabelledBy,
53
+ });
54
+ constructor() {
55
+ // Self-healing scroll loop: activeId change -> scrollIntoView ->
56
+ // overflow IO sees new visibility -> More dropdown self-trims.
57
+ // Policy is swappable via CNGX_ORGANISM_SCROLL_SYNC_FACTORY.
58
+ inject(CNGX_ORGANISM_SCROLL_SYNC_FACTORY)({
59
+ activeId: this.presenter.activeId,
60
+ hostElement: this.hostElement,
61
+ injector: this.injector,
62
+ });
63
+ }
64
+ // Map<id, CngxTab> for O(1) labelTemplateFor / contentTemplateFor.
65
+ // Structural equal on id-set + directive identity prevents cascade
66
+ // on shape-stable contentChildren re-emissions.
67
+ tabDirectiveById = inject(CNGX_DIRECTIVE_BY_ID_MAP_FACTORY)({
68
+ source: this.tabDirectives,
69
+ });
70
+ /**
71
+ * Resolved 3-stage cascade for `errorBadge`, `rejectionIcon`, `busySpinner`.
72
+ * `null` -> render built-in default span.
73
+ */
74
+ templates = createTabGroupTemplateBindings({
75
+ errorBadgeSlot: this.errorBadgeSlot,
76
+ rejectionIconSlot: this.rejectionIconSlot,
77
+ busySpinnerSlot: this.busySpinnerSlot,
78
+ config: this.config,
79
+ });
80
+ tabs = this.presenter.tabs;
81
+ activeIndex = this.presenter.activeIndex;
82
+ activeId = this.presenter.activeId;
83
+ orientation = this.presenter.orientation;
84
+ isSelected(tab) {
85
+ return tab.id === this.activeId();
86
+ }
87
+ isTabBusy(tab) {
88
+ if (this.presenter.commitState.status() !== 'pending') {
89
+ return false;
90
+ }
91
+ const intended = this.presenter.intendedIndex();
92
+ if (intended === undefined) {
93
+ return false;
94
+ }
95
+ return this.tabs()[intended]?.id === tab.id;
96
+ }
97
+ tabHeaderId(tab) {
98
+ return `${tab.id}-header`;
99
+ }
100
+ tabPanelId(tab) {
101
+ return `${tab.id}-panel`;
102
+ }
103
+ tabDescriptorId(tab) {
104
+ return `${tab.id}-desc`;
105
+ }
106
+ /** `true` when a bound error-aggregator opted in to revealing errors. */
107
+ showErrorBadge(tab) {
108
+ return !!tab.errorAggregator()?.shouldShow();
109
+ }
110
+ /**
111
+ * Stable per-tab `*cngxTabErrorBadge` context cache. Context is
112
+ * `{ tab }` only (no reactive fields), so a `WeakMap` keeps the
113
+ * reference stable and lets `*ngTemplateOutlet`'s `Object.is`
114
+ * input-diff short-circuit the embedded-view rebind.
115
+ */
116
+ errorBadgeContextCache = new WeakMap();
117
+ /** `WeakMap`-cached context for `*cngxTabErrorBadge`. Stable ref per tab. */
118
+ errorBadgeContextFor(tab) {
119
+ let ctx = this.errorBadgeContextCache.get(tab);
120
+ if (!ctx) {
121
+ ctx = { tab };
122
+ this.errorBadgeContextCache.set(tab, ctx);
123
+ }
124
+ return ctx;
125
+ }
126
+ /**
127
+ * Context for `*cngxTabBusySpinner`. Allocates fresh per CD —
128
+ * `intendedIndex` is reactive, and `*ngTemplateOutlet` only
129
+ * re-evaluates `let-*` bindings when the context reference changes
130
+ * (`Object.is` input-diff); a cached mutated object would leave
131
+ * consumer bindings stale. `intendedIndex` is non-undefined by gate
132
+ * — `isTabBusy(tab)` returning `true` requires it.
133
+ */
134
+ busySpinnerContextFor(tab) {
135
+ return { tab, intendedIndex: this.presenter.intendedIndex() ?? -1 };
136
+ }
137
+ /**
138
+ * Context for `*cngxTabRejectionIcon`. `originLabel` matches the
139
+ * `liveAnnouncement` priority chain so visual + SR phrasing align.
140
+ * Allocates fresh per CD for the same reason as
141
+ * {@link busySpinnerContextFor}.
142
+ */
143
+ rejectionIconContextFor(failedIndex) {
144
+ const originIdx = this.presenter.originIndexDuringCommit();
145
+ const originLabel = originIdx !== undefined ? this.presenter.tabs()[originIdx]?.label() : undefined;
146
+ return { failedIndex, originLabel };
147
+ }
148
+ handleHeaderClick(tab) {
149
+ if (tab.disabled()) {
150
+ return;
151
+ }
152
+ const idx = this.tabs().findIndex((t) => t.id === tab.id);
153
+ if (idx >= 0) {
154
+ this.presenter.select(idx);
155
+ }
156
+ }
157
+ // CngxTabPanelHost contract — presenter owns clamping, disabled-skip,
158
+ // commit-action gating.
159
+ selectById(id) {
160
+ this.presenter.selectById(id);
161
+ }
162
+ /**
163
+ * Clear the presenter's `lastFailedIndex` rejection flag — exposed
164
+ * so template-ref consumers (`#tg="cngxTabGroup"`) can dismiss the
165
+ * decoration without injecting the host token.
166
+ */
167
+ clearLastFailed() {
168
+ this.presenter.clearLastFailed();
169
+ }
170
+ labelTemplateFor(id) {
171
+ return (this.tabDirectiveById().get(id)?.labelTemplate()?.templateRef ?? null);
172
+ }
173
+ contentTemplateFor(id) {
174
+ return (this.tabDirectiveById().get(id)?.contentTemplate()?.templateRef ?? null);
175
+ }
176
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
177
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxTabGroup, isStandalone: true, selector: "cngx-tab-group", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "attr.aria-roledescription": "announcements.tabsRoleDescription()", "attr.aria-orientation": "presenter.orientation()", "attr.data-orientation": "presenter.orientation()", "attr.aria-label": "announcements.resolvedAriaLabel()", "attr.aria-labelledby": "ariaLabelledBy()", "class.cngx-tabs": "true" } }, providers: [{ provide: CNGX_TAB_PANEL_HOST, useExisting: CngxTabGroup }], queries: [{ propertyName: "tabDirectives", predicate: CngxTab, descendants: true, isSignal: true }, { propertyName: "errorBadgeSlot", first: true, predicate: CngxTabErrorBadge, descendants: true, isSignal: true }, { propertyName: "rejectionIconSlot", first: true, predicate: CngxTabRejectionIcon, descendants: true, isSignal: true }, { propertyName: "busySpinnerSlot", first: true, predicate: CngxTabBusySpinner, descendants: true, isSignal: true }], exportAs: ["cngxTabGroup"], hostDirectives: [{ directive: i1.CngxTabGroupPresenter, inputs: ["activeIndex", "activeIndex", "orientation", "orientation", "loop", "loop", "commitAction", "commitAction", "commitMode", "commitMode"], outputs: ["activeIndexChange", "activeIndexChange"] }, { directive: i2.CngxRovingTabindex, inputs: ["orientation", "orientation", "loop", "loop"] }, { directive: i2.CngxFocusRestore }], ngImport: i0, template: "<div class=\"cngx-tabs__strip-wrapper\">\n@let failedIdx = presenter.lastFailedIndex();\n<div\n class=\"cngx-tabs__strip\"\n role=\"tablist\"\n [attr.aria-orientation]=\"presenter.orientation()\"\n>\n @for (tab of tabs(); track tab.id; let i = $index) {\n <button\n type=\"button\"\n cngxRovingItem\n class=\"cngx-tabs__tab\"\n [class.cngx-tab--rejected]=\"failedIdx === i\"\n role=\"tab\"\n [id]=\"tabHeaderId(tab)\"\n [attr.aria-label]=\"announcements.tabAriaLabel(tab, i + 1)\"\n [attr.aria-selected]=\"isSelected(tab) ? 'true' : 'false'\"\n [attr.aria-controls]=\"tabPanelId(tab)\"\n [attr.aria-disabled]=\"tab.disabled() ? 'true' : null\"\n [attr.aria-busy]=\"isTabBusy(tab) ? 'true' : null\"\n [attr.aria-describedby]=\"tabDescriptorId(tab)\"\n [cngxRovingItemDisabled]=\"tab.disabled()\"\n (click)=\"handleHeaderClick(tab)\"\n >\n <span class=\"cngx-tabs__label\">\n @let labelTpl = labelTemplateFor(tab.id);\n @if (labelTpl) {\n <ng-container *ngTemplateOutlet=\"labelTpl\"></ng-container>\n } @else {\n {{ tab.label() }}\n }\n </span>\n @if (showErrorBadge(tab)) {\n @let errorBadgeTpl = templates.errorBadge();\n @if (errorBadgeTpl) {\n <ng-container\n *ngTemplateOutlet=\"\n errorBadgeTpl;\n context: errorBadgeContextFor(tab)\n \"\n ></ng-container>\n } @else {\n <span class=\"cngx-tabs__badge\" aria-hidden=\"true\">{{\n glyphs.errorBadge\n }}</span>\n }\n }\n @if (failedIdx === i) {\n @let rejectionIconTpl = templates.rejectionIcon();\n @if (rejectionIconTpl) {\n <ng-container\n *ngTemplateOutlet=\"\n rejectionIconTpl;\n context: rejectionIconContextFor(i)\n \"\n ></ng-container>\n } @else {\n <span class=\"cngx-tabs__rejection-icon\" aria-hidden=\"true\">{{\n glyphs.rejectionIcon\n }}</span>\n }\n }\n @if (isTabBusy(tab)) {\n @let busySpinnerTpl = templates.busySpinner();\n @if (busySpinnerTpl) {\n <ng-container\n *ngTemplateOutlet=\"\n busySpinnerTpl;\n context: busySpinnerContextFor(tab)\n \"\n ></ng-container>\n } @else {\n <span class=\"cngx-tabs__busy-spinner\" aria-hidden=\"true\"></span>\n }\n }\n <span class=\"cngx-sr-only\" [id]=\"tabDescriptorId(tab)\">{{\n announcements.statusPhrase(tab)\n }}</span>\n </button>\n }\n</div>\n<ng-content select=\"cngx-tab-overflow\"></ng-content>\n</div>\n\n<div class=\"cngx-tabs__panels\">\n @for (tab of tabs(); track tab.id) {\n <div\n class=\"cngx-tabs__panel\"\n role=\"tabpanel\"\n [id]=\"tabPanelId(tab)\"\n [attr.aria-labelledby]=\"tabHeaderId(tab)\"\n [attr.aria-roledescription]=\"announcements.tabPanelRoleDescription()\"\n [hidden]=\"!isSelected(tab)\"\n >\n @let contentTpl = contentTemplateFor(tab.id);\n @if (contentTpl) {\n <ng-container *ngTemplateOutlet=\"contentTpl\"></ng-container>\n }\n </div>\n }\n</div>\n\n<span class=\"cngx-tabs__live-region cngx-sr-only\" cngxLiveRegion>{{\n announcements.liveAnnouncement()\n}}</span>\n\n<!--\n Generic slot for opt-in skin sub-components other than the\n overflow molecule (which projects into the strip-wrapper via the\n named `select=\"cngx-tab-overflow\"` slot above). Projected content\n sees `CNGX_TAB_PANEL_HOST` via the organism's provider, so\n molecules inject the contract without reaching for the concrete\n `CngxTabGroup` class.\n-->\n<ng-content></ng-content>\n", styles: [":host{display:block}.cngx-tabs__strip-wrapper{display:flex;flex-direction:row;align-items:stretch;position:relative}.cngx-tabs__strip{display:flex;flex-direction:row;flex-wrap:nowrap;align-items:stretch;flex:1 1 auto;min-width:0;gap:var(--cngx-tab-gap, .5rem);padding:var(--cngx-tab-strip-padding, .5rem 0);background:var(--cngx-tab-strip-bg, transparent);overflow-x:hidden;overflow-y:hidden;scroll-snap-type:x proximity}.cngx-tabs__tab{display:inline-flex;align-items:center;gap:var(--cngx-tab-gap, .5rem);padding:var(--cngx-tab-padding, .5rem .75rem);border:0;background:var(--cngx-tab-bg, transparent);color:var(--cngx-tab-color, currentColor);cursor:pointer;font:inherit;text-align:start;white-space:nowrap;scroll-snap-align:start}.cngx-tabs__tab[aria-selected=true]{color:var(--cngx-tab-active-color, currentColor)}.cngx-tabs__tab[aria-disabled=true]{cursor:not-allowed;opacity:var(--cngx-tab-disabled-opacity, .55)}.cngx-tabs__tab:focus-visible{outline:var(--cngx-tab-focus-ring, 2px solid currentColor);outline-offset:var(--cngx-tab-focus-offset, 2px)}.cngx-tabs__tab[aria-busy=true]{cursor:progress}.cngx-tabs__label{flex:1 1 auto;min-width:0}.cngx-tabs__badge{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;background:var(--cngx-tab-error-badge-color, #c62828);margin-inline-start:var(--cngx-tab-gap, .5rem)}.cngx-tabs__busy-spinner{display:inline-block;width:var(--cngx-tab-busy-spinner-size, 1rem);height:var(--cngx-tab-busy-spinner-size, 1rem);border:2px solid transparent;border-top-color:var(--cngx-tab-busy-spinner-color, currentColor);border-right-color:var(--cngx-tab-busy-spinner-color, currentColor);border-radius:50%;flex:0 0 auto;margin-inline-start:var(--cngx-tab-gap, .5rem);animation:cngx-tabs-spin .75s linear infinite}@keyframes cngx-tabs-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.cngx-tabs__panels{display:block}.cngx-tabs__panel{display:block;padding:var(--cngx-tab-padding, .5rem .75rem)}.cngx-tabs__panel[hidden]{display:none}.cngx-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}:host([data-orientation=\"vertical\"]){display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:var(--cngx-tab-gap, .5rem);align-items:start}:host([data-orientation=\"vertical\"]) .cngx-tabs__strip{flex-direction:column;flex-wrap:nowrap;overflow-x:hidden;overflow-y:auto;scroll-snap-type:y proximity}:host([data-orientation=\"vertical\"]) .cngx-tabs__tab{scroll-snap-align:start;white-space:normal}@media(prefers-reduced-motion:reduce){.cngx-tabs__busy-spinner{animation:none!important}}.cngx-tabs__rejection-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:var(--cngx-tab-rejection-icon-size, 1.25rem);height:var(--cngx-tab-rejection-icon-size, 1.25rem);border-radius:50%;background:var(--cngx-tab-rejection-icon-color, #c62828);color:var(--cngx-tab-rejection-icon-text, #fff);font-size:var(--cngx-tab-rejection-icon-font-size, .875rem);font-weight:700;line-height:1;margin-inline-start:var(--cngx-tab-gap, .5rem)}.cngx-tabs__tab.cngx-tab--rejected{outline:var( --cngx-tab-rejected-outline, 2px solid var(--cngx-tab-rejection-icon-color, #c62828) );outline-offset:var(--cngx-tab-rejected-outline-offset, 1px)}@media(prefers-reduced-motion:no-preference){.cngx-tabs__tab.cngx-tab--rejected{animation:cngx-tab-pulse-error var(--cngx-tab-rejected-pulse-duration, .6s) ease-out}@keyframes cngx-tab-pulse-error{0%{background:var(--cngx-tab-bg, transparent)}50%{background:var(--cngx-tab-rejected-pulse-bg, rgba(198, 40, 40, .18))}to{background:var(--cngx-tab-bg, transparent)}}}\n", ":host{font:inherit}.cngx-tabs__strip{border-bottom:var(--cngx-tab-strip-border, 1px solid currentColor)}.cngx-tabs__tab{position:relative;border-bottom:var(--cngx-tab-indicator-thickness, 2px) solid transparent;margin-bottom:calc(var(--cngx-tab-indicator-thickness, 2px) * -1);transition:color var(--cngx-tab-transition-duration, .15s) ease,border-color var(--cngx-tab-transition-duration, .15s) ease}.cngx-tabs__tab:hover:not([aria-disabled=true]){color:var(--cngx-tab-hover-color, var(--cngx-tab-active-color))}.cngx-tabs__tab[aria-selected=true]{color:var(--cngx-tab-active-color);border-bottom-color:var(--cngx-tab-active-indicator-color, currentColor)}:host([data-orientation=\"vertical\"]) .cngx-tabs__strip{border-bottom:0;border-inline-end:var(--cngx-tab-strip-border, 1px solid currentColor)}:host([data-orientation=\"vertical\"]) .cngx-tabs__tab{border-bottom:0;margin-bottom:0;border-inline-end:var(--cngx-tab-indicator-thickness, 2px) solid transparent;margin-inline-end:calc(var(--cngx-tab-indicator-thickness, 2px) * -1)}:host([data-orientation=\"vertical\"]) .cngx-tabs__tab[aria-selected=true]{border-inline-end-color:var( --cngx-tab-active-indicator-color, currentColor )}.cngx-tabs__badge{width:var(--cngx-tab-badge-size, 1.25rem);height:var(--cngx-tab-badge-size, 1.25rem);border-radius:50%;color:var(--cngx-tab-error-badge-text-color, white);font-size:var(--cngx-tab-badge-font-size, .75em);font-weight:var(--cngx-tab-badge-font-weight, 700);line-height:1}@media(prefers-reduced-motion:reduce){.cngx-tabs__tab{transition:none!important}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CngxLiveRegion, selector: "[cngxLiveRegion]", inputs: ["politeness", "atomic", "relevant"], exportAs: ["cngxLiveRegion"] }, { kind: "directive", type: CngxRovingItem, selector: "[cngxRovingItem]", inputs: ["cngxRovingItemDisabled"], exportAs: ["cngxRovingItem"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
178
+ }
179
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabGroup, decorators: [{
180
+ type: Component,
181
+ args: [{ selector: 'cngx-tab-group', exportAs: 'cngxTabGroup', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet, CngxLiveRegion, CngxRovingItem], hostDirectives: [
182
+ {
183
+ directive: CngxTabGroupPresenter,
184
+ inputs: [
185
+ 'activeIndex',
186
+ 'orientation',
187
+ 'loop',
188
+ 'commitAction',
189
+ 'commitMode',
190
+ ],
191
+ outputs: ['activeIndexChange'],
192
+ },
193
+ {
194
+ directive: CngxRovingTabindex,
195
+ inputs: ['orientation', 'loop'],
196
+ },
197
+ { directive: CngxFocusRestore },
198
+ ], providers: [{ provide: CNGX_TAB_PANEL_HOST, useExisting: CngxTabGroup }], host: {
199
+ role: 'group',
200
+ '[attr.aria-roledescription]': 'announcements.tabsRoleDescription()',
201
+ '[attr.aria-orientation]': 'presenter.orientation()',
202
+ '[attr.data-orientation]': 'presenter.orientation()',
203
+ '[attr.aria-label]': 'announcements.resolvedAriaLabel()',
204
+ '[attr.aria-labelledby]': 'ariaLabelledBy()',
205
+ '[class.cngx-tabs]': 'true',
206
+ }, template: "<div class=\"cngx-tabs__strip-wrapper\">\n@let failedIdx = presenter.lastFailedIndex();\n<div\n class=\"cngx-tabs__strip\"\n role=\"tablist\"\n [attr.aria-orientation]=\"presenter.orientation()\"\n>\n @for (tab of tabs(); track tab.id; let i = $index) {\n <button\n type=\"button\"\n cngxRovingItem\n class=\"cngx-tabs__tab\"\n [class.cngx-tab--rejected]=\"failedIdx === i\"\n role=\"tab\"\n [id]=\"tabHeaderId(tab)\"\n [attr.aria-label]=\"announcements.tabAriaLabel(tab, i + 1)\"\n [attr.aria-selected]=\"isSelected(tab) ? 'true' : 'false'\"\n [attr.aria-controls]=\"tabPanelId(tab)\"\n [attr.aria-disabled]=\"tab.disabled() ? 'true' : null\"\n [attr.aria-busy]=\"isTabBusy(tab) ? 'true' : null\"\n [attr.aria-describedby]=\"tabDescriptorId(tab)\"\n [cngxRovingItemDisabled]=\"tab.disabled()\"\n (click)=\"handleHeaderClick(tab)\"\n >\n <span class=\"cngx-tabs__label\">\n @let labelTpl = labelTemplateFor(tab.id);\n @if (labelTpl) {\n <ng-container *ngTemplateOutlet=\"labelTpl\"></ng-container>\n } @else {\n {{ tab.label() }}\n }\n </span>\n @if (showErrorBadge(tab)) {\n @let errorBadgeTpl = templates.errorBadge();\n @if (errorBadgeTpl) {\n <ng-container\n *ngTemplateOutlet=\"\n errorBadgeTpl;\n context: errorBadgeContextFor(tab)\n \"\n ></ng-container>\n } @else {\n <span class=\"cngx-tabs__badge\" aria-hidden=\"true\">{{\n glyphs.errorBadge\n }}</span>\n }\n }\n @if (failedIdx === i) {\n @let rejectionIconTpl = templates.rejectionIcon();\n @if (rejectionIconTpl) {\n <ng-container\n *ngTemplateOutlet=\"\n rejectionIconTpl;\n context: rejectionIconContextFor(i)\n \"\n ></ng-container>\n } @else {\n <span class=\"cngx-tabs__rejection-icon\" aria-hidden=\"true\">{{\n glyphs.rejectionIcon\n }}</span>\n }\n }\n @if (isTabBusy(tab)) {\n @let busySpinnerTpl = templates.busySpinner();\n @if (busySpinnerTpl) {\n <ng-container\n *ngTemplateOutlet=\"\n busySpinnerTpl;\n context: busySpinnerContextFor(tab)\n \"\n ></ng-container>\n } @else {\n <span class=\"cngx-tabs__busy-spinner\" aria-hidden=\"true\"></span>\n }\n }\n <span class=\"cngx-sr-only\" [id]=\"tabDescriptorId(tab)\">{{\n announcements.statusPhrase(tab)\n }}</span>\n </button>\n }\n</div>\n<ng-content select=\"cngx-tab-overflow\"></ng-content>\n</div>\n\n<div class=\"cngx-tabs__panels\">\n @for (tab of tabs(); track tab.id) {\n <div\n class=\"cngx-tabs__panel\"\n role=\"tabpanel\"\n [id]=\"tabPanelId(tab)\"\n [attr.aria-labelledby]=\"tabHeaderId(tab)\"\n [attr.aria-roledescription]=\"announcements.tabPanelRoleDescription()\"\n [hidden]=\"!isSelected(tab)\"\n >\n @let contentTpl = contentTemplateFor(tab.id);\n @if (contentTpl) {\n <ng-container *ngTemplateOutlet=\"contentTpl\"></ng-container>\n }\n </div>\n }\n</div>\n\n<span class=\"cngx-tabs__live-region cngx-sr-only\" cngxLiveRegion>{{\n announcements.liveAnnouncement()\n}}</span>\n\n<!--\n Generic slot for opt-in skin sub-components other than the\n overflow molecule (which projects into the strip-wrapper via the\n named `select=\"cngx-tab-overflow\"` slot above). Projected content\n sees `CNGX_TAB_PANEL_HOST` via the organism's provider, so\n molecules inject the contract without reaching for the concrete\n `CngxTabGroup` class.\n-->\n<ng-content></ng-content>\n", styles: [":host{display:block}.cngx-tabs__strip-wrapper{display:flex;flex-direction:row;align-items:stretch;position:relative}.cngx-tabs__strip{display:flex;flex-direction:row;flex-wrap:nowrap;align-items:stretch;flex:1 1 auto;min-width:0;gap:var(--cngx-tab-gap, .5rem);padding:var(--cngx-tab-strip-padding, .5rem 0);background:var(--cngx-tab-strip-bg, transparent);overflow-x:hidden;overflow-y:hidden;scroll-snap-type:x proximity}.cngx-tabs__tab{display:inline-flex;align-items:center;gap:var(--cngx-tab-gap, .5rem);padding:var(--cngx-tab-padding, .5rem .75rem);border:0;background:var(--cngx-tab-bg, transparent);color:var(--cngx-tab-color, currentColor);cursor:pointer;font:inherit;text-align:start;white-space:nowrap;scroll-snap-align:start}.cngx-tabs__tab[aria-selected=true]{color:var(--cngx-tab-active-color, currentColor)}.cngx-tabs__tab[aria-disabled=true]{cursor:not-allowed;opacity:var(--cngx-tab-disabled-opacity, .55)}.cngx-tabs__tab:focus-visible{outline:var(--cngx-tab-focus-ring, 2px solid currentColor);outline-offset:var(--cngx-tab-focus-offset, 2px)}.cngx-tabs__tab[aria-busy=true]{cursor:progress}.cngx-tabs__label{flex:1 1 auto;min-width:0}.cngx-tabs__badge{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;background:var(--cngx-tab-error-badge-color, #c62828);margin-inline-start:var(--cngx-tab-gap, .5rem)}.cngx-tabs__busy-spinner{display:inline-block;width:var(--cngx-tab-busy-spinner-size, 1rem);height:var(--cngx-tab-busy-spinner-size, 1rem);border:2px solid transparent;border-top-color:var(--cngx-tab-busy-spinner-color, currentColor);border-right-color:var(--cngx-tab-busy-spinner-color, currentColor);border-radius:50%;flex:0 0 auto;margin-inline-start:var(--cngx-tab-gap, .5rem);animation:cngx-tabs-spin .75s linear infinite}@keyframes cngx-tabs-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.cngx-tabs__panels{display:block}.cngx-tabs__panel{display:block;padding:var(--cngx-tab-padding, .5rem .75rem)}.cngx-tabs__panel[hidden]{display:none}.cngx-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}:host([data-orientation=\"vertical\"]){display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:var(--cngx-tab-gap, .5rem);align-items:start}:host([data-orientation=\"vertical\"]) .cngx-tabs__strip{flex-direction:column;flex-wrap:nowrap;overflow-x:hidden;overflow-y:auto;scroll-snap-type:y proximity}:host([data-orientation=\"vertical\"]) .cngx-tabs__tab{scroll-snap-align:start;white-space:normal}@media(prefers-reduced-motion:reduce){.cngx-tabs__busy-spinner{animation:none!important}}.cngx-tabs__rejection-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:var(--cngx-tab-rejection-icon-size, 1.25rem);height:var(--cngx-tab-rejection-icon-size, 1.25rem);border-radius:50%;background:var(--cngx-tab-rejection-icon-color, #c62828);color:var(--cngx-tab-rejection-icon-text, #fff);font-size:var(--cngx-tab-rejection-icon-font-size, .875rem);font-weight:700;line-height:1;margin-inline-start:var(--cngx-tab-gap, .5rem)}.cngx-tabs__tab.cngx-tab--rejected{outline:var( --cngx-tab-rejected-outline, 2px solid var(--cngx-tab-rejection-icon-color, #c62828) );outline-offset:var(--cngx-tab-rejected-outline-offset, 1px)}@media(prefers-reduced-motion:no-preference){.cngx-tabs__tab.cngx-tab--rejected{animation:cngx-tab-pulse-error var(--cngx-tab-rejected-pulse-duration, .6s) ease-out}@keyframes cngx-tab-pulse-error{0%{background:var(--cngx-tab-bg, transparent)}50%{background:var(--cngx-tab-rejected-pulse-bg, rgba(198, 40, 40, .18))}to{background:var(--cngx-tab-bg, transparent)}}}\n", ":host{font:inherit}.cngx-tabs__strip{border-bottom:var(--cngx-tab-strip-border, 1px solid currentColor)}.cngx-tabs__tab{position:relative;border-bottom:var(--cngx-tab-indicator-thickness, 2px) solid transparent;margin-bottom:calc(var(--cngx-tab-indicator-thickness, 2px) * -1);transition:color var(--cngx-tab-transition-duration, .15s) ease,border-color var(--cngx-tab-transition-duration, .15s) ease}.cngx-tabs__tab:hover:not([aria-disabled=true]){color:var(--cngx-tab-hover-color, var(--cngx-tab-active-color))}.cngx-tabs__tab[aria-selected=true]{color:var(--cngx-tab-active-color);border-bottom-color:var(--cngx-tab-active-indicator-color, currentColor)}:host([data-orientation=\"vertical\"]) .cngx-tabs__strip{border-bottom:0;border-inline-end:var(--cngx-tab-strip-border, 1px solid currentColor)}:host([data-orientation=\"vertical\"]) .cngx-tabs__tab{border-bottom:0;margin-bottom:0;border-inline-end:var(--cngx-tab-indicator-thickness, 2px) solid transparent;margin-inline-end:calc(var(--cngx-tab-indicator-thickness, 2px) * -1)}:host([data-orientation=\"vertical\"]) .cngx-tabs__tab[aria-selected=true]{border-inline-end-color:var( --cngx-tab-active-indicator-color, currentColor )}.cngx-tabs__badge{width:var(--cngx-tab-badge-size, 1.25rem);height:var(--cngx-tab-badge-size, 1.25rem);border-radius:50%;color:var(--cngx-tab-error-badge-text-color, white);font-size:var(--cngx-tab-badge-font-size, .75em);font-weight:var(--cngx-tab-badge-font-weight, 700);line-height:1}@media(prefers-reduced-motion:reduce){.cngx-tabs__tab{transition:none!important}}\n"] }]
207
+ }], ctorParameters: () => [], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], tabDirectives: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxTab), { ...{
208
+ descendants: true,
209
+ }, isSignal: true }] }], errorBadgeSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabErrorBadge), { isSignal: true }] }], rejectionIconSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabRejectionIcon), { isSignal: true }] }], busySpinnerSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabBusySpinner), { isSignal: true }] }] } });
210
+
211
+ /** Structural equal for `hiddenTabs` — same ids in same order. */
212
+ function tabIdListEqual(a, b) {
213
+ if (a === b) {
214
+ return true;
215
+ }
216
+ if (a.length !== b.length) {
217
+ return false;
218
+ }
219
+ for (let i = 0; i < a.length; i++) {
220
+ if (a[i].id !== b[i].id) {
221
+ return false;
222
+ }
223
+ }
224
+ return true;
225
+ }
226
+ /** Auto-open keys for the trigger button (APG combobox). */
227
+ const NAV_OPEN_KEYS = new Set(['ArrowDown', 'ArrowUp', 'Home', 'End']);
228
+ /**
229
+ * Structural equal for `visibilityState`. Without this, the
230
+ * `update((prev) => new Map(prev))` cycle in `handleIntersections`
231
+ * cascades into `hiddenTabs` on every IO fire even when no tab
232
+ * actually flipped visibility.
233
+ */
234
+ function mapBoolEqual(a, b) {
235
+ if (a === b) {
236
+ return true;
237
+ }
238
+ if (a.size !== b.size) {
239
+ return false;
240
+ }
241
+ for (const [key, value] of a) {
242
+ if (b.get(key) !== value) {
243
+ return false;
244
+ }
245
+ }
246
+ return true;
247
+ }
248
+ /**
249
+ * Opt-in overflow indicator for `<cngx-tab-group>`. Surfaces clipped
250
+ * tab buttons through a "More" `CngxPopover` dropdown. Talks to the
251
+ * organism only via {@link CNGX_TAB_PANEL_HOST}.
252
+ *
253
+ * Visibility is tracked through a native `IntersectionObserver`
254
+ * rooted on the parent strip — `CngxIntersectionObserver` doesn't
255
+ * fit (single-element scope, can't reach sibling `viewChildren`).
256
+ * `threshold: 0` — only fully-clipped tabs surface. Combined with
257
+ * the organism's `scrollIntoView` effect this forms the self-healing
258
+ * loop: pick hidden tab -> strip scrolls -> IO fires -> `hiddenTabs`
259
+ * self-trims.
260
+ */
261
+ class CngxTabOverflow {
262
+ // Projected via <ng-content>, so DI walks up to the parent's injector.
263
+ // `{ host: true }` would scope to the molecule and miss the provider.
264
+ panelHost = inject(CNGX_TAB_PANEL_HOST);
265
+ i18n = injectTabsI18n();
266
+ popover = viewChild.required(CngxPopover);
267
+ adRef = viewChild.required(CngxActiveDescendant);
268
+ hostElement = inject(ElementRef).nativeElement;
269
+ destroyRef = inject(DestroyRef);
270
+ // DOM-resolution strategy. Default factory targets the cngx-native
271
+ // strip selectors; Material/custom variants swap via providers.
272
+ adapter = inject(CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY)();
273
+ // tab id -> visibility. `undefined` = not yet observed (treat as
274
+ // visible — prevents More-button flash on first render).
275
+ // `linkedSignal` prunes stale ids when the tabs list changes;
276
+ // observer re-attach lives in the effect below. `mapBoolEqual`
277
+ // suppresses identity-only re-emissions from the IO callback.
278
+ visibilityState = linkedSignal({ ...(ngDevMode ? { debugName: "visibilityState" } : /* istanbul ignore next */ {}), source: () => this.panelHost.tabs(),
279
+ computation: (tabs, prev) => {
280
+ if (!prev) {
281
+ return new Map();
282
+ }
283
+ const liveIds = new Set(tabs.map((t) => t.id));
284
+ const next = new Map();
285
+ for (const [id, vis] of prev.value) {
286
+ if (liveIds.has(id)) {
287
+ next.set(id, vis);
288
+ }
289
+ }
290
+ return next;
291
+ },
292
+ equal: mapBoolEqual });
293
+ hiddenTabs = computed(() => {
294
+ const visMap = this.visibilityState();
295
+ return this.panelHost.tabs().filter((t) => visMap.get(t.id) === false);
296
+ }, { ...(ngDevMode ? { debugName: "hiddenTabs" } : /* istanbul ignore next */ {}), equal: tabIdListEqual });
297
+ hasHiddenTabs = computed(() => this.hiddenTabs().length > 0, { ...(ngDevMode ? { debugName: "hasHiddenTabs" } : /* istanbul ignore next */ {}), equal: Object.is });
298
+ // Counter projected into trigger label + aria-label. Explicit
299
+ // computed isolates `Object.is` distinct-gate from `hiddenTabs`
300
+ // identity churn — prevents flicker on length-equal re-emissions.
301
+ hiddenCount = computed(() => this.hiddenTabs().length, ...(ngDevMode ? [{ debugName: "hiddenCount" }] : /* istanbul ignore next */ []));
302
+ // ARIA menu-button pattern: <button aria-haspopup="menu"> + popover
303
+ // role="menu". Quick-jump navigation (selectById is not a value
304
+ // commit), so menu/menuitem is correct — listbox/option implies
305
+ // persistent aria-selected. WAI-ARIA 1.2 §combobox forbids
306
+ // aria-haspopup="menu", so combobox is deliberately not used.
307
+ adItemId = tabOverflowOptionId;
308
+ // Read first — TS field-init order; downstream fields snapshot off this.
309
+ tabsConfig = injectTabsConfig();
310
+ // 3-stage cascade: directive > config.templates.overflow* > built-in.
311
+ // `contentChild` must be a field-direct initializer (Angular AOT).
312
+ triggerSlot = contentChild(CngxTabOverflowTrigger, ...(ngDevMode ? [{ debugName: "triggerSlot" }] : /* istanbul ignore next */ []));
313
+ itemSlot = contentChild(CngxTabOverflowItem, ...(ngDevMode ? [{ debugName: "itemSlot" }] : /* istanbul ignore next */ []));
314
+ templates = createTabOverflowTemplateBindings({
315
+ triggerSlot: this.triggerSlot,
316
+ itemSlot: this.itemSlot,
317
+ config: this.tabsConfig,
318
+ hiddenCount: this.hiddenCount,
319
+ hiddenTabs: this.hiddenTabs,
320
+ pickTab: (tab) => this.pickTab(tab),
321
+ });
322
+ observer = null;
323
+ // Variant-agnostic target -> id lookup. cngx-native uses
324
+ // `${id}-header`, Material `mat-tab-group-N-label-M`.
325
+ targetToHandleId = new WeakMap();
326
+ // IO-debounce knobs — see `CngxTabsConfig.overflowStabilizeMs` /
327
+ // `.overflowMaxDeferMs` for semantics. Captured once at construction.
328
+ stabilizeMs = this.tabsConfig.overflowStabilizeMs ?? 100;
329
+ maxDeferMs = this.tabsConfig.overflowMaxDeferMs ?? 250;
330
+ stabilizeHandle = null;
331
+ pendingEntries = [];
332
+ // performance.now() of the first entry since the last commit; null
333
+ // between commits. Drives the max-defer cap.
334
+ firstPendingAt = null;
335
+ // rAF-scheduled IO attach retry. `display: none` toggles do NOT
336
+ // recover — unmount/remount is required to re-arm. Policy swap
337
+ // via CNGX_DOM_ANCHOR_RETRY_FACTORY.
338
+ attachRetry = inject(CNGX_DOM_ANCHOR_RETRY_FACTORY)({
339
+ attempt: () => {
340
+ const root = this.resolveStrip();
341
+ if (!root) {
342
+ return null;
343
+ }
344
+ // threshold: 0 — any visible pixel = "in the strip". Drives
345
+ // the self-healing loop with the organism's scrollIntoView.
346
+ this.observer = new IntersectionObserver((entries) => this.handleIntersections(entries), { root, threshold: 0 });
347
+ this.observeCurrentTabs();
348
+ return true;
349
+ },
350
+ maxAttempts: 60,
351
+ schedule: (cb) => {
352
+ const handle = requestAnimationFrame(cb);
353
+ return () => cancelAnimationFrame(handle);
354
+ },
355
+ onGiveUp: () => {
356
+ if (isDevMode()) {
357
+ console.warn('[CngxTabOverflow] Strip wrapper not found after 60 attach ' +
358
+ 'attempts; the More popover will not surface clipped tabs. ' +
359
+ 'Verify the molecule is projected inside <cngx-tab-group> ' +
360
+ 'via its <ng-content> slot.');
361
+ }
362
+ },
363
+ });
364
+ constructor() {
365
+ afterNextRender(() => this.attachRetry.start());
366
+ // Re-observe on tab-list change. Stale-id pruning is derived in
367
+ // `visibilityState`'s linkedSignal source.
368
+ effect(() => {
369
+ this.panelHost.tabs();
370
+ untracked(() => {
371
+ if (!this.observer) {
372
+ return;
373
+ }
374
+ this.observer.disconnect();
375
+ this.observeCurrentTabs();
376
+ });
377
+ });
378
+ inject(CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY)(this.popover, this.adRef);
379
+ this.destroyRef.onDestroy(() => {
380
+ this.attachRetry.cancel();
381
+ if (this.stabilizeHandle !== null) {
382
+ clearTimeout(this.stabilizeHandle);
383
+ this.stabilizeHandle = null;
384
+ }
385
+ this.firstPendingAt = null;
386
+ this.pendingEntries.length = 0;
387
+ this.observer?.disconnect();
388
+ this.observer = null;
389
+ });
390
+ }
391
+ pickTab(tab) {
392
+ this.panelHost.selectById(tab.id);
393
+ this.popover().hide();
394
+ }
395
+ /** AD `(activated)` — Enter / Space on a highlighted option picks. */
396
+ handleAdActivated(value) {
397
+ const tab = value;
398
+ if (tab?.id) {
399
+ this.pickTab(tab);
400
+ }
401
+ }
402
+ /**
403
+ * Auto-opens popover on nav-key when collapsed. AD's host listener
404
+ * fires first, so `activeIndex` is already set when this runs.
405
+ * No-op while open — AD owns navigation.
406
+ */
407
+ handleTriggerKeydown(event) {
408
+ if (this.popover().isVisible() || !this.hasHiddenTabs()) {
409
+ return;
410
+ }
411
+ if (NAV_OPEN_KEYS.has(event.key)) {
412
+ this.popover().show();
413
+ }
414
+ }
415
+ observeCurrentTabs() {
416
+ if (!this.observer) {
417
+ return;
418
+ }
419
+ const root = this.resolveStrip();
420
+ if (!root) {
421
+ return;
422
+ }
423
+ const tabs = this.panelHost.tabs();
424
+ for (let idx = 0; idx < tabs.length; idx++) {
425
+ const button = this.adapter.resolveTabButton(tabs[idx], root, idx);
426
+ if (button) {
427
+ this.targetToHandleId.set(button, tabs[idx].id);
428
+ this.observer.observe(button);
429
+ }
430
+ }
431
+ }
432
+ handleIntersections(entries) {
433
+ // Buffer entries; signal write deferred to commitPendingVisibility
434
+ // once IO settles for stabilizeMs (capped by maxDeferMs).
435
+ for (const entry of entries) {
436
+ this.pendingEntries.push(entry);
437
+ }
438
+ const now = performance.now();
439
+ this.firstPendingAt ??= now;
440
+ if (this.stabilizeHandle !== null) {
441
+ clearTimeout(this.stabilizeHandle);
442
+ }
443
+ // Wait min(stabilizeMs, remaining max-defer). Math.max(0, …)
444
+ // guards a negative remaining after a long task.
445
+ const elapsed = now - this.firstPendingAt;
446
+ const maxDeferRemaining = this.maxDeferMs - elapsed;
447
+ const wait = Math.max(0, Math.min(this.stabilizeMs, maxDeferRemaining));
448
+ this.stabilizeHandle = setTimeout(() => this.commitPendingVisibility(), wait);
449
+ }
450
+ commitPendingVisibility() {
451
+ this.stabilizeHandle = null;
452
+ this.firstPendingAt = null;
453
+ const entries = this.pendingEntries;
454
+ if (entries.length === 0) {
455
+ return;
456
+ }
457
+ this.pendingEntries = [];
458
+ this.visibilityState.update((prev) => {
459
+ const next = new Map(prev);
460
+ for (const entry of entries) {
461
+ const target = entry.target;
462
+ const tabId = this.targetToHandleId.get(target);
463
+ if (tabId === undefined) {
464
+ // Stale registration during disconnect/observeCurrentTabs
465
+ // churn — skip rather than mis-key.
466
+ continue;
467
+ }
468
+ // threshold: 0 — partially-clipped stays visible; only
469
+ // fully-clipped surfaces as hidden.
470
+ next.set(tabId, entry.isIntersecting);
471
+ }
472
+ return next;
473
+ });
474
+ }
475
+ /**
476
+ * IO-root resolution via the injected adapter. Returns `null`
477
+ * before the molecule is anchored — the rAF retry loop re-polls.
478
+ */
479
+ resolveStrip() {
480
+ return this.adapter.resolveStripRoot(this.panelHost, this.hostElement);
481
+ }
482
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabOverflow, deps: [], target: i0.ɵɵFactoryTarget.Component });
483
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxTabOverflow, isStandalone: true, selector: "cngx-tab-overflow", host: { properties: { "class.cngx-tab-overflow": "true" } }, queries: [{ propertyName: "triggerSlot", first: true, predicate: CngxTabOverflowTrigger, descendants: true, isSignal: true }, { propertyName: "itemSlot", first: true, predicate: CngxTabOverflowItem, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "popover", first: true, predicate: CngxPopover, descendants: true, isSignal: true }, { propertyName: "adRef", first: true, predicate: CngxActiveDescendant, descendants: true, isSignal: true }], exportAs: ["cngxTabOverflow"], ngImport: i0, template: "<button\n type=\"button\"\n class=\"cngx-tab-overflow__trigger\"\n cngxActiveDescendant\n #ad=\"cngxActiveDescendant\"\n [items]=\"templates.adItems()\"\n [cngxPopoverTrigger]=\"overflowPopover\"\n [haspopup]=\"'menu'\"\n [hidden]=\"!hasHiddenTabs()\"\n [attr.aria-label]=\"i18n.moreTabsLabel(hiddenCount())\"\n (activated)=\"handleAdActivated($event)\"\n (keydown)=\"handleTriggerKeydown($event)\"\n (click)=\"overflowPopover.toggle()\"\n>\n @let triggerTpl = templates.triggerTemplate();\n @if (triggerTpl) {\n <ng-container\n *ngTemplateOutlet=\"triggerTpl; context: templates.triggerContext()\"\n />\n } @else {\n {{ i18n.moreTabsLabel(hiddenCount()) }}\n }\n</button>\n\n<div\n cngxPopover\n #overflowPopover=\"cngxPopover\"\n cngxClickOutside\n [eventType]=\"'click'\"\n [enabled]=\"overflowPopover.isVisible()\"\n (clickOutside)=\"overflowPopover.hide()\"\n role=\"menu\"\n class=\"cngx-tab-overflow__panel\"\n placement=\"bottom-end\"\n panelClass=\"cngx-tab-overflow__panel-surface\"\n [attr.aria-label]=\"i18n.moreTabsLabel(hiddenCount())\"\n>\n <!--\n `role=\"presentation\"` flattens the <ul> away from the\n accessibility tree so each <li role=\"menuitem\"> is exposed as a\n direct child of the role=\"menu\" landmark on the popover surface.\n Each item carries a stable id derived from the tab handle id;\n CngxActiveDescendant on the trigger steers `aria-activedescendant`\n at one of these ids while the user navigates with\n ArrowUp/Down/Home/End/typeahead. The popover is a quick-jump\n navigation surface \u2014 selecting an item triggers `selectById`,\n not a value commit \u2014 so menu/menuitem is the spec-correct pattern\n (listbox/option carries `aria-selected` semantics that do not\n apply to a transient navigation popup).\n -->\n <ul class=\"cngx-tab-overflow__list\" role=\"presentation\">\n @for (tab of hiddenTabs(); track tab.id; let i = $index) {\n <li\n role=\"menuitem\"\n class=\"cngx-tab-overflow__item\"\n [class.cngx-tab-overflow__item--active]=\"ad.activeId() === adItemId(tab)\"\n [id]=\"adItemId(tab)\"\n [attr.data-tab-id]=\"tab.id\"\n [attr.aria-disabled]=\"tab.disabled() ? 'true' : 'false'\"\n (click)=\"!tab.disabled() && pickTab(tab)\"\n >\n @let itemTpl = templates.itemTemplate();\n @if (itemTpl) {\n <ng-container\n *ngTemplateOutlet=\"itemTpl; context: templates.buildItemContext(tab, i)\"\n />\n } @else {\n {{ tab.label() ?? tab.id }}\n }\n </li>\n }\n </ul>\n</div>\n", styles: [":host{display:inline-flex;align-items:center;flex:0 0 auto;background:var( --cngx-tab-overflow-bg, var(--cngx-tab-strip-bg, transparent) )}.cngx-tab-overflow__trigger{display:inline-flex;align-items:center;gap:var(--cngx-tab-gap, .5rem);padding:var(--cngx-tab-padding, .5rem .75rem);border:0;background:var(--cngx-tab-overflow-button-bg, transparent);color:var(--cngx-tab-color);cursor:pointer;font:inherit;border-radius:var(--cngx-tab-overflow-button-radius, .25rem)}.cngx-tab-overflow__trigger[hidden]{display:none}.cngx-tab-overflow__trigger:focus-visible{outline:var(--cngx-tab-focus-ring, 2px solid currentColor);outline-offset:var(--cngx-tab-focus-offset, 2px)}.cngx-tab-overflow__panel-surface{min-width:var(--cngx-tab-overflow-popover-min-width, 12rem);max-height:var(--cngx-tab-overflow-popover-max-height, 16rem);background:var(--cngx-tab-overflow-popover-bg, white);border:var(--cngx-tab-overflow-popover-border, 1px solid currentColor);border-radius:var(--cngx-tab-overflow-popover-radius, .25rem);overflow:auto;padding:var(--cngx-tab-overflow-popover-padding, .25rem 0)}.cngx-tab-overflow__list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}.cngx-tab-overflow__item{padding:var( --cngx-tab-overflow-item-padding, .5rem .75rem );cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap}.cngx-tab-overflow__item:hover{background:var(--cngx-tab-overflow-item-hover-bg, rgba(0, 0, 0, .05))}.cngx-tab-overflow__item--active{background:var( --cngx-tab-overflow-item-active-bg, var(--cngx-tab-overflow-item-hover-bg, rgba(0, 0, 0, .08)) );outline:var( --cngx-tab-overflow-item-active-outline, 2px solid currentColor );outline-offset:var(--cngx-tab-overflow-item-active-outline-offset, -2px)}.cngx-tab-overflow__item[aria-disabled=true]{cursor:not-allowed;opacity:var(--cngx-tab-disabled-opacity, .55)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CngxActiveDescendant, selector: "[cngxActiveDescendant]", inputs: ["items", "orientation", "loop", "typeahead", "typeaheadDebounce", "autoHighlightFirst", "skipDisabled", "virtualCount"], outputs: ["activated", "highlighted"], exportAs: ["cngxActiveDescendant"] }, { kind: "directive", type: CngxClickOutside, selector: "[cngxClickOutside]", inputs: ["eventType", "enabled"], outputs: ["clickOutside"], exportAs: ["cngxClickOutside"] }, { kind: "directive", type: CngxPopover, selector: "[cngxPopover]", inputs: ["placement", "offset", "closeOnEscape", "mode", "cngxPopoverOpen", "exclusive"], exportAs: ["cngxPopover"] }, { kind: "directive", type: CngxPopoverTrigger, selector: "[cngxPopoverTrigger]", inputs: ["cngxPopoverTrigger", "haspopup"], exportAs: ["cngxPopoverTrigger"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
484
+ }
485
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabOverflow, decorators: [{
486
+ type: Component,
487
+ args: [{ selector: 'cngx-tab-overflow', exportAs: 'cngxTabOverflow', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
488
+ NgTemplateOutlet,
489
+ CngxActiveDescendant,
490
+ CngxClickOutside,
491
+ CngxPopover,
492
+ CngxPopoverTrigger,
493
+ ], host: {
494
+ '[class.cngx-tab-overflow]': 'true',
495
+ }, template: "<button\n type=\"button\"\n class=\"cngx-tab-overflow__trigger\"\n cngxActiveDescendant\n #ad=\"cngxActiveDescendant\"\n [items]=\"templates.adItems()\"\n [cngxPopoverTrigger]=\"overflowPopover\"\n [haspopup]=\"'menu'\"\n [hidden]=\"!hasHiddenTabs()\"\n [attr.aria-label]=\"i18n.moreTabsLabel(hiddenCount())\"\n (activated)=\"handleAdActivated($event)\"\n (keydown)=\"handleTriggerKeydown($event)\"\n (click)=\"overflowPopover.toggle()\"\n>\n @let triggerTpl = templates.triggerTemplate();\n @if (triggerTpl) {\n <ng-container\n *ngTemplateOutlet=\"triggerTpl; context: templates.triggerContext()\"\n />\n } @else {\n {{ i18n.moreTabsLabel(hiddenCount()) }}\n }\n</button>\n\n<div\n cngxPopover\n #overflowPopover=\"cngxPopover\"\n cngxClickOutside\n [eventType]=\"'click'\"\n [enabled]=\"overflowPopover.isVisible()\"\n (clickOutside)=\"overflowPopover.hide()\"\n role=\"menu\"\n class=\"cngx-tab-overflow__panel\"\n placement=\"bottom-end\"\n panelClass=\"cngx-tab-overflow__panel-surface\"\n [attr.aria-label]=\"i18n.moreTabsLabel(hiddenCount())\"\n>\n <!--\n `role=\"presentation\"` flattens the <ul> away from the\n accessibility tree so each <li role=\"menuitem\"> is exposed as a\n direct child of the role=\"menu\" landmark on the popover surface.\n Each item carries a stable id derived from the tab handle id;\n CngxActiveDescendant on the trigger steers `aria-activedescendant`\n at one of these ids while the user navigates with\n ArrowUp/Down/Home/End/typeahead. The popover is a quick-jump\n navigation surface \u2014 selecting an item triggers `selectById`,\n not a value commit \u2014 so menu/menuitem is the spec-correct pattern\n (listbox/option carries `aria-selected` semantics that do not\n apply to a transient navigation popup).\n -->\n <ul class=\"cngx-tab-overflow__list\" role=\"presentation\">\n @for (tab of hiddenTabs(); track tab.id; let i = $index) {\n <li\n role=\"menuitem\"\n class=\"cngx-tab-overflow__item\"\n [class.cngx-tab-overflow__item--active]=\"ad.activeId() === adItemId(tab)\"\n [id]=\"adItemId(tab)\"\n [attr.data-tab-id]=\"tab.id\"\n [attr.aria-disabled]=\"tab.disabled() ? 'true' : 'false'\"\n (click)=\"!tab.disabled() && pickTab(tab)\"\n >\n @let itemTpl = templates.itemTemplate();\n @if (itemTpl) {\n <ng-container\n *ngTemplateOutlet=\"itemTpl; context: templates.buildItemContext(tab, i)\"\n />\n } @else {\n {{ tab.label() ?? tab.id }}\n }\n </li>\n }\n </ul>\n</div>\n", styles: [":host{display:inline-flex;align-items:center;flex:0 0 auto;background:var( --cngx-tab-overflow-bg, var(--cngx-tab-strip-bg, transparent) )}.cngx-tab-overflow__trigger{display:inline-flex;align-items:center;gap:var(--cngx-tab-gap, .5rem);padding:var(--cngx-tab-padding, .5rem .75rem);border:0;background:var(--cngx-tab-overflow-button-bg, transparent);color:var(--cngx-tab-color);cursor:pointer;font:inherit;border-radius:var(--cngx-tab-overflow-button-radius, .25rem)}.cngx-tab-overflow__trigger[hidden]{display:none}.cngx-tab-overflow__trigger:focus-visible{outline:var(--cngx-tab-focus-ring, 2px solid currentColor);outline-offset:var(--cngx-tab-focus-offset, 2px)}.cngx-tab-overflow__panel-surface{min-width:var(--cngx-tab-overflow-popover-min-width, 12rem);max-height:var(--cngx-tab-overflow-popover-max-height, 16rem);background:var(--cngx-tab-overflow-popover-bg, white);border:var(--cngx-tab-overflow-popover-border, 1px solid currentColor);border-radius:var(--cngx-tab-overflow-popover-radius, .25rem);overflow:auto;padding:var(--cngx-tab-overflow-popover-padding, .25rem 0)}.cngx-tab-overflow__list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}.cngx-tab-overflow__item{padding:var( --cngx-tab-overflow-item-padding, .5rem .75rem );cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap}.cngx-tab-overflow__item:hover{background:var(--cngx-tab-overflow-item-hover-bg, rgba(0, 0, 0, .05))}.cngx-tab-overflow__item--active{background:var( --cngx-tab-overflow-item-active-bg, var(--cngx-tab-overflow-item-hover-bg, rgba(0, 0, 0, .08)) );outline:var( --cngx-tab-overflow-item-active-outline, 2px solid currentColor );outline-offset:var(--cngx-tab-overflow-item-active-outline-offset, -2px)}.cngx-tab-overflow__item[aria-disabled=true]{cursor:not-allowed;opacity:var(--cngx-tab-disabled-opacity, .55)}\n"] }]
496
+ }], ctorParameters: () => [], propDecorators: { popover: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxPopover), { isSignal: true }] }], adRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxActiveDescendant), { isSignal: true }] }], triggerSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabOverflowTrigger), { isSignal: true }] }], itemSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabOverflowItem), { isSignal: true }] }] } });
497
+
498
+ /**
499
+ * @module @cngx/ui/tabs
500
+ */
501
+
502
+ /**
503
+ * Generated bundle index. Do not edit.
504
+ */
505
+
506
+ export { CngxTabGroup, CngxTabOverflow };
507
+ //# sourceMappingURL=cngx-ui-tabs.mjs.map