@cngx/common 0.1.0-rc.3 → 0.1.0-rc.4

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 (37) hide show
  1. package/display/README.md +1 -0
  2. package/fesm2022/cngx-common-a11y.mjs +123 -3
  3. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  4. package/fesm2022/cngx-common-card.mjs +8 -8
  5. package/fesm2022/cngx-common-card.mjs.map +1 -1
  6. package/fesm2022/cngx-common-data.mjs +691 -52
  7. package/fesm2022/cngx-common-data.mjs.map +1 -1
  8. package/fesm2022/cngx-common-display.mjs +320 -8
  9. package/fesm2022/cngx-common-display.mjs.map +1 -1
  10. package/fesm2022/cngx-common-interactive.mjs +1603 -75
  11. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  12. package/fesm2022/cngx-common-layout.mjs +187 -3
  13. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  14. package/fesm2022/cngx-common-popover.mjs +63 -8
  15. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  16. package/fesm2022/cngx-common.mjs +1 -1
  17. package/interactive/README.md +101 -0
  18. package/layout/README.md +39 -1
  19. package/package.json +1 -1
  20. package/theming/components/cngx-accordion.css +147 -0
  21. package/theming/components/cngx-badge.css +6 -0
  22. package/theming/components/cngx-bottom-sheet.css +8 -1
  23. package/theming/components/cngx-breadcrumb.css +108 -0
  24. package/theming/components/cngx-button-toggle.css +6 -0
  25. package/theming/components/cngx-data-grid.css +154 -0
  26. package/theming/components/cngx-dialog.css +4 -0
  27. package/theming/components/cngx-divider.css +4 -0
  28. package/theming/components/cngx-listbox.css +6 -0
  29. package/theming/components/cngx-menu.css +7 -0
  30. package/theming/components/cngx-slider.css +237 -0
  31. package/theming/components/cngx-tooltip.css +6 -0
  32. package/types/cngx-common-a11y.d.ts +67 -2
  33. package/types/cngx-common-data.d.ts +444 -22
  34. package/types/cngx-common-display.d.ts +189 -1
  35. package/types/cngx-common-interactive.d.ts +1014 -31
  36. package/types/cngx-common-layout.d.ts +88 -3
  37. package/types/cngx-common-popover.d.ts +25 -4
@@ -1,5 +1,5 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { ElementRef, Signal, TemplateRef } from '@angular/core';
2
+ import { ElementRef, Signal, WritableSignal, TemplateRef } from '@angular/core';
3
3
  import * as i1 from '@cngx/common/a11y';
4
4
 
