@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,233 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @cngx/ui/mat-tabs — Material-themed sticky-error skin.
|
|
3
|
+
*
|
|
4
|
+
* Applied imperatively by `[cngxMatTabs]` (via Renderer2) onto the
|
|
5
|
+
* `<button>.mat-mdc-tab` element whose index matches
|
|
6
|
+
* `presenter.lastFailedIndex()`. The class persists until the user
|
|
7
|
+
* successfully re-picks the failed target OR programmatically
|
|
8
|
+
* dismisses via `clearLastFailed()`.
|
|
9
|
+
*
|
|
10
|
+
* Themed via `--mat-sys-error` by default with `--cngx-mat-tab-error-*`
|
|
11
|
+
* consumer overrides. Three-tier fallback: consumer override →
|
|
12
|
+
* Material design token → hard-coded `#c62828`.
|
|
13
|
+
*
|
|
14
|
+
* No animation: `tabs-accepted-debt §3` covers the cngx-native pulse
|
|
15
|
+
* keyframe limitation; the Material variant ships no pulse for the
|
|
16
|
+
* same architectural reason (avoids competing with Material's
|
|
17
|
+
* existing ink-bar transition + ripple). Re-evaluate when ≥1 consumer
|
|
18
|
+
* issue requests a pulse OR a sibling cngx feature adopts a shared
|
|
19
|
+
* `createPulseOnEdge` factory the Material variant can compose
|
|
20
|
+
* against.
|
|
21
|
+
*
|
|
22
|
+
* Shipped as a standalone stylesheet asset (NOT folded into JS via
|
|
23
|
+
* `styleUrls` — Angular only honours `styleUrls` on `@Component`,
|
|
24
|
+
* not on `@Directive`). Consumer imports once in their global
|
|
25
|
+
* stylesheet — Material-ecosystem prebuilt-themes pattern.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Specificity bump to `.mat-mdc-tab.cngx-mat-tab--error` (0,2,0) is
|
|
30
|
+
* load-bearing — Material 21's `.mdc-tab` rule (0,1,0) sets
|
|
31
|
+
* `outline: none` to suppress the browser's default focus outline,
|
|
32
|
+
* and ships those styles inline via the component decorator. Since
|
|
33
|
+
* the component-scoped CSS is injected into `<head>` AFTER the
|
|
34
|
+
* `angular.json` global styles when the component first renders,
|
|
35
|
+
* a same-specificity rule loses the cascade — `outline` would be
|
|
36
|
+
* stripped and only `color` / `font-weight` would land. Mirrors
|
|
37
|
+
* the same bump on `.mat-mdc-tab.cngx-mat-tab--has-errors::before`
|
|
38
|
+
* below.
|
|
39
|
+
*/
|
|
40
|
+
.mat-mdc-tab.cngx-mat-tab--error {
|
|
41
|
+
color: var(--cngx-mat-tab-error-color, var(--mat-sys-error, #c62828));
|
|
42
|
+
outline: var(--cngx-mat-tab-error-outline, 2px solid currentColor);
|
|
43
|
+
outline-offset: var(--cngx-mat-tab-error-outline-offset, 1px);
|
|
44
|
+
font-weight: var(--cngx-mat-tab-error-font-weight, 600);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.mat-mdc-tab-disabled.cngx-mat-tab--error {
|
|
48
|
+
/*
|
|
49
|
+
* A disabled-and-rejected tab keeps the rejection signal but
|
|
50
|
+
* fades to disambiguate it from a healthy disabled tab. Material
|
|
51
|
+
* itself dims disabled tabs via the `--mat-tab-header-disabled-*`
|
|
52
|
+
* tokens; this overlay multiplies the dimming.
|
|
53
|
+
*/
|
|
54
|
+
opacity: 0.7;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
* Per-tab form-error aggregation badge. Distinct semantic from
|
|
59
|
+
* `--error` — `--error` means "your last commit was refused";
|
|
60
|
+
* `--has-errors` means "this tab contains form-validation errors
|
|
61
|
+
* right now". The two coexist (different sources, different
|
|
62
|
+
* lifecycles, different remediation paths) and a tab can carry both
|
|
63
|
+
* simultaneously.
|
|
64
|
+
*
|
|
65
|
+
* Three-tier fallback per CSS var: consumer override → Material
|
|
66
|
+
* design token → hard-coded value. The badge glyph is a `::before`
|
|
67
|
+
* pseudo-element so it stacks cleanly with Material's own focus
|
|
68
|
+
* ring and ripple — Material's button uses neither `::before` nor
|
|
69
|
+
* `::after` for its core visuals.
|
|
70
|
+
*
|
|
71
|
+
* No animation: same `tabs-accepted-debt §3` rationale as
|
|
72
|
+
* `--error` — pulse-on-edge is deferred to a future shared
|
|
73
|
+
* `createPulseOnEdge` factory.
|
|
74
|
+
*/
|
|
75
|
+
.cngx-mat-tab--has-errors {
|
|
76
|
+
position: relative;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
* Specificity is `.mat-mdc-tab.cngx-mat-tab--has-errors` (0,2,1)
|
|
81
|
+
* to beat Material's own `.mat-focus-indicator::before` (0,1,1)
|
|
82
|
+
* which sets `inset: 0` on the same pseudo-element. Without the
|
|
83
|
+
* boost, the `top` / `inset-inline-end` declarations get collapsed
|
|
84
|
+
* to 0 by Material's later-cascade rule and the badge sits dead-
|
|
85
|
+
* centred under the focus ring instead of at the trailing-top
|
|
86
|
+
* corner. Right + transform fall back for older inset-inline-end
|
|
87
|
+
* support.
|
|
88
|
+
*/
|
|
89
|
+
.mat-mdc-tab.cngx-mat-tab--has-errors::before {
|
|
90
|
+
content: '!';
|
|
91
|
+
position: absolute;
|
|
92
|
+
top: var(--cngx-mat-tab-has-errors-glyph-offset, 4px);
|
|
93
|
+
right: var(--cngx-mat-tab-has-errors-glyph-offset, 4px);
|
|
94
|
+
inset-inline-end: var(--cngx-mat-tab-has-errors-glyph-offset, 4px);
|
|
95
|
+
inset-inline-start: auto;
|
|
96
|
+
bottom: auto;
|
|
97
|
+
display: inline-flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
width: var(--cngx-mat-tab-has-errors-glyph-size, 16px);
|
|
101
|
+
height: var(--cngx-mat-tab-has-errors-glyph-size, 16px);
|
|
102
|
+
margin: 0;
|
|
103
|
+
border: 0;
|
|
104
|
+
border-radius: 50%;
|
|
105
|
+
background: var(
|
|
106
|
+
--cngx-mat-tab-has-errors-color,
|
|
107
|
+
var(--mat-sys-error, #c62828)
|
|
108
|
+
);
|
|
109
|
+
color: var(
|
|
110
|
+
--cngx-mat-tab-has-errors-glyph-color,
|
|
111
|
+
var(--mat-sys-on-error, #ffffff)
|
|
112
|
+
);
|
|
113
|
+
font-size: calc(var(--cngx-mat-tab-has-errors-glyph-size, 16px) * 0.75);
|
|
114
|
+
font-weight: var(--cngx-mat-tab-has-errors-font-weight, 700);
|
|
115
|
+
line-height: 1;
|
|
116
|
+
pointer-events: none;
|
|
117
|
+
z-index: 1;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/*
|
|
121
|
+
* Co-occurrence: when a tab is BOTH rejected and carries form
|
|
122
|
+
* errors, the rejection outline already draws focus to the edges;
|
|
123
|
+
* shift the has-errors badge slightly inward so the two signals
|
|
124
|
+
* read as distinct rather than visually merging.
|
|
125
|
+
*/
|
|
126
|
+
.mat-mdc-tab.cngx-mat-tab--error.cngx-mat-tab--has-errors::before {
|
|
127
|
+
top: var(--cngx-mat-tab-has-errors-glyph-offset-stacked, 6px);
|
|
128
|
+
right: var(--cngx-mat-tab-has-errors-glyph-offset-stacked, 6px);
|
|
129
|
+
inset-inline-end: var(--cngx-mat-tab-has-errors-glyph-offset-stacked, 6px);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/*
|
|
133
|
+
* Trailing-edge skin for the dynamically-mounted `<cngx-tab-overflow>`
|
|
134
|
+
* molecule. `[cngxMatTabs]` programmatically appends the molecule
|
|
135
|
+
* into `.mat-mdc-tab-header` and adds the `cngx-mat-tabs-more` class
|
|
136
|
+
* via `Renderer2` (`mat-tabs.directive.ts`'s afterNextRender block).
|
|
137
|
+
*
|
|
138
|
+
* Layout: flex item alongside `.mat-mdc-tab-label-container`. Material's
|
|
139
|
+
* `.mat-mdc-tab-header` is itself a flex container, so the More
|
|
140
|
+
* affordance flows naturally as a sibling of the label-container —
|
|
141
|
+
* the label-container shrinks to fit, the More button takes its
|
|
142
|
+
* natural width, and the trailing tab is no longer occluded by an
|
|
143
|
+
* absolutely-positioned overlay. If consumers opt back into
|
|
144
|
+
* Material's pagination (see the auto-hide rule below), the
|
|
145
|
+
* pagination-after arrow becomes a third flex sibling and the
|
|
146
|
+
* available width is split across all three; the IntersectionObserver
|
|
147
|
+
* picks up the new layout automatically.
|
|
148
|
+
*
|
|
149
|
+
* Three-tier fallback per CSS var: consumer override → Material
|
|
150
|
+
* design token → hard-coded value.
|
|
151
|
+
*/
|
|
152
|
+
.cngx-mat-tabs-more {
|
|
153
|
+
flex: 0 0 auto;
|
|
154
|
+
align-self: stretch;
|
|
155
|
+
display: flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
z-index: var(--cngx-mat-tabs-more-z, 2);
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
* Drive the molecule's own component-API cascade variables. The
|
|
161
|
+
* `<cngx-tab-overflow>` :host CSS defaults `--cngx-tab-overflow-bg`
|
|
162
|
+
* to `transparent` (sensible for the cngx-native variant that sits
|
|
163
|
+
* in a flow-positioned strip wrapper); the Material variant gives
|
|
164
|
+
* the More button an opaque surface so it reads as a distinct
|
|
165
|
+
* affordance against Material's strip background even when the
|
|
166
|
+
* popover panel is closed. The component's :host rule reads these
|
|
167
|
+
* variables, so resolution happens at the right specificity tier
|
|
168
|
+
* without us shouting through a higher-specificity selector.
|
|
169
|
+
*/
|
|
170
|
+
--cngx-tab-overflow-bg: var(
|
|
171
|
+
--cngx-mat-tabs-more-bg,
|
|
172
|
+
var(--mat-app-background-color, #ffffff)
|
|
173
|
+
);
|
|
174
|
+
--cngx-tab-overflow-button-bg: var(
|
|
175
|
+
--cngx-mat-tabs-more-bg,
|
|
176
|
+
var(--mat-app-background-color, #ffffff)
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
box-shadow: var(
|
|
180
|
+
--cngx-mat-tabs-more-shadow,
|
|
181
|
+
-8px 0 8px -4px rgba(0, 0, 0, 0.1)
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/*
|
|
186
|
+
* Collapse the wrapper to zero layout space when the inner trigger
|
|
187
|
+
* button is hidden (= no clipped tabs). Without this, the molecule's
|
|
188
|
+
* `display: inline-flex` :host rule keeps reserving width for an
|
|
189
|
+
* empty wrapper — the label-container would shrink even when no
|
|
190
|
+
* overflow exists.
|
|
191
|
+
*/
|
|
192
|
+
.cngx-mat-tabs-more:has(.cngx-tab-overflow__trigger[hidden]) {
|
|
193
|
+
display: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/*
|
|
197
|
+
* Material's pagination arrows (`<` / `>`) remain visible alongside
|
|
198
|
+
* the More button: both are flex siblings of `.mat-mdc-tab-label-container`
|
|
199
|
+
* inside `.mat-mdc-tab-header`, so the available width is split across
|
|
200
|
+
* all of them and the IntersectionObserver picks up the new container
|
|
201
|
+
* width automatically. Consumers who want to hide Material's
|
|
202
|
+
* pagination (More button as the only overflow affordance) can do so
|
|
203
|
+
* with a one-line theme-level override:
|
|
204
|
+
*
|
|
205
|
+
* .mat-mdc-tab-header:has(cngx-tab-overflow)
|
|
206
|
+
* .mat-mdc-tab-header-pagination {
|
|
207
|
+
* display: none;
|
|
208
|
+
* }
|
|
209
|
+
*/
|
|
210
|
+
|
|
211
|
+
/*
|
|
212
|
+
* SR-only utility for the per-tab error descriptor span
|
|
213
|
+
* (`<span class="cngx-sr-only" id="${handle.id}-errors">` mounted by
|
|
214
|
+
* the aggregator-decoration effect). The span carries the consumer-
|
|
215
|
+
* supplied `aggregator.announcement()` phrase; AT reads it through
|
|
216
|
+
* the patched `aria-describedby`, sighted users see only the badge
|
|
217
|
+
* glyph. `@cngx/ui/mat-tabs` ships this utility inside its own
|
|
218
|
+
* stylesheet so consumers importing only `mat-tabs.css` (per the
|
|
219
|
+
* README) do not paint the announcement inline next to the tab
|
|
220
|
+
* label. Mirrors the rule in `@cngx/common/tabs/styles/tabs-base.css`
|
|
221
|
+
* for the cngx-native variant.
|
|
222
|
+
*/
|
|
223
|
+
.cngx-sr-only {
|
|
224
|
+
position: absolute;
|
|
225
|
+
width: 1px;
|
|
226
|
+
height: 1px;
|
|
227
|
+
margin: -1px;
|
|
228
|
+
padding: 0;
|
|
229
|
+
overflow: hidden;
|
|
230
|
+
clip: rect(0, 0, 0, 0);
|
|
231
|
+
white-space: nowrap;
|
|
232
|
+
border: 0;
|
|
233
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# CngxMatPaginator
|
|
2
|
+
|
|
3
|
+
Material paginator wrapper connecting to a CngxPaginate directive via explicit `[cngxPaginateRef]` input.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { CngxMatPaginator } from '@cngx/ui/material';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Component, signal } from '@angular/core';
|
|
15
|
+
import { MatTableModule } from '@angular/material/table';
|
|
16
|
+
import { CngxPaginate } from '@cngx/common/data';
|
|
17
|
+
import { CngxMatPaginator } from '@cngx/ui/material';
|
|
18
|
+
|
|
19
|
+
@Component({
|
|
20
|
+
selector: 'app-example',
|
|
21
|
+
template: `
|
|
22
|
+
<div cngxPaginate #pg="cngxPaginate" [total]="items.length">
|
|
23
|
+
<table mat-table [dataSource]="paginatedItems()">
|
|
24
|
+
<!-- table columns -->
|
|
25
|
+
</table>
|
|
26
|
+
</div>
|
|
27
|
+
<cngx-mat-paginator [cngxPaginateRef]="pg" />
|
|
28
|
+
`,
|
|
29
|
+
imports: [MatTableModule, CngxMatPaginator],
|
|
30
|
+
})
|
|
31
|
+
export class ExampleComponent {
|
|
32
|
+
readonly items = [];
|
|
33
|
+
|
|
34
|
+
readonly paginatedItems = computed(() => {
|
|
35
|
+
const pg = inject(CngxPaginate);
|
|
36
|
+
return this.items.slice(pg.pageIndex() * pg.pageSize(), (pg.pageIndex() + 1) * pg.pageSize());
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Overview
|
|
42
|
+
|
|
43
|
+
`CngxMatPaginator` is a Material Design paginator component that wraps the Material `mat-paginator` element and wires it to a `CngxPaginate` directive. It provides:
|
|
44
|
+
|
|
45
|
+
- **Type-safe integration** — Explicit `[cngxPaginateRef]` input (no ancestor injection)
|
|
46
|
+
- **Automatic state sync** — Page index, page size, and total count are automatically synchronized
|
|
47
|
+
- **Page size selector** — Customizable page size options via `[pageSizeOptions]`
|
|
48
|
+
- **Disabled state** — Paginator disables when `CngxPaginate.isBusy()` is true
|
|
49
|
+
|
|
50
|
+
The component requires an explicit reference to the `CngxPaginate` directive instance — no hidden ancestor injection, no implicit wiring.
|
|
51
|
+
|
|
52
|
+
## Accessibility
|
|
53
|
+
|
|
54
|
+
`CngxMatPaginator` delegates accessibility to Material's `mat-paginator` component. The Material paginator is fully accessible with:
|
|
55
|
+
|
|
56
|
+
- **ARIA labels** — Paginator navigation and page size controls are properly labeled
|
|
57
|
+
- **Keyboard navigation** — Tab order and keyboard shortcuts for page navigation
|
|
58
|
+
- **Disabled state** — When `isBusy()` is true, controls are disabled and announced to screen readers
|
|
59
|
+
|
|
60
|
+
## Composition
|
|
61
|
+
|
|
62
|
+
`CngxMatPaginator` composes:
|
|
63
|
+
|
|
64
|
+
- **Material paginator** — `mat-paginator` component from `@angular/material/paginator`
|
|
65
|
+
- **CngxPaginate directive** — Manages pagination state (page index, page size, total)
|
|
66
|
+
- **Event handling** — Subscribes to Material paginator's `page` event and updates directive state
|
|
67
|
+
|
|
68
|
+
## How It Works
|
|
69
|
+
|
|
70
|
+
1. **Setup** — Consumer applies `cngxPaginate` on a container element and assigns a template reference
|
|
71
|
+
2. **Data binding** — Consumer passes `[total]="items.length"` to the directive
|
|
72
|
+
3. **Component wire-up** — `CngxMatPaginator` binds to the directive via `[cngxPaginateRef]`
|
|
73
|
+
4. **State sync** — Component reads `ref.pageIndex()`, `ref.pageSize()`, `ref.total()` and binds to Material's `mat-paginator`
|
|
74
|
+
5. **User interaction** — When user changes page or page size, Material's `page` event fires
|
|
75
|
+
6. **State update** — `CngxMatPaginator.handlePage()` calls `ref.setPageSize()` and `ref.setPage()` to update directive state
|
|
76
|
+
7. **Data refresh** — Consumer reactively filters/slices data based on directive signals
|
|
77
|
+
|
|
78
|
+
## Material Theming
|
|
79
|
+
|
|
80
|
+
`CngxMatPaginator` uses the standard Material `mat-paginator` component, which inherits theming from your Material theme automatically. No additional theme configuration needed — include the Material theme in your global stylesheet.
|
|
81
|
+
|
|
82
|
+
```scss
|
|
83
|
+
@use '@angular/material' as mat;
|
|
84
|
+
|
|
85
|
+
$theme: mat.define-theme((...));
|
|
86
|
+
|
|
87
|
+
html {
|
|
88
|
+
@include mat.all-component-themes($theme);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# CngxOverlay
|
|
2
|
+
|
|
3
|
+
Typed wrapper service over Angular CDK Overlay with typed result streams.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { CngxOverlay, provideOverlay } from '@cngx/ui/overlay';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Component, inject } from '@angular/core';
|
|
15
|
+
import { CngxOverlay, provideOverlay } from '@cngx/ui/overlay';
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'app-example',
|
|
19
|
+
template: ` <button (click)="openDialog()">Open Dialog</button> `,
|
|
20
|
+
providers: [provideOverlay()],
|
|
21
|
+
})
|
|
22
|
+
export class ExampleComponent {
|
|
23
|
+
private readonly overlay = inject(CngxOverlay);
|
|
24
|
+
|
|
25
|
+
openDialog(): void {
|
|
26
|
+
const ref = this.overlay.open(MyDialogComponent, { hasBackdrop: true });
|
|
27
|
+
ref.afterClosed$.subscribe((result) => {
|
|
28
|
+
console.log('Dialog closed with:', result);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
|
|
36
|
+
`CngxOverlay` is a thin, type-safe service wrapper over Angular CDK Overlay. It simplifies the component attachment pattern and provides a typed result stream via `CngxOverlayRef<R>`.
|
|
37
|
+
|
|
38
|
+
Key features:
|
|
39
|
+
|
|
40
|
+
- **Type-safe result streams** — `CngxOverlayRef<R>` with generic result type
|
|
41
|
+
- **Sensible defaults** — Centered backdrop by default; customize via CDK `OverlayConfig`
|
|
42
|
+
- **Simple API** — `open(component, config)` and `close(result)`
|
|
43
|
+
- **Backdrop dismiss** — Auto-closes on backdrop click (configurable)
|
|
44
|
+
|
|
45
|
+
## Configuration
|
|
46
|
+
|
|
47
|
+
`CngxOverlayConfig` is a type alias for the CDK `OverlayConfig` object. Supported options:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
type CngxOverlayConfig = Partial<OverlayConfig>;
|
|
51
|
+
|
|
52
|
+
// Example:
|
|
53
|
+
const ref = overlay.open(MyComponent, {
|
|
54
|
+
hasBackdrop: true,
|
|
55
|
+
backdropClass: 'my-backdrop',
|
|
56
|
+
panelClass: 'my-panel',
|
|
57
|
+
maxHeight: '80vh',
|
|
58
|
+
width: '600px',
|
|
59
|
+
positionStrategy: overlay.position().global().centerHorizontally(),
|
|
60
|
+
scrollStrategy: overlay.scrollStrategies.block(),
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Default behavior:
|
|
65
|
+
|
|
66
|
+
- `hasBackdrop: true`
|
|
67
|
+
- `positionStrategy: global().centerHorizontally().centerVertically()`
|
|
68
|
+
- All other CDK defaults
|
|
69
|
+
|
|
70
|
+
## Accessibility
|
|
71
|
+
|
|
72
|
+
`CngxOverlay` provides the CDK overlay service and component portal attachment. Accessibility is the responsibility of the overlay component:
|
|
73
|
+
|
|
74
|
+
- **Focus trap** — Use CDK's `cdkTrapFocus` on your overlay content
|
|
75
|
+
- **Backdrop dismissal** — Backdrop click auto-closes; use `closeOnBackdropClick` in your component
|
|
76
|
+
- **Focus restoration** — Store focus before opening, restore on close (standard pattern)
|
|
77
|
+
- **ARIA roles** — Overlay component must declare `role="dialog"`, `role="menu"`, etc.
|
|
78
|
+
|
|
79
|
+
## Composition
|
|
80
|
+
|
|
81
|
+
`CngxOverlay` composes:
|
|
82
|
+
|
|
83
|
+
- **CDK Overlay service** — Position strategies, scroll strategies, portal attachment
|
|
84
|
+
- **ComponentPortal** — Attaches components to the overlay DOM
|
|
85
|
+
- **Injector.create** — Creates a child injector with the overlay ref available to the component
|
|
86
|
+
|
|
87
|
+
## Type Safety
|
|
88
|
+
|
|
89
|
+
The generic type parameters on `open` provide compile-time type checking:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// Result type is inferred from the second generic
|
|
93
|
+
const ref = overlay.open<MyComponent, MyResultType>(MyComponent);
|
|
94
|
+
|
|
95
|
+
// ref.afterClosed$ is Observable<MyResultType | undefined>
|
|
96
|
+
ref.afterClosed$.subscribe((result: MyResultType | undefined) => {
|
|
97
|
+
// TS knows result type here
|
|
98
|
+
});
|
|
99
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cngx/ui",
|
|
3
|
+
"version": "0.0.1-rc.0",
|
|
4
|
+
"description": "Material-backed organisms (overlay, layout, feedback shell, empty-state) for the cngx Angular component library.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cngx",
|
|
7
|
+
"angular",
|
|
8
|
+
"signals",
|
|
9
|
+
"material",
|
|
10
|
+
"ui",
|
|
11
|
+
"overlay",
|
|
12
|
+
"feedback",
|
|
13
|
+
"components"
|
|
14
|
+
],
|
|
15
|
+
"author": "Christian Weiss <c.weiss@sobit.at>",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"homepage": "https://github.com/cngxjs/cngx#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/cngxjs/cngx/issues"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/cngxjs/cngx.git",
|
|
24
|
+
"directory": "projects/ui"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@angular/cdk": "^21.2.0",
|
|
28
|
+
"@angular/common": "^21.2.0",
|
|
29
|
+
"@angular/core": "^21.2.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"tslib": "^2.3.0"
|
|
33
|
+
},
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"module": "fesm2022/cngx-ui.mjs",
|
|
36
|
+
"typings": "types/cngx-ui.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
"./package.json": {
|
|
39
|
+
"default": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./types/cngx-ui.d.ts",
|
|
43
|
+
"default": "./fesm2022/cngx-ui.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./action-button": {
|
|
46
|
+
"types": "./types/cngx-ui-action-button.d.ts",
|
|
47
|
+
"default": "./fesm2022/cngx-ui-action-button.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./empty-state": {
|
|
50
|
+
"types": "./types/cngx-ui-empty-state.d.ts",
|
|
51
|
+
"default": "./fesm2022/cngx-ui-empty-state.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./feedback": {
|
|
54
|
+
"types": "./types/cngx-ui-feedback.d.ts",
|
|
55
|
+
"default": "./fesm2022/cngx-ui-feedback.mjs"
|
|
56
|
+
},
|
|
57
|
+
"./layout": {
|
|
58
|
+
"types": "./types/cngx-ui-layout.d.ts",
|
|
59
|
+
"default": "./fesm2022/cngx-ui-layout.mjs"
|
|
60
|
+
},
|
|
61
|
+
"./mat-stepper": {
|
|
62
|
+
"types": "./types/cngx-ui-mat-stepper.d.ts",
|
|
63
|
+
"default": "./fesm2022/cngx-ui-mat-stepper.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./mat-tabs": {
|
|
66
|
+
"types": "./types/cngx-ui-mat-tabs.d.ts",
|
|
67
|
+
"default": "./fesm2022/cngx-ui-mat-tabs.mjs"
|
|
68
|
+
},
|
|
69
|
+
"./material": {
|
|
70
|
+
"types": "./types/cngx-ui-material.d.ts",
|
|
71
|
+
"default": "./fesm2022/cngx-ui-material.mjs"
|
|
72
|
+
},
|
|
73
|
+
"./overlay": {
|
|
74
|
+
"types": "./types/cngx-ui-overlay.d.ts",
|
|
75
|
+
"default": "./fesm2022/cngx-ui-overlay.mjs"
|
|
76
|
+
},
|
|
77
|
+
"./sidenav": {
|
|
78
|
+
"types": "./types/cngx-ui-sidenav.d.ts",
|
|
79
|
+
"default": "./fesm2022/cngx-ui-sidenav.mjs"
|
|
80
|
+
},
|
|
81
|
+
"./skeleton": {
|
|
82
|
+
"types": "./types/cngx-ui-skeleton.d.ts",
|
|
83
|
+
"default": "./fesm2022/cngx-ui-skeleton.mjs"
|
|
84
|
+
},
|
|
85
|
+
"./speak": {
|
|
86
|
+
"types": "./types/cngx-ui-speak.d.ts",
|
|
87
|
+
"default": "./fesm2022/cngx-ui-speak.mjs"
|
|
88
|
+
},
|
|
89
|
+
"./stepper": {
|
|
90
|
+
"types": "./types/cngx-ui-stepper.d.ts",
|
|
91
|
+
"default": "./fesm2022/cngx-ui-stepper.mjs"
|
|
92
|
+
},
|
|
93
|
+
"./tabs": {
|
|
94
|
+
"types": "./types/cngx-ui-tabs.d.ts",
|
|
95
|
+
"default": "./fesm2022/cngx-ui-tabs.mjs"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# CngxSidenav
|
|
2
|
+
|
|
3
|
+
Declarative sidebar component supporting responsive mode switching, two-way opened binding, and content projection.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import {
|
|
9
|
+
CngxSidenav,
|
|
10
|
+
CngxSidenavLayout,
|
|
11
|
+
CngxSidenavContent,
|
|
12
|
+
CngxSidenavHeader,
|
|
13
|
+
CngxSidenavFooter,
|
|
14
|
+
} from '@cngx/ui';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Component } from '@angular/core';
|
|
21
|
+
import {
|
|
22
|
+
CngxSidenav,
|
|
23
|
+
CngxSidenavLayout,
|
|
24
|
+
CngxSidenavContent,
|
|
25
|
+
CngxSidenavHeader,
|
|
26
|
+
CngxSidenavFooter,
|
|
27
|
+
} from '@cngx/ui';
|
|
28
|
+
|
|
29
|
+
@Component({
|
|
30
|
+
selector: 'app-example',
|
|
31
|
+
template: `
|
|
32
|
+
<cngx-sidenav-layout>
|
|
33
|
+
<cngx-sidenav position="start" [(opened)]="navOpen" [responsive]="'(min-width: 1024px)'">
|
|
34
|
+
<cngx-sidenav-header>Logo</cngx-sidenav-header>
|
|
35
|
+
<a cngxNavLink [active]="true">Dashboard</a>
|
|
36
|
+
<cngx-sidenav-footer>v1.0</cngx-sidenav-footer>
|
|
37
|
+
</cngx-sidenav>
|
|
38
|
+
<cngx-sidenav-content>
|
|
39
|
+
<router-outlet />
|
|
40
|
+
</cngx-sidenav-content>
|
|
41
|
+
</cngx-sidenav-layout>
|
|
42
|
+
`,
|
|
43
|
+
imports: [
|
|
44
|
+
CngxSidenav,
|
|
45
|
+
CngxSidenavLayout,
|
|
46
|
+
CngxSidenavContent,
|
|
47
|
+
CngxSidenavHeader,
|
|
48
|
+
CngxSidenavFooter,
|
|
49
|
+
],
|
|
50
|
+
})
|
|
51
|
+
export class ExampleComponent {
|
|
52
|
+
navOpen = signal(false);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Overview
|
|
57
|
+
|
|
58
|
+
`CngxSidenav` is a composable sidebar component that handles drawer behavior, keyboard shortcuts, responsive mode switching, and optional resize functionality. It coordinates with `CngxSidenavLayout` for backdrop and scroll-lock management.
|
|
59
|
+
|
|
60
|
+
Key features:
|
|
61
|
+
|
|
62
|
+
- **Mode switching:** `over` (overlay), `push` (nudges content), `side` (permanent), `mini` (collapsed icon rail with hover expand)
|
|
63
|
+
- **Responsive:** Media query-driven mode override via `[responsive]` input
|
|
64
|
+
- **Two-way binding:** `[(opened)]` synchronizes with external state
|
|
65
|
+
- **Resize:** Optional drag handle with min/max constraints
|
|
66
|
+
- **Keyboard:** Escape closes overlay, configurable global shortcut via `[shortcut]`
|
|
67
|
+
- **RTL-aware:** `position="start"` / `"end"` flip logically in RTL
|
|
68
|
+
|
|
69
|
+
## Accessibility
|
|
70
|
+
|
|
71
|
+
`CngxSidenav` is fully accessible:
|
|
72
|
+
|
|
73
|
+
- **ARIA roles:** Sidebar carries `role="complementary"` with optional `[attr.aria-label]`. In overlay mode, `aria-hidden="true"` when closed.
|
|
74
|
+
- **Keyboard interaction:**
|
|
75
|
+
- `Escape` — Closes overlay mode sidenav
|
|
76
|
+
- Custom shortcut (if configured) — Toggles opened state globally
|
|
77
|
+
- **Screen reader:** Complementary landmark announces the sidebar label; scroll lock prevents reading body content when sidebar is open in overlay.
|
|
78
|
+
- **Focus management:** On overlay close, focus is not automatically restored (consumer must manage).
|
|
79
|
+
|
|
80
|
+
## Composition
|
|
81
|
+
|
|
82
|
+
`CngxSidenav` composes these atoms internally:
|
|
83
|
+
|
|
84
|
+
- **Responsive media query:** Inline `matchMedia` listener wired to `mediaMatches` signal
|
|
85
|
+
- **Keyboard shortcut:** Global document listener via `effect(onCleanup)`
|
|
86
|
+
- **Scroll lock:** Coordinate with `CngxSidenavLayout` via `hasOverlay` computed
|
|
87
|
+
- **Resize:** Pointer-capture drag with RAFed position updates
|
|
88
|
+
|
|
89
|
+
## Styling
|
|
90
|
+
|
|
91
|
+
All dimensions and colors use CSS Custom Properties with Material 3 defaults:
|
|
92
|
+
|
|
93
|
+
```scss
|
|
94
|
+
// Override in your component or global styles
|
|
95
|
+
:host {
|
|
96
|
+
--cngx-sidenav-width: 320px;
|
|
97
|
+
--cngx-sidenav-transition-duration: 0.3s;
|
|
98
|
+
--cngx-sidenav-bg: var(--mat-sys-surface-container, #f9fafb);
|
|
99
|
+
--cngx-sidenav-color: var(--mat-sys-on-surface, #333);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Material Theme
|
|
104
|
+
|
|
105
|
+
Include the theme SCSS files in your global stylesheet:
|
|
106
|
+
|
|
107
|
+
```scss
|
|
108
|
+
@use '@angular/material' as mat;
|
|
109
|
+
@use '@cngx/ui/sidenav/sidenav-theme' as sidenav;
|
|
110
|
+
@use '@cngx/ui/sidenav/nav-link-theme' as nav-link;
|
|
111
|
+
|
|
112
|
+
$theme: mat.define-theme((...));
|
|
113
|
+
|
|
114
|
+
html {
|
|
115
|
+
@include mat.all-component-themes($theme);
|
|
116
|
+
@include sidenav.theme($theme);
|
|
117
|
+
@include nav-link.theme($theme);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The theme mixin provides:
|
|
122
|
+
|
|
123
|
+
- Base spacing and timing tokens
|
|
124
|
+
- Material 3 system color tokens (`--mat-sys-*`) with fallback RGB values
|
|
125
|
+
- Material 2 palette color mappings
|
|
126
|
+
- Backdrop, header, and footer styling
|
|
127
|
+
- Support for both M3 and M2 themes (auto-detected)
|