@cngx/common 0.1.0-rc.7 → 0.1.0-rc.9
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/card/README.md +2 -1
- package/command/README.md +29 -0
- package/data/README.md +15 -3
- package/dialog/README.md +23 -1
- package/fesm2022/cngx-common-a11y.mjs +517 -184
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +62 -17
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +301 -46
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +1221 -479
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +97 -16
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +1496 -499
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +236 -61
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +364 -93
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2040 -1046
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +955 -125
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +1293 -89
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +997 -453
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1794 -1265
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +151 -61
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/interactive/README.md +15 -4
- package/layout/README.md +37 -1
- package/package.json +20 -7
- package/popover/README.md +58 -2
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +91 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +11 -8
- package/theming/components/cngx-accordion.css +1 -1
- package/theming/components/cngx-backdrop.css +12 -0
- package/theming/components/cngx-button-toggle.css +29 -3
- package/theming/components/cngx-data-grid.css +168 -1
- package/theming/components/cngx-dialog.css +13 -0
- package/theming/components/cngx-listbox.css +21 -12
- package/theming/components/cngx-menu.css +56 -16
- package/theming/components/cngx-popover-sheet.css +402 -0
- package/theming/components/cngx-popover.css +28 -0
- package/theming/components/cngx-recycler-placeholder.css +196 -0
- package/theming/components/cngx-ripple.css +1 -1
- package/theming/components/cngx-slider.css +32 -1
- package/theming/components/cngx-tooltip.css +12 -0
- package/timeline/README.md +155 -0
- package/types/cngx-common-a11y.d.ts +205 -28
- package/types/cngx-common-card.d.ts +201 -17
- package/types/cngx-common-chart.d.ts +345 -48
- package/types/cngx-common-command.d.ts +50 -10
- package/types/cngx-common-data.d.ts +743 -92
- package/types/cngx-common-dialog.d.ts +161 -10
- package/types/cngx-common-display.d.ts +356 -142
- package/types/cngx-common-interactive.d.ts +910 -226
- package/types/cngx-common-layout.d.ts +603 -32
- package/types/cngx-common-popover.d.ts +612 -49
- package/types/cngx-common-stepper.d.ts +526 -237
- package/types/cngx-common-tabs.d.ts +358 -75
- package/types/cngx-common-timeline.d.ts +108 -22
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @overview
|
|
3
|
+
* Theming bridge for the `CngxRecyclerPlaceholder` directive. The directive
|
|
4
|
+
* sets the `cngx-recycler-placeholder` class on the offset spacer(s) of a
|
|
5
|
+
* virtualized surface and writes `--cngx-recycler-placeholder-row-height` from
|
|
6
|
+
* the recycler's `rowSizeHint`. Importing this file fills the exposed offset
|
|
7
|
+
* region with soft, row-aligned ghost rows during a fast fling or teleport
|
|
8
|
+
* jump. The layer lives on the spacers only - never behind rendered rows - so a
|
|
9
|
+
* populated list never shows it.
|
|
10
|
+
*
|
|
11
|
+
* **Look**
|
|
12
|
+
*
|
|
13
|
+
* Not a hard skeleton bar. Each row period paints one low-alpha band with
|
|
14
|
+
* feathered top/bottom edges (a gradient fade into the gap), inset horizontally
|
|
15
|
+
* so it reads as a content line rather than a full-width block. The alpha fill
|
|
16
|
+
* sits on any surface without a solid color of its own, so it stays subtle in
|
|
17
|
+
* both themes.
|
|
18
|
+
*
|
|
19
|
+
* **Rhythm**
|
|
20
|
+
*
|
|
21
|
+
* The period is `--cngx-recycler-placeholder-row-height`; because the offset is
|
|
22
|
+
* a whole multiple of the row height, the bands line up with the real rows just
|
|
23
|
+
* beyond the gap. `--cngx-recycler-placeholder-band-height` is the solid core
|
|
24
|
+
* within each period; the remainder feathers into the gap.
|
|
25
|
+
*
|
|
26
|
+
* **Shimmer**
|
|
27
|
+
*
|
|
28
|
+
* `.cngx-recycler-placeholder--shimmer` sweeps a faint highlight across the
|
|
29
|
+
* bands and animates its `background-position`. The directive toggles the class
|
|
30
|
+
* from a `(prefers-reduced-motion: reduce)` signal, so reduced motion simply
|
|
31
|
+
* drops the class. Only the background moves.
|
|
32
|
+
*
|
|
33
|
+
* **Dark mode**
|
|
34
|
+
*
|
|
35
|
+
* The fill and shimmer are white-alpha in dark mode so they read on a dark
|
|
36
|
+
* surface. Unlayered, direct selectors so they beat the layered defaults.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
@layer cngx.tokens {
|
|
40
|
+
/**
|
|
41
|
+
* Repeat period of the ghost rows (px). Set inline by the directive from the
|
|
42
|
+
* recycler's `rowSizeHint`; the initial applies when no row height resolves.
|
|
43
|
+
* `inherits: true` so an ancestor mapping reaches the spacer that hosts it.
|
|
44
|
+
* @group Layout
|
|
45
|
+
*/
|
|
46
|
+
@property --cngx-recycler-placeholder-row-height {
|
|
47
|
+
syntax: '<length>';
|
|
48
|
+
inherits: true;
|
|
49
|
+
initial-value: 48px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Solid core height of the band within each row period; the remainder
|
|
54
|
+
* feathers into the gap between bands.
|
|
55
|
+
* @group Layout
|
|
56
|
+
*/
|
|
57
|
+
@property --cngx-recycler-placeholder-band-height {
|
|
58
|
+
syntax: '<length>';
|
|
59
|
+
inherits: true;
|
|
60
|
+
initial-value: 20px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Horizontal inset of each band from the layer edges, so bands read as
|
|
65
|
+
* content lines rather than full-width blocks.
|
|
66
|
+
* @group Layout
|
|
67
|
+
*/
|
|
68
|
+
@property --cngx-recycler-placeholder-inset {
|
|
69
|
+
syntax: '<length>';
|
|
70
|
+
inherits: true;
|
|
71
|
+
initial-value: 12px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Corner softness of each band. Applied as the feather radius of the gradient
|
|
76
|
+
* edges via the band/gap split; kept as a token for tunability.
|
|
77
|
+
* @group Surface
|
|
78
|
+
*/
|
|
79
|
+
@property --cngx-recycler-placeholder-radius {
|
|
80
|
+
syntax: '<length>';
|
|
81
|
+
inherits: true;
|
|
82
|
+
initial-value: 6px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Fill of the ghost bands. A low-alpha ink so the layer sits softly on any
|
|
87
|
+
* surface without a solid color of its own.
|
|
88
|
+
* @group Surface
|
|
89
|
+
*/
|
|
90
|
+
@property --cngx-recycler-placeholder-color {
|
|
91
|
+
syntax: '<color>';
|
|
92
|
+
inherits: true;
|
|
93
|
+
initial-value: oklch(0.55 0.02 260 / 0.1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Highlight swept across the bands in shimmer mode.
|
|
98
|
+
* @group Motion
|
|
99
|
+
*/
|
|
100
|
+
@property --cngx-recycler-placeholder-shimmer-color {
|
|
101
|
+
syntax: '<color>';
|
|
102
|
+
inherits: true;
|
|
103
|
+
initial-value: oklch(1 0 0 / 0.35);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Duration of one shimmer sweep.
|
|
108
|
+
* @group Motion
|
|
109
|
+
*/
|
|
110
|
+
@property --cngx-recycler-placeholder-shimmer-duration {
|
|
111
|
+
syntax: '*';
|
|
112
|
+
inherits: true;
|
|
113
|
+
initial-value: 1.6s;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@layer cngx.components {
|
|
118
|
+
/* One feathered band per row period. The band core is centered in the period
|
|
119
|
+
* and fades to transparent across the surrounding gap, so edges read soft.
|
|
120
|
+
* repeat-y + a sub-100% background width insets the bands horizontally. */
|
|
121
|
+
.cngx-recycler-placeholder {
|
|
122
|
+
--_cngx-rp-feather: calc(
|
|
123
|
+
(
|
|
124
|
+
var(--cngx-recycler-placeholder-row-height, 48px) -
|
|
125
|
+
var(--cngx-recycler-placeholder-band-height, 20px)
|
|
126
|
+
) / 2
|
|
127
|
+
);
|
|
128
|
+
background-image: repeating-linear-gradient(
|
|
129
|
+
to bottom,
|
|
130
|
+
transparent 0,
|
|
131
|
+
var(--cngx-recycler-placeholder-color, oklch(0.55 0.02 260 / 0.1)) var(--_cngx-rp-feather),
|
|
132
|
+
var(--cngx-recycler-placeholder-color, oklch(0.55 0.02 260 / 0.1))
|
|
133
|
+
calc(var(--_cngx-rp-feather) + var(--cngx-recycler-placeholder-band-height, 20px)),
|
|
134
|
+
transparent var(--cngx-recycler-placeholder-row-height, 48px)
|
|
135
|
+
);
|
|
136
|
+
background-repeat: repeat-y;
|
|
137
|
+
background-size: calc(100% - 2 * var(--cngx-recycler-placeholder-inset, 12px)) 100%;
|
|
138
|
+
background-position: center top;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* Shimmer: a faint highlight band (first layer) swept over the static ghost
|
|
142
|
+
* rows (second layer). Only the background moves. */
|
|
143
|
+
.cngx-recycler-placeholder--shimmer {
|
|
144
|
+
background-image:
|
|
145
|
+
linear-gradient(
|
|
146
|
+
90deg,
|
|
147
|
+
transparent 0,
|
|
148
|
+
var(--cngx-recycler-placeholder-shimmer-color, oklch(1 0 0 / 0.35)) 50%,
|
|
149
|
+
transparent 100%
|
|
150
|
+
),
|
|
151
|
+
repeating-linear-gradient(
|
|
152
|
+
to bottom,
|
|
153
|
+
transparent 0,
|
|
154
|
+
var(--cngx-recycler-placeholder-color, oklch(0.55 0.02 260 / 0.1)) var(--_cngx-rp-feather),
|
|
155
|
+
var(--cngx-recycler-placeholder-color, oklch(0.55 0.02 260 / 0.1))
|
|
156
|
+
calc(var(--_cngx-rp-feather) + var(--cngx-recycler-placeholder-band-height, 20px)),
|
|
157
|
+
transparent var(--cngx-recycler-placeholder-row-height, 48px)
|
|
158
|
+
);
|
|
159
|
+
background-repeat: no-repeat, repeat-y;
|
|
160
|
+
background-size:
|
|
161
|
+
200% 100%,
|
|
162
|
+
calc(100% - 2 * var(--cngx-recycler-placeholder-inset, 12px)) 100%;
|
|
163
|
+
background-position:
|
|
164
|
+
-100% 0,
|
|
165
|
+
center top;
|
|
166
|
+
animation: cngx-recycler-placeholder-shimmer
|
|
167
|
+
var(--cngx-recycler-placeholder-shimmer-duration, 1.6s) ease-in-out infinite;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@keyframes cngx-recycler-placeholder-shimmer {
|
|
172
|
+
from {
|
|
173
|
+
background-position:
|
|
174
|
+
-100% 0,
|
|
175
|
+
center top;
|
|
176
|
+
}
|
|
177
|
+
to {
|
|
178
|
+
background-position:
|
|
179
|
+
200% 0,
|
|
180
|
+
center top;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* Dark mode: white-alpha fill + shimmer so the layer reads on a dark surface.
|
|
185
|
+
* Unlayered, direct selectors so they beat the layered defaults. */
|
|
186
|
+
@media (prefers-color-scheme: dark) {
|
|
187
|
+
:root:not([data-color-scheme='light']):not(.light) .cngx-recycler-placeholder {
|
|
188
|
+
--cngx-recycler-placeholder-color: oklch(1 0 0 / 0.09);
|
|
189
|
+
--cngx-recycler-placeholder-shimmer-color: oklch(1 0 0 / 0.16);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
[data-color-scheme='dark'] .cngx-recycler-placeholder,
|
|
193
|
+
.dark .cngx-recycler-placeholder {
|
|
194
|
+
--cngx-recycler-placeholder-color: oklch(1 0 0 / 0.09);
|
|
195
|
+
--cngx-recycler-placeholder-shimmer-color: oklch(1 0 0 / 0.16);
|
|
196
|
+
}
|
|
@@ -103,9 +103,13 @@
|
|
|
103
103
|
cursor: pointer;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
/* Disabled by colour, never opacity (the field recipe). */
|
|
106
107
|
:is([cngxSliderTrack], [cngxRangeSliderTrack])[aria-disabled='true'] {
|
|
107
|
-
opacity: 0.5;
|
|
108
108
|
cursor: not-allowed;
|
|
109
|
+
--cngx-slider-fill-color: color-mix(in oklab, var(--cngx-color-text, oklch(0.2 0.01 250)) 38%, transparent);
|
|
110
|
+
--cngx-slider-thumb-border-color: color-mix(in oklab, var(--cngx-color-text, oklch(0.2 0.01 250)) 38%, transparent);
|
|
111
|
+
--cngx-slider-track-color: color-mix(in oklab, var(--cngx-color-text, oklch(0.2 0.01 250)) 12%, transparent);
|
|
112
|
+
color: color-mix(in oklab, var(--cngx-color-text, oklch(0.2 0.01 250)) 38%, transparent);
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
:is([cngxSliderTrack], [cngxRangeSliderTrack]) .cngx-slider__track {
|
|
@@ -235,3 +239,30 @@
|
|
|
235
239
|
translate: -50% 50%;
|
|
236
240
|
}
|
|
237
241
|
}
|
|
242
|
+
|
|
243
|
+
/* forced-colors (WHCM): track and fill are painted only with background (the
|
|
244
|
+
* range band is a gradient), which the forced palette flattens to Canvas - the
|
|
245
|
+
* value and range vanish and only the thumb rings remain. Opt the track and
|
|
246
|
+
* fill out of forcing and feed the existing colour tokens system keywords, so
|
|
247
|
+
* every orientation keeps its own geometry: CanvasText track, Highlight value.
|
|
248
|
+
* A disabled slider reads GrayText on a Canvas track with a GrayText edge, so
|
|
249
|
+
* the value stays visible. Unlayered, after the base rules. */
|
|
250
|
+
@media (forced-colors: active) {
|
|
251
|
+
:is([cngxSliderTrack], [cngxRangeSliderTrack]) {
|
|
252
|
+
--cngx-slider-track-color: CanvasText;
|
|
253
|
+
--cngx-slider-fill-color: Highlight;
|
|
254
|
+
}
|
|
255
|
+
:is([cngxSliderTrack], [cngxRangeSliderTrack]) :is(.cngx-slider__track, .cngx-slider__fill) {
|
|
256
|
+
forced-color-adjust: none;
|
|
257
|
+
}
|
|
258
|
+
:is([cngxSliderTrack], [cngxRangeSliderTrack])[aria-disabled='true'] {
|
|
259
|
+
--cngx-slider-track-color: Canvas;
|
|
260
|
+
--cngx-slider-fill-color: GrayText;
|
|
261
|
+
--cngx-slider-thumb-border-color: GrayText;
|
|
262
|
+
color: GrayText;
|
|
263
|
+
}
|
|
264
|
+
:is([cngxSliderTrack], [cngxRangeSliderTrack])[aria-disabled='true'] .cngx-slider__track {
|
|
265
|
+
outline: 1px solid GrayText;
|
|
266
|
+
outline-offset: -1px;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
@@ -161,7 +161,11 @@
|
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
* Duration of the open / close transition.
|
|
164
|
+
*
|
|
165
|
+
* Derives from the `--cngx-duration-fast` rung of the motion scale; a
|
|
166
|
+
* `--cngx-duration-*` brand override re-times it library-wide.
|
|
164
167
|
* @group Motion
|
|
168
|
+
* @relatedTo provideMotion, CngxMotionScope, injectMotion
|
|
165
169
|
*/
|
|
166
170
|
@property --cngx-tooltip-transition-duration {
|
|
167
171
|
syntax: '<time>';
|
|
@@ -169,6 +173,14 @@
|
|
|
169
173
|
initial-value: 150ms;
|
|
170
174
|
}
|
|
171
175
|
|
|
176
|
+
/* Derive from the motion scale. The registered initial-value wins over the
|
|
177
|
+
* read-site var() fallback, so the token must be SET from the scale for a
|
|
178
|
+
* --cngx-duration-* brand override to reach the transition. Host SET (read
|
|
179
|
+
* is on :scope); layer cngx.tokens keeps the Material bridge winning. */
|
|
180
|
+
:where(.cngx-tooltip) {
|
|
181
|
+
--cngx-tooltip-transition-duration: var(--cngx-duration-fast);
|
|
182
|
+
}
|
|
183
|
+
|
|
172
184
|
/**
|
|
173
185
|
* Easing curve of the open / close transition.
|
|
174
186
|
* @group Motion
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# @cngx/common/timeline
|
|
2
|
+
|
|
3
|
+
Headless timeline core. This entry ships everything `<cngx-timeline>` composes but does not own: the grouping presenter, the row atoms (item, marker, connector), the projection and template slot directives, the marker-host DI contract, and the label/template config cascade. Reach for it directly when a row should render standalone without the organism, when an app-wide override (bucketing, marker template, labels) has to be provided, or when an ejected skin needs the brain without the styled component. For the styled, async-state-driven feed, use [`@cngx/ui/timeline`](../../ui/timeline/) - that README covers grouping modes, layout, skins and the body switch.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import {
|
|
9
|
+
CngxTimelineItem,
|
|
10
|
+
CngxTimelineTime,
|
|
11
|
+
createTimelineGrouping,
|
|
12
|
+
provideTimelineConfig,
|
|
13
|
+
} from '@cngx/common/timeline';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
A row is a terminal composable unit, not a fragment of the organism. It ships its own token SET rules, so it renders complete and density-correct with no `<cngx-timeline>` above it:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { Component } from '@angular/core';
|
|
22
|
+
import { CngxTimelineItem, CngxTimelineTime } from '@cngx/common/timeline';
|
|
23
|
+
import { CngxTime } from '@cngx/common/display';
|
|
24
|
+
|
|
25
|
+
@Component({
|
|
26
|
+
selector: 'app-example',
|
|
27
|
+
template: `
|
|
28
|
+
<cngx-timeline-item status="done" position="last">
|
|
29
|
+
<cngx-time cngxTimelineTime [date]="deployedAt" />
|
|
30
|
+
<p>Deployment finished</p>
|
|
31
|
+
</cngx-timeline-item>
|
|
32
|
+
`,
|
|
33
|
+
imports: [CngxTimelineItem, CngxTimelineTime, CngxTime],
|
|
34
|
+
})
|
|
35
|
+
export class ExampleComponent {
|
|
36
|
+
protected readonly deployedAt = new Date();
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Grouping presenter
|
|
41
|
+
|
|
42
|
+
`createTimelineGrouping` derives sorted date bands from a flat list. Pure derivation over one `linkedSignal`; nothing is synced, the input array is never mutated.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const grouping = createTimelineGrouping({
|
|
46
|
+
items: this.events, // () => readonly T[]
|
|
47
|
+
dateAccessor: (event) => event.occurredAt, // Date | string | number
|
|
48
|
+
groupBy: () => 'day', // 'day' | 'week' | 'month' | 'none' | TimelineGroupingFn<T>
|
|
49
|
+
direction: () => 'desc', // 'asc' | 'desc'
|
|
50
|
+
});
|
|
51
|
+
grouping.groups(); // Signal<readonly TimelineGroup<T>[]>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Every reactive knob is a zero-arg accessor, so a `Signal` or `input()` passes directly. Three properties make it the organism's only data path:
|
|
55
|
+
|
|
56
|
+
- **Defensive stable sort.** Input order is irrelevant; items sharing a timestamp keep their input order in both directions.
|
|
57
|
+
- **Local-calendar bucketing.** `day` / `week` / `month` read local date fields, so 23- and 25-hour DST days group as one day. Weeks start Monday. UTC or fiscal rules go through a `TimelineGroupingFn<T>` returning `{ key, start }`.
|
|
58
|
+
- **Append-stability.** Bands whose items are the same object references hand back the same band reference, keyed on identity rather than id - a refetch returns new objects and must not pin a band to a stale payload.
|
|
59
|
+
|
|
60
|
+
A `TimelineGroup<T>` carries `key` (stable, doubles as `@for` track and `aria-labelledby` seed), `start` (local bucket start) and `items`. It carries no label; formatting is a locale concern owned by the header slot or `labels.groupLabel`.
|
|
61
|
+
|
|
62
|
+
`CNGX_TIMELINE_GROUPING_FACTORY` resolves the presenter the organism builds bands with (type `CngxTimelineGroupingFactory`, defaults to `createTimelineGrouping`). Override at root for app-wide bucketing rules, or in `viewProviders` for one component. Wrap rather than replace: call `createTimelineGrouping` inside the override and post-process its `groups`.
|
|
63
|
+
|
|
64
|
+
## Row atoms
|
|
65
|
+
|
|
66
|
+
### CngxTimelineItem
|
|
67
|
+
|
|
68
|
+
One event: marker, rail segment, optional timestamp, projected body. Two independent state channels that compose - `status` is editorial (where the event sits in the history), `state` is whether this row's own data is in flight or failed. A failed row paints `rejected` and announces the failure without discarding the editorial status it returns to after a retry.
|
|
69
|
+
|
|
70
|
+
|Input|Type|Default|Description|
|
|
71
|
+
|-|-|-|-|
|
|
72
|
+
|`status`|`TimelineStatus \| undefined`|`undefined`|`'done' \| 'active' \| 'upcoming' \| 'rejected'`. Drives marker/rail colour and the SR status line|
|
|
73
|
+
|`state`|`CngxAsyncState<unknown> \| undefined`|`undefined`|This row's own async state; sets `aria-busy`, repaints as rejected on error|
|
|
74
|
+
|`position`|`TimelineConnectorPosition`|`'middle'`|Forwarded to the rail; `'last'` / `'only'` stop it|
|
|
75
|
+
|`item`|`unknown`|`undefined`|Payload handed to an app-wide `*cngxTimelineMarkerTpl` as `$implicit`|
|
|
76
|
+
|
|
77
|
+
The `TimelineStatus` vocabulary is deliberately narrow: it describes a history, not what the user may do. A timeline needing `disabled` or `current` is a stepper - see `@cngx/common/stepper`.
|
|
78
|
+
|
|
79
|
+
### CngxTimelineMarker and CngxTimelineConnector
|
|
80
|
+
|
|
81
|
+
Both usable standalone, both decorative and `aria-hidden` - the owning item carries the semantics.
|
|
82
|
+
|
|
83
|
+
|Component|Inputs|Notes|
|
|
84
|
+
|-|-|-|
|
|
85
|
+
|`<cngx-timeline-marker>`|`status`, `busy`|Status-coloured dot; projects a glyph, icon or avatar. `busy` pulses via `box-shadow` (no box change, suppressed under reduced motion)|
|
|
86
|
+
|`<cngx-timeline-connector>`|`status`, `position`|Rail segment. `upcoming` dashed, `rejected` danger-toned; `position: 'first' \| 'middle' \| 'last' \| 'only'` clips the ends, `'only'` renders nothing. Logical properties throughout, so RTL needs no override|
|
|
87
|
+
|
|
88
|
+
### Projection slots on the row
|
|
89
|
+
|
|
90
|
+
|Directive|Placement|
|
|
91
|
+
|-|-|
|
|
92
|
+
|`[cngxTimelineTime]`|Timestamp; positioned by the active mode raster. Pair with `<cngx-time>` from `@cngx/common/display`|
|
|
93
|
+
|`[cngxTimelineOpposite]`|Far side of the rail from the body. Keep it non-interactive - it projects ahead of the body, and dev mode warns on focusable content|
|
|
94
|
+
|`[cngxTimelineMarkerContent]`|Inside the marker dot; wins over the timeline-wide `*cngxTimelineMarkerTpl` (most-local-wins)|
|
|
95
|
+
|`[cngxTimelineContent]`|Explicit body marker; unslotted content lands in the body anyway|
|
|
96
|
+
|
|
97
|
+
## Template slots
|
|
98
|
+
|
|
99
|
+
Eight structural directives, consumed by the organism through the three-stage cascade: per-instance directive, then `CngxTimelineConfig.templates`, then built-in markup.
|
|
100
|
+
|
|
101
|
+
|Directive|Context|Config key|
|
|
102
|
+
|-|-|-|
|
|
103
|
+
|`CngxTimelineItemTpl` (`*cngxTimelineItem`)|`$implicit: T`, `index`, `first`, `last`, `group` (per group, not per timeline)|`item`|
|
|
104
|
+
|`CngxTimelineDateHeader`|`$implicit: TimelineGroup<T>`|`dateHeader`|
|
|
105
|
+
|`CngxTimelineMarkerTpl`|`$implicit: T`, `status`|`marker`|
|
|
106
|
+
|`CngxTimelineEmpty`|`$implicit: EmptyReason`|`empty`|
|
|
107
|
+
|`CngxTimelineError`|`$implicit: unknown`, `retry`|`error`|
|
|
108
|
+
|`CngxTimelineRetryButton`|`$implicit: () => void`|`retryButton`|
|
|
109
|
+
|`CngxTimelineLoadingTail`|none|`loadingTail`|
|
|
110
|
+
|`CngxTimelineSkeleton`|none|`skeleton`|
|
|
111
|
+
|
|
112
|
+
The three generic slots carry a type-pinning input: bind the same array the timeline renders (`[cngxTimelineItem]="events()"`) and the `let-` variables come out typed. The binding is never read at runtime - it is the `ngForOf` mechanism, and leaving it off falls back to `unknown`. The class is `CngxTimelineItemTpl` so it does not collide with the `CngxTimelineItem` component; the selector consumers write stays `cngxTimelineItem`.
|
|
113
|
+
|
|
114
|
+
## Marker host token
|
|
115
|
+
|
|
116
|
+
`CNGX_TIMELINE_MARKER_HOST` is how a row reaches the timeline-wide marker template. The organism is data-driven - the consumer writes `<cngx-timeline-item>` inside the row template themselves, so the organism has no handle on the marker. It provides `CngxTimelineMarkerHost` (`markerTpl: Signal<TemplateRef<...> | null>`, already resolved through the config cascade); the row injects it optionally and falls back to its own `[cngxTimelineMarkerContent]` projection. A token rather than a parent class keeps the row usable standalone.
|
|
117
|
+
|
|
118
|
+
## Configuration
|
|
119
|
+
|
|
120
|
+
Labels and app-wide slot templates, nothing behavioural. Resolution: per-instance input, then `provideTimelineConfigAt`, then `provideTimelineConfig`, then library defaults.
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
provideTimelineConfig(
|
|
124
|
+
withTimelineLabels({
|
|
125
|
+
retry: 'Erneut versuchen',
|
|
126
|
+
emptyFallback: 'Noch keine Ereignisse.',
|
|
127
|
+
groupLabel: (group, locale) => group.start.toLocaleDateString(locale, { dateStyle: 'medium' }),
|
|
128
|
+
}),
|
|
129
|
+
withTimelineTemplates({ empty: myEmptyTemplate }),
|
|
130
|
+
);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- Defaults are English; a missing translation shows English text, never a blank surface. `labels.status` merges key by key, so renaming one status keeps the other three.
|
|
134
|
+
- `provideTimelineConfigAt(...)` returns `Provider[]` for `viewProviders` and merges onto the enclosing config, so a region re-phrases one label without resetting the rest.
|
|
135
|
+
- `injectTimelineConfig()` reads the resolved config in an injection context; `CNGX_TIMELINE_CONFIG` is the raw token.
|
|
136
|
+
- `CngxTimelineLabels` covers `timelineRegion`, `retry`, `errorFallback`, `emptyFallback`, `loading`, `refreshing`, `itemBusy`, `itemErrorFallback`, the `status` map and `groupLabel`. `groupLabel` receives the app locale as its second argument and re-runs when `CNGX_LOCALE` switches.
|
|
137
|
+
|
|
138
|
+
## Accessibility
|
|
139
|
+
|
|
140
|
+
What the headless layer contributes, before any organism ARIA:
|
|
141
|
+
|
|
142
|
+
- Marker and connector are `aria-hidden`. Colour is never the only channel: the status reaches assistive tech through a screen-reader-only line on the item, fed from `labels.status`, rendered only while it has something to say.
|
|
143
|
+
- `aria-busy` on the item is a `computed()` over the row's own `state`, not the list's.
|
|
144
|
+
- A failed row paints `rejected`, announces it (the announcement always matches the paint), and renders a visible inline error from `labels.itemErrorFallback`. Both read as row content in DOM order - the host has no role, so `aria-describedby` would resolve nowhere.
|
|
145
|
+
- Dev mode warns once per row when `[cngxTimelineOpposite]` contains focusable content: the slot projects ahead of the body, so a control there takes focus before the row it belongs to.
|
|
146
|
+
- Every string a surface can render without a consumer slot is localisable through `withTimelineLabels`.
|
|
147
|
+
|
|
148
|
+
## See Also
|
|
149
|
+
|
|
150
|
+
- [`@cngx/ui/timeline`](../../ui/timeline/) - the styled organism: grouping inputs, layout, skins, async body, Material bridge
|
|
151
|
+
- [`@cngx/common/stepper`](../stepper/) - guided process; timeline is history
|
|
152
|
+
- [`CngxTime`](../display/) - relative timestamp formatting for `[cngxTimelineTime]`
|
|
153
|
+
- [`CngxAsyncState`](../../core/) - the per-row `[state]` contract
|
|
154
|
+
- [API on compodocx](https://cngxjs.github.io/cngx/)
|
|
155
|
+
- Tests: `projects/common/timeline/*.spec.ts`
|