@cngx/ui 0.1.0-rc.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -59
- package/action-button/README.md +170 -53
- package/breadcrumb/README.md +5 -6
- package/collection/README.md +1 -1
- package/command-palette/README.md +4 -3
- package/data-grid-accordion/README.md +1 -1
- package/empty-state/README.md +2 -3
- package/feedback/README.md +1 -1
- package/fesm2022/cngx-ui-a11y.mjs +13 -23
- package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
- package/fesm2022/cngx-ui-accordion.mjs +44 -66
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +213 -335
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +60 -80
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-chart-panel.mjs +18 -31
- package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
- package/fesm2022/cngx-ui-collection.mjs +28 -44
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +29 -51
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
- package/fesm2022/cngx-ui-context-menu.mjs +78 -83
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +52 -74
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-empty-state.mjs +17 -44
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +589 -467
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-layout.mjs +17 -13
- package/fesm2022/cngx-ui-layout.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +3 -5
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-paginator.mjs +5 -9
- package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-stepper.mjs +6 -9
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +71 -68
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-nav-rail.mjs +440 -0
- package/fesm2022/cngx-ui-nav-rail.mjs.map +1 -0
- package/fesm2022/cngx-ui-overlay.mjs +9 -10
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +149 -171
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +858 -721
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +17 -19
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +21 -74
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stat-card.mjs +39 -62
- package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
- package/fesm2022/cngx-ui-stepper.mjs +207 -90
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +71 -32
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +21 -27
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
- package/fesm2022/cngx-ui-toc.mjs +27 -40
- package/fesm2022/cngx-ui-toc.mjs.map +1 -1
- package/fesm2022/cngx-ui.mjs +5 -5
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/mat-tabs/README.md +28 -14
- package/mat-tabs/styles/mat-tabs.css +233 -258
- package/nav-rail/README.md +325 -0
- package/package.json +10 -5
- package/paginator/README.md +10 -0
- package/schematics/ng-add/index.js +7 -7
- package/schematics/ng-add/schema.json +5 -0
- package/sidenav/README.md +150 -55
- package/skeleton/README.md +1 -1
- package/speak/README.md +1 -2
- package/stepper/README.md +20 -5
- package/tabs/README.md +13 -0
- package/timeline/README.md +1 -1
- package/toc/README.md +1 -1
- package/types/cngx-ui-a11y.d.ts +20 -38
- package/types/cngx-ui-accordion.d.ts +45 -77
- package/types/cngx-ui-action-button.d.ts +113 -151
- package/types/cngx-ui-breadcrumb.d.ts +58 -94
- package/types/cngx-ui-chart-panel.d.ts +22 -40
- package/types/cngx-ui-collection.d.ts +30 -53
- package/types/cngx-ui-command-palette.d.ts +40 -64
- package/types/cngx-ui-context-menu.d.ts +67 -44
- package/types/cngx-ui-data-grid-accordion.d.ts +49 -77
- package/types/cngx-ui-empty-state.d.ts +18 -8
- package/types/cngx-ui-feedback.d.ts +264 -289
- package/types/cngx-ui-layout.d.ts +4 -12
- package/types/cngx-ui-mat-accordion.d.ts +2 -3
- package/types/cngx-ui-mat-paginator.d.ts +4 -10
- package/types/cngx-ui-mat-stepper.d.ts +5 -10
- package/types/cngx-ui-mat-tabs.d.ts +43 -69
- package/types/cngx-ui-nav-rail.d.ts +416 -0
- package/types/cngx-ui-overlay.d.ts +4 -13
- package/types/cngx-ui-paginator.d.ts +164 -154
- package/types/cngx-ui-sidenav.d.ts +557 -437
- package/types/cngx-ui-skeleton.d.ts +7 -13
- package/types/cngx-ui-speak.d.ts +40 -24
- package/types/cngx-ui-stat-card.d.ts +45 -36
- package/types/cngx-ui-stepper.d.ts +183 -62
- package/types/cngx-ui-tabs.d.ts +101 -27
- package/types/cngx-ui-timeline.d.ts +20 -48
- package/types/cngx-ui-toc.d.ts +30 -51
- package/types/cngx-ui.d.ts +1 -1
|
@@ -1,391 +1,269 @@
|
|
|
1
|
-
import { NgTemplateOutlet } from '@angular/common';
|
|
2
1
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject, input,
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
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';
|
|
7
8
|
import { cngxDevWarn } from '@cngx/utils';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
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.
|
|
11
14
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* 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.
|
|
16
18
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
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'`.
|
|
19
21
|
*
|
|
20
|
-
*
|
|
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).
|
|
21
24
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* ### With string labels
|
|
28
|
-
* ```html
|
|
29
|
-
* <cngx-action-button [action]="save"
|
|
30
|
-
* pendingLabel="Saving..." succeededLabel="Saved!" failedLabel="Failed">
|
|
31
|
-
* Save
|
|
32
|
-
* </cngx-action-button>
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* ### With template slots
|
|
36
|
-
* ```html
|
|
37
|
-
* <cngx-action-button [action]="save">
|
|
38
|
-
* Save Draft
|
|
39
|
-
* <ng-template cngxPending><mat-spinner diameter="18" /> Saving...</ng-template>
|
|
40
|
-
* <ng-template cngxSucceeded>Saved!</ng-template>
|
|
41
|
-
* <ng-template cngxFailed let-err>{{ err }} - retry?</ng-template>
|
|
42
|
-
* </cngx-action-button>
|
|
25
|
+
* ```ts
|
|
26
|
+
* hostDirectives: [
|
|
27
|
+
* // ...button brain, async click, action status brain
|
|
28
|
+
* { directive: CngxActionToast, inputs: ['toastSuccess', 'toastError'] },
|
|
29
|
+
* ],
|
|
43
30
|
* ```
|
|
44
31
|
*
|
|
45
|
-
* ### With toast feedback
|
|
46
|
-
* ```html
|
|
47
|
-
* <cngx-action-button [action]="save" toastSuccess="Saved" toastError="Save failed">
|
|
48
|
-
* Save
|
|
49
|
-
* </cngx-action-button>
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* @category ui/action-button
|
|
53
|
-
* @docsKind primary
|
|
54
32
|
* @wcag AA
|
|
55
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/action-button/action-
|
|
56
|
-
* @since 0.
|
|
57
|
-
* @relatedTo
|
|
58
|
-
*
|
|
59
|
-
* @
|
|
60
|
-
* @slot cngxFailed Replaces the label when the action fails; gets the error.
|
|
61
|
-
* <example-url>http://localhost:4200/#/ui/action-button/async-button/random-outcome</example-url>
|
|
62
|
-
* <example-url>http://localhost:4200/#/ui/action-button/async-button/string-labels</example-url>
|
|
63
|
-
* <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
|
|
64
38
|
*/
|
|
65
|
-
class
|
|
39
|
+
class CngxActionToast {
|
|
40
|
+
status = inject(CNGX_ACTION_STATUS);
|
|
66
41
|
toaster = inject(CngxToaster, { optional: true });
|
|
67
42
|
errorDetail = injectErrorDetail();
|
|
68
43
|
feedbackI18n = injectFeedbackI18n();
|
|
69
44
|
externalToastOn = inject(CngxToastOn, { self: true, optional: true });
|
|
70
|
-
i18n = injectInteractiveI18n();
|
|
71
|
-
/** The async action to execute on click. */
|
|
72
|
-
action = input.required(...(ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []));
|
|
73
|
-
/** Duration in ms to show success/error feedback. Passed through to `cngxAsyncClick`. */
|
|
74
|
-
feedbackDuration = input(2000, ...(ngDevMode ? [{ debugName: "feedbackDuration" }] : /* istanbul ignore next */ []));
|
|
75
|
-
/** When `false`, clicks are ignored. Passed through to `cngxAsyncClick`. */
|
|
76
|
-
enabled = input(true, ...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
|
|
77
|
-
/** Button type attribute. Defaults to `'button'` to prevent accidental form submits. */
|
|
78
|
-
type = input('button', ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
79
|
-
/** Visual variant - sets CSS class `cngx-action-button--{variant}`. */
|
|
80
|
-
variant = input('primary', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
81
|
-
/**
|
|
82
|
-
* SR announcement on success. Falls back to `succeededLabel`, then
|
|
83
|
-
* `CNGX_INTERACTIVE_I18N.asyncClickSucceeded`.
|
|
84
|
-
*/
|
|
85
|
-
succeededAnnouncement = input(undefined, ...(ngDevMode ? [{ debugName: "succeededAnnouncement" }] : /* istanbul ignore next */ []));
|
|
86
|
-
/**
|
|
87
|
-
* SR announcement on failure. Falls back to `failedLabel`, then
|
|
88
|
-
* `CNGX_INTERACTIVE_I18N.asyncClickFailed`.
|
|
89
|
-
*/
|
|
90
|
-
failedAnnouncement = input(undefined, ...(ngDevMode ? [{ debugName: "failedAnnouncement" }] : /* istanbul ignore next */ []));
|
|
91
|
-
/** Fallback text while pending (when no `cngxPending` template is projected). */
|
|
92
|
-
pendingLabel = input(undefined, ...(ngDevMode ? [{ debugName: "pendingLabel" }] : /* istanbul ignore next */ []));
|
|
93
|
-
/** Fallback text after success (when no `cngxSucceeded` template is projected). */
|
|
94
|
-
succeededLabel = input(undefined, ...(ngDevMode ? [{ debugName: "succeededLabel" }] : /* istanbul ignore next */ []));
|
|
95
|
-
/** Fallback text after failure (when no `cngxFailed` template is projected). */
|
|
96
|
-
failedLabel = input(undefined, ...(ngDevMode ? [{ debugName: "failedLabel" }] : /* istanbul ignore next */ []));
|
|
97
|
-
/**
|
|
98
|
-
* Bind an external async state to derive visual status from.
|
|
99
|
-
* When set, the button's status display follows `externalState.status()`.
|
|
100
|
-
*/
|
|
101
|
-
externalState = input(undefined, ...(ngDevMode ? [{ debugName: "externalState" }] : /* istanbul ignore next */ []));
|
|
102
|
-
/**
|
|
103
|
-
* Reason the button is disabled, announced to screen readers while
|
|
104
|
-
* `[enabled]` is `false`. Rendered into a hidden region and referenced by
|
|
105
|
-
* `aria-describedby` only while disabled - an enabled button never carries
|
|
106
|
-
* the reference. No effect when `[enabled]` is `true`.
|
|
107
|
-
*/
|
|
108
|
-
disabledReason = input(undefined, ...(ngDevMode ? [{ debugName: "disabledReason" }] : /* istanbul ignore next */ []));
|
|
109
45
|
/**
|
|
110
|
-
* Toast message on success.
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* `toastSuccessDuration` should be >= `feedbackDuration` to avoid rapid re-fire
|
|
114
|
-
* 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.
|
|
115
48
|
*/
|
|
116
49
|
toastSuccess = input(undefined, ...(ngDevMode ? [{ debugName: "toastSuccess" }] : /* istanbul ignore next */ []));
|
|
117
50
|
/** Toast message on error. */
|
|
118
51
|
toastError = input(undefined, ...(ngDevMode ? [{ debugName: "toastError" }] : /* istanbul ignore next */ []));
|
|
119
|
-
/** Include the error detail message in the error toast body. */
|
|
120
|
-
toastErrorDetail = input(false, ...(ngDevMode ? [{ debugName: "toastErrorDetail" }] : /* istanbul ignore next */ []));
|
|
121
|
-
/** Duration for success toasts in ms. */
|
|
122
|
-
toastSuccessDuration = input(3000, ...(ngDevMode ? [{ debugName: "toastSuccessDuration" }] : /* istanbul ignore next */ []));
|
|
123
|
-
/** Duration for error toasts - `'persistent'` means manual dismiss only. */
|
|
124
|
-
toastErrorDuration = input('persistent', ...(ngDevMode ? [{ debugName: "toastErrorDuration" }] : /* istanbul ignore next */ []));
|
|
125
|
-
/** @internal - inner CngxAsyncClick directive instance. Non-required to allow safe pre-view-init reads. */
|
|
126
|
-
asyncClick = viewChild(CngxAsyncClick, ...(ngDevMode ? [{ debugName: "asyncClick" }] : /* istanbul ignore next */ []));
|
|
127
|
-
/**
|
|
128
|
-
* @internal - effective status: reflects external `[externalState]` if
|
|
129
|
-
* bound (through the shared `CngxAsyncStatus` reflection - one home for
|
|
130
|
-
* the state→display-bucket mapping), otherwise reads the inner
|
|
131
|
-
* `CngxAsyncClick` directive.
|
|
132
|
-
*/
|
|
133
|
-
effectiveStatus = computed(() => {
|
|
134
|
-
const ext = this.externalState();
|
|
135
|
-
if (ext) {
|
|
136
|
-
return reflectAsyncDisplayStatus(ext);
|
|
137
|
-
}
|
|
138
|
-
// Guard against pre-view-init reads of `state` from consumers.
|
|
139
|
-
const click = this.asyncClick();
|
|
140
|
-
return click ? click.status() : 'idle';
|
|
141
|
-
}, ...(ngDevMode ? [{ debugName: "effectiveStatus" }] : /* istanbul ignore next */ []));
|
|
142
|
-
/** @internal - effective error value from external state or inner directive. */
|
|
143
|
-
effectiveError = computed(() => {
|
|
144
|
-
const ext = this.externalState();
|
|
145
|
-
if (ext) {
|
|
146
|
-
return ext.error();
|
|
147
|
-
}
|
|
148
|
-
const click = this.asyncClick();
|
|
149
|
-
return click ? click.error() : undefined;
|
|
150
|
-
}, ...(ngDevMode ? [{ debugName: "effectiveError" }] : /* istanbul ignore next */ []));
|
|
151
|
-
/** @internal - busy while the effective status (inner or external) is pending. */
|
|
152
|
-
effectiveBusy = computed(() => this.effectiveStatus() === 'pending', ...(ngDevMode ? [{ debugName: "effectiveBusy" }] : /* istanbul ignore next */ []));
|
|
153
|
-
/**
|
|
154
|
-
* @internal - what the inner `CngxAsyncClick` may act on: only when the
|
|
155
|
-
* consumer enabled it AND no effective operation is in flight. Feeding this
|
|
156
|
-
* as `[enabled]` routes external-pending through the atom's own click guard,
|
|
157
|
-
* so a click cannot start a second run while an external state is pending.
|
|
158
|
-
*/
|
|
159
|
-
clickEnabled = computed(() => this.enabled() && this.effectiveStatus() !== 'pending', ...(ngDevMode ? [{ debugName: "clickEnabled" }] : /* istanbul ignore next */ []));
|
|
160
52
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
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.
|
|
164
57
|
*/
|
|
165
|
-
|
|
166
|
-
switch (this.effectiveStatus()) {
|
|
167
|
-
case 'success':
|
|
168
|
-
return untracked(() => this.succeededAnnouncement() ??
|
|
169
|
-
this.succeededLabel() ??
|
|
170
|
-
this.i18n().asyncClickSucceeded);
|
|
171
|
-
case 'error':
|
|
172
|
-
return untracked(() => this.failedAnnouncement() ?? this.failedLabel() ?? this.i18n().asyncClickFailed);
|
|
173
|
-
default:
|
|
174
|
-
return '';
|
|
175
|
-
}
|
|
176
|
-
}, ...(ngDevMode ? [{ debugName: "effectiveAnnouncement" }] : /* istanbul ignore next */ []));
|
|
177
|
-
/** @internal - stable id for the disabled-reason region. */
|
|
178
|
-
reasonId = nextUid('cngx-action-button-reason');
|
|
58
|
+
toastErrorDetail = input(false, ...(ngDevMode ? [{ debugName: "toastErrorDetail" }] : /* istanbul ignore next */ []));
|
|
179
59
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* node, so the id must be gated on the state it describes rather than left
|
|
183
|
-
* permanently pointing at a hidden region.
|
|
60
|
+
* Duration for success toasts in ms. Unbound, `CngxToaster` resolves it:
|
|
61
|
+
* `withToasts({ defaultDuration })`, else 5000 ms.
|
|
184
62
|
*/
|
|
185
|
-
|
|
186
|
-
lastUpdatedState = signal(undefined, ...(ngDevMode ? [{ debugName: "lastUpdatedState" }] : /* istanbul ignore next */ []));
|
|
63
|
+
toastSuccessDuration = input(undefined, ...(ngDevMode ? [{ debugName: "toastSuccessDuration" }] : /* istanbul ignore next */ []));
|
|
187
64
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* Reflects the external state when `[externalState]` is bound,
|
|
191
|
-
* otherwise the inner `CngxAsyncClick` directive's state.
|
|
192
|
-
*
|
|
193
|
-
* 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.
|
|
194
67
|
*/
|
|
195
|
-
|
|
196
|
-
status: this.effectiveStatus,
|
|
197
|
-
data: computed(() => undefined),
|
|
198
|
-
error: this.effectiveError,
|
|
199
|
-
lastUpdated: this.lastUpdatedState.asReadonly(),
|
|
200
|
-
});
|
|
201
|
-
/** @internal */
|
|
202
|
-
pendingTpl = contentChild(CngxPending, ...(ngDevMode ? [{ debugName: "pendingTpl" }] : /* istanbul ignore next */ []));
|
|
203
|
-
/** @internal */
|
|
204
|
-
succeededTpl = contentChild(CngxSucceeded, ...(ngDevMode ? [{ debugName: "succeededTpl" }] : /* istanbul ignore next */ []));
|
|
205
|
-
/** @internal */
|
|
206
|
-
failedTpl = contentChild(CngxFailed, ...(ngDevMode ? [{ debugName: "failedTpl" }] : /* istanbul ignore next */ []));
|
|
68
|
+
toastErrorDuration = input(undefined, ...(ngDevMode ? [{ debugName: "toastErrorDuration" }] : /* istanbul ignore next */ []));
|
|
207
69
|
constructor() {
|
|
208
70
|
// Double-toast guard, consumer placed [cngxToastOn] on the same element.
|
|
209
71
|
// After the first render: template-bound inputs are unset in the constructor.
|
|
210
72
|
if (typeof ngDevMode !== 'undefined' && ngDevMode && this.externalToastOn) {
|
|
211
73
|
afterNextRender(() => {
|
|
212
74
|
if (this.toastSuccess() || this.toastError()) {
|
|
213
|
-
cngxDevWarn('CNGX3008', '[
|
|
75
|
+
cngxDevWarn('CNGX3008', '[cngxActionToast] [toastSuccess]/[toastError] inputs and [cngxToastOn] ' +
|
|
214
76
|
'on the same element will fire duplicate toasts. Use one or the other.');
|
|
215
77
|
}
|
|
216
78
|
});
|
|
217
79
|
}
|
|
218
|
-
|
|
219
|
-
effect(() => {
|
|
220
|
-
const status = tracker.current();
|
|
221
|
-
const previous = tracker.previous();
|
|
222
|
-
if (status === previous) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
// Only the transition edge may re-run this body. The toast inputs and
|
|
226
|
-
// effectiveError are read untracked: previous() stays stale for the whole
|
|
227
|
-
// settled window, so a tracked read would re-fire the toast on any input
|
|
228
|
-
// rebind while status sits in success/error. Doctrine: bridge effects
|
|
229
|
-
// untrack service calls.
|
|
230
|
-
untracked(() => {
|
|
231
|
-
if (status === 'success') {
|
|
232
|
-
// Producer write for the buildAsyncStateView `lastUpdated` slot (no other
|
|
233
|
-
// source feeds it) - state production, not derived-state sync. This is the
|
|
234
|
-
// sanctioned signal-write-in-effect class, same as the async-state-view pattern.
|
|
235
|
-
this.lastUpdatedState.set(new Date());
|
|
236
|
-
const msg = this.toastSuccess();
|
|
237
|
-
if (msg && this.toaster) {
|
|
238
|
-
this.toaster.show({
|
|
239
|
-
message: msg,
|
|
240
|
-
severity: 'success',
|
|
241
|
-
duration: this.toastSuccessDuration(),
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (status === 'error') {
|
|
246
|
-
const msg = this.toastError();
|
|
247
|
-
if (msg && this.toaster) {
|
|
248
|
-
const err = this.effectiveError();
|
|
249
|
-
const detail = this.toastErrorDetail() && err != null ? this.errorDetail(err) : undefined;
|
|
250
|
-
this.toaster.show({
|
|
251
|
-
message: detail ? this.feedbackI18n().errorWithDetail(msg, detail) : msg,
|
|
252
|
-
severity: 'error',
|
|
253
|
-
duration: this.toastErrorDuration(),
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
});
|
|
80
|
+
this.status.outcome.subscribe((outcome) => untracked(() => this.showToast(outcome)));
|
|
259
81
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
[autoAnnounce]="false"
|
|
271
|
-
[succeededAnnouncement]="succeededAnnouncement() ?? succeededLabel()"
|
|
272
|
-
[failedAnnouncement]="failedAnnouncement() ?? failedLabel()"
|
|
273
|
-
[attr.aria-describedby]="describedBy()"
|
|
274
|
-
[class]="'cngx-action-button cngx-action-button--' + variant()"
|
|
275
|
-
>
|
|
276
|
-
@switch (effectiveStatus()) {
|
|
277
|
-
@case ('pending') {
|
|
278
|
-
@if (pendingTpl(); as tpl) {
|
|
279
|
-
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
280
|
-
} @else if (pendingLabel()) {
|
|
281
|
-
{{ pendingLabel() }}
|
|
282
|
-
} @else {
|
|
283
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
@case ('success') {
|
|
287
|
-
@if (succeededTpl(); as tpl) {
|
|
288
|
-
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
289
|
-
} @else if (succeededLabel()) {
|
|
290
|
-
{{ succeededLabel() }}
|
|
291
|
-
} @else {
|
|
292
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
293
|
-
}
|
|
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;
|
|
294
92
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
} @else if (failedLabel()) {
|
|
301
|
-
{{ failedLabel() }}
|
|
302
|
-
} @else {
|
|
303
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
304
|
-
}
|
|
93
|
+
return status === 'success' ? !!this.toastSuccess() : !!this.toastError();
|
|
94
|
+
}
|
|
95
|
+
showToast({ status, error }) {
|
|
96
|
+
if (!this.toaster) {
|
|
97
|
+
return;
|
|
305
98
|
}
|
|
306
|
-
|
|
307
|
-
|
|
99
|
+
const toast = resolveOutcomeToast(this, status, error, this.errorDetail, this.feedbackI18n());
|
|
100
|
+
if (toast) {
|
|
101
|
+
this.toaster.show(toast);
|
|
308
102
|
}
|
|
309
|
-
}
|
|
310
|
-
</button>
|
|
311
|
-
@if (disabledReason(); as reason) {
|
|
312
|
-
<span [id]="reasonId" class="cngx-action-button__sr-only">{{ reason }}</span>
|
|
313
103
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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 });
|
|
318
195
|
}
|
|
319
196
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActionButton, decorators: [{
|
|
320
197
|
type: Component,
|
|
321
|
-
args: [{ selector: '
|
|
322
|
-
|
|
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',
|
|
323
246
|
}, template: `
|
|
324
|
-
<ng-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
[feedbackDuration]="feedbackDuration()"
|
|
330
|
-
[enabled]="clickEnabled()"
|
|
331
|
-
[busy]="effectiveBusy()"
|
|
332
|
-
[autoAnnounce]="false"
|
|
333
|
-
[succeededAnnouncement]="succeededAnnouncement() ?? succeededLabel()"
|
|
334
|
-
[failedAnnouncement]="failedAnnouncement() ?? failedLabel()"
|
|
335
|
-
[attr.aria-describedby]="describedBy()"
|
|
336
|
-
[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"
|
|
337
252
|
>
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
} @else {
|
|
345
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
@case ('success') {
|
|
349
|
-
@if (succeededTpl(); as tpl) {
|
|
350
|
-
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
351
|
-
} @else if (succeededLabel()) {
|
|
352
|
-
{{ succeededLabel() }}
|
|
353
|
-
} @else {
|
|
354
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
@case ('error') {
|
|
358
|
-
@if (failedTpl(); as tpl) {
|
|
359
|
-
<ng-container
|
|
360
|
-
*ngTemplateOutlet="tpl.templateRef; context: { $implicit: effectiveError() }"
|
|
361
|
-
/>
|
|
362
|
-
} @else if (failedLabel()) {
|
|
363
|
-
{{ failedLabel() }}
|
|
364
|
-
} @else {
|
|
365
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
@default {
|
|
369
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
</button>
|
|
373
|
-
@if (disabledReason(); as reason) {
|
|
374
|
-
<span [id]="reasonId" class="cngx-action-button__sr-only">{{ reason }}</span>
|
|
375
|
-
}
|
|
376
|
-
<span aria-live="polite" aria-atomic="true" class="cngx-action-button__sr-only">{{
|
|
377
|
-
effectiveAnnouncement()
|
|
378
|
-
}}</span>
|
|
379
|
-
`, 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"] }]
|
|
380
|
-
}], 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 }] }] } });
|
|
381
259
|
|
|
382
260
|
/**
|
|
383
|
-
* @module
|
|
261
|
+
* @module `@cngx/ui/action-button`
|
|
384
262
|
*/
|
|
385
263
|
|
|
386
264
|
/**
|
|
387
265
|
* Generated bundle index. Do not edit.
|
|
388
266
|
*/
|
|
389
267
|
|
|
390
|
-
export { CngxActionButton };
|
|
268
|
+
export { CngxActionButton, CngxActionToast };
|
|
391
269
|
//# sourceMappingURL=cngx-ui-action-button.mjs.map
|