@cngx/common 0.1.0-rc.6 → 0.1.0-rc.7

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 (62) hide show
  1. package/chart/README.md +85 -0
  2. package/command/README.md +157 -0
  3. package/data/README.md +23 -0
  4. package/fesm2022/cngx-common-a11y.mjs +247 -85
  5. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  6. package/fesm2022/cngx-common-audio.mjs +37 -37
  7. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  8. package/fesm2022/cngx-common-card.mjs +13 -9
  9. package/fesm2022/cngx-common-card.mjs.map +1 -1
  10. package/fesm2022/cngx-common-chart.mjs +3404 -1392
  11. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  12. package/fesm2022/cngx-common-command.mjs +144 -0
  13. package/fesm2022/cngx-common-command.mjs.map +1 -0
  14. package/fesm2022/cngx-common-data.mjs +304 -213
  15. package/fesm2022/cngx-common-data.mjs.map +1 -1
  16. package/fesm2022/cngx-common-dialog.mjs +369 -100
  17. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  18. package/fesm2022/cngx-common-display.mjs +138 -24
  19. package/fesm2022/cngx-common-display.mjs.map +1 -1
  20. package/fesm2022/cngx-common-interactive.mjs +1089 -459
  21. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  22. package/fesm2022/cngx-common-layout.mjs +113 -61
  23. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  24. package/fesm2022/cngx-common-popover.mjs +430 -54
  25. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  26. package/fesm2022/cngx-common-stepper.mjs +107 -49
  27. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  28. package/fesm2022/cngx-common-tabs.mjs +1170 -752
  29. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  30. package/fesm2022/cngx-common-timeline.mjs +1086 -0
  31. package/fesm2022/cngx-common-timeline.mjs.map +1 -0
  32. package/fesm2022/cngx-common.mjs +2 -2
  33. package/fesm2022/cngx-common.mjs.map +1 -1
  34. package/package.json +11 -1
  35. package/stepper/README.md +1 -1
  36. package/theming/components/cngx-accordion.css +3 -0
  37. package/theming/components/cngx-badge.css +22 -0
  38. package/theming/components/cngx-bottom-sheet.css +14 -2
  39. package/theming/components/cngx-breadcrumb.css +8 -0
  40. package/theming/components/cngx-button-toggle.css +44 -2
  41. package/theming/components/cngx-data-grid.css +66 -0
  42. package/theming/components/cngx-dialog.css +12 -0
  43. package/theming/components/cngx-divider.css +12 -0
  44. package/theming/components/cngx-listbox.css +27 -0
  45. package/theming/components/cngx-menu.css +36 -0
  46. package/theming/components/cngx-ripple.css +1 -1
  47. package/theming/components/cngx-tooltip.css +11 -0
  48. package/types/cngx-common-a11y.d.ts +63 -17
  49. package/types/cngx-common-audio.d.ts +32 -32
  50. package/types/cngx-common-card.d.ts +10 -3
  51. package/types/cngx-common-chart.d.ts +1281 -141
  52. package/types/cngx-common-command.d.ts +167 -0
  53. package/types/cngx-common-data.d.ts +264 -98
  54. package/types/cngx-common-dialog.d.ts +214 -25
  55. package/types/cngx-common-display.d.ts +83 -13
  56. package/types/cngx-common-interactive.d.ts +708 -174
  57. package/types/cngx-common-layout.d.ts +48 -1
  58. package/types/cngx-common-popover.d.ts +120 -3
  59. package/types/cngx-common-stepper.d.ts +55 -5
  60. package/types/cngx-common-tabs.d.ts +386 -25
  61. package/types/cngx-common-timeline.d.ts +1059 -0
  62. package/types/cngx-common.d.ts +1 -1
