@cngx/ui 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.
Files changed (108) hide show
  1. package/README.md +118 -59
  2. package/action-button/README.md +170 -53
  3. package/breadcrumb/README.md +5 -6
  4. package/collection/README.md +1 -1
  5. package/command-palette/README.md +9 -5
  6. package/data-grid-accordion/README.md +1 -1
  7. package/empty-state/README.md +2 -3
  8. package/feedback/README.md +1 -1
  9. package/fesm2022/cngx-ui-a11y.mjs +13 -23
  10. package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
  11. package/fesm2022/cngx-ui-accordion.mjs +55 -60
  12. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  13. package/fesm2022/cngx-ui-action-button.mjs +220 -339
  14. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  15. package/fesm2022/cngx-ui-breadcrumb.mjs +100 -80
  16. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  17. package/fesm2022/cngx-ui-chart-panel.mjs +18 -31
  18. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
  19. package/fesm2022/cngx-ui-collection.mjs +28 -34
  20. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  21. package/fesm2022/cngx-ui-command-palette.mjs +29 -51
  22. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
  23. package/fesm2022/cngx-ui-context-menu.mjs +138 -89
  24. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
  25. package/fesm2022/cngx-ui-data-grid-accordion.mjs +135 -77
  26. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  27. package/fesm2022/cngx-ui-empty-state.mjs +17 -44
  28. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
  29. package/fesm2022/cngx-ui-feedback.mjs +648 -495
  30. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  31. package/fesm2022/cngx-ui-layout.mjs +17 -13
  32. package/fesm2022/cngx-ui-layout.mjs.map +1 -1
  33. package/fesm2022/cngx-ui-mat-accordion.mjs +6 -7
  34. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  35. package/fesm2022/cngx-ui-mat-paginator.mjs +5 -9
  36. package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
  37. package/fesm2022/cngx-ui-mat-stepper.mjs +6 -9
  38. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
  39. package/fesm2022/cngx-ui-mat-tabs.mjs +315 -134
  40. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  41. package/fesm2022/cngx-ui-nav-rail.mjs +440 -0
  42. package/fesm2022/cngx-ui-nav-rail.mjs.map +1 -0
  43. package/fesm2022/cngx-ui-overlay.mjs +9 -10
  44. package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
  45. package/fesm2022/cngx-ui-paginator.mjs +212 -188
  46. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  47. package/fesm2022/cngx-ui-sidenav.mjs +872 -721
  48. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  49. package/fesm2022/cngx-ui-skeleton.mjs +17 -19
  50. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  51. package/fesm2022/cngx-ui-speak.mjs +21 -74
  52. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  53. package/fesm2022/cngx-ui-stat-card.mjs +39 -62
  54. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
  55. package/fesm2022/cngx-ui-stepper.mjs +259 -130
  56. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  57. package/fesm2022/cngx-ui-tabs.mjs +148 -50
  58. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  59. package/fesm2022/cngx-ui-timeline.mjs +48 -32
  60. package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
  61. package/fesm2022/cngx-ui-toc.mjs +59 -48
  62. package/fesm2022/cngx-ui-toc.mjs.map +1 -1
  63. package/fesm2022/cngx-ui.mjs +5 -5
  64. package/fesm2022/cngx-ui.mjs.map +1 -1
  65. package/mat-tabs/README.md +57 -19
  66. package/mat-tabs/styles/mat-tabs.css +285 -163
  67. package/nav-rail/README.md +325 -0
  68. package/package.json +37 -8
  69. package/paginator/README.md +10 -0
  70. package/schematics/collection.json +9 -0
  71. package/schematics/ng-add/index.js +9 -0
  72. package/schematics/ng-add/schema.json +96 -0
  73. package/schematics/package.json +3 -0
  74. package/sidenav/README.md +150 -55
  75. package/skeleton/README.md +1 -1
  76. package/speak/README.md +1 -2
  77. package/stepper/README.md +20 -5
  78. package/tabs/README.md +13 -0
  79. package/timeline/README.md +1 -1
  80. package/toc/README.md +1 -1
  81. package/types/cngx-ui-a11y.d.ts +20 -38
  82. package/types/cngx-ui-accordion.d.ts +46 -71
  83. package/types/cngx-ui-action-button.d.ts +113 -151
  84. package/types/cngx-ui-breadcrumb.d.ts +60 -85
  85. package/types/cngx-ui-chart-panel.d.ts +22 -40
  86. package/types/cngx-ui-collection.d.ts +30 -43
  87. package/types/cngx-ui-command-palette.d.ts +40 -64
  88. package/types/cngx-ui-context-menu.d.ts +109 -48
  89. package/types/cngx-ui-data-grid-accordion.d.ts +50 -75
  90. package/types/cngx-ui-empty-state.d.ts +18 -8
  91. package/types/cngx-ui-feedback.d.ts +275 -292
  92. package/types/cngx-ui-layout.d.ts +4 -12
  93. package/types/cngx-ui-mat-accordion.d.ts +5 -5
  94. package/types/cngx-ui-mat-paginator.d.ts +4 -10
  95. package/types/cngx-ui-mat-stepper.d.ts +5 -10
  96. package/types/cngx-ui-mat-tabs.d.ts +86 -89
  97. package/types/cngx-ui-nav-rail.d.ts +416 -0
  98. package/types/cngx-ui-overlay.d.ts +4 -13
  99. package/types/cngx-ui-paginator.d.ts +186 -161
  100. package/types/cngx-ui-sidenav.d.ts +557 -437
  101. package/types/cngx-ui-skeleton.d.ts +7 -13
  102. package/types/cngx-ui-speak.d.ts +40 -24
  103. package/types/cngx-ui-stat-card.d.ts +45 -36
  104. package/types/cngx-ui-stepper.d.ts +205 -84
  105. package/types/cngx-ui-tabs.d.ts +104 -28
  106. package/types/cngx-ui-timeline.d.ts +31 -51
  107. package/types/cngx-ui-toc.d.ts +43 -54
  108. package/types/cngx-ui.d.ts +1 -1
@@ -1,388 +1,269 @@
1
- import { NgTemplateOutlet } from '@angular/common';
2
1
  import * as i0 from '@angular/core';