5
5
  /**
@@ -343,6 +343,91 @@ declare class CngxMediaQuery {
343
343
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxMediaQuery, "[cngxMediaQuery]", ["cngxMediaQuery"], { "query": { "alias": "cngxMediaQuery"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
344
344
  }
345
345
 
346
+ /**
347
+ * Inject-form of {@link CngxMediaQuery}: returns a reactive
348
+ * `Signal<boolean>` that reflects whether the host window currently matches
349
+ * a CSS media query, without needing a host element.
350
+ *
351
+ * Use it where the directive form has nowhere to attach - inside a route
352
+ * guard, a store, a `computed()`, or any injection context that reacts to a
353
+ * viewport or preference query. For host-bound templates, prefer the
354
+ * `[cngxMediaQuery]` directive; for pure styling, prefer CSS `@media` /
355
+ * `@container`.
356
+ *
357
+ * Wraps `window.matchMedia()`: seeds the signal from `MediaQueryList.matches`,
358
+ * updates on the `change` event, and removes the listener via `DestroyRef`
359
+ * when the injection scope is destroyed. In SSR / non-DOM environments (no
360
+ * `defaultView` or no `matchMedia`) it returns a static `false` signal and
361
+ * wires no listener, so it never throws off the browser.
362
+ *
363
+ * Returns a `Signal<boolean>` - never an `Observable`; the reactive boundary
364
+ * stays inside cngx.
365
+ *
366
+ * ```typescript
367
+ * @Component({ … })
368
+ * export class Dashboard {
369
+ * private readonly compact = injectMediaQuery('(max-width: 640px)');
370
+ * protected readonly layout = computed(() => (this.compact() ? 'stacked' : 'grid'));
371
+ * }
372
+ * ```
373
+ *
374
+ * @param query A CSS media query string, e.g. `(max-width: 640px)`.
375
+ * @returns A reactive `Signal<boolean>` tracking the query's match state.
376
+ * @category common/layout
377
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/observers/inject-media-query.ts
378
+ * @since 0.1.0
379
+ * @relatedTo CngxMediaQuery, CngxResizeObserver
380
+ * <example-url>http://localhost:4200/#/common/layout/media-query/inject-breakpoint-signal</example-url>
381
+ */
382
+ declare function injectMediaQuery(query: string): Signal<boolean>;
383
+
384
+ /**
385
+ * Options for {@link injectQueryParamSync}.
386
+ *
387
+ * `param` accepts a live `Signal<string>` so a bound `[param]` rename stays
388
+ * reactive; a plain string is wrapped internally. `serialize`/`deserialize`
389
+ * default to a boolean codec (`true` -> `'open'`, absence -> `false`); pass an
390
+ * identity codec (`v => v ?? null` / `raw => raw`) to sync string ids.
391
+ */
392
+ interface QueryParamSyncOptions<T = boolean> {
393
+ /** Query-param key. A `Signal<string>` keeps a bound rename live. */
394
+ readonly param: string | Signal<string>;
395
+ /** `T` -> URL string, or `null` to remove the key. Default: boolean codec. */
396
+ readonly serialize?: (value: T) => string | null;
397
+ /** URL string (or `null` when absent) -> `T`. Default: boolean codec. */
398
+ readonly deserialize?: (raw: string | null) => T;
399
+ /** Invoked with the rejection reason when `router.navigate` rejects. */
400
+ readonly onSyncError?: (err: unknown) => void;
401
+ }
402
+ /**
403
+ * Bidirectional sync between a caller-owned `WritableSignal<T>` and a named
404
+ * query param. URL wins on initial load (deep-link intent); after hydrate the
405
+ * signal is the source and reflects outward. Re-hydrates on browser
406
+ * back/forward. Dev-warns once and no-ops when `@angular/router` is absent.
407
+ *
408
+ * Loop-safety (the core of this helper): the reflect effect writes the URL in
409
+ * `untracked()` and skips `navigate` when the serialized `state()` equals the
410
+ * last value it wrote - a local closure seeded from the initial URL read, not
411
+ * the live URL param (the live param races the navigate-settle window). The
412
+ * hydrate path updates that same closure whenever it accepts a URL value, so
413
+ * back/forward re-hydration never triggers a reflex navigate. A `param` rename
414
+ * is migrated in one navigate (`{ [old]: null, [new]: serialize(state()) }`)
415
+ * by a dedicated effect whose only tracked source is the normalized param
416
+ * signal; its first run seeds bookkeeping and never navigates.
417
+ *
418
+ * The `state.set` inside the hydrate effect is a deliberate signal-write-in-
419
+ * effect: the URL is an external system and `state` is a caller-owned signal
420
+ * the consumer must stay able to toggle, so hydrate cannot be a `computed`. It
421
+ * is edge-guarded by serialized equality and wrapped in `untracked()`.
422
+ *
423
+ * @category common/layout
424
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/layout/router/inject-query-param-sync.ts
425
+ * @since 0.1.0
426
+ * @relatedTo CngxStepperRouterSync
427
+ * <example-url>http://localhost:4200/#/common/layout/router/persisted-toggle</example-url>
428
+ */
429
+ declare function injectQueryParamSync<T = boolean>(state: WritableSignal<T>, opts: QueryParamSyncOptions<T>): void;
430
+
346
431
  /**
347
432
  * Observes size changes of the host element via the `ResizeObserver` API.
348
433
  *
@@ -896,5 +981,5 @@ declare class CngxExpandableText {
896
981
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxExpandableText, "cngx-expandable-text", ["cngxExpandableText"], { "lines": { "alias": "lines"; "required": false; "isSignal": true; }; "expanded": { "alias": "expanded"; "required": false; "isSignal": true; }; "moreLabel": { "alias": "moreLabel"; "required": false; "isSignal": true; }; "lessLabel": { "alias": "lessLabel"; "required": false; "isSignal": true; }; }, { "expanded": "expandedChange"; }, ["customToggle"], ["*"], true, never>;
897
982
  }
898
983
 
899
- export { CngxBackdrop, CngxDrawer, CngxDrawerContent, CngxDrawerPanel, CngxExpandableText, CngxExpandableToggle, CngxHighlight, CngxInfiniteScroll, CngxIntersectionObserver, CngxMediaQuery, CngxResizeObserver, CngxScrollLock, CngxScrollSpy, CngxSkeleton, CngxStickyHeader, CngxTruncate };
900
- export type { CngxExpandableToggleContext, DrawerMode, DrawerPosition };
984
+ export { CngxBackdrop, CngxDrawer, CngxDrawerContent, CngxDrawerPanel, CngxExpandableText, CngxExpandableToggle, CngxHighlight, CngxInfiniteScroll, CngxIntersectionObserver, CngxMediaQuery, CngxResizeObserver, CngxScrollLock, CngxScrollSpy, CngxSkeleton, CngxStickyHeader, CngxTruncate, injectMediaQuery, injectQueryParamSync };
985
+ export type { CngxExpandableToggleContext, DrawerMode, DrawerPosition, QueryParamSyncOptions };
@@ -175,6 +175,14 @@ declare class CngxPopover {
175
175
  readonly offset: _angular_core.InputSignal<number>;
176
176
  /** Whether Escape key dismisses the popover. */
177
177
  readonly closeOnEscape: _angular_core.InputSignal<boolean>;
