@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,98 @@
|
|
|
1
|
+
# CngxSkeletonContainer
|
|
2
|
+
|
|
3
|
+
Skeleton loading container with built-in placeholder repetition and async state integration.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { CngxSkeletonContainer, CngxSkeletonPlaceholder } from '@cngx/ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Component } from '@angular/core';
|
|
15
|
+
import { CngxSkeletonContainer, CngxSkeletonPlaceholder } from '@cngx/ui';
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'app-example',
|
|
19
|
+
template: `
|
|
20
|
+
<cngx-skeleton [state]="data()">
|
|
21
|
+
<ng-template cngxSkeletonPlaceholder>
|
|
22
|
+
<div class="skeleton-card"></div>
|
|
23
|
+
</ng-template>
|
|
24
|
+
<app-card *ngFor="let item of data().data()" [item]="item" />
|
|
25
|
+
</cngx-skeleton>
|
|
26
|
+
`,
|
|
27
|
+
imports: [CngxSkeletonContainer, CngxSkeletonPlaceholder],
|
|
28
|
+
})
|
|
29
|
+
export class ExampleComponent {
|
|
30
|
+
readonly data = injectAsyncState(() => this.http.get('/api/items'));
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
|
|
36
|
+
`CngxSkeletonContainer` (selector: `<cngx-skeleton>`) manages skeleton placeholder rendering and transitions. It handles:
|
|
37
|
+
|
|
38
|
+
- **Conditional rendering:** Shows placeholders during loading, content when loaded
|
|
39
|
+
- **Repetition:** Repeats placeholder template via `[count]` input
|
|
40
|
+
- **Shimmer animation:** Optional shimmer effect that respects `prefers-reduced-motion`
|
|
41
|
+
- **Async state integration:** Automatically hides when data arrives (via `[state]` input)
|
|
42
|
+
- **DOM efficiency:** Uses `display: contents` — no wrapper overhead
|
|
43
|
+
- **ARIA:** Sets `aria-busy="true"` while loading
|
|
44
|
+
|
|
45
|
+
The component is composable with `CngxSkeletonPlaceholder` directive (content projection). No boilerplate `@if/@for` needed — the component handles template repetition internally.
|
|
46
|
+
|
|
47
|
+
## Accessibility
|
|
48
|
+
|
|
49
|
+
`CngxSkeletonContainer` is fully accessible:
|
|
50
|
+
|
|
51
|
+
- **ARIA attributes:** `[attr.aria-busy]="isLoading()"` signals that content is being loaded.
|
|
52
|
+
- **Reduced motion:** Shimmer animation is disabled when `prefers-reduced-motion: reduce` is set.
|
|
53
|
+
- **Screen reader:** Skeletons are visual placeholders; their content is not announced. When loading completes, real content replaces placeholders seamlessly.
|
|
54
|
+
|
|
55
|
+
## Composition
|
|
56
|
+
|
|
57
|
+
`CngxSkeletonContainer` composes:
|
|
58
|
+
|
|
59
|
+
- **Async state integration:** Reads from `CngxAsyncState<T>` via `state()` input
|
|
60
|
+
- **Placeholder projection:** `CngxSkeletonPlaceholder` directive for template marking
|
|
61
|
+
- **Reduced motion detection:** Inline `matchMedia` listener for `prefers-reduced-motion`
|
|
62
|
+
|
|
63
|
+
## Styling
|
|
64
|
+
|
|
65
|
+
All animation values use CSS Custom Properties:
|
|
66
|
+
|
|
67
|
+
```scss
|
|
68
|
+
// Override in your component or global styles
|
|
69
|
+
:host {
|
|
70
|
+
--cngx-spin-duration: 1.5s;
|
|
71
|
+
--cngx-spin-easing: cubic-bezier(0.4, 0, 0.2, 1);
|
|
72
|
+
--cngx-pulse-duration: 2s;
|
|
73
|
+
--cngx-pulse-easing: ease-in-out;
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Material Theme
|
|
78
|
+
|
|
79
|
+
Include the theme SCSS in your global stylesheet:
|
|
80
|
+
|
|
81
|
+
```scss
|
|
82
|
+
@use '@angular/material' as mat;
|
|
83
|
+
@use '@cngx/ui/skeleton/skeleton-theme' as skeleton;
|
|
84
|
+
|
|
85
|
+
$theme: mat.define-theme((...));
|
|
86
|
+
|
|
87
|
+
html {
|
|
88
|
+
@include mat.all-component-themes($theme);
|
|
89
|
+
@include skeleton.theme($theme);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The theme mixin provides:
|
|
94
|
+
|
|
95
|
+
- Base animation timing (`--cngx-spin-duration`, `--cngx-pulse-duration`)
|
|
96
|
+
- Color tokens derived from Material palette
|
|
97
|
+
- Reduced-motion respecting animations
|
|
98
|
+
- Support for both M3 and M2 themes
|
package/speak/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# CngxSpeakButton
|
|
2
|
+
|
|
3
|
+
Cognitive accessibility component connecting to a CngxSpeak directive to control text-to-speech playback.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { CngxSpeakButton } from '@cngx/ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Component } from '@angular/core';
|
|
15
|
+
import { CngxSpeakButton } from '@cngx/ui';
|
|
16
|
+
import { CngxSpeak } from '@cngx/common';
|
|
17
|
+
|
|
18
|
+
@Component({
|
|
19
|
+
selector: 'app-example',
|
|
20
|
+
template: `
|
|
21
|
+
<p [cngxSpeak]="textContent" #tts="cngxSpeak">
|
|
22
|
+
{{ textContent }}
|
|
23
|
+
</p>
|
|
24
|
+
<cngx-speak-button [speakRef]="tts" />
|
|
25
|
+
`,
|
|
26
|
+
imports: [CngxSpeakButton, CngxSpeak],
|
|
27
|
+
})
|
|
28
|
+
export class ExampleComponent {
|
|
29
|
+
textContent = 'Click the speaker button to hear this text.';
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Overview
|
|
34
|
+
|
|
35
|
+
`CngxSpeakButton` is a ready-made speaker button that connects to a `CngxSpeak` directive via an explicit `[speakRef]` input. It provides:
|
|
36
|
+
|
|
37
|
+
- **Speaker and stop icons** — Built-in SVGs that toggle based on speaking state
|
|
38
|
+
- **Accessible labels** — ARIA labels that reflect the current state ("Read aloud" / "Stop speaking")
|
|
39
|
+
- **Cognitive accessibility** — Part of CngxSpeak, targeting dyslexia and reading ease
|
|
40
|
+
- **Full theming control** — CSS custom properties for styling, Material theme SCSS integration
|
|
41
|
+
- **No ancestor injection** — Explicit `[speakRef]` wiring prevents hidden dependencies
|
|
42
|
+
|
|
43
|
+
## Accessibility
|
|
44
|
+
|
|
45
|
+
`CngxSpeakButton` is designed for cognitive accessibility:
|
|
46
|
+
|
|
47
|
+
- **ARIA labels:** Button label dynamically changes between "Read aloud" (idle) and "Stop speaking" (active).
|
|
48
|
+
- **Icon semantics:** SVG icons are marked `aria-hidden="true"` — the text label carries the meaning.
|
|
49
|
+
- **CngxSpeak integration:** The underlying `CngxSpeak` directive handles the speech synthesis API, managing pause/resume, focus restoration, and `prefers-reduced-motion` respect.
|
|
50
|
+
- **Cognitive focus:** Targets users with dyslexia, ADHD, and reading difficulties by providing auditory reinforcement alongside visual text.
|
|
51
|
+
|
|
52
|
+
## Composition
|
|
53
|
+
|
|
54
|
+
`CngxSpeakButton` is a simple wrapper around:
|
|
55
|
+
|
|
56
|
+
- **CngxSpeak directive** — Provides the `speaking()` signal and `toggle()` method
|
|
57
|
+
- **Built-in SVGs** — Speaker icon (idle state) and stop icon (speaking state)
|
|
58
|
+
- **CSS custom properties** — Full theming support
|
|
59
|
+
|
|
60
|
+
No host directives or internal atoms — purely a UI shell for the speech synthesis API.
|
|
61
|
+
|
|
62
|
+
## Material Theme
|
|
63
|
+
|
|
64
|
+
Include the theme SCSS in your global stylesheet:
|
|
65
|
+
|
|
66
|
+
```scss
|
|
67
|
+
@use '@angular/material' as mat;
|
|
68
|
+
@use '@cngx/ui/speak/speak-button-theme' as speak;
|
|
69
|
+
|
|
70
|
+
$theme: mat.define-theme((...));
|
|
71
|
+
|
|
72
|
+
html {
|
|
73
|
+
@include mat.all-component-themes($theme);
|
|
74
|
+
@include speak.theme($theme);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The theme mixin provides:
|
|
79
|
+
|
|
80
|
+
- Material 3 system color tokens (`--mat-sys-*`) with fallback defaults
|
|
81
|
+
- Material 2 palette color mappings
|
|
82
|
+
- Automatic theme version detection (M3 vs M2)
|
|
83
|
+
|
|
84
|
+
## Philosophy: Cognitive Accessibility
|
|
85
|
+
|
|
86
|
+
CngxSpeak / CngxSpeakButton are part of cngx's commitment to cognitive accessibility. Rather than treating a11y as an audit checkbox, these components embed accessibility into the architecture:
|
|
87
|
+
|
|
88
|
+
- **Dyslexia support** — Auditory reinforcement helps users with dyslexia parse text more effectively
|
|
89
|
+
- **ADHD support** — Multi-modal input (visual + audio) aids concentration and retention
|
|
90
|
+
- **Aging users** — Larger, clear button with obvious visual feedback
|
|
91
|
+
- **Non-native speakers** — Audio pronunciation aids comprehension
|
|
92
|
+
|
|
93
|
+
The philosophy is: communication is architecture, not a side effect. Every component owes users clarity at every point in time.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@use 'sass:math';
|
|
3
|
+
@use '@angular/material' as mat;
|
|
4
|
+
|
|
5
|
+
// Include in your global theme stylesheet alongside the Material theme:
|
|
6
|
+
//
|
|
7
|
+
// @use '@angular/material' as mat;
|
|
8
|
+
// @use '@cngx/ui/speak/speak-button-theme' as speak;
|
|
9
|
+
//
|
|
10
|
+
// $theme: mat.define-theme((...));
|
|
11
|
+
//
|
|
12
|
+
// html {
|
|
13
|
+
// @include mat.all-component-themes($theme);
|
|
14
|
+
// @include speak.theme($theme);
|
|
15
|
+
// }
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@mixin base() {
|
|
19
|
+
--cngx-speak-btn-size: 36px;
|
|
20
|
+
--cngx-speak-btn-icon-size: 18px;
|
|
21
|
+
--cngx-speak-btn-radius: 8px;
|
|
22
|
+
--cngx-speak-btn-border-width: 1px;
|
|
23
|
+
--cngx-speak-btn-transition: 0.15s;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@mixin color($theme) {
|
|
27
|
+
@if mat.get-theme-version($theme) == 1 {
|
|
28
|
+
// M3 — use Material sys tokens
|
|
29
|
+
--cngx-speak-btn-bg: var(--mat-sys-surface-container-low);
|
|
30
|
+
--cngx-speak-btn-hover-bg: var(--mat-sys-surface-container);
|
|
31
|
+
--cngx-speak-btn-color: var(--mat-sys-on-surface-variant);
|
|
32
|
+
--cngx-speak-btn-active-color: var(--mat-sys-primary);
|
|
33
|
+
--cngx-speak-btn-speaking-bg: var(--mat-sys-primary);
|
|
34
|
+
--cngx-speak-btn-speaking-color: var(--mat-sys-on-primary);
|
|
35
|
+
--cngx-border: var(--mat-sys-outline-variant);
|
|
36
|
+
} @else {
|
|
37
|
+
// M2 — derive from palette
|
|
38
|
+
--cngx-speak-btn-bg: #{mat.get-theme-color($theme, background, card)};
|
|
39
|
+
--cngx-speak-btn-hover-bg: #{rgba(mat.get-theme-color($theme, primary), 0.04)};
|
|
40
|
+
--cngx-speak-btn-color: rgba(0, 0, 0, 0.54);
|
|
41
|
+
--cngx-speak-btn-active-color: #{mat.get-theme-color($theme, primary)};
|
|
42
|
+
--cngx-speak-btn-speaking-bg: #{mat.get-theme-color($theme, primary)};
|
|
43
|
+
--cngx-speak-btn-speaking-color: #fff;
|
|
44
|
+
--cngx-border: rgba(0, 0, 0, 0.12);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@mixin density($theme) {
|
|
49
|
+
$scale: mat.get-theme-density($theme);
|
|
50
|
+
$scale: math.max(-4, math.min(0, $scale));
|
|
51
|
+
|
|
52
|
+
$sizes: (
|
|
53
|
+
0: 36px,
|
|
54
|
+
-1: 32px,
|
|
55
|
+
-2: 28px,
|
|
56
|
+
-3: 24px,
|
|
57
|
+
-4: 20px,
|
|
58
|
+
);
|
|
59
|
+
$icon-sizes: (
|
|
60
|
+
0: 18px,
|
|
61
|
+
-1: 16px,
|
|
62
|
+
-2: 14px,
|
|
63
|
+
-3: 12px,
|
|
64
|
+
-4: 10px,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
--cngx-speak-btn-size: #{map.get($sizes, $scale)};
|
|
68
|
+
--cngx-speak-btn-icon-size: #{map.get($icon-sizes, $scale)};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@mixin theme($theme) {
|
|
73
|
+
:where(cngx-speak-button) {
|
|
74
|
+
@include base();
|
|
75
|
+
@include color($theme);
|
|
76
|
+
@include density($theme);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @cngx/ui/stepper
|
|
2
|
+
|
|
3
|
+
CNGX-standard `<cngx-stepper>` organism. Composes the `CngxStepperPresenter` brain (from `@cngx/common/stepper`) with `CngxRovingTabindex` and `CngxFocusRestore` via `hostDirectives`. W3C step pattern compliant — `role="group"` + `aria-roledescription="stepper"` host, `role="region"` panels, reactive `aria-current` / `aria-busy` / `aria-describedby` on every step button.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
`<cngx-stepper>` is the cngx-native stepper skin: thin component, signals everywhere, full ARIA, optional commit-action lifecycle, optional router sync, optional error aggregation. Material consumers reach for `<cngx-mat-stepper>` (sibling `@cngx/ui/mat-stepper` entry) instead — both share the same `CngxStepperPresenter` brain.
|
|
8
|
+
|
|
9
|
+
The organism's body is template + reactive ARIA only. All state lives in the presenter (composed via `hostDirectives`). The component class is ~260 LOC; the template is ~70 lines; structural CSS lives in `styles/stepper-base.css`, thematic CSS in `stepper.component.css` — both routed through `--cngx-stepper-*` custom properties for theming.
|
|
10
|
+
|
|
11
|
+
## Exports
|
|
12
|
+
|
|
13
|
+
| Export | Selector | Description |
|
|
14
|
+
| ------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `CngxStepper` | `cngx-stepper` | The organism. Composes `CngxStepperPresenter` (presenter brain), `CngxRovingTabindex` (keyboard nav), `CngxFocusRestore` (focus management) via `hostDirectives`. |
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<cngx-stepper [(activeStepIndex)]="active" aria-label="Wizard">
|
|
19
|
+
<div cngxStep label="Profile">
|
|
20
|
+
<ng-template cngxStepContent>Profile content…</ng-template>
|
|
21
|
+
</div>
|
|
22
|
+
<div cngxStepGroup label="Settings">
|
|
23
|
+
<div cngxStep label="Notifications">…</div>
|
|
24
|
+
<div cngxStep label="Security">…</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div cngxStep label="Done">…</div>
|
|
27
|
+
</cngx-stepper>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`<cngxStep>` and `<cngxStepGroup>` atoms (from `@cngx/common/stepper`) register themselves with the enclosing presenter on construction. Group nodes nest steps; the strip renders both step buttons and group headers with `role="group"` + `aria-roledescription="step group"`.
|
|
31
|
+
|
|
32
|
+
## ARIA contract
|
|
33
|
+
|
|
34
|
+
The organism is W3C step-pattern compliant:
|
|
35
|
+
|
|
36
|
+
- Host element: `role="group"` + `aria-roledescription` (configurable via `withStepperFallbackLabels({ stepRoleDescription })`) + `aria-orientation` + `data-orientation` (for CSS hooks) + `aria-label` / `aria-labelledby`.
|
|
37
|
+
- Step button: `aria-current="step"` (when active) + `aria-controls="<step-id>-panel"` + `aria-disabled` (when disabled) + `aria-busy="true"` (during commit-action pending) + `aria-describedby="<step-id>-desc"` (always present; visibility via SR phrase).
|
|
38
|
+
- Step panel: `role="region"` + `aria-labelledby="<step-id>-header"` + `[hidden]="!isActive"`.
|
|
39
|
+
- Group header: `role="group"` + `aria-roledescription="step group"` + `data-step-depth` + `data-state` + `aria-describedby` (rolls up children's aggregated status).
|
|
40
|
+
- Live region: planned for Phase 3 commit-lifecycle SR announcements; deliberately NOT composed via `hostDirectives` because `CngxLiveRegion` would clobber the host's `role="group"` landmark.
|
package/tabs/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @cngx/ui/tabs
|
|
2
|
+
|
|
3
|
+
CDK skin for the cngx tabs system. A thin, Material-free rendering of `<cngx-tab-group>` and `<cngx-tab-overflow>` that applies the presenter from `@cngx/common/tabs` and stays out of its way.
|
|
4
|
+
|
|
5
|
+
## When you reach for it
|
|
6
|
+
|
|
7
|
+
You want a tab strip with:
|
|
8
|
+
|
|
9
|
+
- Async-aware tab activation (optimistic or pessimistic commit, per-tab busy and error markers).
|
|
10
|
+
- An overflow menu when the tabs do not fit available width.
|
|
11
|
+
- Full keyboard navigation (roving tabindex, arrow keys, `Home`/`End`, `Enter`/`Space`).
|
|
12
|
+
- No Material runtime — either because you ship your own design system or because the bundle cost matters.
|
|
13
|
+
|
|
14
|
+
If you want the same behaviour rendered in Material 3, import `@cngx/ui/mat-tabs` instead. The brain is shared between the two skins.
|
|
15
|
+
|
|
16
|
+
## Mental model
|
|
17
|
+
|
|
18
|
+
`<cngx-tab-group>` is a presenter applied as a `hostDirective`. The tab group component itself is thin — it forwards inputs and renders a CDK-based `<div role="tablist">`. All the state — active tab, commit lifecycle, overflow recompute, ARIA wiring — lives in the presenter from `@cngx/common/tabs`. That separation is what makes a Material twin possible without duplication.
|
|
19
|
+
|
|
20
|
+
Two pieces give the tab strip its character:
|
|
21
|
+
|
|
22
|
+
- **Commit lifecycle.** Activating a tab can fire an async action. In optimistic mode the tab becomes active immediately and rolls back on error; in pessimistic mode it stays inactive until success. Per-tab busy and error markers ride the same channel.
|
|
23
|
+
- **Overflow.** When tabs do not fit, the overflowing ones collapse into a "more" menu. Recompute is debounced through an `IntersectionObserver` so resize storms do not thrash the layout.
|
|
24
|
+
|
|
25
|
+
## Companion entries
|
|
26
|
+
|
|
27
|
+
- **`@cngx/common/tabs`** — the headless brain, configuration cascade, slot directives.
|
|
28
|
+
- **`@cngx/ui/mat-tabs`** — Material twin of this skin.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as _cngx_core_utils from '@cngx/core/utils';
|
|
2
|
+
import { CngxAsyncState } from '@cngx/core/utils';
|
|
3
|
+
import * as _angular_core from '@angular/core';
|
|
4
|
+
import { AsyncAction, CngxPending, CngxSucceeded, CngxFailed } from '@cngx/common/interactive';
|
|
5
|
+
|
|
6
|
+
/** Visual variant for the action button — maps to a CSS class. */
|
|
7
|
+
type ActionButtonVariant = 'primary' | 'secondary' | 'ghost';
|
|
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
|
+
declare class CngxActionButton {
|
|
52
|
+
private readonly toaster;
|
|
53
|
+
private readonly externalToastOn;
|
|
54
|
+
/** The async action to execute on click. */
|
|
55
|
+
readonly action: _angular_core.InputSignal<AsyncAction>;
|
|
56
|
+
/** Duration in ms to show success/error feedback. Passed through to `cngxAsyncClick`. */
|
|
57
|
+
readonly feedbackDuration: _angular_core.InputSignal<number>;
|
|
58
|
+
/** When `false`, clicks are ignored. Passed through to `cngxAsyncClick`. */
|
|
59
|
+
readonly enabled: _angular_core.InputSignal<boolean>;
|
|
60
|
+
/** Button type attribute. Defaults to `'button'` to prevent accidental form submits. */
|
|
61
|
+
readonly type: _angular_core.InputSignal<"button" | "submit" | "reset">;
|
|
62
|
+
/** Visual variant — sets CSS class `cngx-action-button--{variant}`. */
|
|
63
|
+
readonly variant: _angular_core.InputSignal<ActionButtonVariant>;
|
|
64
|
+
/** SR announcement on success. Falls back to `succeededLabel`, then `'Action succeeded'`. */
|
|
65
|
+
readonly succeededAnnouncement: _angular_core.InputSignal<string | undefined>;
|
|
66
|
+
/** SR announcement on failure. Falls back to `failedLabel`, then `'Action failed'`. */
|
|
67
|
+
readonly failedAnnouncement: _angular_core.InputSignal<string | undefined>;
|
|
68
|
+
/** Fallback text while pending (when no `cngxPending` template is projected). */
|
|
69
|
+
readonly pendingLabel: _angular_core.InputSignal<string | undefined>;
|
|
70
|
+
/** Fallback text after success (when no `cngxSucceeded` template is projected). */
|
|
71
|
+
readonly succeededLabel: _angular_core.InputSignal<string | undefined>;
|
|
72
|
+
/** Fallback text after failure (when no `cngxFailed` template is projected). */
|
|
73
|
+
readonly failedLabel: _angular_core.InputSignal<string | undefined>;
|
|
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
|
+
readonly externalState: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
|
|
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
|
+
readonly toastSuccess: _angular_core.InputSignal<string | undefined>;
|
|
87
|
+
/** Toast message on error. */
|
|
88
|
+
readonly toastError: _angular_core.InputSignal<string | undefined>;
|
|
89
|
+
/** Include the error detail message in the error toast body. */
|
|
90
|
+
readonly toastErrorDetail: _angular_core.InputSignal<boolean>;
|
|
91
|
+
/** Duration for success toasts in ms. */
|
|
92
|
+
readonly toastSuccessDuration: _angular_core.InputSignal<number>;
|
|
93
|
+
/** Duration for error toasts — `'persistent'` means manual dismiss only. */
|
|
94
|
+
readonly toastErrorDuration: _angular_core.InputSignal<number | "persistent">;
|
|
95
|
+
/** @internal — inner CngxAsyncClick directive instance. Non-required to allow safe pre-view-init reads. */
|
|
96
|
+
private readonly asyncClick;
|
|
97
|
+
/**
|
|
98
|
+
* @internal — effective status: reads from external `[externalState]` if bound,
|
|
99
|
+
* otherwise from the inner `CngxAsyncClick` directive.
|
|
100
|
+
*/
|
|
101
|
+
protected readonly effectiveStatus: _angular_core.Signal<_cngx_core_utils.AsyncStatus>;
|
|
102
|
+
/** @internal — effective error value from external state or inner directive. */
|
|
103
|
+
protected readonly effectiveError: _angular_core.Signal<unknown>;
|
|
104
|
+
private readonly lastUpdatedState;
|
|
105
|
+
/**
|
|
106
|
+
* Full `CngxAsyncState` view of this button's effective lifecycle.
|
|
107
|
+
*
|
|
108
|
+
* Reflects the external state when `[externalState]` is bound,
|
|
109
|
+
* otherwise the inner `CngxAsyncClick` directive's state.
|
|
110
|
+
*
|
|
111
|
+
* Bind to any state consumer: `<cngx-alert [state]="btn.state" />`.
|
|
112
|
+
*/
|
|
113
|
+
readonly state: CngxAsyncState<unknown>;
|
|
114
|
+
/** @internal */
|
|
115
|
+
protected readonly pendingTpl: _angular_core.Signal<CngxPending | undefined>;
|
|
116
|
+
/** @internal */
|
|
117
|
+
protected readonly succeededTpl: _angular_core.Signal<CngxSucceeded | undefined>;
|
|
118
|
+
/** @internal */
|
|
119
|
+
protected readonly failedTpl: _angular_core.Signal<CngxFailed | undefined>;
|
|
120
|
+
constructor();
|
|
121
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxActionButton, never>;
|
|
122
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxActionButton, "cngx-action-button", ["cngxActionButton"], { "action": { "alias": "action"; "required": true; "isSignal": true; }; "feedbackDuration": { "alias": "feedbackDuration"; "required": false; "isSignal": true; }; "enabled": { "alias": "enabled"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "succeededAnnouncement": { "alias": "succeededAnnouncement"; "required": false; "isSignal": true; }; "failedAnnouncement": { "alias": "failedAnnouncement"; "required": false; "isSignal": true; }; "pendingLabel": { "alias": "pendingLabel"; "required": false; "isSignal": true; }; "succeededLabel": { "alias": "succeededLabel"; "required": false; "isSignal": true; }; "failedLabel": { "alias": "failedLabel"; "required": false; "isSignal": true; }; "externalState": { "alias": "externalState"; "required": false; "isSignal": true; }; "toastSuccess": { "alias": "toastSuccess"; "required": false; "isSignal": true; }; "toastError": { "alias": "toastError"; "required": false; "isSignal": true; }; "toastErrorDetail": { "alias": "toastErrorDetail"; "required": false; "isSignal": true; }; "toastSuccessDuration": { "alias": "toastSuccessDuration"; "required": false; "isSignal": true; }; "toastErrorDuration": { "alias": "toastErrorDuration"; "required": false; "isSignal": true; }; }, {}, ["pendingTpl", "succeededTpl", "failedTpl"], ["*"], true, never>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { CngxActionButton };
|
|
126
|
+
export type { ActionButtonVariant };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { CngxAsyncState } from '@cngx/core/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Empty-state display atom for grids, tables, lists, and dashboards.
|
|
6
|
+
*
|
|
7
|
+
* Communicates why a view is empty and what the user can do next.
|
|
8
|
+
* Supports three UX contexts via the parent's `emptyReason`:
|
|
9
|
+
* - **first-use** — onboarding, show what's possible
|
|
10
|
+
* - **no-results** — recovery, offer filter reset or search change
|
|
11
|
+
* - **cleared** — confirmation, everything is done
|
|
12
|
+
*
|
|
13
|
+
* Icon is provided via the `[cngxEmptyStateIcon]` content slot — no Material
|
|
14
|
+
* dependency. Consumers project `<mat-icon>`, `<svg>`, or any icon system.
|
|
15
|
+
*
|
|
16
|
+
* ```html
|
|
17
|
+
* <cngx-empty-state title="No results" description="Try a different search term">
|
|
18
|
+
* <mat-icon cngxEmptyStateIcon>search_off</mat-icon>
|
|
19
|
+
* <button cngxEmptyStateAction (click)="resetSearch()">Reset</button>
|
|
20
|
+
* </cngx-empty-state>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare class CngxEmptyState {
|
|
24
|
+
private readonly uid;
|
|
25
|
+
/** Primary message — what state the user is in. */
|
|
26
|
+
readonly title: _angular_core.InputSignal<string>;
|
|
27
|
+
/** Supporting detail — clarifies context and suggests next steps. */
|
|
28
|
+
readonly description: _angular_core.InputSignal<string | undefined>;
|
|
29
|
+
/** Bind an async state — auto-hides when data is not empty. */
|
|
30
|
+
readonly state: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
|
|
31
|
+
/** @internal — hidden when state is bound and data is not empty or still loading. */
|
|
32
|
+
protected readonly shouldHide: _angular_core.Signal<boolean>;
|
|
33
|
+
/** @internal */
|
|
34
|
+
protected readonly titleId: string;
|
|
35
|
+
/** @internal */
|
|
36
|
+
protected readonly descriptionId: string;
|
|
37
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxEmptyState, never>;
|
|
38
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxEmptyState, "cngx-empty-state", never, { "title": { "alias": "title"; "required": true; "isSignal": true; }; "description": { "alias": "description"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; }, {}, never, ["[cngxEmptyStateIcon]", "[cngxEmptyStateIllustration]", "[cngxEmptyStateAction]", "[cngxEmptyStateSecondary]"], true, never>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { CngxEmptyState };
|