@cngx/common 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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/a11y/README.md +77 -0
  4. package/card/README.md +79 -0
  5. package/chart/README.md +31 -0
  6. package/data/README.md +883 -0
  7. package/dialog/README.md +84 -0
  8. package/display/README.md +30 -0
  9. package/fesm2022/cngx-common-a11y.mjs +1260 -0
  10. package/fesm2022/cngx-common-a11y.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +765 -0
  12. package/fesm2022/cngx-common-card.mjs.map +1 -0
  13. package/fesm2022/cngx-common-chart.mjs +2943 -0
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -0
  15. package/fesm2022/cngx-common-data.mjs +2886 -0
  16. package/fesm2022/cngx-common-data.mjs.map +1 -0
  17. package/fesm2022/cngx-common-dialog.mjs +1366 -0
  18. package/fesm2022/cngx-common-dialog.mjs.map +1 -0
  19. package/fesm2022/cngx-common-display.mjs +1603 -0
  20. package/fesm2022/cngx-common-display.mjs.map +1 -0
  21. package/fesm2022/cngx-common-interactive.mjs +8185 -0
  22. package/fesm2022/cngx-common-interactive.mjs.map +1 -0
  23. package/fesm2022/cngx-common-layout.mjs +1335 -0
  24. package/fesm2022/cngx-common-layout.mjs.map +1 -0
  25. package/fesm2022/cngx-common-popover.mjs +1200 -0
  26. package/fesm2022/cngx-common-popover.mjs.map +1 -0
  27. package/fesm2022/cngx-common-stepper.mjs +1350 -0
  28. package/fesm2022/cngx-common-stepper.mjs.map +1 -0
  29. package/fesm2022/cngx-common-tabs.mjs +1551 -0
  30. package/fesm2022/cngx-common-tabs.mjs.map +1 -0
  31. package/fesm2022/cngx-common.mjs +34 -0
  32. package/fesm2022/cngx-common.mjs.map +1 -0
  33. package/interactive/README.md +211 -0
  34. package/layout/README.md +117 -0
  35. package/package.json +100 -0
  36. package/popover/README.md +218 -0
  37. package/stepper/README.md +102 -0
  38. package/tabs/README.md +32 -0
  39. package/types/cngx-common-a11y.d.ts +616 -0
  40. package/types/cngx-common-card.d.ts +413 -0
  41. package/types/cngx-common-chart.d.ts +1081 -0
  42. package/types/cngx-common-data.d.ts +1460 -0
  43. package/types/cngx-common-dialog.d.ts +772 -0
  44. package/types/cngx-common-display.d.ts +1136 -0
  45. package/types/cngx-common-interactive.d.ts +5013 -0
  46. package/types/cngx-common-layout.d.ts +737 -0
  47. package/types/cngx-common-popover.d.ts +520 -0
  48. package/types/cngx-common-stepper.d.ts +982 -0
  49. package/types/cngx-common-tabs.d.ts +1237 -0
  50. package/types/cngx-common.d.ts +13 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Christian Weiss
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @cngx/common
2
+
3
+ Headless behavioral directives for Angular. Composition atoms and molecules built on Angular CDK.
4
+
5
+ ## Entry Points
6
+
7
+ | Entry Point | Description |
8
+ |-|-|
9
+ | `@cngx/common/a11y` | ARIA and accessibility directives |
10
+ | `@cngx/common/interactive` | Click, gesture, navigation, and action directives |
11
+ | `@cngx/common/layout` | Layout observation, scroll, drawer, and skeleton directives |
12
+ | `@cngx/common/data` | Sort, filter, paginate, and data source utilities |
13
+
14
+ The primary `@cngx/common` re-exports all four entry points for backwards compatibility.
15
+
16
+ ## Peer Dependencies
17
+
18
+ `@angular/core`, `@angular/common`, `@angular/cdk`
package/a11y/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @cngx/common/a11y
2
+
3
+ Accessibility behavior directives — focus management, keyboard navigation, live regions, and motion detection.
4
+
5
+ ## CngxRovingTabindex
6
+
7
+ Implements the [WAI-ARIA roving tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex) pattern for composite widgets. Only the active item has `tabindex="0"` — all others get `tabindex="-1"`. Arrow keys move focus within the group; Tab leaves it entirely.
8
+
9
+ ```html
10
+ <div cngxRovingTabindex orientation="horizontal" [loop]="true" #rv="cngxRovingTabindex">
11
+ <button cngxRovingItem>Cut</button>
12
+ <button cngxRovingItem>Copy</button>
13
+ <button cngxRovingItem>Paste</button>
14
+ </div>
15
+ ```
16
+
17
+ ### CngxRovingTabindex Keyboard
18
+
19
+ | Key | Action |
20
+ | -------------------------- | -------------------------------------- |
21
+ | `ArrowRight` / `ArrowDown` | Move to next item (axis-dependent) |
22
+ | `ArrowLeft` / `ArrowUp` | Move to previous item (axis-dependent) |
23
+ | `Home` | Jump to first enabled item |
24
+ | `End` | Jump to last enabled item |
25
+ | `Tab` | Leave the group (standard tab order) |
26
+
27
+ ### Notes
28
+
29
+ - Disabled items are skipped during arrow-key navigation.
30
+ - `activeIndex` is clamped to the valid range when items are added/removed.
31
+ - Items are discovered via `contentChildren(CngxRovingItem)`.
32
+
33
+ ---
34
+
35
+ ## CngxFocusRestore
36
+
37
+ Captures the previously focused element on init and restores focus when the host is destroyed. Prevents focus from falling to `<body>` when dynamic content is removed.
38
+
39
+ ```html
40
+ @if (panelOpen()) {
41
+ <div cngxFocusRestore>
42
+ Panel content…
43
+ <button (click)="panelOpen.set(false)">Close</button>
44
+ </div>
45
+ }
46
+ ```
47
+
48
+ ### Fallback Chain
49
+
50
+ 1. Stored element (if still in DOM)
51
+ 2. Explicit `fallback` input
52
+ 3. Nearest focusable ancestor
53
+ 4. Nothing (focus stays where it is)
54
+
55
+ ---
56
+
57
+ ## CngxAutofocus
58
+
59
+ Reactive autofocus for dynamically inserted elements. The native `autofocus` attribute only works on initial page load — this directive handles dialogs, panels, steppers, and conditional views.
60
+
61
+ ```html
62
+ @if (showSearch()) {
63
+ <input [cngxAutofocus]="true" placeholder="Search…" />
64
+ }
65
+ ```
66
+
67
+ ### Notes
68
+
69
+ - Uses `afterNextRender` for initial focus — never synchronous.
70
+ - `delay > 0` uses `setTimeout`; `delay === 0` uses `afterNextRender`.
71
+ - Tracks `when` transitions via `effect()` — only re-focuses on `false → true`.
72
+
73
+ ---
74
+
75
+ ## Other Exports
76
+
77
+ `CngxAriaExpanded`, `CngxFocusTrap`, `CngxFocusVisible`, `CngxLiveRegion`, `CngxReducedMotion`
package/card/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # CngxCard
2
+
3
+ Semantic card component that adapts its host element role based on the archetype (article/button/link). The host element **is** the semantic element — no inner wrapper, no double focus rings.
4
+
5
+ ## Quick Start
6
+
7
+ ```typescript
8
+ import { Component, signal } from '@angular/core';
9
+ import {
10
+ CngxCard,
11
+ CngxCardGrid,
12
+ CngxCardHeader,
13
+ CngxCardBody,
14
+ CngxCardTitle,
15
+ } from '@cngx/common/card';
16
+
17
+ @Component({
18
+ selector: 'app-example',
19
+ template: `
20
+ <cngx-card-grid [items]="items()">
21
+ @for (item of items(); track item.id) {
22
+ <cngx-card as="button" (clicked)="onSelect(item)">
23
+ <header cngxCardHeader>
24
+ <h3 cngxCardTitle>{{ item.name }}</h3>
25
+ </header>
26
+ <div cngxCardBody>{{ item.description }}</div>
27
+ </cngx-card>
28
+ }
29
+ </cngx-card-grid>
30
+ `,
31
+ imports: [CngxCard, CngxCardGrid, CngxCardHeader, CngxCardBody, CngxCardTitle],
32
+ })
33
+ export class ExampleComponent {
34
+ items = signal([
35
+ { id: 1, name: 'Patient A', description: 'Active monitoring' },
36
+ { id: 2, name: 'Patient B', description: 'In recovery' },
37
+ ]);
38
+
39
+ onSelect(item: (typeof this.items)[0]) {
40
+ console.log('Selected:', item);
41
+ }
42
+ }
43
+ ```
44
+
45
+ ## Accessibility
46
+
47
+ CngxCard is fully accessible:
48
+
49
+ - **ARIA roles:** `role="article"` (default), `role="button"`, or `role="link"` based on `as` input
50
+ - **Keyboard interaction:**
51
+ - `Enter` / `Space`: Activate interactive cards (button/link)
52
+ - `Arrow Left/Right`: Navigate cards in grid (CngxRovingTabindex)
53
+ - `Home` / `End`: Jump to first/last card in grid
54
+ - **Screen reader:** `aria-busy` when loading; live region announces "Loading", "Selected", "Deselected" state changes; `aria-describedby` points to disabled reason explanation
55
+ - **Focus management:** Interactive cards get `tabindex="0"` when standalone; CngxCardGrid's roving tabindex manages focus among cards
56
+
57
+ ## Composition
58
+
59
+ CngxCard composes `CngxRovingItem` as a host directive for keyboard navigation within `CngxCardGrid`.
60
+
61
+ CngxCardGrid composes `CngxRovingTabindex` as a host directive — all arrow key/Home/End navigation is built in automatically.
62
+
63
+ ## Material Theme
64
+
65
+ CngxCard ships with Material 3 styling via CSS custom properties. To apply full Material theming (density, typography, color tokens), import the theme file in your global styles:
66
+
67
+ ```scss
68
+ @import '@cngx/common/card/card-theme';
69
+
70
+ @include cngx-card-theme($material-theme);
71
+ @include cngx-card-density(-1); // compact
72
+ ```
73
+
74
+ Density levels:
75
+
76
+ - `-2` → extra compact
77
+ - `-1` → compact
78
+ - `0` → default (Material default)
79
+ - `1` → comfortable
@@ -0,0 +1,31 @@
1
+ # @cngx/common/chart
2
+
3
+ Declarative, Signal-first chart system. Built as two layers: composable atoms (one container, one directive per axis or layer) and preset molecules (sparkline, donut, stacked bar, threshold gauge) for the common shapes.
4
+
5
+ ## When you reach for it
6
+
7
+ You are visualising data inside an Angular template and want chart behaviour that lives in the same reactivity graph as the rest of your component — not a wrapper around an imperative library. Typical reasons:
8
+
9
+ - A single-series sparkline next to a value cell — no axes, no legend, just a glanceable trend.
10
+ - A KPI tile with a donut or stacked bar showing composition or progress.
11
+ - A custom chart shape that the presets do not cover, where you want to compose your own `<svg:g>` layers against scales the container provides.
12
+ - Async data sources where loading, refresh, and error states should render through the same surface as the chart itself rather than as separate UI.
13
+
14
+ ## Mental model
15
+
16
+ A cngx chart is just an SVG with a shared **chart context** — scales, dimensions, and theme tokens — exposed via DI to its children. Atoms read the context to render their slice (axis ticks, line path, bar rectangles, scatter points). Preset molecules wire the common combinations together so you do not assemble them every time.
17
+
18
+ Three properties make the chart system feel different from a wrapped library:
19
+
20
+ - **Reactive scales.** The X and Y scales are signals derived from the data and container dimensions. Resizing the container or swapping data triggers exactly the layers whose inputs changed — no full re-layout.
21
+ - **Async-native.** Bind `[state]` and the chart switches between skeleton, content, refresh, empty, and error views the same way every other cngx surface does. Loading is a built-in mode, not a parent wrapper.
22
+ - **Override slots.** Loading, empty, and error placeholders are template slots; the chart never blocks you from owning the UX of a failed fetch.
23
+
24
+ ## Status
25
+
26
+ Under active development. Treat the **preset molecules** as stable for adoption. Treat the **atom internals** (axis tick computation, layer projection caching, custom-layer authoring) as still in flux until the chart-area master plan closes — APIs may move between minor releases.
27
+
28
+ ## See also
29
+
30
+ - Components, atoms, scales, and slot directives are listed in the **API** tab.
31
+ - Live examples and theming in the demo app under `dev-app/src/app/demos/common/chart/`.