3
- import { inject, input, viewChild, computed, untracked, signal, contentChild, effect, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
4
- import { injectInteractiveI18n, CngxAsyncClick, reflectAsyncDisplayStatus, CngxPending, CngxSucceeded, CngxFailed } from '@cngx/common/interactive';
5
- import { nextUid, buildAsyncStateView, createTransitionTracker } from '@cngx/core/utils';
6
- import { CngxToaster, injectErrorDetail, injectFeedbackI18n, CngxToastOn } from '@cngx/ui/feedback';
2
+ import { inject, input, afterNextRender, untracked, Directive, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import * as i1 from '@cngx/common/button';
4
+ import { CngxButtonBrain, CngxButtonStart, CngxButtonEnd, CngxButtonAdornment, provideButtonHost, provideActionStatusHost } from '@cngx/common/button';
5
+ import * as i2 from '@cngx/common/interactive';
6
+ import { CNGX_ACTION_STATUS, CNGX_ANNOUNCEMENT_COVER, CngxActionStatusStack, CngxAsyncClick, CngxActionStatusBrain } from '@cngx/common/interactive';
7
+ import { CngxToaster, injectErrorDetail, injectFeedbackI18n, CngxToastOn, resolveOutcomeToast } from '@cngx/ui/feedback';
8
+ import { cngxDevWarn } from '@cngx/utils';
7
9
 
8
10
  /**
9
- * Action button organism with built-in status communication.
11
+ * Raises one toast per outcome of an action host on `CngxActionStatusBrain`: each own settle
12
+ * and each `success` / `error` edge of a bound `[externalState]`, read from
13
+ * `CNGX_ACTION_STATUS.outcome`. Two settles before one render are two toasts.
10
14
  *
11
- * Coordinates between the `CngxAsyncClick` atom (mechanism, ARIA, lifecycle)
12
- * and the consumer (intent, styling, labels). Provides template projection
13
- * for pending/succeeded/failed states and an `aria-live` region for screen
14
- * reader announcements.
15
+ * Host directive only: `CngxActionButton` co-hosts it, an ejected action host lists it in
16
+ * `hostDirectives`. Without a `CngxToaster` (`provideFeedback(withToasts())` or
17
+ * `provideToasts()`) it does nothing.
15
18
  *
16
- * Uses `display: contents` - the host produces no DOM box. The inner `<button>`
17
- * carries the `[cngxAsyncClick]` directive directly.
19
+ * A shown toast already announces its outcome, so via `CNGX_ANNOUNCEMENT_COVER` the live region
20
+ * stays empty for that outcome unless the brain's `announce` is `'always'`.
18
21
  *
19
- * For full control, use `[cngxAsyncClick]` directly on any element instead.
22
+ * Do not combine it with `[cngxToastOn]` on the same element: both toast the same outcome, and
23
+ * development builds warn [`CNGX3008`](/error-codes/cngx3008.md).
20
24
  *
21
- * ### Minimal (covers 80% of cases)
22
- * ```html
23
- * <cngx-action-button [action]="save">Save</cngx-action-button>
24
- * ```
25
- *
26
- * ### With string labels
27
- * ```html
28
- * <cngx-action-button [action]="save"
29
- * pendingLabel="Saving..." succeededLabel="Saved!" failedLabel="Failed">
30
- * Save
31
- * </cngx-action-button>
32
- * ```
33
- *
34
- * ### With template slots
35
- * ```html
36
- * <cngx-action-button [action]="save">
37
- * Save Draft
38
- * <ng-template cngxPending><mat-spinner diameter="18" /> Saving...</ng-template>
39
- * <ng-template cngxSucceeded>Saved!</ng-template>
40
- * <ng-template cngxFailed let-err>{{ err }} - retry?</ng-template>
41
- * </cngx-action-button>
25
+ * ```ts
26
+ * hostDirectives: [
27
+ * // ...button brain, async click, action status brain
28
+ * { directive: CngxActionToast, inputs: ['toastSuccess', 'toastError'] },
29
+ * ],
42
30
  * ```
43
31
  *
44
- * ### With toast feedback
45
- * ```html
46
- * <cngx-action-button [action]="save" toastSuccess="Saved" toastError="Save failed">
47
- * Save
48
- * </cngx-action-button>
49
- * ```
50
- *
51
- * @category ui/action-button
52
- * @docsKind primary
53
32
  * @wcag AA
54
- * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/action-button/action-button.ts
55
- * @since 0.1.0
56
- * @relatedTo CngxAsyncClick, CngxPending, CngxSucceeded, CngxFailed, CngxToaster
57
- * @slot cngxPending Replaces the label while the action runs.
58
- * @slot cngxSucceeded Replaces the label after the action succeeds.
59
- * @slot cngxFailed Replaces the label when the action fails; gets the error.
60
- * <example-url>http://localhost:4200/#/ui/action-button/async-button/random-outcome</example-url>
61
- * <example-url>http://localhost:4200/#/ui/action-button/async-button/string-labels</example-url>
62
- * <example-url>http://localhost:4200/#/ui/action-button/async-button/template-slots</example-url>
33
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/action-button/action-toast.directive.ts
34
+ * @since 0.3.0
35
+ * @relatedTo CngxActionButton, CngxActionStatusBrain, CNGX_ANNOUNCEMENT_COVER, CngxToaster, CngxToastOn, withToasts, provideToasts, withErrorDetail, CNGX_ACTION_STATUS
36
+ * <example-url>/#/ui/action-button/async-button/toasts</example-url>
37
+ * @axis level molecule
63
38
  */
64
- class CngxActionButton {
39
+ class CngxActionToast {
40
+ status = inject(CNGX_ACTION_STATUS);
65
41
  toaster = inject(CngxToaster, { optional: true });
66
42
  errorDetail = injectErrorDetail();
67
43
  feedbackI18n = injectFeedbackI18n();
68
44
  externalToastOn = inject(CngxToastOn, { self: true, optional: true });
69
- i18n = injectInteractiveI18n();
70
- /** The async action to execute on click. */
71
- action = input.required(...(ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []));
72
- /** Duration in ms to show success/error feedback. Passed through to `cngxAsyncClick`. */
73
- feedbackDuration = input(2000, ...(ngDevMode ? [{ debugName: "feedbackDuration" }] : /* istanbul ignore next */ []));
74
- /** When `false`, clicks are ignored. Passed through to `cngxAsyncClick`. */
75
- enabled = input(true, ...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
76
- /** Button type attribute. Defaults to `'button'` to prevent accidental form submits. */
77
- type = input('button', ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
78
- /** Visual variant - sets CSS class `cngx-action-button--{variant}`. */
79
- variant = input('primary', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
80
- /**
81
- * SR announcement on success. Falls back to `succeededLabel`, then
82
- * `CNGX_INTERACTIVE_I18N.asyncClickSucceeded`.
83
- */
84
- succeededAnnouncement = input(undefined, ...(ngDevMode ? [{ debugName: "succeededAnnouncement" }] : /* istanbul ignore next */ []));
85
- /**
86
- * SR announcement on failure. Falls back to `failedLabel`, then
87
- * `CNGX_INTERACTIVE_I18N.asyncClickFailed`.
88
- */
89
- failedAnnouncement = input(undefined, ...(ngDevMode ? [{ debugName: "failedAnnouncement" }] : /* istanbul ignore next */ []));
90
- /** Fallback text while pending (when no `cngxPending` template is projected). */
91
- pendingLabel = input(undefined, ...(ngDevMode ? [{ debugName: "pendingLabel" }] : /* istanbul ignore next */ []));
92
- /** Fallback text after success (when no `cngxSucceeded` template is projected). */
93
- succeededLabel = input(undefined, ...(ngDevMode ? [{ debugName: "succeededLabel" }] : /* istanbul ignore next */ []));
94
- /** Fallback text after failure (when no `cngxFailed` template is projected). */
95
- failedLabel = input(undefined, ...(ngDevMode ? [{ debugName: "failedLabel" }] : /* istanbul ignore next */ []));
96
- /**
97
- * Bind an external async state to derive visual status from.
98
- * When set, the button's status display follows `externalState.status()`.
99
- */
100
- externalState = input(undefined, ...(ngDevMode ? [{ debugName: "externalState" }] : /* istanbul ignore next */ []));
101
- /**
102
- * Reason the button is disabled, announced to screen readers while
103
- * `[enabled]` is `false`. Rendered into a hidden region and referenced by
104
- * `aria-describedby` only while disabled - an enabled button never carries
105
- * the reference. No effect when `[enabled]` is `true`.
106
- */
107
- disabledReason = input(undefined, ...(ngDevMode ? [{ debugName: "disabledReason" }] : /* istanbul ignore next */ []));
108
45
  /**
109
- * Toast message on success. Requires `CngxToaster` (via `provideFeedback(withToasts())`
110
- * or `provideToasts()`). Silently ignored when toaster is not provided.
111
- *
112
- * `toastSuccessDuration` should be >= `feedbackDuration` to avoid rapid re-fire
113
- * on repeated clicks that floods the SR announcement queue.
46
+ * Toast message on success. Repeats inside the toaster's dedup window
47
+ * (`withToasts({ dedupWindow })`, 1000 ms by default) merge into one toast with a count.
114
48
  */
115
49
  toastSuccess = input(undefined, ...(ngDevMode ? [{ debugName: "toastSuccess" }] : /* istanbul ignore next */ []));
116
50
  /** Toast message on error. */
117
51
  toastError = input(undefined, ...(ngDevMode ? [{ debugName: "toastError" }] : /* istanbul ignore next */ []));
118
- /** Include the error detail message in the error toast body. */
119
- toastErrorDetail = input(false, ...(ngDevMode ? [{ debugName: "toastErrorDetail" }] : /* istanbul ignore next */ []));
120
- /** Duration for success toasts in ms. */
121
- toastSuccessDuration = input(3000, ...(ngDevMode ? [{ debugName: "toastSuccessDuration" }] : /* istanbul ignore next */ []));
122
- /** Duration for error toasts - `'persistent'` means manual dismiss only. */
123
- toastErrorDuration = input('persistent', ...(ngDevMode ? [{ debugName: "toastErrorDuration" }] : /* istanbul ignore next */ []));
124
- /** @internal - inner CngxAsyncClick directive instance. Non-required to allow safe pre-view-init reads. */
125
- asyncClick = viewChild(CngxAsyncClick, ...(ngDevMode ? [{ debugName: "asyncClick" }] : /* istanbul ignore next */ []));
126
- /**
127
- * @internal - effective status: reflects external `[externalState]` if
128
- * bound (through the shared `CngxAsyncStatus` reflection - one home for
129
- * the state→display-bucket mapping), otherwise reads the inner
130
- * `CngxAsyncClick` directive.
131
- */
132
- effectiveStatus = computed(() => {
133
- const ext = this.externalState();
134
- if (ext) {
135
- return reflectAsyncDisplayStatus(ext);
136
- }
137
- // Guard against pre-view-init reads of `state` from consumers.
138
- const click = this.asyncClick();
139
- return click ? click.status() : 'idle';
140
- }, ...(ngDevMode ? [{ debugName: "effectiveStatus" }] : /* istanbul ignore next */ []));
141
- /** @internal - effective error value from external state or inner directive. */
142
- effectiveError = computed(() => {
143
- const ext = this.externalState();
144
- if (ext) {
145
- return ext.error();
146
- }
147
- const click = this.asyncClick();
148
- return click ? click.error() : undefined;
149
- }, ...(ngDevMode ? [{ debugName: "effectiveError" }] : /* istanbul ignore next */ []));
150
- /** @internal - busy while the effective status (inner or external) is pending. */
151
- effectiveBusy = computed(() => this.effectiveStatus() === 'pending', ...(ngDevMode ? [{ debugName: "effectiveBusy" }] : /* istanbul ignore next */ []));
152
- /**
153
- * @internal - what the inner `CngxAsyncClick` may act on: only when the
154
- * consumer enabled it AND no effective operation is in flight. Feeding this
155
- * as `[enabled]` routes external-pending through the atom's own click guard,
156
- * so a click cannot start a second run while an external state is pending.
157
- */
158
- clickEnabled = computed(() => this.enabled() && this.effectiveStatus() !== 'pending', ...(ngDevMode ? [{ debugName: "clickEnabled" }] : /* istanbul ignore next */ []));
159
52
  /**
160
- * @internal - SR announcement derived from the effective status, so an
161
- * external success/error settles audibly too (the inner directive only
162
- * knows its own runs). Mirrors the label fallback chain the template uses.
53
+ * Appends the error detail to the error toast message. The detail comes from
54
+ * `provideFeedback(withErrorDetail(...))`. Without a mapping, development builds append the
55
+ * raw error message and warn once ([`CNGX3004`](/error-codes/cngx3004.md)); production builds
56
+ * append nothing.
163
57
  */
164
- effectiveAnnouncement = computed(() => {
165
- switch (this.effectiveStatus()) {
166
- case 'success':
167
- return untracked(() => this.succeededAnnouncement() ??
168
- this.succeededLabel() ??
169
- this.i18n().asyncClickSucceeded);
170
- case 'error':
171
- return untracked(() => this.failedAnnouncement() ?? this.failedLabel() ?? this.i18n().asyncClickFailed);
172
- default:
173
- return '';
174
- }
175
- }, ...(ngDevMode ? [{ debugName: "effectiveAnnouncement" }] : /* istanbul ignore next */ []));
176
- /** @internal - stable id for the disabled-reason region. */
177
- reasonId = nextUid('cngx-action-button-reason');
58
+ toastErrorDetail = input(false, ...(ngDevMode ? [{ debugName: "toastErrorDetail" }] : /* istanbul ignore next */ []));
178
59
  /**
179
- * @internal - reference the reason region only while actually disabled by
180
- * intent and a reason exists. accname traverses a directly referenced hidden
181
- * node, so the id must be gated on the state it describes rather than left
182
- * permanently pointing at a hidden region.
60
+ * Duration for success toasts in ms. Unbound, `CngxToaster` resolves it:
61
+ * `withToasts({ defaultDuration })`, else 5000 ms.
183
62
  */
184
- describedBy = computed(() => !this.enabled() && this.disabledReason() ? this.reasonId : null, ...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
185
- lastUpdatedState = signal(undefined, ...(ngDevMode ? [{ debugName: "lastUpdatedState" }] : /* istanbul ignore next */ []));
63
+ toastSuccessDuration = input(undefined, ...(ngDevMode ? [{ debugName: "toastSuccessDuration" }] : /* istanbul ignore next */ []));
186
64
  /**
187
- * Full `CngxAsyncState` view of this button's effective lifecycle.
188
- *
189
- * Reflects the external state when `[externalState]` is bound,
190
- * otherwise the inner `CngxAsyncClick` directive's state.
191
- *
192
- * Bind to any state consumer: `<cngx-alert [state]="btn.state" />`.
65
+ * Duration for error toasts in ms, or `'persistent'` for manual dismiss only. Unbound, the
66
+ * toaster keeps an error toast until it is dismissed.
193
67
  */
194
- state = buildAsyncStateView({
195
- status: this.effectiveStatus,
196
- data: computed(() => undefined),
197
- error: this.effectiveError,
198
- lastUpdated: this.lastUpdatedState.asReadonly(),
199
- });
200
- /** @internal */
201
- pendingTpl = contentChild(CngxPending, ...(ngDevMode ? [{ debugName: "pendingTpl" }] : /* istanbul ignore next */ []));
202
- /** @internal */
203
- succeededTpl = contentChild(CngxSucceeded, ...(ngDevMode ? [{ debugName: "succeededTpl" }] : /* istanbul ignore next */ []));
204
- /** @internal */
205
- failedTpl = contentChild(CngxFailed, ...(ngDevMode ? [{ debugName: "failedTpl" }] : /* istanbul ignore next */ []));
68
+ toastErrorDuration = input(undefined, ...(ngDevMode ? [{ debugName: "toastErrorDuration" }] : /* istanbul ignore next */ []));
206
69
  constructor() {
207
70
  // Double-toast guard, consumer placed [cngxToastOn] on the same element.
208
- if (typeof ngDevMode !== 'undefined' &&
209
- ngDevMode &&
210
- this.externalToastOn &&
211
- (this.toastSuccess() || this.toastError())) {
212
- console.warn('CngxActionButton: [toastSuccess]/[toastError] inputs and [cngxToastOn] ' +
213
- 'on the same element will fire duplicate toasts. Use one or the other.');
214
- }
215
- const tracker = createTransitionTracker(() => this.effectiveStatus());
216
- effect(() => {
217
- const status = tracker.current();
218
- const previous = tracker.previous();
219
- if (status === previous) {
220
- return;
221
- }
222
- // Only the transition edge may re-run this body. The toast inputs and
223
- // effectiveError are read untracked: previous() stays stale for the whole
224
- // settled window, so a tracked read would re-fire the toast on any input
225
- // rebind while status sits in success/error. Doctrine: bridge effects
226
- // untrack service calls.
227
- untracked(() => {
228
- if (status === 'success') {
229
- // Producer write for the buildAsyncStateView `lastUpdated` slot (no other
230
- // source feeds it) - state production, not derived-state sync. This is the
231
- // sanctioned signal-write-in-effect class, same as the async-state-view pattern.
232
- this.lastUpdatedState.set(new Date());
233
- const msg = this.toastSuccess();
234
- if (msg && this.toaster) {
235
- this.toaster.show({
236
- message: msg,
237
- severity: 'success',
238
- duration: this.toastSuccessDuration(),
239
- });
240
- }
241
- }
242
- if (status === 'error') {
243
- const msg = this.toastError();
244
- if (msg && this.toaster) {
245
- const err = this.effectiveError();
246
- const detail = this.toastErrorDetail() && err != null ? this.errorDetail(err) : undefined;
247
- this.toaster.show({
248
- message: detail ? this.feedbackI18n().errorWithDetail(msg, detail) : msg,
249
- severity: 'error',
250
- duration: this.toastErrorDuration(),
251
- });
252
- }
71
+ // After the first render: template-bound inputs are unset in the constructor.
72
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && this.externalToastOn) {
73
+ afterNextRender(() => {
74
+ if (this.toastSuccess() || this.toastError()) {
75
+ cngxDevWarn('CNGX3008', '[cngxActionToast] [toastSuccess]/[toastError] inputs and [cngxToastOn] ' +
76
+ 'on the same element will fire duplicate toasts. Use one or the other.');
253
77
  }
254
78
  });
255
- });
256
- }
257
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActionButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
258
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxActionButton, isStandalone: true, selector: "cngx-action-button", inputs: { action: { classPropertyName: "action", publicName: "action", isSignal: true, isRequired: true, transformFunction: null }, feedbackDuration: { classPropertyName: "feedbackDuration", publicName: "feedbackDuration", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, succeededAnnouncement: { classPropertyName: "succeededAnnouncement", publicName: "succeededAnnouncement", isSignal: true, isRequired: false, transformFunction: null }, failedAnnouncement: { classPropertyName: "failedAnnouncement", publicName: "failedAnnouncement", isSignal: true, isRequired: false, transformFunction: null }, pendingLabel: { classPropertyName: "pendingLabel", publicName: "pendingLabel", isSignal: true, isRequired: false, transformFunction: null }, succeededLabel: { classPropertyName: "succeededLabel", publicName: "succeededLabel", isSignal: true, isRequired: false, transformFunction: null }, failedLabel: { classPropertyName: "failedLabel", publicName: "failedLabel", isSignal: true, isRequired: false, transformFunction: null }, externalState: { classPropertyName: "externalState", publicName: "externalState", isSignal: true, isRequired: false, transformFunction: null }, disabledReason: { classPropertyName: "disabledReason", publicName: "disabledReason", isSignal: true, isRequired: false, transformFunction: null }, toastSuccess: { classPropertyName: "toastSuccess", publicName: "toastSuccess", isSignal: true, isRequired: false, transformFunction: null }, toastError: { classPropertyName: "toastError", publicName: "toastError", isSignal: true, isRequired: false, transformFunction: null }, toastErrorDetail: { classPropertyName: "toastErrorDetail", publicName: "toastErrorDetail", isSignal: true, isRequired: false, transformFunction: null }, toastSuccessDuration: { classPropertyName: "toastSuccessDuration", publicName: "toastSuccessDuration", isSignal: true, isRequired: false, transformFunction: null }, toastErrorDuration: { classPropertyName: "toastErrorDuration", publicName: "toastErrorDuration", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: contents" }, queries: [{ propertyName: "pendingTpl", first: true, predicate: CngxPending, descendants: true, isSignal: true }, { propertyName: "succeededTpl", first: true, predicate: CngxSucceeded, descendants: true, isSignal: true }, { propertyName: "failedTpl", first: true, predicate: CngxFailed, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "asyncClick", first: true, predicate: CngxAsyncClick, descendants: true, isSignal: true }], exportAs: ["cngxActionButton"], ngImport: i0, template: `
259
- <ng-template #idle><ng-content /></ng-template>
260
-
261
- <button
262
- [type]="type()"
263
- [cngxAsyncClick]="action()"
264
- [feedbackDuration]="feedbackDuration()"
265
- [enabled]="clickEnabled()"
266
- [busy]="effectiveBusy()"
267
- [autoAnnounce]="false"
268
- [succeededAnnouncement]="succeededAnnouncement() ?? succeededLabel()"
269
- [failedAnnouncement]="failedAnnouncement() ?? failedLabel()"
270
- [attr.aria-describedby]="describedBy()"
271
- [class]="'cngx-action-button cngx-action-button--' + variant()"
272
- >
273
- @switch (effectiveStatus()) {
274
- @case ('pending') {
275
- @if (pendingTpl(); as tpl) {
276
- <ng-container *ngTemplateOutlet="tpl.templateRef" />
277
- } @else if (pendingLabel()) {
278
- {{ pendingLabel() }}
279
- } @else {
280
- <ng-container *ngTemplateOutlet="idle" />
281
- }
282
79
  }
283
- @case ('success') {
284
- @if (succeededTpl(); as tpl) {
285
- <ng-container *ngTemplateOutlet="tpl.templateRef" />
286
- } @else if (succeededLabel()) {
287
- {{ succeededLabel() }}
288
- } @else {
289
- <ng-container *ngTemplateOutlet="idle" />
290
- }
80
+ this.status.outcome.subscribe((outcome) => untracked(() => this.showToast(outcome)));
81
+ }
82
+ /**
83
+ * `true` when a shown toast already announces this outcome, unless the
84
+ * brain's `[announce]` is `'always'`.
85
+ */
86
+ covers(status) {
87
+ return untracked(() => this.status.announce() !== 'always' && this.toastCovers(status));
88
+ }
89
+ toastCovers(status) {
90
+ if (!this.toaster) {
91
+ return false;
291
92
  }
292
- @case ('error') {
293
- @if (failedTpl(); as tpl) {
294
- <ng-container
295
- *ngTemplateOutlet="tpl.templateRef; context: { $implicit: effectiveError() }"
296
- />
297
- } @else if (failedLabel()) {
298
- {{ failedLabel() }}
299
- } @else {
300
- <ng-container *ngTemplateOutlet="idle" />
301
- }
93
+ return status === 'success' ? !!this.toastSuccess() : !!this.toastError();
94
+ }
95
+ showToast({ status, error }) {
96
+ if (!this.toaster) {
97
+ return;
302
98
  }
303
- @default {
304
- <ng-container *ngTemplateOutlet="idle" />
99
+ const toast = resolveOutcomeToast(this, status, error, this.errorDetail, this.feedbackI18n());
100
+ if (toast) {
101
+ this.toaster.show(toast);
305
102
  }
306
- }
307
- </button>
308
- @if (disabledReason(); as reason) {
309
- <span [id]="reasonId" class="cngx-action-button__sr-only">{{ reason }}</span>
310
103
  }
311
- <span aria-live="polite" aria-atomic="true" class="cngx-action-button__sr-only">{{
312
- effectiveAnnouncement()
313
- }}</span>
314
- `, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-action-btn-transition{syntax: \"*\"; inherits: false; initial-value: .2s ease;}:where(.cngx-action-button){--cngx-action-btn-transition: var(--cngx-duration-base) ease}@property --cngx-action-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 6px;}@property --cngx-action-btn-padding{syntax: \"*\"; inherits: false; initial-value: 8px 16px;}@property --cngx-action-btn-border{syntax: \"<color>\"; inherits: false; initial-value: oklch(.87 0 0);}@property --cngx-action-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-action-btn-pending-opacity{syntax: \"<number>\"; inherits: false; initial-value: .7;}@property --cngx-action-btn-succeeded-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(.95 .04 145);}@property --cngx-action-btn-succeeded-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .15 145);}@property --cngx-action-btn-succeeded-border{syntax: \"<color>\"; inherits: false; initial-value: oklch(.5 .15 145);}@property --cngx-action-btn-failed-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(.95 .025 25);}@property --cngx-action-btn-failed-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.45 .15 25);}@property --cngx-action-btn-failed-border{syntax: \"<color>\"; inherits: false; initial-value: oklch(.45 .15 25);}@property --cngx-action-btn-ghost-hover-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(0 0 0 / .04);}@property --cngx-action-btn-primary-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(.55 .15 250);}@property --cngx-action-btn-primary-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-action-btn-secondary-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-action-btn-secondary-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.55 .15 250);}@property --cngx-action-btn-secondary-border{syntax: \"<color>\"; inherits: false; initial-value: oklch(.55 .005 290);}@property --cngx-action-btn-ghost-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.34 .005 290);}}@layer cngx.components{.cngx-action-button{--cngx-action-btn-padding: var(--cngx-space-sm) var(--cngx-space-md);cursor:pointer;border:1px solid var(--cngx-action-btn-border, var(--cngx-color-border, oklch(.87 0 0)));border-radius:var(--cngx-action-btn-radius, 6px);padding:var(--cngx-action-btn-padding, 8px 16px);min-block-size:var(--cngx-target-min, 0px);font:inherit;background:var(--cngx-action-btn-bg, transparent);color:inherit;transition:background-color var(--cngx-action-btn-transition, .2s ease),color var(--cngx-action-btn-transition, .2s ease),border-color var(--cngx-action-btn-transition, .2s ease),opacity var(--cngx-action-btn-transition, .2s ease)}.cngx-action-button--primary{background:var(--cngx-action-btn-primary-bg, var(--cngx-color-primary, oklch(.55 .15 250)));color:var(--cngx-action-btn-primary-color, oklch(1 0 0));border-color:var( --cngx-action-btn-primary-bg, var(--cngx-color-primary, oklch(.55 .15 250)) )}.cngx-action-button--secondary{background:var(--cngx-action-btn-secondary-bg, transparent);color:var(--cngx-action-btn-secondary-color, var(--cngx-color-primary, oklch(.55 .15 250)));border-color:var( --cngx-action-btn-secondary-border, var(--cngx-color-border, oklch(.55 .005 290)) )}.cngx-action-button--ghost{background:transparent;color:var(--cngx-action-btn-ghost-color, var(--cngx-color-text, oklch(.34 .005 290)));border-color:transparent}.cngx-action-button--ghost:hover{background:var(--cngx-action-btn-ghost-hover-bg, oklch(0 0 0 / .04))}.cngx-action-button__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CngxAsyncClick, selector: "[cngxAsyncClick]", inputs: ["cngxAsyncClick", "feedbackDuration", "enabled", "busy", "succeededAnnouncement", "failedAnnouncement", "autoAnnounce"], exportAs: ["cngxAsyncClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
104
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActionToast, deps: [], target: i0.ɵɵFactoryTarget.Directive });
105
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxActionToast, isStandalone: true, inputs: { toastSuccess: { classPropertyName: "toastSuccess", publicName: "toastSuccess", isSignal: true, isRequired: false, transformFunction: null }, toastError: { classPropertyName: "toastError", publicName: "toastError", isSignal: true, isRequired: false, transformFunction: null }, toastErrorDetail: { classPropertyName: "toastErrorDetail", publicName: "toastErrorDetail", isSignal: true, isRequired: false, transformFunction: null }, toastSuccessDuration: { classPropertyName: "toastSuccessDuration", publicName: "toastSuccessDuration", isSignal: true, isRequired: false, transformFunction: null }, toastErrorDuration: { classPropertyName: "toastErrorDuration", publicName: "toastErrorDuration", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: CNGX_ANNOUNCEMENT_COVER, useExisting: CngxActionToast, multi: true }], exportAs: ["cngxActionToast"], ngImport: i0 });
106
+ }
107
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActionToast, decorators: [{
108
+ type: Directive,
109
+ args: [{
110
+ standalone: true,
111
+ exportAs: 'cngxActionToast',
112
+ providers: [{ provide: CNGX_ANNOUNCEMENT_COVER, useExisting: CngxActionToast, multi: true }],
113
+ }]
114
+ }], ctorParameters: () => [], propDecorators: { toastSuccess: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastSuccess", required: false }] }], toastError: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastError", required: false }] }], toastErrorDetail: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastErrorDetail", required: false }] }], toastSuccessDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastSuccessDuration", required: false }] }], toastErrorDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastErrorDuration", required: false }] }] } });
115
+
116
+ /**
117
+ * Async action button on the cngx button brain. Runs an action on click and reports the
118
+ * outcome in its label, in a live region and, with the toast inputs, in a toast.
119
+ *
120
+ * Use it over `cngxButton` with `[cngxAsyncClick]` when the label should change per outcome,
121
+ * when the button reflects an `[externalState]` it does not own, or when the outcome raises a
122
+ * toast. Variant, tone, size and `disabled` with a reason work as on `cngxButton`.
123
+ *
124
+ * The labels sit stacked in one cell, so the width never jumps. The result label shows once the
125
+ * busy visual releases; `aria-busy` and the click guard hold until then. Each outcome is spoken
126
+ * once in the live region, in the words the button shows.
127
+ *
128
+ * The English language pack ships no status labels. Without a bound label, a template or
129
+ * `withActionStatusLabels` the visible label never changes and only the live region reports
130
+ * the outcome. The slot directives come from `@cngx/common/interactive`.
131
+ *
132
+ * The button publishes `CNGX_BUTTON_STATE`, so it can be the main action of a `cngxSplitButton`.
133
+ *
134
+ * To eject, list `CngxButtonBrain`, `CngxAsyncClick`, `CngxActionStatusBrain` and
135
+ * `CngxActionToast` in `hostDirectives` with `provideButtonHost()` and
136
+ * `provideActionStatusHost()`.
137
+ *
138
+ * ```html
139
+ * <button cngxActionButton [action]="save">
140
+ * Save Draft
141
+ * <ng-template cngxPending>Saving...</ng-template>
142
+ * <ng-template cngxSucceeded>Saved!</ng-template>
143
+ * <ng-template cngxFailed let-err>{{ err }} - retry?</ng-template>
144
+ * </button>
145
+ * ```
146
+ *
147
+ * @wcag AA
148
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/action-button/action-button.ts
149
+ * @since 0.3.0
150
+ * @relatedTo CngxButton, CngxButtonBrain, CngxAsyncClick, CngxActionStatusBrain, CngxActionToast, CngxPending, CngxSucceeded, CngxFailed, CngxSplitButton, CngxToastOn, withActionStatusLabels, withActionStatusTemplates, CngxPopoverAction
151
+ * @slot cngxPending Replaces the label while the action runs, once the run outlasts the show delay.
152
+ * @slot cngxSucceeded Replaces the label after the action succeeds, once the busy visual releases.
153
+ * @slot cngxFailed Replaces the label when the action fails, once the busy visual releases; gets the error.
154
+ * <example-url>/#/ui/action-button/async-button/random-outcome</example-url>
155
+ * <example-url>/#/ui/action-button/async-button/string-labels</example-url>
156
+ * <example-url>/#/ui/action-button/async-button/template-slots</example-url>
157
+ * <example-url>/#/ui/action-button/async-button/external-state</example-url>
158
+ * <example-url>/#/ui/action-button/async-button/toasts</example-url>
159
+ * <example-url>/#/ui/action-button/async-button/disabled-with-reason</example-url>
160
+ * <example-url>/#/ui/action-button/async-button/busy-timing</example-url>
161
+ * <example-url>/#/ui/action-button/async-button/announcements-and-outputs</example-url>
162
+ * <example-url>/#/ui/action-button/async-button/app-wide-labels</example-url>
163
+ * @axis level organism
164
+ */
165
+ class CngxActionButton {
166
+ brain = inject(CngxButtonBrain);
167
+ actionStatus = inject(CNGX_ACTION_STATUS);
168
+ startSlot = contentChild(CngxButtonStart, ...(ngDevMode ? [{ debugName: "startSlot" }] : /* istanbul ignore next */ []));
169
+ endSlot = contentChild(CngxButtonEnd, ...(ngDevMode ? [{ debugName: "endSlot" }] : /* istanbul ignore next */ []));
170
+ /** Effective status: `[externalState]` when bound, else the run. Immediate, not gated. */
171
+ status = this.actionStatus.status;
172
+ /** `true` while the busy visual shows (the run after the show delay, held for its min-dwell). */
173
+ busyVisible = this.brain.busyVisible;
174
+ /**
175
+ * Effective lifecycle as `CngxAsyncState`, for `[state]="btn.state"`. `lastUpdated` is the
176
+ * last successful own run, or the bound state's value with no fallback to own runs.
177
+ */
178
+ state = this.actionStatus.state;
179
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActionButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
180
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.4", type: CngxActionButton, isStandalone: true, selector: "button[cngxActionButton]", host: { properties: { "attr.data-start": "startSlot() ? \"\" : null", "attr.data-end": "endSlot() ? \"\" : null" }, classAttribute: "cngx-button cngx-action-button" }, providers: [
181
+ provideButtonHost('cngxActionButton', { defaultVariant: 'solid' }),
182
+ provideActionStatusHost(),
183
+ ], queries: [{ propertyName: "startSlot", first: true, predicate: CngxButtonStart, descendants: true, isSignal: true }, { propertyName: "endSlot", first: true, predicate: CngxButtonEnd, descendants: true, isSignal: true }], exportAs: ["cngxActionButton"], hostDirectives: [{ directive: i1.CngxButtonBrain, inputs: ["variant", "cngxActionButton", "tone", "tone", "size", "size", "disabled", "disabled", "disabledReason", "disabledReason", "cngxDescribedBy", "cngxDescribedBy", "type", "type"] }, { directive: i2.CngxAsyncClick, inputs: ["cngxAsyncClick", "action", "feedbackDuration", "feedbackDuration", "showDelay", "showDelay", "minDwell", "minDwell"], outputs: ["settled", "settled"] }, { directive: i2.CngxActionStatusBrain, inputs: ["succeededAnnouncement", "succeededAnnouncement", "failedAnnouncement", "failedAnnouncement", "announce", "announce", "pendingLabel", "pendingLabel", "succeededLabel", "succeededLabel", "failedLabel", "failedLabel", "externalState", "externalState"], outputs: ["outcome", "outcome"] }, { directive: CngxActionToast, inputs: ["toastSuccess", "toastSuccess", "toastError", "toastError", "toastErrorDetail", "toastErrorDetail", "toastSuccessDuration", "toastSuccessDuration", "toastErrorDuration", "toastErrorDuration"] }], ngImport: i0, template: `
184
+ <ng-content select="[cngxButtonStart]" />
185
+ <span
186
+ class="cngx-button__label cngx-action-button__labels"
187
+ cngxActionStatusStack
188
+ cellClass="cngx-action-button__label"
189
+ >
190
+ <ng-content />
191
+ </span>
192
+ <ng-content select="[cngxButtonEnd]" />
193
+ <cngx-button-adornment />
194
+ `, isInline: true, styles: [""], dependencies: [{ kind: "component", type: CngxActionStatusStack, selector: "span[cngxActionStatusStack]", inputs: ["cellClass"] }, { kind: "component", type: CngxButtonAdornment, selector: "cngx-button-adornment" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
315
195
  }
316
196
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActionButton, decorators: [{
317
197
  type: Component,
318
- args: [{ selector: 'cngx-action-button', standalone: true, imports: [NgTemplateOutlet, CngxAsyncClick], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cngxActionButton', host: {
319
- style: 'display: contents',
198
+ args: [{ selector: 'button[cngxActionButton]', standalone: true, imports: [CngxActionStatusStack, CngxButtonAdornment], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cngxActionButton', hostDirectives: [
199
+ {
200
+ directive: CngxButtonBrain,
201
+ inputs: [
202
+ 'variant: cngxActionButton',
203
+ 'tone',
204
+ 'size',
205
+ 'disabled',
206
+ 'disabledReason',
207
+ 'cngxDescribedBy',
208
+ 'type',
209
+ ],
210
+ },
211
+ {
212
+ directive: CngxAsyncClick,
213
+ inputs: ['cngxAsyncClick: action', 'feedbackDuration', 'showDelay', 'minDwell'],
214
+ outputs: ['settled'],
215
+ },
216
+ {
217
+ directive: CngxActionStatusBrain,
218
+ outputs: ['outcome'],
219
+ inputs: [
220
+ 'succeededAnnouncement',
221
+ 'failedAnnouncement',
222
+ 'announce',
223
+ 'pendingLabel',
224
+ 'succeededLabel',
225
+ 'failedLabel',
226
+ 'externalState',
227
+ ],
228
+ },
229
+ {
230
+ directive: CngxActionToast,
231
+ inputs: [
232
+ 'toastSuccess',
233
+ 'toastError',
234
+ 'toastErrorDetail',
235
+ 'toastSuccessDuration',
236
+ 'toastErrorDuration',
237
+ ],
238
+ },
239
+ ], providers: [
240
+ provideButtonHost('cngxActionButton', { defaultVariant: 'solid' }),
241
+ provideActionStatusHost(),
242
+ ], host: {
243
+ class: 'cngx-button cngx-action-button',
244
+ '[attr.data-start]': 'startSlot() ? "" : null',
245
+ '[attr.data-end]': 'endSlot() ? "" : null',
320
246
  }, template: `
321
- <ng-template #idle><ng-content /></ng-template>
322
-
323
- <button
324
- [type]="type()"
325
- [cngxAsyncClick]="action()"
326
- [feedbackDuration]="feedbackDuration()"
327
- [enabled]="clickEnabled()"
328
- [busy]="effectiveBusy()"
329
- [autoAnnounce]="false"
330
- [succeededAnnouncement]="succeededAnnouncement() ?? succeededLabel()"
331
- [failedAnnouncement]="failedAnnouncement() ?? failedLabel()"
332
- [attr.aria-describedby]="describedBy()"
333
- [class]="'cngx-action-button cngx-action-button--' + variant()"
247
+ <ng-content select="[cngxButtonStart]" />
248
+ <span
249
+ class="cngx-button__label cngx-action-button__labels"
250
+ cngxActionStatusStack
251
+ cellClass="cngx-action-button__label"
334
252
  >
335
- @switch (effectiveStatus()) {
336
- @case ('pending') {
337
- @if (pendingTpl(); as tpl) {
338
- <ng-container *ngTemplateOutlet="tpl.templateRef" />
339
- } @else if (pendingLabel()) {
340
- {{ pendingLabel() }}
341
- } @else {
342
- <ng-container *ngTemplateOutlet="idle" />
343
- }
344
- }
345
- @case ('success') {
346
- @if (succeededTpl(); as tpl) {
347
- <ng-container *ngTemplateOutlet="tpl.templateRef" />
348
- } @else if (succeededLabel()) {
349
- {{ succeededLabel() }}
350
- } @else {
351
- <ng-container *ngTemplateOutlet="idle" />
352
- }
353
- }
354
- @case ('error') {
355
- @if (failedTpl(); as tpl) {
356
- <ng-container
357
- *ngTemplateOutlet="tpl.templateRef; context: { $implicit: effectiveError() }"
358
- />
359
- } @else if (failedLabel()) {
360
- {{ failedLabel() }}
361
- } @else {
362
- <ng-container *ngTemplateOutlet="idle" />
363
- }
364
- }
365
- @default {
366
- <ng-container *ngTemplateOutlet="idle" />
367
- }
368
- }
369
- </button>
370
- @if (disabledReason(); as reason) {
371
- <span [id]="reasonId" class="cngx-action-button__sr-only">{{ reason }}</span>
372
- }
373
- <span aria-live="polite" aria-atomic="true" class="cngx-action-button__sr-only">{{
374
- effectiveAnnouncement()
375
- }}</span>
376
- `, styles: ["@layer cngx.tokens{@property --cngx-action-btn-transition{syntax: \"*\"; inherits: false; initial-value: .2s ease;}:where(.cngx-action-button){--cngx-action-btn-transition: var(--cngx-duration-base) ease}@property --cngx-action-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 6px;}@property --cngx-action-btn-padding{syntax: \"*\"; inherits: false; initial-value: 8px 16px;}@property --cngx-action-btn-border{syntax: \"<color>\"; inherits: false; initial-value: oklch(.87 0 0);}@property --cngx-action-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-action-btn-pending-opacity{syntax: \"<number>\"; inherits: false; initial-value: .7;}@property --cngx-action-btn-succeeded-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(.95 .04 145);}@property --cngx-action-btn-succeeded-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .15 145);}@property --cngx-action-btn-succeeded-border{syntax: \"<color>\"; inherits: false; initial-value: oklch(.5 .15 145);}@property --cngx-action-btn-failed-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(.95 .025 25);}@property --cngx-action-btn-failed-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.45 .15 25);}@property --cngx-action-btn-failed-border{syntax: \"<color>\"; inherits: false; initial-value: oklch(.45 .15 25);}@property --cngx-action-btn-ghost-hover-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(0 0 0 / .04);}@property --cngx-action-btn-primary-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(.55 .15 250);}@property --cngx-action-btn-primary-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-action-btn-secondary-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-action-btn-secondary-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.55 .15 250);}@property --cngx-action-btn-secondary-border{syntax: \"<color>\"; inherits: false; initial-value: oklch(.55 .005 290);}@property --cngx-action-btn-ghost-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.34 .005 290);}}@layer cngx.components{.cngx-action-button{--cngx-action-btn-padding: var(--cngx-space-sm) var(--cngx-space-md);cursor:pointer;border:1px solid var(--cngx-action-btn-border, var(--cngx-color-border, oklch(.87 0 0)));border-radius:var(--cngx-action-btn-radius, 6px);padding:var(--cngx-action-btn-padding, 8px 16px);min-block-size:var(--cngx-target-min, 0px);font:inherit;background:var(--cngx-action-btn-bg, transparent);color:inherit;transition:background-color var(--cngx-action-btn-transition, .2s ease),color var(--cngx-action-btn-transition, .2s ease),border-color var(--cngx-action-btn-transition, .2s ease),opacity var(--cngx-action-btn-transition, .2s ease)}.cngx-action-button--primary{background:var(--cngx-action-btn-primary-bg, var(--cngx-color-primary, oklch(.55 .15 250)));color:var(--cngx-action-btn-primary-color, oklch(1 0 0));border-color:var( --cngx-action-btn-primary-bg, var(--cngx-color-primary, oklch(.55 .15 250)) )}.cngx-action-button--secondary{background:var(--cngx-action-btn-secondary-bg, transparent);color:var(--cngx-action-btn-secondary-color, var(--cngx-color-primary, oklch(.55 .15 250)));border-color:var( --cngx-action-btn-secondary-border, var(--cngx-color-border, oklch(.55 .005 290)) )}.cngx-action-button--ghost{background:transparent;color:var(--cngx-action-btn-ghost-color, var(--cngx-color-text, oklch(.34 .005 290)));border-color:transparent}.cngx-action-button--ghost:hover{background:var(--cngx-action-btn-ghost-hover-bg, oklch(0 0 0 / .04))}.cngx-action-button__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}}\n"] }]
377
- }], ctorParameters: () => [], propDecorators: { action: [{ type: i0.Input, args: [{ isSignal: true, alias: "action", required: true }] }], feedbackDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "feedbackDuration", required: false }] }], enabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "enabled", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], succeededAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "succeededAnnouncement", required: false }] }], failedAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "failedAnnouncement", required: false }] }], pendingLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "pendingLabel", required: false }] }], succeededLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "succeededLabel", required: false }] }], failedLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "failedLabel", required: false }] }], externalState: [{ type: i0.Input, args: [{ isSignal: true, alias: "externalState", required: false }] }], disabledReason: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledReason", required: false }] }], toastSuccess: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastSuccess", required: false }] }], toastError: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastError", required: false }] }], toastErrorDetail: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastErrorDetail", required: false }] }], toastSuccessDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastSuccessDuration", required: false }] }], toastErrorDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastErrorDuration", required: false }] }], asyncClick: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxAsyncClick), { isSignal: true }] }], pendingTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPending), { isSignal: true }] }], succeededTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxSucceeded), { isSignal: true }] }], failedTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxFailed), { isSignal: true }] }] } });
253
+ <ng-content />
254
+ </span>
255
+ <ng-content select="[cngxButtonEnd]" />
256
+ <cngx-button-adornment />
257
+ ` }]
258
+ }], propDecorators: { startSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxButtonStart), { isSignal: true }] }], endSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxButtonEnd), { isSignal: true }] }] } });
378
259
 
379
260
  /**
380
- * @module @cngx/ui/action-button
261
+ * @module `@cngx/ui/action-button`
381
262
  */
382
263
 
383
264
  /**
384
265
  * Generated bundle index. Do not edit.
385
266
  */
386
267
 
387
- export { CngxActionButton };
268
+ export { CngxActionButton, CngxActionToast };
388
269
  //# sourceMappingURL=cngx-ui-action-button.mjs.map