178
+ /**
179
+ * Whether a `pointerdown` outside both the popover and its anchor (trigger)
180
+ * dismisses it - menu / listbox light-dismiss. Opt-in (default `false`) so
181
+ * existing manual-mode popovers keep full control; the anchor is excluded so
182
+ * a click on the trigger toggles via the trigger's own handler instead of
183
+ * being closed here and immediately reopened.
184
+ */
185
+ readonly closeOnOutsideClick: _angular_core.InputSignal<boolean>;
178
186
  /** Native popover mode. `'manual'` for full control, `'auto'` for browser light dismiss. */
179
187
  readonly mode: _angular_core.InputSignal<PopoverMode>;
180
188
  /**
@@ -267,6 +275,12 @@ declare class CngxPopover {
267
275
  /** Toggle between open and closed. */
268
276
  toggle(): void;
269
277
  protected handleToggle(e: ToggleEvent): void;
278
+ /**
279
+ * @internal Called by the global outside-click listener for every open
280
+ * popover. Hides this one when it opted into `closeOnOutsideClick` and the
281
+ * pointerdown landed outside both its panel and its anchor (trigger).
282
+ */
283
+ closeIfOutsidePointerDown(target: EventTarget | null): void;
270
284
  /**
271
285
  * Apply Floating UI positioning when CSS Anchor is not supported
272
286
  * and the consumer has provided the fallback via `provideFloatingFallback()`.
@@ -284,7 +298,7 @@ declare class CngxPopover {
284
298
  private startClosing;
285
299
  private finalize;
286
300
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxPopover, never>;
287
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxPopover, "[cngxPopover]", ["cngxPopover"], { "placement": { "alias": "placement"; "required": false; "isSignal": true; }; "positionTryFallbacks": { "alias": "positionTryFallbacks"; "required": false; "isSignal": true; }; "offset": { "alias": "offset"; "required": false; "isSignal": true; }; "closeOnEscape": { "alias": "closeOnEscape"; "required": false; "isSignal": true; }; "mode": { "alias": "mode"; "required": false; "isSignal": true; }; "controlledOpen": { "alias": "cngxPopoverOpen"; "required": false; "isSignal": true; }; "exclusive": { "alias": "exclusive"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
301
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxPopover, "[cngxPopover]", ["cngxPopover"], { "placement": { "alias": "placement"; "required": false; "isSignal": true; }; "positionTryFallbacks": { "alias": "positionTryFallbacks"; "required": false; "isSignal": true; }; "offset": { "alias": "offset"; "required": false; "isSignal": true; }; "closeOnEscape": { "alias": "closeOnEscape"; "required": false; "isSignal": true; }; "closeOnOutsideClick": { "alias": "closeOnOutsideClick"; "required": false; "isSignal": true; }; "mode": { "alias": "mode"; "required": false; "isSignal": true; }; "controlledOpen": { "alias": "cngxPopoverOpen"; "required": false; "isSignal": true; }; "exclusive": { "alias": "exclusive"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
288
302
  }
289
303
 
290
304
  /**
@@ -329,8 +343,14 @@ declare class CngxPopoverTrigger {
329
343
  * `CngxPopoverPanel`). Final fallback when neither is set is `'true'`.
330
344
  * Accepts the W3C-spec values for supported popup-container roles:
331
345
  * `'dialog'`, `'listbox'`, `'menu'`, `'tree'`, or `'true'`.
346
+ *
347
+ * Pass `'none'` to emit no `aria-haspopup` at all - correct for a
348
+ * disclosure whose popup is not one of the recognised widget types
349
+ * (e.g. a list of links), where `aria-expanded` alone describes the
350
+ * trigger. `'none'` wins over the composer hint, so it also cancels a
351
+ * `CngxPopoverPanel`'s `'dialog'` default.
332
352
  */
333
- readonly haspopupInput: _angular_core.InputSignal<PopoverHaspopup | undefined>;
353
+ readonly haspopupInput: _angular_core.InputSignal<PopoverHaspopup | "none" | undefined>;
334
354
  /**
335
355
  * When `true`, captures `document.activeElement` the moment the
336
356
  * popover transitions to a visible state and restores focus to that
@@ -343,9 +363,10 @@ declare class CngxPopoverTrigger {
343
363
  * Resolved `aria-haspopup`. Consumer override (`haspopup` on the
344
364
  * trigger element) wins; otherwise the popover's `haspopup` signal
345
365
  * (set by composers like `CngxPopoverPanel`) decides; final fallback
346
- * is `'true'`.
366
+ * is `'true'`. The `'none'` sentinel resolves to `null` so the host
367
+ * binding drops the attribute entirely.
347
368
  */
348
- protected readonly haspopup: _angular_core.Signal<PopoverHaspopup>;
369
+ protected readonly haspopup: _angular_core.Signal<PopoverHaspopup | null>;
349
370
  protected readonly cssAnchorName: _angular_core.Signal<string | null>;
350
371
  private savedFocus;
351
372
  constructor();