@@ -1,10 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, output, inject, ElementRef, signal, afterNextRender, effect, Directive, computed, DestroyRef, isSignal, untracked, model, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
2
+ import { input, output, inject, ElementRef, signal, afterNextRender, effect, Directive, computed, DestroyRef, isSignal, untracked, isDevMode, model, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
3
3
  import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
4
4
  import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
5
5
  import { fromEvent } from 'rxjs';
6
6
  import * as i1 from '@cngx/common/a11y';
7
7
  import { CngxFocusTrap } from '@cngx/common/a11y';
8
+ import { observeMediaQuery, createMediaQuerySignal } from '@cngx/core/utils';
8
9
  import { Router, ActivatedRoute } from '@angular/router';
9
10
 
10
11
  /**
@@ -472,16 +473,7 @@ class CngxMediaQuery {
472
473
  matches = this.matchesState.asReadonly();
473
474
  constructor() {
474
475
  effect((onCleanup) => {
475
- const win = this.win;
476
- if (!win) {
477
- this.matchesState.set(false);
478
- return;
479
- }
480
- const mql = win.matchMedia(this.query());
481
- this.matchesState.set(mql.matches);
482
- const handler = (e) => this.matchesState.set(e.matches);
483
- mql.addEventListener('change', handler);
484
- onCleanup(() => mql.removeEventListener('change', handler));
476
+ onCleanup(observeMediaQuery(this.win, this.query(), (matches) => this.matchesState.set(matches)));
485
477
  });
486
478
  }
487
479
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMediaQuery, deps: [], target: i0.ɵɵFactoryTarget.Directive });
@@ -533,16 +525,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
533
525
  * <example-url>http://localhost:4200/#/common/layout/media-query/inject-breakpoint-signal</example-url>
534
526
  */
535
527
  function injectMediaQuery(query) {
536
- const win = inject(DOCUMENT).defaultView;
537
- if (!win || typeof win.matchMedia !== 'function') {
538
- return signal(false).asReadonly();
539
- }
540
- const mql = win.matchMedia(query);
541
- const matches = signal(mql.matches, ...(ngDevMode ? [{ debugName: "matches" }] : /* istanbul ignore next */ []));
542
- const handler = (event) => matches.set(event.matches);
543
- mql.addEventListener('change', handler);
544
- inject(DestroyRef).onDestroy(() => mql.removeEventListener('change', handler));
545
- return matches.asReadonly();
528
+ return createMediaQuerySignal(query, inject(DestroyRef), inject(DOCUMENT).defaultView);
546
529
  }
547
530
 
548
531
  /**
@@ -753,13 +736,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
753
736
  }], ctorParameters: () => [], propDecorators: { box: [{ type: i0.Input, args: [{ isSignal: true, alias: "box", required: false }] }], resize: [{ type: i0.Output, args: ["resize"] }] } });
754
737
 
755
738
  /**
756
- * Shared ref-count for scroll lock instances on the same document.
739
+ * Ref-count per document root. Module-private on purpose: this file is the
740
+ * single owner of the lock state. A second copy of this map (the pre-extraction
741
+ * state: one in `CngxScrollLock`, one in `CngxDialog`) shares the dataset keys
742
+ * below without sharing the count, so interleaved acquire/release across the
743
+ * two owners corrupts each other's saved overflow values.
757
744
  *
758
745
  * @internal
759
746
  */
760
747
  const lockCounts = new WeakMap();
761
- /** @internal */
762
- function acquireScrollLock(html) {
748
+ /**
749
+ * Acquire a ref-counted scroll lock on a document root and get back the
750
+ * matching release function.
751
+ *
752
+ * The first active lock saves the current `overflow` / `scrollbar-gutter`
753
+ * inline styles and sets `overflow: hidden` + `scrollbar-gutter: stable`
754
+ * (no layout shift when the scrollbar disappears). Releasing the last active
755
+ * lock restores the saved values. The returned release function is
756
+ * idempotent - calling it twice cannot over-decrement the count.
757
+ *
758
+ * Shared engine behind `CngxScrollLock` and `CngxDialog`'s modal scroll lock;
759
+ * consumers composing their own overlay primitives can use it directly.
760
+ *
761
+ * ```typescript
762
+ * const release = createScrollLock(document.documentElement);
763
+ * // ... overlay open ...
764
+ * release();
765
+ * ```
766
+ *
767
+ * @param html - The document root (`document.documentElement`) to lock.
768
+ * @returns Release function for this acquisition. Idempotent.
769
+ *
770
+ * @category common/layout
771
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/scroll/scroll-lock-core.ts
772
+ * @since 0.1.0
773
+ * @relatedTo CngxScrollLock, CngxDialog
774
+ */
775
+ function createScrollLock(html) {
763
776
  const count = lockCounts.get(html) ?? 0;
764
777
  if (count === 0) {
765
778
  html.dataset['cngxPrevOverflow'] = html.style.overflow;
@@ -768,21 +781,26 @@ function acquireScrollLock(html) {
768
781
  html.style.scrollbarGutter = 'stable';
769
782
  }
770
783
  lockCounts.set(html, count + 1);
784
+ let released = false;
785
+ return () => {
786
+ if (released) {
787
+ return;
788
+ }
789
+ released = true;
790
+ const current = lockCounts.get(html) ?? 0;
791
+ if (current <= 1) {
792
+ html.style.overflow = html.dataset['cngxPrevOverflow'] ?? '';
793
+ html.style.scrollbarGutter = html.dataset['cngxPrevScrollbarGutter'] ?? '';
794
+ delete html.dataset['cngxPrevOverflow'];
795
+ delete html.dataset['cngxPrevScrollbarGutter'];
796
+ lockCounts.set(html, 0);
797
+ }
798
+ else {
799
+ lockCounts.set(html, current - 1);
800
+ }
801
+ };
771
802
  }
772
- /** @internal */
773
- function releaseScrollLock(html) {
774
- const count = lockCounts.get(html) ?? 0;
775
- if (count <= 1) {
776
- html.style.overflow = html.dataset['cngxPrevOverflow'] ?? '';
777
- html.style.scrollbarGutter = html.dataset['cngxPrevScrollbarGutter'] ?? '';
778
- delete html.dataset['cngxPrevOverflow'];
779
- delete html.dataset['cngxPrevScrollbarGutter'];
780
- lockCounts.set(html, 0);
781
- }
782
- else {
783
- lockCounts.set(html, count - 1);
784
- }
785
- }
803
+
786
804
  /**
787
805
  * Prevents scrolling on the document body when enabled.
788
806
  *
@@ -817,21 +835,18 @@ class CngxScrollLock {
817
835
  enabled = input(false, { ...(ngDevMode ? { debugName: "enabled" } : /* istanbul ignore next */ {}), alias: 'cngxScrollLock' });
