@cngx/common 0.0.1-rc.0 → 0.1.0-rc.1
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/a11y/README.md +13 -16
- package/card/README.md +2 -21
- package/chart/README.md +5 -8
- package/data/README.md +45 -47
- package/dialog/README.md +12 -15
- package/display/README.md +5 -9
- package/fesm2022/cngx-common-a11y.mjs +164 -51
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +157 -69
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +389 -92
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +311 -151
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +167 -29
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +445 -110
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2059 -435
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +188 -31
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +711 -90
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +1479 -73
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1144 -85
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +5 -5
- package/layout/README.md +2 -2
- package/package.json +7 -6
- package/popover/README.md +8 -34
- package/stepper/README.md +69 -8
- package/tabs/README.md +6 -6
- package/theming/components/cngx-async.css +74 -0
- package/theming/components/cngx-backdrop.css +73 -0
- package/theming/components/cngx-badge.css +340 -0
- package/theming/components/cngx-bottom-sheet.css +201 -0
- package/theming/components/cngx-button-toggle.css +99 -0
- package/theming/components/cngx-dialog.css +358 -0
- package/theming/components/cngx-divider.css +145 -0
- package/theming/components/cngx-listbox.css +220 -0
- package/theming/components/cngx-menu.css +371 -0
- package/theming/components/cngx-ripple.css +116 -0
- package/theming/components/cngx-tooltip.css +265 -0
- package/theming/system-tokens.css +24 -0
- package/types/cngx-common-a11y.d.ts +159 -38
- package/types/cngx-common-card.d.ts +137 -22
- package/types/cngx-common-chart.d.ts +337 -40
- package/types/cngx-common-data.d.ts +277 -45
- package/types/cngx-common-dialog.d.ts +162 -22
- package/types/cngx-common-display.d.ts +422 -78
- package/types/cngx-common-interactive.d.ts +1880 -305
- package/types/cngx-common-layout.d.ts +191 -28
- package/types/cngx-common-popover.d.ts +632 -87
- package/types/cngx-common-stepper.d.ts +1360 -45
- package/types/cngx-common-tabs.d.ts +1139 -56
- package/types/cngx-common.d.ts +1 -1
- package/README.md +0 -18
|
@@ -14,26 +14,41 @@ import { CngxFocusTrap } from '@cngx/common/a11y';
|
|
|
14
14
|
* attribute, preventing focus and interaction behind the backdrop.
|
|
15
15
|
* This is critical for a11y in modal/drawer overlays.
|
|
16
16
|
*
|
|
17
|
-
* The directive is purely behavioral
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* The directive is purely behavioral - it toggles the
|
|
18
|
+
* `.cngx-backdrop--visible` class and `aria-hidden` attribute. Visual
|
|
19
|
+
* styling is opt-in: either consume the shipped default stylesheet or
|
|
20
|
+
* provide your own.
|
|
20
21
|
*
|
|
21
|
-
* ### Drawer backdrop
|
|
22
|
+
* ### Drawer backdrop with shipped defaults (recommended)
|
|
22
23
|
* ```html
|
|
23
24
|
* <div cngxDrawer #drawer="cngxDrawer">
|
|
24
25
|
* <div [cngxBackdrop]="drawer.opened()" (backdropClick)="drawer.close()"
|
|
25
|
-
* class="
|
|
26
|
+
* class="cngx-backdrop"></div>
|
|
26
27
|
* <nav [cngxDrawerPanel]="drawer">…</nav>
|
|
27
28
|
* <main [cngxDrawerContent]="drawer">…</main>
|
|
28
29
|
* </div>
|
|
29
30
|
* ```
|
|
31
|
+
* ```css
|
|
32
|
+
* @import '@cngx/common/theming/components/cngx-backdrop.css';
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* Token surface (Three-Tier-Override):
|
|
36
|
+
* - `--cngx-backdrop-bg` (scrim color, default `oklch(0 0 0 / 0.5)`)
|
|
37
|
+
* - `--cngx-backdrop-transition-duration` (default `200ms`)
|
|
38
|
+
*
|
|
39
|
+
* ### Custom styling (no opt-in class)
|
|
40
|
+
* If the shipped defaults don't fit, omit the `.cngx-backdrop` class and
|
|
41
|
+
* style your own host class - the directive still toggles
|
|
42
|
+
* `.cngx-backdrop--visible` on the host element.
|
|
30
43
|
*
|
|
31
|
-
*
|
|
44
|
+
* ```html
|
|
45
|
+
* <div [cngxBackdrop]="visible()" class="my-backdrop"></div>
|
|
46
|
+
* ```
|
|
32
47
|
* ```css
|
|
33
48
|
* .my-backdrop {
|
|
34
49
|
* position: fixed;
|
|
35
50
|
* inset: 0;
|
|
36
|
-
* background:
|
|
51
|
+
* background: rgba(0, 0, 0, 0.3);
|
|
37
52
|
* opacity: 0;
|
|
38
53
|
* pointer-events: none;
|
|
39
54
|
* transition: opacity 0.25s ease;
|
|
@@ -43,6 +58,13 @@ import { CngxFocusTrap } from '@cngx/common/a11y';
|
|
|
43
58
|
* pointer-events: auto;
|
|
44
59
|
* }
|
|
45
60
|
* ```
|
|
61
|
+
*
|
|
62
|
+
* @category common/layout
|
|
63
|
+
* @wcag AA
|
|
64
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/drawer/backdrop.directive.ts
|
|
65
|
+
* @since 0.1.0
|
|
66
|
+
* @relatedTo CngxDrawer, CngxDrawerPanel, CngxScrollLock
|
|
67
|
+
* <example-url>http://localhost:4200/#/common/layout/backdrop/overlay-with-inert</example-url>
|
|
46
68
|
*/
|
|
47
69
|
class CngxBackdrop {
|
|
48
70
|
/** Whether the backdrop is visible and siblings are inert. */
|
|
@@ -97,7 +119,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
97
119
|
* (internal state via `open()` / `close()` / `toggle()`) modes.
|
|
98
120
|
*
|
|
99
121
|
* Child directives (`CngxDrawerPanel`, `CngxDrawerContent`) receive a
|
|
100
|
-
* reference to this directive via an explicit input
|
|
122
|
+
* reference to this directive via an explicit input - no ancestor injection.
|
|
101
123
|
*
|
|
102
124
|
* ### Uncontrolled
|
|
103
125
|
* ```html
|
|
@@ -115,14 +137,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
115
137
|
* …
|
|
116
138
|
* </div>
|
|
117
139
|
* ```
|
|
140
|
+
*
|
|
141
|
+
* @category common/layout
|
|
142
|
+
* @docsKind primary
|
|
143
|
+
* @wcag AA
|
|
144
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/drawer/drawer.directive.ts
|
|
145
|
+
* @since 0.1.0
|
|
146
|
+
* @relatedTo CngxDrawerPanel, CngxDrawerContent, CngxBackdrop, CngxScrollLock
|
|
147
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/basic-scroll-lock-backdrop</example-url>
|
|
148
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/controlled-mode</example-url>
|
|
149
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/direction-all-four-sides</example-url>
|
|
150
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/events-openedchange-closed</example-url>
|
|
151
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/mode-over-push-side</example-url>
|
|
152
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/pattern-consumer-wiring</example-url>
|
|
118
153
|
*/
|
|
119
154
|
class CngxDrawer {
|
|
120
|
-
/** @internal Host element ref
|
|
155
|
+
/** @internal Host element ref - used by `CngxDrawerPanel` for click-outside containment. */
|
|
121
156
|
elementRef = inject((ElementRef));
|
|
122
157
|
/** Controlled opened state. When bound, takes precedence over internal state. */
|
|
123
158
|
openedInput = input(undefined, { ...(ngDevMode ? { debugName: "openedInput" } : /* istanbul ignore next */ {}), alias: 'cngxDrawerOpened' });
|
|
124
159
|
openedState = signal(false, ...(ngDevMode ? [{ debugName: "openedState" }] : /* istanbul ignore next */ []));
|
|
125
|
-
/** Resolved opened state
|
|
160
|
+
/** Resolved opened state - controlled input wins over internal state. */
|
|
126
161
|
opened = computed(() => this.openedInput() ?? this.openedState(), ...(ngDevMode ? [{ debugName: "opened" }] : /* istanbul ignore next */ []));
|
|
127
162
|
/** Emitted when the opened state changes. Wire to a signal for two-way binding. */
|
|
128
163
|
openedChange = output();
|
|
@@ -169,9 +204,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
169
204
|
|
|
170
205
|
/**
|
|
171
206
|
* The sliding panel of a drawer. Reads its open state from an explicit
|
|
172
|
-
* `[cngxDrawerPanel]` reference
|
|
207
|
+
* `[cngxDrawerPanel]` reference - no ancestor injection.
|
|
173
208
|
*
|
|
174
|
-
* Composes `CngxFocusTrap` as a `hostDirective`
|
|
209
|
+
* Composes `CngxFocusTrap` as a `hostDirective` - the consumer controls
|
|
175
210
|
* the `[enabled]` and `[autoFocus]` inputs from the template.
|
|
176
211
|
*
|
|
177
212
|
* Optionally closes the drawer when the user clicks outside the panel
|
|
@@ -183,6 +218,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
183
218
|
* <a href="/home">Home</a>
|
|
184
219
|
* </nav>
|
|
185
220
|
* ```
|
|
221
|
+
*
|
|
222
|
+
* @category common/layout
|
|
223
|
+
* @wcag AA
|
|
224
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/drawer/drawer-panel.directive.ts
|
|
225
|
+
* @since 0.1.0
|
|
226
|
+
* @relatedTo CngxDrawer, CngxDrawerContent, CngxFocusTrap
|
|
227
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/basic-scroll-lock-backdrop</example-url>
|
|
228
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/controlled-mode</example-url>
|
|
229
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/direction-all-four-sides</example-url>
|
|
230
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/events-openedchange-closed</example-url>
|
|
231
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/mode-over-push-side</example-url>
|
|
232
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/pattern-consumer-wiring</example-url>
|
|
186
233
|
*/
|
|
187
234
|
class CngxDrawerPanel {
|
|
188
235
|
/** Reference to the parent `CngxDrawer` state owner. */
|
|
@@ -191,9 +238,9 @@ class CngxDrawerPanel {
|
|
|
191
238
|
position = input('left', ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
192
239
|
/**
|
|
193
240
|
* How the panel interacts with the content area:
|
|
194
|
-
* - `'over'` (default)
|
|
195
|
-
* - `'push'`
|
|
196
|
-
* - `'side'`
|
|
241
|
+
* - `'over'` (default) - overlays content (absolute positioned)
|
|
242
|
+
* - `'push'` - pushes content aside (content gets margin)
|
|
243
|
+
* - `'side'` - always visible, no toggle behavior
|
|
197
244
|
*/
|
|
198
245
|
mode = input('over', ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
|
|
199
246
|
/** Whether clicking outside the panel closes the drawer. */
|
|
@@ -202,7 +249,7 @@ class CngxDrawerPanel {
|
|
|
202
249
|
isOpen = computed(() => this.mode() === 'side' || this.drawerRef().opened(), ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
203
250
|
constructor() {
|
|
204
251
|
const doc = inject(DOCUMENT);
|
|
205
|
-
// Hit-test against the container, not the panel
|
|
252
|
+
// Hit-test against the container, not the panel - toggle buttons and backdrops
|
|
206
253
|
// sit inside the container and must not count as outside clicks.
|
|
207
254
|
fromEvent(doc, 'click')
|
|
208
255
|
.pipe(takeUntilDestroyed())
|
|
@@ -252,6 +299,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
252
299
|
* Page content
|
|
253
300
|
* </main>
|
|
254
301
|
* ```
|
|
302
|
+
*
|
|
303
|
+
* @category common/layout
|
|
304
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/drawer/drawer-content.directive.ts
|
|
305
|
+
* @since 0.1.0
|
|
306
|
+
* @relatedTo CngxDrawer, CngxDrawerPanel
|
|
307
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/basic-scroll-lock-backdrop</example-url>
|
|
308
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/controlled-mode</example-url>
|
|
309
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/direction-all-four-sides</example-url>
|
|
310
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/events-openedchange-closed</example-url>
|
|
311
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/mode-over-push-side</example-url>
|
|
312
|
+
* <example-url>http://localhost:4200/#/common/layout/drawer/pattern-consumer-wiring</example-url>
|
|
255
313
|
*/
|
|
256
314
|
class CngxDrawerContent {
|
|
257
315
|
/** Reference to the parent `CngxDrawer` state owner. */
|
|
@@ -307,6 +365,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
307
365
|
* Observed within a scrollable parent
|
|
308
366
|
* </div>
|
|
309
367
|
* ```
|
|
368
|
+
*
|
|
369
|
+
* @category common/layout
|
|
370
|
+
* @docsKind primary
|
|
371
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/observers/intersection-observer.directive.ts
|
|
372
|
+
* @since 0.1.0
|
|
373
|
+
* @relatedTo CngxResizeObserver, CngxMediaQuery, CngxInfiniteScroll, CngxScrollSpy
|
|
374
|
+
* <example-url>http://localhost:4200/#/common/layout/intersection-observer/scroll-sentinel</example-url>
|
|
310
375
|
*/
|
|
311
376
|
class CngxIntersectionObserver {
|
|
312
377
|
/** CSS selector for the scroll container root. `null` (default) uses the viewport. */
|
|
@@ -389,6 +454,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
389
454
|
* @if (dark.matches()) { <span>Dark mode active</span> }
|
|
390
455
|
* </div>
|
|
391
456
|
* ```
|
|
457
|
+
*
|
|
458
|
+
* @category common/layout
|
|
459
|
+
* @docsKind primary
|
|
460
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/observers/media-query.directive.ts
|
|
461
|
+
* @since 0.1.0
|
|
462
|
+
* @relatedTo CngxResizeObserver, CngxIntersectionObserver
|
|
463
|
+
* <example-url>http://localhost:4200/#/common/layout/media-query/viewport-breakpoints</example-url>
|
|
392
464
|
*/
|
|
393
465
|
class CngxMediaQuery {
|
|
394
466
|
/** The CSS media query string to evaluate. */
|
|
@@ -446,6 +518,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
446
518
|
* readonly ro = viewChild(CngxResizeObserver);
|
|
447
519
|
* readonly columns = computed(() => (this.ro()?.width() ?? 0) > 600 ? 3 : 1);
|
|
448
520
|
* ```
|
|
521
|
+
*
|
|
522
|
+
* @category common/layout
|
|
523
|
+
* @docsKind primary
|
|
524
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/observers/resize-observer.directive.ts
|
|
525
|
+
* @since 0.1.0
|
|
526
|
+
* @relatedTo CngxIntersectionObserver, CngxMediaQuery
|
|
527
|
+
* <example-url>http://localhost:4200/#/common/layout/resize-observer/live-size</example-url>
|
|
449
528
|
*/
|
|
450
529
|
class CngxResizeObserver {
|
|
451
530
|
/** Which box model to observe. `'content-box'` (default), `'border-box'`, or `'device-pixel-content-box'`. */
|
|
@@ -489,8 +568,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
489
568
|
}]
|
|
490
569
|
}], ctorParameters: () => [], propDecorators: { box: [{ type: i0.Input, args: [{ isSignal: true, alias: "box", required: false }] }], resize: [{ type: i0.Output, args: ["resize"] }] } });
|
|
491
570
|
|
|
492
|
-
/**
|
|
571
|
+
/**
|
|
572
|
+
* Shared ref-count for scroll lock instances on the same document.
|
|
573
|
+
*
|
|
574
|
+
* @internal
|
|
575
|
+
*/
|
|
493
576
|
const lockCounts = new WeakMap();
|
|
577
|
+
/** @internal */
|
|
494
578
|
function acquireScrollLock(html) {
|
|
495
579
|
const count = lockCounts.get(html) ?? 0;
|
|
496
580
|
if (count === 0) {
|
|
@@ -501,6 +585,7 @@ function acquireScrollLock(html) {
|
|
|
501
585
|
}
|
|
502
586
|
lockCounts.set(html, count + 1);
|
|
503
587
|
}
|
|
588
|
+
/** @internal */
|
|
504
589
|
function releaseScrollLock(html) {
|
|
505
590
|
const count = lockCounts.get(html) ?? 0;
|
|
506
591
|
if (count <= 1) {
|
|
@@ -521,7 +606,7 @@ function releaseScrollLock(html) {
|
|
|
521
606
|
* prevent layout shift when the scrollbar disappears. Restores original
|
|
522
607
|
* values when all lock instances are released.
|
|
523
608
|
*
|
|
524
|
-
* Multiple instances are ref-counted
|
|
609
|
+
* Multiple instances are ref-counted - the original styles are only
|
|
525
610
|
* restored when the last lock is released.
|
|
526
611
|
*
|
|
527
612
|
* ### With a drawer
|
|
@@ -535,6 +620,13 @@ function releaseScrollLock(html) {
|
|
|
535
620
|
* ```html
|
|
536
621
|
* <div [cngxScrollLock]="isModalOpen()">…</div>
|
|
537
622
|
* ```
|
|
623
|
+
*
|
|
624
|
+
* @category common/layout
|
|
625
|
+
* @docsKind primary
|
|
626
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/scroll/scroll-lock.directive.ts
|
|
627
|
+
* @since 0.1.0
|
|
628
|
+
* @relatedTo CngxDrawer, CngxBackdrop
|
|
629
|
+
* <example-url>http://localhost:4200/#/common/layout/scroll-lock/toggle</example-url>
|
|
538
630
|
*/
|
|
539
631
|
class CngxScrollLock {
|
|
540
632
|
/** Whether scroll lock is active. */
|
|
@@ -609,13 +701,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
609
701
|
* }
|
|
610
702
|
* </div>
|
|
611
703
|
* ```
|
|
704
|
+
*
|
|
705
|
+
* @category common/layout
|
|
706
|
+
* @docsKind primary
|
|
707
|
+
* @wcag AA
|
|
708
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/text/skeleton.directive.ts
|
|
709
|
+
* @since 0.1.0
|
|
710
|
+
* @relatedTo CngxTruncate, CngxExpandableText, CngxHighlight
|
|
711
|
+
* <example-url>http://localhost:4200/#/common/layout/skeleton/basic-skeleton</example-url>
|
|
712
|
+
* <example-url>http://localhost:4200/#/common/layout/skeleton/skeleton-container</example-url>
|
|
612
713
|
*/
|
|
613
714
|
class CngxSkeleton {
|
|
614
715
|
/** Controls the loading state. */
|
|
615
716
|
skeleton = input(false, { ...(ngDevMode ? { debugName: "skeleton" } : /* istanbul ignore next */ {}), alias: 'cngxSkeleton' });
|
|
616
717
|
/** Enables the `.cngx-skeleton--shimmer` class (respects `prefers-reduced-motion`). */
|
|
617
718
|
shimmer = input(true, ...(ngDevMode ? [{ debugName: "shimmer" }] : /* istanbul ignore next */ []));
|
|
618
|
-
/** Repeat count
|
|
719
|
+
/** Repeat count - exposed via the `indices()` signal for `@for` rendering. */
|
|
619
720
|
count = input(1, ...(ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []));
|
|
620
721
|
prefersReducedMotion;
|
|
621
722
|
constructor() {
|
|
@@ -634,7 +735,7 @@ class CngxSkeleton {
|
|
|
634
735
|
loading = computed(() => this.skeleton(), ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
635
736
|
/** Array of indices for `@for` rendering of repeated skeleton elements. */
|
|
636
737
|
indices = computed(() => Array.from({ length: this.count() }, (_, i) => i), ...(ngDevMode ? [{ debugName: "indices" }] : /* istanbul ignore next */ []));
|
|
637
|
-
/** @internal
|
|
738
|
+
/** @internal - shimmer class condition. */
|
|
638
739
|
showShimmer = computed(() => this.loading() && this.shimmer() && !this.prefersReducedMotion(), ...(ngDevMode ? [{ debugName: "showShimmer" }] : /* istanbul ignore next */ []));
|
|
639
740
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSkeleton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
640
741
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxSkeleton, isStandalone: true, selector: "[cngxSkeleton]", inputs: { skeleton: { classPropertyName: "skeleton", publicName: "cngxSkeleton", isSignal: true, isRequired: false, transformFunction: null }, shimmer: { classPropertyName: "shimmer", publicName: "shimmer", isSignal: true, isRequired: false, transformFunction: null }, count: { classPropertyName: "count", publicName: "count", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-skeleton--loading": "loading()", "class.cngx-skeleton--shimmer": "showShimmer()", "attr.aria-busy": "loading() || null" }, classAttribute: "cngx-skeleton" }, exportAs: ["cngxSkeleton"], ngImport: i0 });
|
|
@@ -696,6 +797,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
696
797
|
* (loadMore)="loadMore()">
|
|
697
798
|
* </div>
|
|
698
799
|
* ```
|
|
800
|
+
*
|
|
801
|
+
* @category common/layout
|
|
802
|
+
* @docsKind primary
|
|
803
|
+
* @wcag AA
|
|
804
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/scroll/infinite-scroll.directive.ts
|
|
805
|
+
* @since 0.1.0
|
|
806
|
+
* @relatedTo CngxIntersectionObserver, CngxScrollSpy, CngxStickyHeader
|
|
807
|
+
* <example-url>http://localhost:4200/#/common/layout/infinite-scroll/scrollable-list</example-url>
|
|
699
808
|
*/
|
|
700
809
|
class CngxInfiniteScroll {
|
|
701
810
|
/** IntersectionObserver threshold (0–1). */
|
|
@@ -789,9 +898,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
789
898
|
* ```css
|
|
790
899
|
* .cngx-sticky--active { box-shadow: 0 2px 4px rgba(0,0,0,.1); }
|
|
791
900
|
* ```
|
|
901
|
+
*
|
|
902
|
+
* @category common/layout
|
|
903
|
+
* @docsKind primary
|
|
904
|
+
* @wcag AA
|
|
905
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/scroll/sticky-header.directive.ts
|
|
906
|
+
* @since 0.1.0
|
|
907
|
+
* @relatedTo CngxScrollSpy, CngxIntersectionObserver
|
|
908
|
+
* <example-url>http://localhost:4200/#/common/layout/sticky-header/sticky-header-with-shadow</example-url>
|
|
792
909
|
*/
|
|
793
910
|
class CngxStickyHeader {
|
|
794
|
-
/** Intersection threshold
|
|
911
|
+
/** Intersection threshold - `0` triggers as soon as the sentinel leaves. */
|
|
795
912
|
threshold = input(0, ...(ngDevMode ? [{ debugName: "threshold" }] : /* istanbul ignore next */ []));
|
|
796
913
|
/** Emitted when the sticky state changes. */
|
|
797
914
|
stickyChange = output();
|
|
@@ -802,7 +919,7 @@ class CngxStickyHeader {
|
|
|
802
919
|
doc = inject(DOCUMENT);
|
|
803
920
|
constructor() {
|
|
804
921
|
const destroyRef = inject(DestroyRef);
|
|
805
|
-
// IntersectionObserver sentinel pattern
|
|
922
|
+
// IntersectionObserver sentinel pattern - host is stuck once the 1px sentinel leaves the viewport.
|
|
806
923
|
afterNextRender(() => {
|
|
807
924
|
const host = this.el.nativeElement;
|
|
808
925
|
const sentinel = this.doc.createElement('div');
|
|
@@ -863,6 +980,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
863
980
|
* <section id="features">…</section>
|
|
864
981
|
* <section id="pricing">…</section>
|
|
865
982
|
* ```
|
|
983
|
+
*
|
|
984
|
+
* @category common/layout
|
|
985
|
+
* @docsKind primary
|
|
986
|
+
* @wcag AA
|
|
987
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/scroll/scroll-spy.directive.ts
|
|
988
|
+
* @since 0.1.0
|
|
989
|
+
* @relatedTo CngxIntersectionObserver, CngxStickyHeader, CngxInfiniteScroll
|
|
990
|
+
* <example-url>http://localhost:4200/#/common/layout/scroll-spy/scroll-based-navigation</example-url>
|
|
866
991
|
*/
|
|
867
992
|
class CngxScrollSpy {
|
|
868
993
|
/** IDs of the sections to observe. */
|
|
@@ -915,7 +1040,7 @@ class CngxScrollSpy {
|
|
|
915
1040
|
.map((id) => this.doc.getElementById(id))
|
|
916
1041
|
.filter((el) => el !== null);
|
|
917
1042
|
if (elements.length === 0) {
|
|
918
|
-
return;
|
|
1043
|
+
return undefined;
|
|
919
1044
|
}
|
|
920
1045
|
const resolvedRoot = rootSelector ? this.doc.querySelector(rootSelector) : null;
|
|
921
1046
|
const observer = new IntersectionObserver((entries) => {
|
|
@@ -963,9 +1088,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
963
1088
|
* <button (click)="expanded.set(!expanded())"
|
|
964
1089
|
* [attr.aria-expanded]="expanded()">
|
|
965
1090
|
* {{ expanded() ? 'Show less' : 'Show more' }}
|
|
966
|
-
* </button>
|
|
967
|
-
* }
|
|
1091
|
+
* </button> * }
|
|
968
1092
|
* ```
|
|
1093
|
+
*
|
|
1094
|
+
* @category common/layout
|
|
1095
|
+
* @docsKind primary
|
|
1096
|
+
* @wcag AA
|
|
1097
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/text/truncate.directive.ts
|
|
1098
|
+
* @since 0.1.0
|
|
1099
|
+
* @relatedTo CngxExpandableText, CngxExpandableToggle, CngxHighlight
|
|
1100
|
+
* <example-url>http://localhost:4200/#/common/layout/truncate/short-text-no-toggle</example-url>
|
|
1101
|
+
* <example-url>http://localhost:4200/#/common/layout/truncate/truncated-text-with-toggle</example-url>
|
|
969
1102
|
*/
|
|
970
1103
|
class CngxTruncate {
|
|
971
1104
|
/** Maximum number of visible lines when collapsed. */
|
|
@@ -978,7 +1111,7 @@ class CngxTruncate {
|
|
|
978
1111
|
el = inject((ElementRef));
|
|
979
1112
|
observer = null;
|
|
980
1113
|
rafHandle = null;
|
|
981
|
-
// null strips the host binding
|
|
1114
|
+
// null strips the host binding - preferred over an empty string for -webkit-line-clamp.
|
|
982
1115
|
/** @internal */
|
|
983
1116
|
clampValue = () => (this.expanded() ? null : String(this.lines()));
|
|
984
1117
|
/** @internal */
|
|
@@ -1014,7 +1147,7 @@ class CngxTruncate {
|
|
|
1014
1147
|
}
|
|
1015
1148
|
/**
|
|
1016
1149
|
* Compares `scrollHeight` vs `clientHeight` to detect overflow.
|
|
1017
|
-
* Only meaningful when collapsed
|
|
1150
|
+
* Only meaningful when collapsed - when expanded, the last known
|
|
1018
1151
|
* clamped state is preserved (can't measure hypothetical clamp height
|
|
1019
1152
|
* while showing full content).
|
|
1020
1153
|
*/
|
|
@@ -1047,7 +1180,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1047
1180
|
* Search-text highlighting via `<mark>` elements.
|
|
1048
1181
|
*
|
|
1049
1182
|
* Walks `TEXT_NODE` children of the host element, splits at match boundaries,
|
|
1050
|
-
* and wraps matched portions in `<mark>` elements. No `innerHTML`
|
|
1183
|
+
* and wraps matched portions in `<mark>` elements. No `innerHTML` - safe by
|
|
1051
1184
|
* construction. The `<mark>` element has correct native SR semantics (announced
|
|
1052
1185
|
* as "highlighted" in most screen readers).
|
|
1053
1186
|
*
|
|
@@ -1066,6 +1199,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1066
1199
|
* CamelCase matters here.
|
|
1067
1200
|
* </p>
|
|
1068
1201
|
* ```
|
|
1202
|
+
*
|
|
1203
|
+
* @category common/layout
|
|
1204
|
+
* @docsKind primary
|
|
1205
|
+
* @wcag AA
|
|
1206
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/text/highlight.directive.ts
|
|
1207
|
+
* @since 0.1.0
|
|
1208
|
+
* @relatedTo CngxTruncate, CngxExpandableText
|
|
1209
|
+
* <example-url>http://localhost:4200/#/common/layout/highlight/live-search-highlighting</example-url>
|
|
1210
|
+
* <example-url>http://localhost:4200/#/common/layout/highlight/multiple-paragraphs</example-url>
|
|
1069
1211
|
*/
|
|
1070
1212
|
class CngxHighlight {
|
|
1071
1213
|
/** The search term to highlight. Empty string clears all highlights. */
|
|
@@ -1077,7 +1219,7 @@ class CngxHighlight {
|
|
|
1077
1219
|
matchCount = this.matchCountState.asReadonly();
|
|
1078
1220
|
el = inject((ElementRef));
|
|
1079
1221
|
doc = inject(DOCUMENT);
|
|
1080
|
-
/** Snapshot of original child nodes
|
|
1222
|
+
/** Snapshot of original child nodes - restored before each re-highlight. */
|
|
1081
1223
|
originalNodes = null;
|
|
1082
1224
|
initialized = signal(false, ...(ngDevMode ? [{ debugName: "initialized" }] : /* istanbul ignore next */ []));
|
|
1083
1225
|
constructor() {
|
|
@@ -1085,7 +1227,7 @@ class CngxHighlight {
|
|
|
1085
1227
|
afterNextRender(() => {
|
|
1086
1228
|
this.initialized.set(true);
|
|
1087
1229
|
});
|
|
1088
|
-
// matchCountState is written via untracked path
|
|
1230
|
+
// matchCountState is written via untracked path - re-entering the effect would loop.
|
|
1089
1231
|
effect(() => {
|
|
1090
1232
|
const term = this.term();
|
|
1091
1233
|
const caseSensitive = this.caseSensitive();
|
|
@@ -1193,6 +1335,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1193
1335
|
* </ng-template>
|
|
1194
1336
|
* </cngx-expandable-text>
|
|
1195
1337
|
* ```
|
|
1338
|
+
*
|
|
1339
|
+
* @category common/layout
|
|
1340
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/text/expandable-text.ts
|
|
1341
|
+
* @since 0.1.0
|
|
1342
|
+
* @relatedTo CngxExpandableText, CngxTruncate
|
|
1196
1343
|
*/
|
|
1197
1344
|
class CngxExpandableToggle {
|
|
1198
1345
|
templateRef;
|
|
@@ -1216,7 +1363,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1216
1363
|
* a "Show more" / "Show less" button when the content is actually clamped.
|
|
1217
1364
|
* Handles `aria-expanded` automatically.
|
|
1218
1365
|
*
|
|
1219
|
-
* Supports custom toggle templates via `ng-template[cngxExpandableToggle]`
|
|
1366
|
+
* Supports custom toggle templates via `ng-template[cngxExpandableToggle]` -
|
|
1220
1367
|
* use for icon buttons or any custom UI instead of plain text labels.
|
|
1221
1368
|
*
|
|
1222
1369
|
* ### Basic usage
|
|
@@ -1242,6 +1389,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1242
1389
|
* </ng-template>
|
|
1243
1390
|
* </cngx-expandable-text>
|
|
1244
1391
|
* ```
|
|
1392
|
+
*
|
|
1393
|
+
* @category common/layout
|
|
1394
|
+
* @docsKind primary
|
|
1395
|
+
* @wcag AA
|
|
1396
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/text/expandable-text.ts
|
|
1397
|
+
* @since 0.1.0
|
|
1398
|
+
* @relatedTo CngxTruncate, CngxExpandableToggle, CngxHighlight
|
|
1399
|
+
* <example-url>http://localhost:4200/#/common/layout/expandable-text/auto-toggle</example-url>
|
|
1400
|
+
* <example-url>http://localhost:4200/#/common/layout/expandable-text/custom-labels</example-url>
|
|
1401
|
+
* <example-url>http://localhost:4200/#/common/layout/expandable-text/custom-toggle-template</example-url>
|
|
1245
1402
|
*/
|
|
1246
1403
|
class CngxExpandableText {
|
|
1247
1404
|
/** Maximum visible lines when collapsed. */
|