@cngx/common 0.1.0-rc.8 → 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/command/README.md +29 -0
- package/data/README.md +5 -2
- package/fesm2022/cngx-common-a11y.mjs +403 -84
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +16 -13
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +4 -3
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +55 -36
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +60 -6
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +185 -37
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +86 -48
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +27 -23
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +324 -122
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +129 -26
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +947 -33
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +300 -166
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +251 -80
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +16 -10
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/layout/README.md +16 -0
- package/package.json +20 -7
- package/popover/README.md +40 -0
- 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 +5 -4
- package/theming/components/cngx-popover-sheet.css +402 -0
- package/theming/components/cngx-popover.css +10 -6
- package/types/cngx-common-a11y.d.ts +167 -14
- package/types/cngx-common-chart.d.ts +8 -7
- package/types/cngx-common-command.d.ts +19 -2
- package/types/cngx-common-data.d.ts +164 -26
- package/types/cngx-common-dialog.d.ts +3 -7
- package/types/cngx-common-interactive.d.ts +52 -17
- package/types/cngx-common-layout.d.ts +37 -5
- package/types/cngx-common-popover.d.ts +353 -13
- package/types/cngx-common-stepper.d.ts +168 -129
- package/types/cngx-common-tabs.d.ts +149 -30
- package/types/cngx-common-timeline.d.ts +27 -7
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, output, inject, ElementRef, signal, afterNextRender, effect, Directive, computed, untracked,
|
|
2
|
+
import { input, output, inject, ElementRef, signal, afterNextRender, effect, Directive, computed, untracked, DestroyRef, InjectionToken, PLATFORM_ID, model, TemplateRef, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { DOCUMENT, isPlatformBrowser, NgTemplateOutlet } from '@angular/common';
|
|
4
4
|
import { toObservable, outputToObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { switchMap, fromEvent } from 'rxjs';
|
|
6
6
|
import { createTransitionTracker, observeMediaQuery, createMediaQuerySignal, coerceSignal, createOverrideMerge } from '@cngx/core/utils';
|
|
7
7
|
import * as i1 from '@cngx/common/a11y';
|
|
8
8
|
import { CngxFocusTrap } from '@cngx/common/a11y';
|
|
9
|
+
import { cngxDevWarn } from '@cngx/utils';
|
|
9
10
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
10
11
|
import { createLanguageSection } from '@cngx/core/i18n';
|
|
11
12
|
|
|
@@ -487,8 +488,8 @@ class CngxIntersectionObserver {
|
|
|
487
488
|
const rootMargin = this.rootMargin();
|
|
488
489
|
const threshold = this.threshold();
|
|
489
490
|
const resolvedRoot = root ? this.doc.querySelector(root) : null;
|
|
490
|
-
if (
|
|
491
|
-
|
|
491
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && root && !resolvedRoot) {
|
|
492
|
+
cngxDevWarn('CNGX1032', `[cngxIntersectionObserver] root selector "${root}" matched no element - ` +
|
|
492
493
|
'falling back to the viewport. A late-rendered root needs a re-bind of [root].');
|
|
493
494
|
}
|
|
494
495
|
const observer = new IntersectionObserver((entries) => {
|
|
@@ -619,17 +620,17 @@ function injectMediaQuery(query) {
|
|
|
619
620
|
* Dev-warning the query-param sync kernel emits when `@angular/router` is
|
|
620
621
|
* not provided. Mirrors {@link warnTabsRouterAbsent} in `@cngx/common/tabs`
|
|
621
622
|
* so the message stays identical across the two sync surfaces; only the
|
|
622
|
-
* `enables` clause differs
|
|
623
|
-
*
|
|
624
|
-
* `
|
|
623
|
+
* `enables` clause differs. A deliberate small copy rather than a shared
|
|
624
|
+
* import - sharing would force the helper onto a `public-api.ts`, and
|
|
625
|
+
* `warn*` matches no approved public-API prefix.
|
|
625
626
|
*
|
|
626
627
|
* @internal
|
|
627
628
|
*/
|
|
628
|
-
function warnRouterAbsent(
|
|
629
|
-
if (!
|
|
629
|
+
function warnRouterAbsent(enables) {
|
|
630
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
630
631
|
return;
|
|
631
632
|
}
|
|
632
|
-
|
|
633
|
+
cngxDevWarn('CNGX1031', `injectQueryParamSync(): no Router / ActivatedRoute available - the URL sync is a no-op. ` +
|
|
633
634
|
`Provide @angular/router via provideRouter(...) to enable ${enables}.`);
|
|
634
635
|
}
|
|
635
636
|
|
|
@@ -662,11 +663,15 @@ function warnRouterAbsent(directive, enables) {
|
|
|
662
663
|
*/
|
|
663
664
|
function injectQueryParamSync(state, opts) {
|
|
664
665
|
const router = inject(Router, { optional: true });
|
|
665
|
-
|
|
666
|
-
|
|
666
|
+
// Router is providedIn: 'root' and resolves without provideRouter(...);
|
|
667
|
+
// ActivatedRoute does not, so it is the "router is set up" signal.
|
|
668
|
+
const route = inject(ActivatedRoute, { optional: true });
|
|
669
|
+
if (!router || !route) {
|
|
670
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
671
|
+
warnRouterAbsent('query-param URL sync');
|
|
672
|
+
}
|
|
667
673
|
return;
|
|
668
674
|
}
|
|
669
|
-
const route = inject(ActivatedRoute);
|
|
670
675
|
const paramSignal = coerceSignal(opts.param);
|
|
671
676
|
const serialize = opts.serialize ?? ((value) => (value ? 'open' : null));
|
|
672
677
|
const deserialize = opts.deserialize ?? ((raw) => (raw != null));
|
|
@@ -1138,6 +1143,102 @@ function createScrollLock(html) {
|
|
|
1138
1143
|
}
|
|
1139
1144
|
};
|
|
1140
1145
|
}
|
|
1146
|
+
// The body properties the pin writes. Only these are saved and restored, so a
|
|
1147
|
+
// style another owner sets on body while the pin is held survives the release.
|
|
1148
|
+
const PINNED_BODY_PROPERTIES = ['position', 'top', 'inset-inline', 'overflow'];
|
|
1149
|
+
/**
|
|
1150
|
+
* Pin state per document root, separate from `lockCounts`: a pin also holds
|
|
1151
|
+
* one `createScrollLock` acquisition, so the html overflow stays shared with
|
|
1152
|
+
* every other owner.
|
|
1153
|
+
*
|
|
1154
|
+
* @internal
|
|
1155
|
+
*/
|
|
1156
|
+
const pins = new WeakMap();
|
|
1157
|
+
/**
|
|
1158
|
+
* Acquire a ref-counted scroll lock that pins the page body in place, for
|
|
1159
|
+
* overlays that must hold on iOS Safari.
|
|
1160
|
+
*
|
|
1161
|
+
* `overflow: hidden` on the root does not stop iOS Safari from scrolling a
|
|
1162
|
+
* page that was already scrolled, and the visual viewport drifts with it, so
|
|
1163
|
+
* a bottom-fixed overlay ends above the visible bottom. The first pin saves
|
|
1164
|
+
* the body's inline `position`, `top`, `inset-inline` and `overflow` and the
|
|
1165
|
+
* scroll position, fixes the body at `top: -scrollY`, and acquires
|
|
1166
|
+
* {@link createScrollLock} on the root. The last
|
|
1167
|
+
* release restores the body, releases the root lock and scrolls back to the
|
|
1168
|
+
* saved position. The returned release function is idempotent.
|
|
1169
|
+
*
|
|
1170
|
+
* `CngxDialog` and `CngxScrollLock` keep {@link createScrollLock}; reach for
|
|
1171
|
+
* this one when the overlay is pinned to the viewport bottom on touch devices.
|
|
1172
|
+
*
|
|
1173
|
+
* ```typescript
|
|
1174
|
+
* const release = createPinnedScrollLock(document.documentElement);
|
|
1175
|
+
* // ... sheet open ...
|
|
1176
|
+
* release();
|
|
1177
|
+
* ```
|
|
1178
|
+
*
|
|
1179
|
+
* @param html - The document root (`document.documentElement`) to lock.
|
|
1180
|
+
* @returns Release function for this acquisition. Idempotent.
|
|
1181
|
+
*
|
|
1182
|
+
* @category common/layout
|
|
1183
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/scroll/scroll-lock-core.ts
|
|
1184
|
+
* @since 0.1.0
|
|
1185
|
+
* @relatedTo createScrollLock, CngxPopoverSheet
|
|
1186
|
+
*/
|
|
1187
|
+
function createPinnedScrollLock(html) {
|
|
1188
|
+
const body = html.ownerDocument.body;
|
|
1189
|
+
const view = html.ownerDocument.defaultView;
|
|
1190
|
+
const existing = pins.get(html);
|
|
1191
|
+
if (existing) {
|
|
1192
|
+
existing.count += 1;
|
|
1193
|
+
}
|
|
1194
|
+
else {
|
|
1195
|
+
const scrollX = view?.scrollX ?? 0;
|
|
1196
|
+
const scrollY = view?.scrollY ?? 0;
|
|
1197
|
+
pins.set(html, {
|
|
1198
|
+
count: 1,
|
|
1199
|
+
saved: new Map(PINNED_BODY_PROPERTIES.map((name) => [
|
|
1200
|
+
name,
|
|
1201
|
+
{
|
|
1202
|
+
value: body.style.getPropertyValue(name),
|
|
1203
|
+
priority: body.style.getPropertyPriority(name),
|
|
1204
|
+
},
|
|
1205
|
+
])),
|
|
1206
|
+
scrollX,
|
|
1207
|
+
scrollY,
|
|
1208
|
+
releaseHtml: createScrollLock(html),
|
|
1209
|
+
});
|
|
1210
|
+
body.style.position = 'fixed';
|
|
1211
|
+
body.style.top = `${-scrollY}px`;
|
|
1212
|
+
body.style.insetInline = '0';
|
|
1213
|
+
body.style.overflow = 'hidden';
|
|
1214
|
+
}
|
|
1215
|
+
let released = false;
|
|
1216
|
+
return () => {
|
|
1217
|
+
if (released) {
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
released = true;
|
|
1221
|
+
const state = pins.get(html);
|
|
1222
|
+
if (!state) {
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
state.count -= 1;
|
|
1226
|
+
if (state.count > 0) {
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
pins.delete(html);
|
|
1230
|
+
for (const [name, { value, priority }] of state.saved) {
|
|
1231
|
+
if (value) {
|
|
1232
|
+
body.style.setProperty(name, value, priority);
|
|
1233
|
+
}
|
|
1234
|
+
else {
|
|
1235
|
+
body.style.removeProperty(name);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
state.releaseHtml();
|
|
1239
|
+
view?.scrollTo({ left: state.scrollX, top: state.scrollY, behavior: 'instant' });
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1141
1242
|
|
|
1142
1243
|
/**
|
|
1143
1244
|
* Prevents scrolling on the document body when enabled.
|
|
@@ -1607,8 +1708,8 @@ class CngxInfiniteScroll {
|
|
|
1607
1708
|
}
|
|
1608
1709
|
const isLoading = () => this.loading();
|
|
1609
1710
|
const resolvedRoot = root ? this.doc.querySelector(root) : null;
|
|
1610
|
-
if (
|
|
1611
|
-
|
|
1711
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && root && !resolvedRoot) {
|
|
1712
|
+
cngxDevWarn('CNGX1032', `[cngxInfiniteScroll] root selector "${root}" matched no element - ` +
|
|
1612
1713
|
'falling back to the viewport. A late-rendered root needs a re-bind of [root].');
|
|
1613
1714
|
}
|
|
1614
1715
|
const observer = new IntersectionObserver((entries) => {
|
|
@@ -1737,10 +1838,11 @@ class CngxStickyHeader {
|
|
|
1737
1838
|
// exactly what `afterNextRender` is for (no reactive-graph node, unlike a
|
|
1738
1839
|
// dep-less effect). The 1px tolerance absorbs sub-pixel layout and browser-zoom
|
|
1739
1840
|
// rounding: "cannot meaningfully scroll" instead of exact equality.
|
|
1740
|
-
if (
|
|
1841
|
+
if (typeof ngDevMode !== 'undefined' &&
|
|
1842
|
+
ngDevMode &&
|
|
1741
1843
|
scrollport &&
|
|
1742
1844
|
scrollport.scrollHeight - scrollport.clientHeight <= 1) {
|
|
1743
|
-
|
|
1845
|
+
cngxDevWarn('CNGX1034', '[cngxStickyHeader] resolves against a scroll container that cannot scroll ' +
|
|
1744
1846
|
'in the block axis (client height equals scroll height), so this header ' +
|
|
1745
1847
|
'will never pin. Give the scrollport a bounded block-size, or drop ' +
|
|
1746
1848
|
'cngxStickyHeader.', { host, scrollport });
|
|
@@ -1779,16 +1881,17 @@ class CngxStickyHeader {
|
|
|
1779
1881
|
/**
|
|
1780
1882
|
* The nearest ancestor that is a scroll container in the block axis - the scrollport
|
|
1781
1883
|
* `position: sticky` resolves against. Walks up from the host's parent to the first
|
|
1782
|
-
* ancestor whose computed `overflow-y` is
|
|
1783
|
-
* ancestor, i.e. the header sticks to the viewport.
|
|
1784
|
-
*
|
|
1785
|
-
*
|
|
1884
|
+
* ancestor whose computed `overflow-y` is `auto`, `scroll` or `hidden`; `null` means
|
|
1885
|
+
* no such ancestor, i.e. the header sticks to the viewport. `clip` clips without
|
|
1886
|
+
* creating a scroll container, so it is skipped. A used `overflow-x` of `auto`,
|
|
1887
|
+
* `scroll` or `hidden` coerces the computed `overflow-y` to `auto`, so this also
|
|
1888
|
+
* catches a horizontal scroll container (e.g. a data grid that scrolls sideways).
|
|
1786
1889
|
*/
|
|
1787
1890
|
resolveScrollParent(host) {
|
|
1788
1891
|
const view = this.doc.defaultView;
|
|
1789
1892
|
for (let node = host.parentElement; node; node = node.parentElement) {
|
|
1790
1893
|
const overflowY = view?.getComputedStyle(node).overflowY;
|
|
1791
|
-
if (overflowY
|
|
1894
|
+
if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'hidden') {
|
|
1792
1895
|
return node;
|
|
1793
1896
|
}
|
|
1794
1897
|
}
|
|
@@ -1893,17 +1996,17 @@ class CngxScrollSpy {
|
|
|
1893
1996
|
const elements = ids
|
|
1894
1997
|
.map((id) => this.doc.getElementById(id))
|
|
1895
1998
|
.filter((el) => el !== null);
|
|
1896
|
-
if (
|
|
1999
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && elements.length < ids.length) {
|
|
1897
2000
|
const missing = ids.filter((id) => !this.doc.getElementById(id));
|
|
1898
|
-
|
|
2001
|
+
cngxDevWarn('CNGX1033', `[cngxScrollSpy] section id(s) not found: ${missing.join(', ')}. ` +
|
|
1899
2002
|
'Late-rendered sections are not observed - re-bind [cngxScrollSpy] once they exist.');
|
|
1900
2003
|
}
|
|
1901
2004
|
if (elements.length === 0) {
|
|
1902
2005
|
return undefined;
|
|
1903
2006
|
}
|
|
1904
2007
|
const resolvedRoot = rootSelector ? this.doc.querySelector(rootSelector) : null;
|
|
1905
|
-
if (
|
|
1906
|
-
|
|
2008
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && rootSelector && !resolvedRoot) {
|
|
2009
|
+
cngxDevWarn('CNGX1032', `[cngxScrollSpy] root selector "${rootSelector}" matched no element - ` +
|
|
1907
2010
|
'falling back to the viewport. A late-rendered root needs a re-bind of [root].');
|
|
1908
2011
|
}
|
|
1909
2012
|
const observer = new IntersectionObserver((entries) => {
|
|
@@ -2451,5 +2554,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2451
2554
|
* Generated bundle index. Do not edit.
|
|
2452
2555
|
*/
|
|
2453
2556
|
|
|
2454
|
-
export { CNGX_CONTAINER_SIZE, CNGX_LAYOUT_I18N, CNGX_LAYOUT_LANGUAGE_EN, CngxBackdrop, CngxContainer, CngxDrawer, CngxDrawerContent, CngxDrawerPanel, CngxExpandableText, CngxExpandableToggle, CngxHighlight, CngxInfiniteScroll, CngxIntersectionObserver, CngxMediaQuery, CngxResizeObserver, CngxScrollEdges, CngxScrollLock, CngxScrollSpy, CngxSkeleton, CngxStickyHeader, CngxTruncate, createContainerSize, createResizeSignal, createScrollEdges, createScrollLock, injectContainerSize, injectLayoutI18n, injectMediaQuery, injectQueryParamSync, observeResize, provideLayoutI18n, withLayoutI18nLabels };
|
|
2557
|
+
export { CNGX_CONTAINER_SIZE, CNGX_LAYOUT_I18N, CNGX_LAYOUT_LANGUAGE_EN, CngxBackdrop, CngxContainer, CngxDrawer, CngxDrawerContent, CngxDrawerPanel, CngxExpandableText, CngxExpandableToggle, CngxHighlight, CngxInfiniteScroll, CngxIntersectionObserver, CngxMediaQuery, CngxResizeObserver, CngxScrollEdges, CngxScrollLock, CngxScrollSpy, CngxSkeleton, CngxStickyHeader, CngxTruncate, createContainerSize, createPinnedScrollLock, createResizeSignal, createScrollEdges, createScrollLock, injectContainerSize, injectLayoutI18n, injectMediaQuery, injectQueryParamSync, observeResize, provideLayoutI18n, withLayoutI18nLabels };
|
|
2455
2558
|
//# sourceMappingURL=cngx-common-layout.mjs.map
|