@truenas/ui-components 0.4.11 → 0.4.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truenas/ui-components",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public"
@@ -1,6 +1,6 @@
1
1
  import * as _truenas_ui_components from '@truenas/ui-components';
2
2
  import * as _angular_core from '@angular/core';
3
- import { Signal, InjectionToken, Renderer2, OnDestroy, ElementRef, AfterViewInit, OnInit, TemplateRef, AfterContentInit, Provider, ChangeDetectorRef, TrackByFunction, OnChanges, DoCheck, SimpleChanges, PipeTransform, ViewContainerRef, AfterViewChecked, ComponentRef } from '@angular/core';
3
+ import { Signal, InjectionToken, Renderer2, OnDestroy, ElementRef, AfterViewInit, TemplateRef, AfterContentInit, Provider, ChangeDetectorRef, OnInit, TrackByFunction, OnChanges, DoCheck, SimpleChanges, PipeTransform, ViewContainerRef, AfterViewChecked, ComponentRef } from '@angular/core';
4
4
  import { ControlValueAccessor, NgControl, AbstractControl } from '@angular/forms';
5
5
  import { ComponentHarness, BaseHarnessFilters, HarnessPredicate, TestKey, HarnessLoader, ModifierKeys as ModifierKeys$1 } from '@angular/cdk/testing';
6
6
  import { SafeHtml, SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
@@ -1300,6 +1300,7 @@ declare class TnButtonComponent implements AfterViewInit {
1300
1300
  classes: _angular_core.Signal<string[]>;
1301
1301
  handleAnchorClick(event: MouseEvent): void;
1302
1302
  private hostRef;
1303
+ constructor();
1303
1304
  private innerRef;
1304
1305
  ngAfterViewInit(): void;
1305
1306
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnButtonComponent, never>;
@@ -1506,7 +1507,7 @@ declare class TnIconComponent {
1506
1507
  }
1507
1508
 
1508
1509
  type TooltipPosition = 'above' | 'below' | 'left' | 'right' | 'before' | 'after';
1509
- declare class TnTooltipDirective implements OnInit, OnDestroy {
1510
+ declare class TnTooltipDirective implements AfterViewInit, OnDestroy {
1510
1511
  message: _angular_core.InputSignal<string>;
1511
1512
  position: _angular_core.InputSignal<TooltipPosition>;
1512
1513
  disabled: _angular_core.InputSignal<boolean>;
@@ -1520,22 +1521,44 @@ declare class TnTooltipDirective implements OnInit, OnDestroy {
1520
1521
  private _isTooltipVisible;
1521
1522
  private _positionSub;
1522
1523
  private _tooltipId;
1523
- /**
1524
- * Only point `aria-describedby` at the tooltip when there is actually a message to
1525
- * describe. Otherwise every host (e.g. an icon button with no tooltip) would carry a
1526
- * dangling reference to a tooltip element that is never rendered.
1527
- */
1528
- protected get _ariaDescribedBy(): string | null;
1529
1524
  private _overlay;
1530
1525
  private _elementRef;
1531
1526
  private _viewContainerRef;
1532
1527
  private _overlayPositionBuilder;
1533
- ngOnInit(): void;
1528
+ private _ariaDescriber;
1529
+ private _viewInitialized;
1530
+ private _describedTarget;
1531
+ private _describedMessage;
1532
+ private _innerObserver;
1533
+ /**
1534
+ * Re-sync the description (see ngAfterViewInit) when the inputs change. The initial
1535
+ * write cannot happen here: on the first run the host's child components (e.g.
1536
+ * tn-button's inner `<button>`) have not rendered yet.
1537
+ */
1538
+ private readonly _syncDescriptionOnInputChange;
1539
+ /**
1540
+ * Expose the message to assistive tech via CDK's AriaDescriber: it keeps the text in
1541
+ * a persistent visually-hidden element (so `aria-describedby` never dangles — the
1542
+ * overlay tooltip only exists while shown) and adds/removes only its own id token,
1543
+ * leaving descriptions the control already carries (form hints, error ids) intact.
1544
+ * The description goes on the interactive element itself: the host when it is one,
1545
+ * otherwise the first interactive descendant (e.g. `<tn-button>`'s inner `<button>`),
1546
+ * because screen readers read descriptions off the focused control, not wrappers.
1547
+ */
1548
+ ngAfterViewInit(): void;
1549
+ private _syncAriaDescription;
1550
+ /**
1551
+ * The overlay tooltip renders its message as HTML (`[innerHTML]`), but AriaDescriber
1552
+ * writes the description as plain text — strip any markup so screen readers never
1553
+ * announce literal tags. DOMParser parses inert markup (no script execution).
1554
+ */
1555
+ private _plainTextMessage;
1556
+ private _removeAriaDescription;
1534
1557
  ngOnDestroy(): void;
1535
1558
  _onMouseEnter(): void;
1536
1559
  _onMouseLeave(): void;
1537
- _onFocus(): void;
1538
- _onBlur(): void;
1560
+ _onFocusIn(): void;
1561
+ _onFocusOut(event: FocusEvent): void;
1539
1562
  _onKeydown(event: KeyboardEvent): void;
1540
1563
  /** Shows the tooltip */
1541
1564
  show(delay?: number): void;
@@ -2977,6 +3000,15 @@ interface TnCardAction {
2977
3000
  handler: () => void;
2978
3001
  disabled?: boolean;
2979
3002
  icon?: string;
3003
+ /**
3004
+ * Tooltip for the action button — useful for explaining why an action is unavailable.
3005
+ * Shows on pointer hover (including while the action is disabled, since hover
3006
+ * retargets to the button's host element) and on keyboard focus while enabled. A
3007
+ * disabled native button is not focusable, so keyboard-only users cannot reach the
3008
+ * reason; screen reader users can still read it when browsing the button via its
3009
+ * persistent `aria-describedby` description.
3010
+ */
3011
+ tooltip?: string;
2980
3012
  /**
2981
3013
  * Test-id applied to the rendered action button. Rendered under whichever attribute name
2982
3014
  * is configured via `TN_TEST_ATTR` (default `data-testid`).