@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,11 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, makeEnvironmentProviders, inject, model, input, computed, signal, isDevMode, afterNextRender, Directive, TemplateRef, contentChild, linkedSignal, DestroyRef, output, effect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
3
3
  import { CNGX_COMMIT_CONTROLLER_FACTORY } from '@cngx/common/data';
4
- import { createTransitionTracker, CNGX_STATEFUL, nextUid, buildAsyncStateView } from '@cngx/core/utils';
4
+ import { createTransitionTracker, CNGX_STATEFUL, nextUid, createMediaQuerySignal, buildAsyncStateView } from '@cngx/core/utils';
5
5
  import { isObservable } from 'rxjs';
6
6
  import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
7
  import { Router, NavigationEnd } from '@angular/router';
8
8
  import { filter } from 'rxjs/operators';
9
+ import { resolveInlineStep } from '@cngx/core';
9
10
  import * as i1 from '@cngx/common/interactive';
10
11
  import { CngxAsyncClick } from '@cngx/common/interactive';
11
12
 
@@ -1145,6 +1146,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1145
1146
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step.directive.ts
1146
1147
  * @since 0.1.0
1147
1148
  * @relatedTo CngxStepGroup, CngxStepperPresenter, CngxStepLabel, CngxStepContent
1149
+ * @slot cngxStepLabel The step's own header label.
1150
+ * @slot cngxStepContent The step body, rendered lazily when the step activates.
1148
1151
  * <example-url>http://localhost:4200/#/ui/stepper/stepper-step-content/typed-lazy-panels</example-url>
1149
1152
  */
1150
1153
  class CngxStep {
@@ -1202,14 +1205,25 @@ class CngxStep {
1202
1205
  return 'idle';
1203
1206
  },
1204
1207
  equal: Object.is });