818
836
  constructor() {
819
837
  const html = inject(DOCUMENT).documentElement;
820
- let locked = false;
838
+ let release = null;
821
839
  effect(() => {
822
- if (this.enabled() && !locked) {
823
- acquireScrollLock(html);
824
- locked = true;
840
+ if (this.enabled() && !release) {
841
+ release = createScrollLock(html);
825
842
  }
826
- else if (!this.enabled() && locked) {
827
- releaseScrollLock(html);
828
- locked = false;
843
+ else if (!this.enabled() && release) {
844
+ release();
845
+ release = null;
829
846
  }
830
847
  });
831
848
  inject(DestroyRef).onDestroy(() => {
832
- if (locked) {
833
- releaseScrollLock(html);
834
- }
849
+ release?.();
835
850
  });
836
851
  }
837
852
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxScrollLock, deps: [], target: i0.ɵɵFactoryTarget.Directive });
@@ -904,16 +919,7 @@ class CngxSkeleton {
904
919
  count = input(1, ...(ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []));
905
920
  prefersReducedMotion;
906
921
  constructor() {
907
- const win = inject(DOCUMENT).defaultView;
908
- const pref = signal(false, ...(ngDevMode ? [{ debugName: "pref" }] : /* istanbul ignore next */ []));
909
- if (win?.matchMedia) {
910
- const mq = win.matchMedia('(prefers-reduced-motion: reduce)');
911
- pref.set(mq.matches);
912
- const listener = (e) => pref.set(e.matches);
913
- mq.addEventListener('change', listener);
914
- inject(DestroyRef).onDestroy(() => mq.removeEventListener('change', listener));
915
- }
916
- this.prefersReducedMotion = pref.asReadonly();
922
+ this.prefersReducedMotion = createMediaQuerySignal('(prefers-reduced-motion: reduce)', inject(DestroyRef), inject(DOCUMENT).defaultView);
917
923
  }
918
924
  /** Whether the skeleton is in loading state. Mirrors the `cngxSkeleton` input. */
919
925
  loading = computed(() => this.skeleton(), ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
@@ -1071,6 +1077,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1071
1077
  * meaning the header is now stuck. Toggles a CSS class for shadow,
1072
1078
  * elevation, or background changes.
1073
1079
  *
1080
+ * The sentinel is observed against the **nearest scroll-container ancestor**
1081
+ * (the first ancestor whose computed `overflow-y` is not `visible`), not the
1082
+ * page - that is the scrollport `position: sticky` resolves against, so
1083
+ * `isSticky()` reports the state the host actually has. A scrollport whose
1084
+ * height is content-driven never scrolls in the block axis, so a header inside
1085
+ * it never pins; in dev mode the directive warns once when it resolves against
1086
+ * such a scrollport.
1087
+ *
1074
1088
  * ### Sticky header with shadow
1075
1089
  * ```html
1076
1090
  * <header cngxStickyHeader #sh="cngxStickyHeader"
@@ -1103,9 +1117,28 @@ class CngxStickyHeader {
1103
1117
  doc = inject(DOCUMENT);
1104
1118
  constructor() {
1105
1119
  const destroyRef = inject(DestroyRef);
1106
- // IntersectionObserver sentinel pattern - host is stuck once the 1px sentinel leaves the viewport.
1120
+ // IntersectionObserver sentinel pattern - host is stuck once the 1px sentinel leaves
1121
+ // the scrollport the host actually sticks to.
1107
1122
  afterNextRender(() => {
1108
1123
  const host = this.el.nativeElement;
1124
+ // Root the sentinel at the scrollport `position: sticky` resolves against, not the
1125
+ // viewport. Observing against the viewport reports a different thing entirely: a
1126
+ // header inside a never-scrolling scrollport would read `isSticky() === true` while
1127
+ // it visibly scrolls away with its content.
1128
+ const scrollport = this.resolveScrollParent(host);
1129
+ // A scrollport whose content fits (client height equals scroll height) never
1130
+ // scrolls in the block axis, so a header inside it can never pin - `isSticky()`
1131
+ // stays false while the whole scrollport moves. Flag the misconfiguration once,
1132
+ // in dev only; a one-shot read here is exactly what `afterNextRender` is for
1133
+ // (no reactive-graph node, unlike a dep-less effect).
1134
+ if (isDevMode() &&
1135
+ scrollport &&
1136
+ scrollport.clientHeight === scrollport.scrollHeight) {
1137
+ console.warn('[cngxStickyHeader] resolves against a scroll container that cannot scroll ' +
1138
+ 'in the block axis (client height equals scroll height), so this header ' +
1139
+ 'will never pin. Give the scrollport a bounded block-size, or drop ' +
1140
+ 'cngxStickyHeader.', { host, scrollport });
1141
+ }
1109
1142
  const sentinel = this.doc.createElement('div');
1110
1143
  sentinel.style.height = '1px';
1111
1144
  sentinel.style.width = '1px';
@@ -1120,7 +1153,7 @@ class CngxStickyHeader {
1120
1153
  this.isStickyState.set(isSticky);
1121
1154
  this.stickyChange.emit(isSticky);
1122
1155
  }
1123
- }, { threshold: this.threshold() });
1156
+ }, { threshold: this.threshold(), root: scrollport });
1124
1157
  observer.observe(sentinel);
1125
1158
  destroyRef.onDestroy(() => {
1126
1159
  observer.disconnect();
@@ -1128,6 +1161,24 @@ class CngxStickyHeader {
1128
1161
  });
1129
1162
  });
1130
1163
  }
1164
+ /**
1165
+ * The nearest ancestor that is a scroll container in the block axis - the scrollport
1166
+ * `position: sticky` resolves against. Walks up from the host's parent to the first
1167
+ * ancestor whose computed `overflow-y` is not `visible`; `null` means no such
1168
+ * ancestor, i.e. the header sticks to the viewport. A used `overflow-x` other than
1169
+ * `visible` coerces the computed `overflow-y` to `auto`, so this also catches a
1170
+ * horizontal scroll container (e.g. a data grid that scrolls sideways).
1171
+ */
1172
+ resolveScrollParent(host) {
1173
+ const view = this.doc.defaultView;
1174
+ for (let node = host.parentElement; node; node = node.parentElement) {
1175
+ const overflowY = view?.getComputedStyle(node).overflowY;
1176
+ if (overflowY && overflowY !== 'visible') {
1177
+ return node;
1178
+ }
1179
+ }
1180
+ return null;
1181
+ }
1131
1182
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStickyHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1132
1183
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxStickyHeader, isStandalone: true, selector: "[cngxStickyHeader]", inputs: { threshold: { classPropertyName: "threshold", publicName: "threshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { stickyChange: "stickyChange" }, host: { properties: { "class.cngx-sticky--active": "isSticky()" }, styleAttribute: "position: sticky; top: 0; z-index: var(--cngx-sticky-z-index, 1)" }, exportAs: ["cngxStickyHeader"], ngImport: i0 });
1133
1184
  }
@@ -1580,6 +1631,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1580
1631
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/text/expandable-text.ts
1581
1632
  * @since 0.1.0
1582
1633
  * @relatedTo CngxTruncate, CngxExpandableToggle, CngxHighlight
1634
+ * @slot cngxExpandableToggle Replaces the show-more control; gets the current expanded state.
1583
1635
  * <example-url>http://localhost:4200/#/common/layout/expandable-text/auto-toggle</example-url>
1584
1636
  * <example-url>http://localhost:4200/#/common/layout/expandable-text/custom-labels</example-url>
1585
1637
  * <example-url>http://localhost:4200/#/common/layout/expandable-text/custom-toggle-template</example-url>
@@ -1672,5 +1724,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1672
1724
  * Generated bundle index. Do not edit.
1673
1725
  */
1674
1726
 
1675
- export { CngxBackdrop, CngxDrawer, CngxDrawerContent, CngxDrawerPanel, CngxExpandableText, CngxExpandableToggle, CngxHighlight, CngxInfiniteScroll, CngxIntersectionObserver, CngxMediaQuery, CngxResizeObserver, CngxScrollLock, CngxScrollSpy, CngxSkeleton, CngxStickyHeader, CngxTruncate, injectMediaQuery, injectQueryParamSync };
1727
+ export { CngxBackdrop, CngxDrawer, CngxDrawerContent, CngxDrawerPanel, CngxExpandableText, CngxExpandableToggle, CngxHighlight, CngxInfiniteScroll, CngxIntersectionObserver, CngxMediaQuery, CngxResizeObserver, CngxScrollLock, CngxScrollSpy, CngxSkeleton, CngxStickyHeader, CngxTruncate, createScrollLock, injectMediaQuery, injectQueryParamSync };
1676
1728
  //# sourceMappingURL=cngx-common-layout.mjs.map