@cngx/ui 0.0.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +550 -0
- package/action-button/README.md +98 -0
- package/empty-state/README.md +103 -0
- package/feedback/README.md +33 -0
- package/fesm2022/cngx-ui-action-button.mjs +319 -0
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -0
- package/fesm2022/cngx-ui-empty-state.mjs +138 -0
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -0
- package/fesm2022/cngx-ui-feedback.mjs +2962 -0
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -0
- package/fesm2022/cngx-ui-layout.mjs +89 -0
- package/fesm2022/cngx-ui-layout.mjs.map +1 -0
- package/fesm2022/cngx-ui-mat-stepper.mjs +567 -0
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -0
- package/fesm2022/cngx-ui-mat-tabs.mjs +1405 -0
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -0
- package/fesm2022/cngx-ui-material.mjs +79 -0
- package/fesm2022/cngx-ui-material.mjs.map +1 -0
- package/fesm2022/cngx-ui-overlay.mjs +91 -0
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -0
- package/fesm2022/cngx-ui-sidenav.mjs +521 -0
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -0
- package/fesm2022/cngx-ui-skeleton.mjs +158 -0
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -0
- package/fesm2022/cngx-ui-speak.mjs +112 -0
- package/fesm2022/cngx-ui-speak.mjs.map +1 -0
- package/fesm2022/cngx-ui-stepper.mjs +312 -0
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -0
- package/fesm2022/cngx-ui-tabs.mjs +507 -0
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -0
- package/fesm2022/cngx-ui.mjs +45 -0
- package/fesm2022/cngx-ui.mjs.map +1 -0
- package/layout/README.md +133 -0
- package/mat-stepper/README.md +34 -0
- package/mat-tabs/README.md +163 -0
- package/mat-tabs/styles/mat-tabs.css +233 -0
- package/material/README.md +90 -0
- package/overlay/README.md +99 -0
- package/package.json +98 -0
- package/sidenav/README.md +127 -0
- package/skeleton/README.md +98 -0
- package/speak/README.md +93 -0
- package/speak/speak-button-theme.scss +78 -0
- package/stepper/README.md +40 -0
- package/tabs/README.md +28 -0
- package/types/cngx-ui-action-button.d.ts +126 -0
- package/types/cngx-ui-empty-state.d.ts +41 -0
- package/types/cngx-ui-feedback.d.ts +1174 -0
- package/types/cngx-ui-layout.d.ts +56 -0
- package/types/cngx-ui-mat-stepper.d.ts +234 -0
- package/types/cngx-ui-mat-tabs.d.ts +664 -0
- package/types/cngx-ui-material.d.ts +36 -0
- package/types/cngx-ui-overlay.d.ts +57 -0
- package/types/cngx-ui-sidenav.d.ts +209 -0
- package/types/cngx-ui-skeleton.d.ts +97 -0
- package/types/cngx-ui-speak.d.ts +31 -0
- package/types/cngx-ui-stepper.d.ts +129 -0
- package/types/cngx-ui-tabs.d.ts +165 -0
- package/types/cngx-ui.d.ts +18 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# CngxEmptyState
|
|
2
|
+
|
|
3
|
+
Empty-state display atom for grids, tables, lists, and dashboards.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { CngxEmptyState } from '@cngx/ui/empty-state';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Component } from '@angular/core';
|
|
15
|
+
import { CngxEmptyState } from '@cngx/ui/empty-state';
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'app-example',
|
|
19
|
+
template: `
|
|
20
|
+
<cngx-empty-state title="No search results" description="Try a different search term">
|
|
21
|
+
<mat-icon cngxEmptyStateIcon>search_off</mat-icon>
|
|
22
|
+
<button cngxEmptyStateAction (click)="resetSearch()">Clear Search</button>
|
|
23
|
+
</cngx-empty-state>
|
|
24
|
+
`,
|
|
25
|
+
imports: [CngxEmptyState],
|
|
26
|
+
})
|
|
27
|
+
export class ExampleComponent {
|
|
28
|
+
resetSearch(): void {
|
|
29
|
+
// Reset logic
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
|
|
36
|
+
`CngxEmptyState` is an atom component that displays when a collection is empty, providing context about why and what the user can do next. It communicates three distinct UX scenarios:
|
|
37
|
+
|
|
38
|
+
1. **First-use** — Onboarding, show what's possible
|
|
39
|
+
2. **No-results** — Recovery, offer filter reset or search change
|
|
40
|
+
3. **Cleared** — Confirmation, everything is done
|
|
41
|
+
|
|
42
|
+
The component supports icon projection via the `[cngxEmptyStateIcon]` slot (no Material dependency) and action buttons via `[cngxEmptyStateAction]`. Integrates with `CngxAsyncState` for automatic visibility control.
|
|
43
|
+
|
|
44
|
+
## Accessibility
|
|
45
|
+
|
|
46
|
+
`CngxEmptyState` is fully accessible:
|
|
47
|
+
|
|
48
|
+
- **ARIA roles:** Host is `role="status"` with `aria-live="polite"` — announces empty state changes.
|
|
49
|
+
- **Labeling:** Title has `id` bound to `aria-labelledby`; description has `id` bound to `aria-describedby` (when present).
|
|
50
|
+
- **Hidden state:** When bound to async state with data, uses `[attr.hidden]` to remove from the accessibility tree.
|
|
51
|
+
- **Screen reader:** Icon is `aria-hidden="true"` (decorative); title and description carry the meaning.
|
|
52
|
+
|
|
53
|
+
## Composition
|
|
54
|
+
|
|
55
|
+
`CngxEmptyState` composes:
|
|
56
|
+
|
|
57
|
+
- **Async state integration** — Reads `CngxAsyncState<T>` and auto-hides when data is not empty
|
|
58
|
+
- **Content projection** — Four named slots for icon, illustration, actions, and secondary content
|
|
59
|
+
- **Auto-ID generation** — Generates unique IDs for title/description ARIA references
|
|
60
|
+
|
|
61
|
+
## Styling
|
|
62
|
+
|
|
63
|
+
All colors and spacing use CSS Custom Properties with sensible defaults:
|
|
64
|
+
|
|
65
|
+
```scss
|
|
66
|
+
// Override in your component or global styles
|
|
67
|
+
:host {
|
|
68
|
+
--cngx-empty-state-padding: 60px 20px;
|
|
69
|
+
--cngx-empty-state-gap: 24px;
|
|
70
|
+
--cngx-empty-state-icon-size: 80px;
|
|
71
|
+
--cngx-empty-state-title-font-size: 20px;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Material Theme
|
|
76
|
+
|
|
77
|
+
Include the theme SCSS in your global stylesheet:
|
|
78
|
+
|
|
79
|
+
```scss
|
|
80
|
+
@use '@angular/material' as mat;
|
|
81
|
+
@use '@cngx/ui/empty-state/empty-state-theme' as empty-state;
|
|
82
|
+
|
|
83
|
+
$theme: mat.define-theme((...));
|
|
84
|
+
|
|
85
|
+
html {
|
|
86
|
+
@include mat.all-component-themes($theme);
|
|
87
|
+
@include empty-state.theme($theme);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The theme mixin provides:
|
|
92
|
+
|
|
93
|
+
- Material 3 system color tokens (`--mat-sys-*`) with fallback defaults
|
|
94
|
+
- Material 2 palette color mappings
|
|
95
|
+
- Automatic theme version detection (M3 vs M2)
|
|
96
|
+
- Icon and text color alignment with Material palette
|
|
97
|
+
|
|
98
|
+
## See Also
|
|
99
|
+
|
|
100
|
+
- [CngxAsyncState](../../core/utils/) — Async state contract
|
|
101
|
+
- [compodoc API documentation](https://cngxjs.github.io/cngx/)
|
|
102
|
+
- Demo: `dev-app/src/app/demos/ui/empty-state-demo/`
|
|
103
|
+
- Tests: `projects/ui/empty-state/empty-state.component.spec.ts`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @cngx/ui/feedback
|
|
2
|
+
|
|
3
|
+
The communication surfaces of cngx — toasts, banners, alerts, loading indicators, and the async-container molecule. The bridge between an async state and the user's eyes.
|
|
4
|
+
|
|
5
|
+
## When you reach for it
|
|
6
|
+
|
|
7
|
+
You have a piece of async state (loading a list, saving a form, retrying a request) and want the user to see what is happening without you wiring four signals into four templates:
|
|
8
|
+
|
|
9
|
+
- **Loading indicators** — spinner, bar, dots, text — whenever a region is busy.
|
|
10
|
+
- **An async-aware container** that swaps between skeleton, content, empty, and error views with a single binding.
|
|
11
|
+
- **Toasts** for ephemeral success and error notifications.
|
|
12
|
+
- **Banners** for persistent top-of-page errors that should clear themselves on the next success.
|
|
13
|
+
- **Alerts** for inline messages bound to a specific area of the page.
|
|
14
|
+
|
|
15
|
+
The transition bridges (`[cngxToastOn]`, `[cngxAlertOn]`, `[cngxBannerOn]`) are the headline ergonomics: declarative attribute directives that watch a `CngxAsyncState` and fire feedback on the right transition without you writing an `effect()` for each one.
|
|
16
|
+
|
|
17
|
+
## Mental model
|
|
18
|
+
|
|
19
|
+
`@cngx/ui/feedback` is the consumer half of the async state machine. `@cngx/core/utils` defines the state interface; producer factories in `@cngx/common/data` create the state; this entry **renders** it. Skeletons, alerts, banners, and toasts are all reactive readers of the same shape.
|
|
20
|
+
|
|
21
|
+
Two patterns make the whole feedback layer feel cohesive:
|
|
22
|
+
|
|
23
|
+
- **State precedence.** Every consumer accepts a `[state]` input that wins over equivalent boolean inputs. Wire state once, every surface stays in sync.
|
|
24
|
+
- **Discovery through DI.** When a transition bridge has no `[state]` binding, it falls back to the `CNGX_STATEFUL` token from its host or any ancestor. Components that own async state (the select family, action button, dialog with submit action, async container) provide that token, so a bare `<button cngxToastOn>` inside them just works.
|
|
25
|
+
|
|
26
|
+
## Bootstrap requirement
|
|
27
|
+
|
|
28
|
+
Toast, banner, and alerter services are **not** `providedIn: 'root'`. Provide them via `provideFeedback(...)` in your application bootstrap, and render the outlets once at the application root. This is intentional — feedback presentation is application-level, not library-level, and forcing the consumer to opt in keeps a tree-shake-friendly footprint when only a subset of surfaces is in use.
|
|
29
|
+
|
|
30
|
+
## See also
|
|
31
|
+
|
|
32
|
+
- Outlet components, services, bridge directives, slot directives, and `with*` config features in the **API** tab.
|
|
33
|
+
- Conceptual deep dive: the "Async State Machine" chapter in the docs sidebar.
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, input, viewChild, computed, signal, contentChild, effect, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { CngxAsyncClick, CngxPending, CngxSucceeded, CngxFailed } from '@cngx/common/interactive';
|
|
5
|
+
import { buildAsyncStateView, createTransitionTracker } from '@cngx/core/utils';
|
|
6
|
+
import { CngxToaster, CngxToastOn } from '@cngx/ui/feedback';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Action button molecule with built-in status communication.
|
|
10
|
+
*
|
|
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
|
+
*
|
|
16
|
+
* Uses `display: contents` — the host produces no DOM box. The inner `<button>`
|
|
17
|
+
* carries the `[cngxAsyncClick]` directive directly.
|
|
18
|
+
*
|
|
19
|
+
* For full control, use `[cngxAsyncClick]` directly on any element instead.
|
|
20
|
+
*
|
|
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>
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
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
|
+
class CngxActionButton {
|
|
52
|
+
toaster = inject(CngxToaster, { optional: true });
|
|
53
|
+
externalToastOn = inject(CngxToastOn, { self: true, optional: true });
|
|
54
|
+
/** The async action to execute on click. */
|
|
55
|
+
action = input.required(...(ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []));
|
|
56
|
+
/** Duration in ms to show success/error feedback. Passed through to `cngxAsyncClick`. */
|
|
57
|
+
feedbackDuration = input(2000, ...(ngDevMode ? [{ debugName: "feedbackDuration" }] : /* istanbul ignore next */ []));
|
|
58
|
+
/** When `false`, clicks are ignored. Passed through to `cngxAsyncClick`. */
|
|
59
|
+
enabled = input(true, ...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
|
|
60
|
+
/** Button type attribute. Defaults to `'button'` to prevent accidental form submits. */
|
|
61
|
+
type = input('button', ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
62
|
+
/** Visual variant — sets CSS class `cngx-action-button--{variant}`. */
|
|
63
|
+
variant = input('primary', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
64
|
+
/** SR announcement on success. Falls back to `succeededLabel`, then `'Action succeeded'`. */
|
|
65
|
+
succeededAnnouncement = input(undefined, ...(ngDevMode ? [{ debugName: "succeededAnnouncement" }] : /* istanbul ignore next */ []));
|
|
66
|
+
/** SR announcement on failure. Falls back to `failedLabel`, then `'Action failed'`. */
|
|
67
|
+
failedAnnouncement = input(undefined, ...(ngDevMode ? [{ debugName: "failedAnnouncement" }] : /* istanbul ignore next */ []));
|
|
68
|
+
/** Fallback text while pending (when no `cngxPending` template is projected). */
|
|
69
|
+
pendingLabel = input(undefined, ...(ngDevMode ? [{ debugName: "pendingLabel" }] : /* istanbul ignore next */ []));
|
|
70
|
+
/** Fallback text after success (when no `cngxSucceeded` template is projected). */
|
|
71
|
+
succeededLabel = input(undefined, ...(ngDevMode ? [{ debugName: "succeededLabel" }] : /* istanbul ignore next */ []));
|
|
72
|
+
/** Fallback text after failure (when no `cngxFailed` template is projected). */
|
|
73
|
+
failedLabel = input(undefined, ...(ngDevMode ? [{ debugName: "failedLabel" }] : /* istanbul ignore next */ []));
|
|
74
|
+
/**
|
|
75
|
+
* Bind an external async state to derive visual status from.
|
|
76
|
+
* When set, the button's status display follows `externalState.status()`.
|
|
77
|
+
*/
|
|
78
|
+
externalState = input(undefined, ...(ngDevMode ? [{ debugName: "externalState" }] : /* istanbul ignore next */ []));
|
|
79
|
+
/**
|
|
80
|
+
* Toast message on success. Requires `CngxToaster` (via `provideFeedback(withToasts())`
|
|
81
|
+
* or `provideToasts()`). Silently ignored when toaster is not provided.
|
|
82
|
+
*
|
|
83
|
+
* `toastSuccessDuration` should be >= `feedbackDuration` to avoid rapid re-fire
|
|
84
|
+
* on repeated clicks that floods the SR announcement queue.
|
|
85
|
+
*/
|
|
86
|
+
toastSuccess = input(undefined, ...(ngDevMode ? [{ debugName: "toastSuccess" }] : /* istanbul ignore next */ []));
|
|
87
|
+
/** Toast message on error. */
|
|
88
|
+
toastError = input(undefined, ...(ngDevMode ? [{ debugName: "toastError" }] : /* istanbul ignore next */ []));
|
|
89
|
+
/** Include the error detail message in the error toast body. */
|
|
90
|
+
toastErrorDetail = input(false, ...(ngDevMode ? [{ debugName: "toastErrorDetail" }] : /* istanbul ignore next */ []));
|
|
91
|
+
/** Duration for success toasts in ms. */
|
|
92
|
+
toastSuccessDuration = input(3000, ...(ngDevMode ? [{ debugName: "toastSuccessDuration" }] : /* istanbul ignore next */ []));
|
|
93
|
+
/** Duration for error toasts — `'persistent'` means manual dismiss only. */
|
|
94
|
+
toastErrorDuration = input('persistent', ...(ngDevMode ? [{ debugName: "toastErrorDuration" }] : /* istanbul ignore next */ []));
|
|
95
|
+
/** @internal — inner CngxAsyncClick directive instance. Non-required to allow safe pre-view-init reads. */
|
|
96
|
+
asyncClick = viewChild(CngxAsyncClick, ...(ngDevMode ? [{ debugName: "asyncClick" }] : /* istanbul ignore next */ []));
|
|
97
|
+
/**
|
|
98
|
+
* @internal — effective status: reads from external `[externalState]` if bound,
|
|
99
|
+
* otherwise from the inner `CngxAsyncClick` directive.
|
|
100
|
+
*/
|
|
101
|
+
effectiveStatus = computed(() => {
|
|
102
|
+
const ext = this.externalState();
|
|
103
|
+
if (ext) {
|
|
104
|
+
const status = ext.status();
|
|
105
|
+
if (status === 'pending') {
|
|
106
|
+
return 'pending';
|
|
107
|
+
}
|
|
108
|
+
if (status === 'success') {
|
|
109
|
+
return 'success';
|
|
110
|
+
}
|
|
111
|
+
if (status === 'error') {
|
|
112
|
+
return 'error';
|
|
113
|
+
}
|
|
114
|
+
return 'idle';
|
|
115
|
+
}
|
|
116
|
+
// viewChild is guaranteed resolved when the template reads this computed.
|
|
117
|
+
// Guard protects consumers reading `state` before view init.
|
|
118
|
+
const click = this.asyncClick();
|
|
119
|
+
return click ? click.status() : 'idle';
|
|
120
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveStatus" }] : /* istanbul ignore next */ []));
|
|
121
|
+
/** @internal — effective error value from external state or inner directive. */
|
|
122
|
+
effectiveError = computed(() => {
|
|
123
|
+
const ext = this.externalState();
|
|
124
|
+
if (ext) {
|
|
125
|
+
return ext.error();
|
|
126
|
+
}
|
|
127
|
+
const click = this.asyncClick();
|
|
128
|
+
return click ? click.error() : undefined;
|
|
129
|
+
}, ...(ngDevMode ? [{ debugName: "effectiveError" }] : /* istanbul ignore next */ []));
|
|
130
|
+
lastUpdatedState = signal(undefined, ...(ngDevMode ? [{ debugName: "lastUpdatedState" }] : /* istanbul ignore next */ []));
|
|
131
|
+
/**
|
|
132
|
+
* Full `CngxAsyncState` view of this button's effective lifecycle.
|
|
133
|
+
*
|
|
134
|
+
* Reflects the external state when `[externalState]` is bound,
|
|
135
|
+
* otherwise the inner `CngxAsyncClick` directive's state.
|
|
136
|
+
*
|
|
137
|
+
* Bind to any state consumer: `<cngx-alert [state]="btn.state" />`.
|
|
138
|
+
*/
|
|
139
|
+
state = buildAsyncStateView({
|
|
140
|
+
status: this.effectiveStatus,
|
|
141
|
+
data: computed(() => undefined),
|
|
142
|
+
error: this.effectiveError,
|
|
143
|
+
lastUpdated: this.lastUpdatedState.asReadonly(),
|
|
144
|
+
});
|
|
145
|
+
/** @internal */
|
|
146
|
+
pendingTpl = contentChild(CngxPending, ...(ngDevMode ? [{ debugName: "pendingTpl" }] : /* istanbul ignore next */ []));
|
|
147
|
+
/** @internal */
|
|
148
|
+
succeededTpl = contentChild(CngxSucceeded, ...(ngDevMode ? [{ debugName: "succeededTpl" }] : /* istanbul ignore next */ []));
|
|
149
|
+
/** @internal */
|
|
150
|
+
failedTpl = contentChild(CngxFailed, ...(ngDevMode ? [{ debugName: "failedTpl" }] : /* istanbul ignore next */ []));
|
|
151
|
+
constructor() {
|
|
152
|
+
// Double-toast guard: warn once if consumer also placed [cngxToastOn] on this element
|
|
153
|
+
if (typeof ngDevMode !== 'undefined' &&
|
|
154
|
+
ngDevMode &&
|
|
155
|
+
this.externalToastOn &&
|
|
156
|
+
(this.toastSuccess() || this.toastError())) {
|
|
157
|
+
console.warn('CngxActionButton: [toastSuccess]/[toastError] inputs and [cngxToastOn] ' +
|
|
158
|
+
'on the same element will fire duplicate toasts. Use one or the other.');
|
|
159
|
+
}
|
|
160
|
+
const tracker = createTransitionTracker(() => this.effectiveStatus());
|
|
161
|
+
effect(() => {
|
|
162
|
+
const status = tracker.current();
|
|
163
|
+
const previous = tracker.previous();
|
|
164
|
+
if (status === previous) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (status === 'success') {
|
|
168
|
+
this.lastUpdatedState.set(new Date());
|
|
169
|
+
const msg = this.toastSuccess();
|
|
170
|
+
if (msg && this.toaster) {
|
|
171
|
+
this.toaster.show({
|
|
172
|
+
message: msg,
|
|
173
|
+
severity: 'success',
|
|
174
|
+
duration: this.toastSuccessDuration(),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (status === 'error') {
|
|
179
|
+
const msg = this.toastError();
|
|
180
|
+
if (msg && this.toaster) {
|
|
181
|
+
const err = this.effectiveError();
|
|
182
|
+
const detail = this.toastErrorDetail() && err != null
|
|
183
|
+
? err instanceof Error
|
|
184
|
+
? err.message
|
|
185
|
+
: typeof err === 'string'
|
|
186
|
+
? err
|
|
187
|
+
: undefined
|
|
188
|
+
: undefined;
|
|
189
|
+
this.toaster.show({
|
|
190
|
+
message: detail ? `${msg}: ${detail}` : msg,
|
|
191
|
+
severity: 'error',
|
|
192
|
+
duration: this.toastErrorDuration(),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActionButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
199
|
+
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 }, 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: `
|
|
200
|
+
<ng-template #idle><ng-content /></ng-template>
|
|
201
|
+
|
|
202
|
+
<button
|
|
203
|
+
[type]="type()"
|
|
204
|
+
[cngxAsyncClick]="action()"
|
|
205
|
+
#btn="cngxAsyncClick"
|
|
206
|
+
[feedbackDuration]="feedbackDuration()"
|
|
207
|
+
[enabled]="enabled()"
|
|
208
|
+
[succeededAnnouncement]="succeededAnnouncement() ?? succeededLabel() ?? 'Action succeeded'"
|
|
209
|
+
[failedAnnouncement]="failedAnnouncement() ?? failedLabel() ?? 'Action failed'"
|
|
210
|
+
[class]="'cngx-action-button cngx-action-button--' + variant()"
|
|
211
|
+
>
|
|
212
|
+
@switch (effectiveStatus()) {
|
|
213
|
+
@case ('pending') {
|
|
214
|
+
@if (pendingTpl(); as tpl) {
|
|
215
|
+
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
216
|
+
} @else if (pendingLabel()) {
|
|
217
|
+
{{ pendingLabel() }}
|
|
218
|
+
} @else {
|
|
219
|
+
<ng-container *ngTemplateOutlet="idle" />
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
@case ('success') {
|
|
223
|
+
@if (succeededTpl(); as tpl) {
|
|
224
|
+
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
225
|
+
} @else if (succeededLabel()) {
|
|
226
|
+
{{ succeededLabel() }}
|
|
227
|
+
} @else {
|
|
228
|
+
<ng-container *ngTemplateOutlet="idle" />
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
@case ('error') {
|
|
232
|
+
@if (failedTpl(); as tpl) {
|
|
233
|
+
<ng-container
|
|
234
|
+
*ngTemplateOutlet="tpl.templateRef; context: { $implicit: effectiveError() }"
|
|
235
|
+
/>
|
|
236
|
+
} @else if (failedLabel()) {
|
|
237
|
+
{{ failedLabel() }}
|
|
238
|
+
} @else {
|
|
239
|
+
<ng-container *ngTemplateOutlet="idle" />
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
@default {
|
|
243
|
+
<ng-container *ngTemplateOutlet="idle" />
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
</button>
|
|
247
|
+
<span aria-live="polite" aria-atomic="true" class="cngx-action-button__sr-only">{{
|
|
248
|
+
btn.announcement()
|
|
249
|
+
}}</span>
|
|
250
|
+
`, isInline: true, styles: [".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", "succeededAnnouncement", "failedAnnouncement"], exportAs: ["cngxAsyncClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
251
|
+
}
|
|
252
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActionButton, decorators: [{
|
|
253
|
+
type: Component,
|
|
254
|
+
args: [{ selector: 'cngx-action-button', standalone: true, imports: [NgTemplateOutlet, CngxAsyncClick], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cngxActionButton', host: {
|
|
255
|
+
style: 'display: contents',
|
|
256
|
+
}, template: `
|
|
257
|
+
<ng-template #idle><ng-content /></ng-template>
|
|
258
|
+
|
|
259
|
+
<button
|
|
260
|
+
[type]="type()"
|
|
261
|
+
[cngxAsyncClick]="action()"
|
|
262
|
+
#btn="cngxAsyncClick"
|
|
263
|
+
[feedbackDuration]="feedbackDuration()"
|
|
264
|
+
[enabled]="enabled()"
|
|
265
|
+
[succeededAnnouncement]="succeededAnnouncement() ?? succeededLabel() ?? 'Action succeeded'"
|
|
266
|
+
[failedAnnouncement]="failedAnnouncement() ?? failedLabel() ?? 'Action failed'"
|
|
267
|
+
[class]="'cngx-action-button cngx-action-button--' + variant()"
|
|
268
|
+
>
|
|
269
|
+
@switch (effectiveStatus()) {
|
|
270
|
+
@case ('pending') {
|
|
271
|
+
@if (pendingTpl(); as tpl) {
|
|
272
|
+
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
273
|
+
} @else if (pendingLabel()) {
|
|
274
|
+
{{ pendingLabel() }}
|
|
275
|
+
} @else {
|
|
276
|
+
<ng-container *ngTemplateOutlet="idle" />
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
@case ('success') {
|
|
280
|
+
@if (succeededTpl(); as tpl) {
|
|
281
|
+
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
282
|
+
} @else if (succeededLabel()) {
|
|
283
|
+
{{ succeededLabel() }}
|
|
284
|
+
} @else {
|
|
285
|
+
<ng-container *ngTemplateOutlet="idle" />
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
@case ('error') {
|
|
289
|
+
@if (failedTpl(); as tpl) {
|
|
290
|
+
<ng-container
|
|
291
|
+
*ngTemplateOutlet="tpl.templateRef; context: { $implicit: effectiveError() }"
|
|
292
|
+
/>
|
|
293
|
+
} @else if (failedLabel()) {
|
|
294
|
+
{{ failedLabel() }}
|
|
295
|
+
} @else {
|
|
296
|
+
<ng-container *ngTemplateOutlet="idle" />
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
@default {
|
|
300
|
+
<ng-container *ngTemplateOutlet="idle" />
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
</button>
|
|
304
|
+
<span aria-live="polite" aria-atomic="true" class="cngx-action-button__sr-only">{{
|
|
305
|
+
btn.announcement()
|
|
306
|
+
}}</span>
|
|
307
|
+
`, styles: [".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"] }]
|
|
308
|
+
}], 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 }] }], 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 }] }] } });
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @module @cngx/ui/action-button
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Generated bundle index. Do not edit.
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
export { CngxActionButton };
|
|
319
|
+
//# sourceMappingURL=cngx-ui-action-button.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cngx-ui-action-button.mjs","sources":["../../../projects/ui/action-button/action-button.ts","../../../projects/ui/action-button/public-api.ts","../../../projects/ui/action-button/cngx-ui-action-button.ts"],"sourcesContent":["import { NgTemplateOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n contentChild,\n effect,\n inject,\n input,\n signal,\n viewChild,\n ViewEncapsulation,\n} from '@angular/core';\nimport {\n CngxAsyncClick,\n CngxFailed,\n CngxPending,\n CngxSucceeded,\n type AsyncAction,\n} from '@cngx/common/interactive';\nimport {\n buildAsyncStateView,\n createTransitionTracker,\n type CngxAsyncState,\n} from '@cngx/core/utils';\nimport { CngxToastOn, CngxToaster } from '@cngx/ui/feedback';\n\n/** Visual variant for the action button — maps to a CSS class. */\nexport type ActionButtonVariant = 'primary' | 'secondary' | 'ghost';\n\n/**\n * Action button molecule with built-in status communication.\n *\n * Coordinates between the `CngxAsyncClick` atom (mechanism, ARIA, lifecycle)\n * and the consumer (intent, styling, labels). Provides template projection\n * for pending/succeeded/failed states and an `aria-live` region for screen\n * reader announcements.\n *\n * Uses `display: contents` — the host produces no DOM box. The inner `<button>`\n * carries the `[cngxAsyncClick]` directive directly.\n *\n * For full control, use `[cngxAsyncClick]` directly on any element instead.\n *\n * ### Minimal (covers 80% of cases)\n * ```html\n * <cngx-action-button [action]=\"save\">Save</cngx-action-button>\n * ```\n *\n * ### With string labels\n * ```html\n * <cngx-action-button [action]=\"save\"\n * pendingLabel=\"Saving...\" succeededLabel=\"Saved!\" failedLabel=\"Failed\">\n * Save\n * </cngx-action-button>\n * ```\n *\n * ### With template slots\n * ```html\n * <cngx-action-button [action]=\"save\">\n * Save Draft\n * <ng-template cngxPending><mat-spinner diameter=\"18\" /> Saving...</ng-template>\n * <ng-template cngxSucceeded>Saved!</ng-template>\n * <ng-template cngxFailed let-err>{{ err }} — retry?</ng-template>\n * </cngx-action-button>\n * ```\n *\n * ### With toast feedback\n * ```html\n * <cngx-action-button [action]=\"save\" toastSuccess=\"Saved\" toastError=\"Save failed\">\n * Save\n * </cngx-action-button>\n * ```\n */\n@Component({\n selector: 'cngx-action-button',\n standalone: true,\n imports: [NgTemplateOutlet, CngxAsyncClick],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n exportAs: 'cngxActionButton',\n host: {\n style: 'display: contents',\n },\n template: `\n <ng-template #idle><ng-content /></ng-template>\n\n <button\n [type]=\"type()\"\n [cngxAsyncClick]=\"action()\"\n #btn=\"cngxAsyncClick\"\n [feedbackDuration]=\"feedbackDuration()\"\n [enabled]=\"enabled()\"\n [succeededAnnouncement]=\"succeededAnnouncement() ?? succeededLabel() ?? 'Action succeeded'\"\n [failedAnnouncement]=\"failedAnnouncement() ?? failedLabel() ?? 'Action failed'\"\n [class]=\"'cngx-action-button cngx-action-button--' + variant()\"\n >\n @switch (effectiveStatus()) {\n @case ('pending') {\n @if (pendingTpl(); as tpl) {\n <ng-container *ngTemplateOutlet=\"tpl.templateRef\" />\n } @else if (pendingLabel()) {\n {{ pendingLabel() }}\n } @else {\n <ng-container *ngTemplateOutlet=\"idle\" />\n }\n }\n @case ('success') {\n @if (succeededTpl(); as tpl) {\n <ng-container *ngTemplateOutlet=\"tpl.templateRef\" />\n } @else if (succeededLabel()) {\n {{ succeededLabel() }}\n } @else {\n <ng-container *ngTemplateOutlet=\"idle\" />\n }\n }\n @case ('error') {\n @if (failedTpl(); as tpl) {\n <ng-container\n *ngTemplateOutlet=\"tpl.templateRef; context: { $implicit: effectiveError() }\"\n />\n } @else if (failedLabel()) {\n {{ failedLabel() }}\n } @else {\n <ng-container *ngTemplateOutlet=\"idle\" />\n }\n }\n @default {\n <ng-container *ngTemplateOutlet=\"idle\" />\n }\n }\n </button>\n <span aria-live=\"polite\" aria-atomic=\"true\" class=\"cngx-action-button__sr-only\">{{\n btn.announcement()\n }}</span>\n `,\n styles: `\n .cngx-action-button__sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n `,\n})\nexport class CngxActionButton {\n private readonly toaster = inject(CngxToaster, { optional: true });\n private readonly externalToastOn = inject(CngxToastOn, { self: true, optional: true });\n\n /** The async action to execute on click. */\n readonly action = input.required<AsyncAction>();\n\n /** Duration in ms to show success/error feedback. Passed through to `cngxAsyncClick`. */\n readonly feedbackDuration = input<number>(2000);\n\n /** When `false`, clicks are ignored. Passed through to `cngxAsyncClick`. */\n readonly enabled = input<boolean>(true);\n\n /** Button type attribute. Defaults to `'button'` to prevent accidental form submits. */\n readonly type = input<'button' | 'submit' | 'reset'>('button');\n\n /** Visual variant — sets CSS class `cngx-action-button--{variant}`. */\n readonly variant = input<ActionButtonVariant>('primary');\n\n /** SR announcement on success. Falls back to `succeededLabel`, then `'Action succeeded'`. */\n readonly succeededAnnouncement = input<string | undefined>(undefined);\n\n /** SR announcement on failure. Falls back to `failedLabel`, then `'Action failed'`. */\n readonly failedAnnouncement = input<string | undefined>(undefined);\n\n /** Fallback text while pending (when no `cngxPending` template is projected). */\n readonly pendingLabel = input<string | undefined>(undefined);\n\n /** Fallback text after success (when no `cngxSucceeded` template is projected). */\n readonly succeededLabel = input<string | undefined>(undefined);\n\n /** Fallback text after failure (when no `cngxFailed` template is projected). */\n readonly failedLabel = input<string | undefined>(undefined);\n\n /**\n * Bind an external async state to derive visual status from.\n * When set, the button's status display follows `externalState.status()`.\n */\n readonly externalState = input<CngxAsyncState<unknown> | undefined>(undefined);\n\n /**\n * Toast message on success. Requires `CngxToaster` (via `provideFeedback(withToasts())`\n * or `provideToasts()`). Silently ignored when toaster is not provided.\n *\n * `toastSuccessDuration` should be >= `feedbackDuration` to avoid rapid re-fire\n * on repeated clicks that floods the SR announcement queue.\n */\n readonly toastSuccess = input<string | undefined>(undefined);\n\n /** Toast message on error. */\n readonly toastError = input<string | undefined>(undefined);\n\n /** Include the error detail message in the error toast body. */\n readonly toastErrorDetail = input<boolean>(false);\n\n /** Duration for success toasts in ms. */\n readonly toastSuccessDuration = input<number>(3000);\n\n /** Duration for error toasts — `'persistent'` means manual dismiss only. */\n readonly toastErrorDuration = input<number | 'persistent'>('persistent');\n\n /** @internal — inner CngxAsyncClick directive instance. Non-required to allow safe pre-view-init reads. */\n private readonly asyncClick = viewChild(CngxAsyncClick);\n\n /**\n * @internal — effective status: reads from external `[externalState]` if bound,\n * otherwise from the inner `CngxAsyncClick` directive.\n */\n protected readonly effectiveStatus = computed(() => {\n const ext = this.externalState();\n if (ext) {\n const status = ext.status();\n if (status === 'pending') {\n return 'pending' as const;\n }\n if (status === 'success') {\n return 'success' as const;\n }\n if (status === 'error') {\n return 'error' as const;\n }\n return 'idle' as const;\n }\n // viewChild is guaranteed resolved when the template reads this computed.\n // Guard protects consumers reading `state` before view init.\n const click = this.asyncClick();\n return click ? click.status() : ('idle' as const);\n });\n\n /** @internal — effective error value from external state or inner directive. */\n protected readonly effectiveError = computed(() => {\n const ext = this.externalState();\n if (ext) {\n return ext.error();\n }\n const click = this.asyncClick();\n return click ? click.error() : undefined;\n });\n\n private readonly lastUpdatedState = signal<Date | undefined>(undefined);\n\n /**\n * Full `CngxAsyncState` view of this button's effective lifecycle.\n *\n * Reflects the external state when `[externalState]` is bound,\n * otherwise the inner `CngxAsyncClick` directive's state.\n *\n * Bind to any state consumer: `<cngx-alert [state]=\"btn.state\" />`.\n */\n readonly state: CngxAsyncState<unknown> = buildAsyncStateView<unknown>({\n status: this.effectiveStatus,\n data: computed(() => undefined),\n error: this.effectiveError,\n lastUpdated: this.lastUpdatedState.asReadonly(),\n });\n\n /** @internal */\n protected readonly pendingTpl = contentChild(CngxPending);\n /** @internal */\n protected readonly succeededTpl = contentChild(CngxSucceeded);\n /** @internal */\n protected readonly failedTpl = contentChild(CngxFailed);\n\n constructor() {\n // Double-toast guard: warn once if consumer also placed [cngxToastOn] on this element\n if (\n typeof ngDevMode !== 'undefined' &&\n ngDevMode &&\n this.externalToastOn &&\n (this.toastSuccess() || this.toastError())\n ) {\n console.warn(\n 'CngxActionButton: [toastSuccess]/[toastError] inputs and [cngxToastOn] ' +\n 'on the same element will fire duplicate toasts. Use one or the other.',\n );\n }\n\n const tracker = createTransitionTracker(() => this.effectiveStatus());\n\n effect(() => {\n const status = tracker.current();\n const previous = tracker.previous();\n\n if (status === previous) {\n return;\n }\n\n if (status === 'success') {\n this.lastUpdatedState.set(new Date());\n const msg = this.toastSuccess();\n if (msg && this.toaster) {\n this.toaster.show({\n message: msg,\n severity: 'success',\n duration: this.toastSuccessDuration(),\n });\n }\n }\n\n if (status === 'error') {\n const msg = this.toastError();\n if (msg && this.toaster) {\n const err = this.effectiveError();\n const detail =\n this.toastErrorDetail() && err != null\n ? err instanceof Error\n ? err.message\n : typeof err === 'string'\n ? err\n : undefined\n : undefined;\n this.toaster.show({\n message: detail ? `${msg}: ${detail}` : msg,\n severity: 'error',\n duration: this.toastErrorDuration(),\n });\n }\n }\n });\n }\n}\n","/**\n * @module @cngx/ui/action-button\n */\n\nexport { CngxActionButton, type ActionButtonVariant } from './action-button';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AA8BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CG;MA6EU,gBAAgB,CAAA;IACV,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACjD,IAAA,eAAe,GAAG,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;AAG7E,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,4EAAe;;AAGtC,IAAA,gBAAgB,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,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,UAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,YAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,UAAA,CAAA,MAuDT,WAAW,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,YAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,UAAA,CAAA,MAET,aAAa,2FAEhB,UAAU,CAAA,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AC9QxD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { nextUid } from '@cngx/core/utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Empty-state display atom for grids, tables, lists, and dashboards.
|
|
7
|
+
*
|
|
8
|
+
* Communicates why a view is empty and what the user can do next.
|
|
9
|
+
* Supports three UX contexts via the parent's `emptyReason`:
|
|
10
|
+
* - **first-use** — onboarding, show what's possible
|
|
11
|
+
* - **no-results** — recovery, offer filter reset or search change
|
|
12
|
+
* - **cleared** — confirmation, everything is done
|
|
13
|
+
*
|
|
14
|
+
* Icon is provided via the `[cngxEmptyStateIcon]` content slot — no Material
|
|
15
|
+
* dependency. Consumers project `<mat-icon>`, `<svg>`, or any icon system.
|
|
16
|
+
*
|
|
17
|
+
* ```html
|
|
18
|
+
* <cngx-empty-state title="No results" description="Try a different search term">
|
|
19
|
+
* <mat-icon cngxEmptyStateIcon>search_off</mat-icon>
|
|
20
|
+
* <button cngxEmptyStateAction (click)="resetSearch()">Reset</button>
|
|
21
|
+
* </cngx-empty-state>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
class CngxEmptyState {
|
|
25
|
+
uid = nextUid('cngx-empty');
|
|
26
|
+
/** Primary message — what state the user is in. */
|
|
27
|
+
title = input.required(...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
28
|
+
/** Supporting detail — clarifies context and suggests next steps. */
|
|
29
|
+
description = input(undefined, ...(ngDevMode ? [{ debugName: "description" }] : /* istanbul ignore next */ []));
|
|
30
|
+
/** Bind an async state — auto-hides when data is not empty. */
|
|
31
|
+
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
32
|
+
/** @internal — hidden when state is bound and data is not empty or still loading. */
|
|
33
|
+
shouldHide = computed(() => {
|
|
34
|
+
const s = this.state();
|
|
35
|
+
if (!s) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
// Hide during loading (skeleton handles that phase) and when data is present
|
|
39
|
+
return s.isLoading() || !s.isEmpty();
|
|
40
|
+
}, ...(ngDevMode ? [{ debugName: "shouldHide" }] : /* istanbul ignore next */ []));
|
|
41
|
+
/** @internal */
|
|
42
|
+
titleId = `${this.uid}-title`;
|
|
43
|
+
/** @internal */
|
|
44
|
+
descriptionId = `${this.uid}-desc`;
|
|
45
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxEmptyState, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
46
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxEmptyState, isStandalone: true, selector: "cngx-empty-state", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: true, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "status", "aria-live": "polite" }, properties: { "attr.aria-labelledby": "titleId", "attr.aria-describedby": "description() ? descriptionId : null", "attr.hidden": "shouldHide() || null" }, classAttribute: "cngx-empty-state" }, ngImport: i0, template: `
|
|
47
|
+
<div class="cngx-empty-state__icon-slot">
|
|
48
|
+
<ng-content select="[cngxEmptyStateIcon]" />
|
|
49
|
+
</div>
|
|
50
|
+
<svg
|
|
51
|
+
class="cngx-empty-state__default-icon"
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
width="48"
|
|
54
|
+
height="48"
|
|
55
|
+
viewBox="0 0 24 24"
|
|
56
|
+
fill="none"
|
|
57
|
+
stroke="currentColor"
|
|
58
|
+
stroke-width="1.5"
|
|
59
|
+
stroke-linecap="round"
|
|
60
|
+
stroke-linejoin="round"
|
|
61
|
+
>
|
|
62
|
+
<path d="M21 8V21H3V8" />
|
|
63
|
+
<path d="M1 3h22v5H1z" />
|
|
64
|
+
<path d="M10 12h4" />
|
|
65
|
+
</svg>
|
|
66
|
+
<ng-content select="[cngxEmptyStateIllustration]" />
|
|
67
|
+
<h3 [id]="titleId" class="cngx-empty-state__title">{{ title() }}</h3>
|
|
68
|
+
@if (description()) {
|
|
69
|
+
<p [id]="descriptionId" class="cngx-empty-state__description">
|
|
70
|
+
{{ description() }}
|
|
71
|
+
</p>
|
|
72
|
+
}
|
|
73
|
+
<div class="cngx-empty-state__actions">
|
|
74
|
+
<ng-content select="[cngxEmptyStateAction]" />
|
|
75
|
+
</div>
|
|
76
|
+
<ng-content select="[cngxEmptyStateSecondary]" />
|
|
77
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
78
|
+
}
|
|
79
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxEmptyState, decorators: [{
|
|
80
|
+
type: Component,
|
|
81
|
+
args: [{
|
|
82
|
+
selector: 'cngx-empty-state',
|
|
83
|
+
standalone: true,
|
|
84
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
85
|
+
encapsulation: ViewEncapsulation.None,
|
|
86
|
+
host: {
|
|
87
|
+
class: 'cngx-empty-state',
|
|
88
|
+
role: 'status',
|
|
89
|
+
'aria-live': 'polite',
|
|
90
|
+
'[attr.aria-labelledby]': 'titleId',
|
|
91
|
+
'[attr.aria-describedby]': 'description() ? descriptionId : null',
|
|
92
|
+
'[attr.hidden]': 'shouldHide() || null',
|
|
93
|
+
},
|
|
94
|
+
template: `
|
|
95
|
+
<div class="cngx-empty-state__icon-slot">
|
|
96
|
+
<ng-content select="[cngxEmptyStateIcon]" />
|
|
97
|
+
</div>
|
|
98
|
+
<svg
|
|
99
|
+
class="cngx-empty-state__default-icon"
|
|
100
|
+
aria-hidden="true"
|
|
101
|
+
width="48"
|
|
102
|
+
height="48"
|
|
103
|
+
viewBox="0 0 24 24"
|
|
104
|
+
fill="none"
|
|
105
|
+
stroke="currentColor"
|
|
106
|
+
stroke-width="1.5"
|
|
107
|
+
stroke-linecap="round"
|
|
108
|
+
stroke-linejoin="round"
|
|
109
|
+
>
|
|
110
|
+
<path d="M21 8V21H3V8" />
|
|
111
|
+
<path d="M1 3h22v5H1z" />
|
|
112
|
+
<path d="M10 12h4" />
|
|
113
|
+
</svg>
|
|
114
|
+
<ng-content select="[cngxEmptyStateIllustration]" />
|
|
115
|
+
<h3 [id]="titleId" class="cngx-empty-state__title">{{ title() }}</h3>
|
|
116
|
+
@if (description()) {
|
|
117
|
+
<p [id]="descriptionId" class="cngx-empty-state__description">
|
|
118
|
+
{{ description() }}
|
|
119
|
+
</p>
|
|
120
|
+
}
|
|
121
|
+
<div class="cngx-empty-state__actions">
|
|
122
|
+
<ng-content select="[cngxEmptyStateAction]" />
|
|
123
|
+
</div>
|
|
124
|
+
<ng-content select="[cngxEmptyStateSecondary]" />
|
|
125
|
+
`,
|
|
126
|
+
}]
|
|
127
|
+
}], propDecorators: { title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: true }] }], description: [{ type: i0.Input, args: [{ isSignal: true, alias: "description", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }] } });
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @module @cngx/ui/empty-state
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Generated bundle index. Do not edit.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
export { CngxEmptyState };
|
|
138
|
+
//# sourceMappingURL=cngx-ui-empty-state.mjs.map
|