1208
+ groupHost = inject(CNGX_STEP_GROUP_HOST, { optional: true });
1209
+ stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
1210
+ destroyRef = inject(DestroyRef);
1205
1211
  constructor() {
1206
- const groupHost = inject(CNGX_STEP_GROUP_HOST, { optional: true });
1207
- const stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
1208
- const host = groupHost ?? stepperHost;
1209
- if (!host) {
1212
+ if (!this.groupHost && !this.stepperHost) {
1210
1213
  throw new Error('CngxStep: no enclosing CngxStepperPresenter or CngxStepGroup found. ' +
1211
1214
  'Wrap the step inside an element carrying [cngxStepper] or [cngxStepGroup].');
1212
1215
  }
1216
+ }
1217
+ ngOnInit() {
1218
+ // Register in ngOnInit, NOT the constructor: a bound `[id]` signal
1219
+ // input is not applied until the first change detection, so a
1220
+ // constructor read captures the default auto-id. The registered id is
1221
+ // the key the router-sync deep-link seed and consumers match against,
1222
+ // so it must reflect the bound `[id]`. ngOnInit still runs before the
1223
+ // host's ngAfterContentInit, so the seed's registry precondition holds;
1224
+ // and it fires ancestor-group-before-descendant-step in DOM order, so
1225
+ // the presenter's insertion-order tree is unchanged. Mirrors CngxTab.
1226
+ const host = this.groupHost ?? this.stepperHost;
1213
1227
  const stepId = this.id();
1214
1228
  host.register({
1215
1229
  id: stepId,
@@ -1220,7 +1234,7 @@ class CngxStep {
1220
1234
  errorAggregator: this.errorAggregator,
1221
1235
  errorMessage: this.errorMessage,
1222
1236
  });
1223
- inject(DestroyRef).onDestroy(() => host.unregister(stepId));
1237
+ this.destroyRef.onDestroy(() => host.unregister(stepId));
1224
1238
  }
1225
1239
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStep, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1226
1240
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxStep, isStandalone: true, selector: "[cngxStep]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, completed: { classPropertyName: "completed", publicName: "completed", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, errorAggregator: { classPropertyName: "errorAggregator", publicName: "errorAggregator", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "labelSlot", first: true, predicate: CngxStepLabel, descendants: true, isSignal: true }, { propertyName: "contentSlot", first: true, predicate: CngxStepContent, descendants: true, isSignal: true }], exportAs: ["cngxStep"], ngImport: i0 });
@@ -1278,6 +1292,7 @@ class CngxStepGroup {
1278
1292
  return 'idle';
1279
1293
  }, { ...(ngDevMode ? { debugName: "aggregatedStatus" } : /* istanbul ignore next */ {}), equal: Object.is });
1280
1294
  stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
1295
+ destroyRef = inject(DestroyRef);
1281
1296
  /**
1282
1297
  * `true` when this group's children are collapsed to the header node:
1283
1298
  * the focus-driven policy is `'expand-active'`, this group does not
@@ -1305,16 +1320,24 @@ class CngxStepGroup {
1305
1320
  throw new Error('CngxStepGroup: no enclosing CngxStepperPresenter found. ' +
1306
1321
  'Wrap the group inside an element carrying [cngxStepper].');
1307
1322
  }
1323
+ }
1324
+ ngOnInit() {
1325
+ // Register in ngOnInit, not the constructor, so a bound `[id]` reaches
1326
+ // the registry (see CngxStep). A group MUST register before its child
1327
+ // steps or the presenter drops the orphaned children; ngOnInit fires an
1328
+ // ancestor group before its descendant steps, so that order holds, and
1329
+ // groups and steps share one lifecycle phase - keeping the presenter's
1330
+ // insertion-order tree identical to the previous constructor ordering.
1331
+ const stepperHost = this.stepperHost;
1308
1332
  const groupId = this.id();
1309
- this.stepperHost.register({
1333
+ stepperHost.register({
1310
1334
  id: groupId,
1311
1335
  kind: 'group',
1312
1336
  label: this.label,
1313
1337
  disabled: this.disabled,
1314
1338
  state: this.aggregatedStatus,
1315
1339
  });
1316
- const stepperHost = this.stepperHost;
1317
- inject(DestroyRef).onDestroy(() => stepperHost.unregister(groupId));
1340
+ this.destroyRef.onDestroy(() => stepperHost.unregister(groupId));
1318
1341
  }
1319
1342
  register(handle) {
1320
1343
  this.childRegistry.update((cur) => [...cur, handle]);
@@ -1742,6 +1765,18 @@ class CngxStepperRouterSync {
1742
1765
  syncError = output();
1743
1766
  host = inject(CNGX_STEPPER_HOST, { host: true });
1744
1767
  router = inject(Router, { optional: true });
1768
+ /**
1769
+ * Latched once the URL seed has reached a registered step, so the
1770
+ * `afterNextRender` fallback cannot run it twice.
1771
+ *
1772
+ * The latch is load-bearing, not decorative: the seed goes through
1773
+ * `selectById` → `select()`, which opens a commit window. Under a
1774
+ * pessimistic commit `activeStepIndex` still holds the *previous* index
1775
+ * while the action is in flight, so the presenter's `target === previous`
1776
+ * bail does not catch the repeat - an unlatched fallback would fire the
1777
+ * consumer's commit-action a second time and supersede the first.
1778
+ */
1779
+ seeded = false;
1745
1780
  constructor() {
1746
1781
  if (!this.router) {
1747
1782
  afterNextRender(() => {
@@ -1751,17 +1786,10 @@ class CngxStepperRouterSync {
1751
1786
  return;
1752
1787
  }
1753
1788
  const router = this.router;
1754
- afterNextRender(() => {
1755
- const initial = this.mode() === 'fragment'
1756
- ? router.routerState.snapshot.root.fragment
1757
- : (router.routerState.snapshot.root.queryParamMap.get(this.paramName()) ?? null);
1758
- if (initial) {
1759
- const value = this.mode() === 'fragment' ? this.parseFragment(initial) : initial;
1760
- if (value) {
1761
- this.host.selectById(value);
1762
- }
1763
- }
1764
- });
1789
+ // Fallback seed for steps that register after content-init (a dynamic
1790
+ // @for over an async step list). Idempotent against the content-init
1791
+ // seed via the `seeded` latch.
1792
+ afterNextRender(() => this.seedFromUrl(router));
1765
1793
  effect(() => {
1766
1794
  const id = this.host.activeStepId();
1767
1795
  if (!id) {
@@ -1789,15 +1817,52 @@ class CngxStepperRouterSync {
1789
1817
  return;
1790
1818
  }
1791
1819
  untracked(() => {
1792
- const next = this.mode() === 'fragment'
1793
- ? this.parseFragment(router.routerState.snapshot.root.fragment ?? '')
1794
- : (router.routerState.snapshot.root.queryParamMap.get(this.paramName()) ?? null);
1820
+ const next = this.readUrlValue(router);
1795
1821
  if (next && next !== this.host.activeStepId()) {
1796
1822
  this.host.selectById(next);
1797
1823
  }
1798
1824
  });
1799
1825
  });
1800
1826
  }
1827
+ /**
1828
+ * Seed from the URL before the stepper renders its panels. `CngxStep`
1829
+ * registers in its constructor, so the registry is populated by the time
1830
+ * this runs, and the host view has not rendered yet - which is what keeps
1831
+ * a `panelMode="lazy"` default step from counting its first render as a
1832
+ * first activation on a deep link that named another step.
1833
+ *
1834
+ * Own router guard: the constructor's early return does not stop
1835
+ * lifecycle hooks from running.
1836
+ */
1837
+ ngAfterContentInit() {
1838
+ if (!this.router) {
1839
+ return;
1840
+ }
1841
+ this.seedFromUrl(this.router);
1842
+ }
1843
+ seedFromUrl(router) {
1844
+ if (this.seeded) {
1845
+ return;
1846
+ }
1847
+ const initial = this.readUrlValue(router);
1848
+ if (!initial) {
1849
+ return;
1850
+ }
1851
+ // Only latch once the target is actually registered. A seed that found
1852
+ // no matching step leaves the fallback armed for steps that register
1853
+ // after content-init.
1854
+ if (!this.host.stepsOnly().some((n) => n.id === initial)) {
1855
+ return;
1856
+ }
1857
+ this.seeded = true;
1858
+ untracked(() => this.host.selectById(initial));
1859
+ }
1860
+ readUrlValue(router) {
1861
+ if (this.mode() === 'fragment') {
1862
+ return this.parseFragment(router.routerState.snapshot.root.fragment ?? '');
1863
+ }
1864
+ return router.routerState.snapshot.root.queryParamMap.get(this.paramName()) ?? null;
1865
+ }
1801
1866
  parseFragment(fragment) {
1802
1867
  const param = this.paramName();
1803
1868
  const segments = fragment.split('&');
@@ -1955,21 +2020,13 @@ function resolveStepperStatusLabel(node, i18n, isActive) {
1955
2020
  * `<cngx-stepper>` to drive its mobile auto-collapse template branch.
1956
2021
  *
1957
2022
  * In SSR / non-DOM environments the signal stays `false` and the
1958
- * listener is never wired.
2023
+ * listener is never wired. Thin wrapper over `createMediaQuerySignal`
2024
+ * from `@cngx/core/utils`, bound to `globalThis`.
1959
2025
  *
1960
2026
  * @category common/stepper
1961
2027
  */
1962
2028
  function createMobileViewportSignal(mediaQuery, destroyRef) {
1963
- const matches = signal(false, ...(ngDevMode ? [{ debugName: "matches" }] : /* istanbul ignore next */ []));
1964
- if (typeof globalThis.matchMedia !== 'function') {
1965
- return matches.asReadonly();
1966
- }
1967
- const mql = globalThis.matchMedia(mediaQuery);
1968
- matches.set(mql.matches);
1969
- const listener = (event) => matches.set(event.matches);
1970
- mql.addEventListener('change', listener);
1971
- destroyRef.onDestroy(() => mql.removeEventListener('change', listener));
1972
- return matches.asReadonly();
2029
+ return createMediaQuerySignal(mediaQuery, destroyRef, globalThis);
1973
2030
  }
1974
2031
  /**
1975
2032
  * Resolves the active stepper display mode by combining a viewport
@@ -2214,14 +2271,17 @@ function createStepperStripKeyboardNav(options) {
2214
2271
  return;
2215
2272
  }
2216
2273
  const isHorizontal = options.presenter.orientation() === 'horizontal';
2217
- const nextKey = isHorizontal ? 'ArrowRight' : 'ArrowDown';
2218
- const prevKey = isHorizontal ? 'ArrowLeft' : 'ArrowUp';
2219
- if (event.key === nextKey) {
2274
+ // Horizontal: the inline arrows flip under rtl. Vertical: the block
2275
+ // arrows (ArrowUp/ArrowDown) never flip.
2276
+ const inlineStep = isHorizontal ? resolveInlineStep(event.key, options.direction()) : null;
2277
+ const isNext = inlineStep === 1 || (!isHorizontal && event.key === 'ArrowDown');
2278
+ const isPrev = inlineStep === -1 || (!isHorizontal && event.key === 'ArrowUp');
2279
+ if (isNext) {
2220
2280
  event.preventDefault();
2221
2281
  options.presenter.selectNext();
2222
2282
  focusActive();
2223
2283
  }
2224
- else if (event.key === prevKey) {
2284
+ else if (isPrev) {
2225
2285
  event.preventDefault();
2226
2286
  options.presenter.selectPrevious();
2227
2287
  focusActive();
@@ -2515,7 +2575,12 @@ function createStepperAnnouncementBuilders(inputs) {
2515
2575
  }
2516
2576
  return '';
2517
2577
  };
2518
- return { liveAnnouncement, statusPhrase, groupStatusPhrase };
2578
+ const descriptorId = (node) => `${node.id}-desc`;
2579
+ const describedBy = (node) => {
2580
+ const phrase = node.kind === 'step' ? statusPhrase(node) : groupStatusPhrase(node);
2581
+ return phrase ? descriptorId(node) : null;
2582
+ };
2583
+ return { liveAnnouncement, statusPhrase, groupStatusPhrase, descriptorId, describedBy };
2519
2584
  }
2520
2585
 
2521
2586
  /**
@@ -2644,20 +2709,13 @@ class CngxStepperCount {
2644
2709
  return fmt(current, total);
2645
2710
  }, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
2646
2711
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperCount, deps: [], target: i0.ɵɵFactoryTarget.Component });
2647
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepperCount, isStandalone: true, selector: "cngx-stepper-count", inputs: { live: { classPropertyName: "live", publicName: "live", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, host: { classPropertyName: "host", publicName: "host", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-stepper-count" }, ngImport: i0, template: '<span [attr.aria-live]="live() ? \'polite\' : null">{{ label() }}</span>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2712
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepperCount, isStandalone: true, selector: "cngx-stepper-count", inputs: { live: { classPropertyName: "live", publicName: "live", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, host: { classPropertyName: "host", publicName: "host", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-stepper-count" }, ngImport: i0, template: '<span [attr.aria-live]="live() ? \'polite\' : null">{{ label() }}</span>', isInline: true, styles: [".cngx-stepper-count span{unicode-bidi:var(--cngx-stepper-count-bidi, isolate);direction:var(--cngx-stepper-count-direction, ltr)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2648
2713
  }
2649
2714
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperCount, decorators: [{
2650
2715
  type: Component,
2651
- args: [{
2652
- selector: 'cngx-stepper-count',
2653
- standalone: true,
2654
- changeDetection: ChangeDetectionStrategy.OnPush,
2655
- encapsulation: ViewEncapsulation.None,
2656
- template: '<span [attr.aria-live]="live() ? \'polite\' : null">{{ label() }}</span>',
2657
- host: {
2716
+ args: [{ selector: 'cngx-stepper-count', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: '<span [attr.aria-live]="live() ? \'polite\' : null">{{ label() }}</span>', host: {
2658
2717
  class: 'cngx-stepper-count',
2659
- },
2660
- }]
2718
+ }, styles: [".cngx-stepper-count span{unicode-bidi:var(--cngx-stepper-count-bidi, isolate);direction:var(--cngx-stepper-count-direction, ltr)}\n"] }]
2661
2719
  }], propDecorators: { live: [{ type: i0.Input, args: [{ isSignal: true, alias: "live", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], host: [{ type: i0.Input, args: [{ isSignal: true, alias: "host", required: false }] }] } });
2662
2720
 
2663
2721
  /**