@truenas/ui-components 0.1.65 → 0.1.67

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.1.65",
3
+ "version": "0.1.67",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public"
@@ -1,5 +1,5 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { ElementRef, OnDestroy, AfterViewInit, OnInit, TemplateRef, AfterContentInit, Provider, ChangeDetectorRef, InjectionToken, Signal, PipeTransform, ViewContainerRef, AfterViewChecked, ComponentRef } from '@angular/core';
2
+ import { OnDestroy, ElementRef, AfterViewInit, OnInit, TemplateRef, AfterContentInit, Provider, ChangeDetectorRef, InjectionToken, Signal, PipeTransform, ViewContainerRef, AfterViewChecked, ComponentRef } from '@angular/core';
3
3
  import { ControlValueAccessor, NgControl } from '@angular/forms';
4
4
  import { ComponentHarness, BaseHarnessFilters, HarnessPredicate, HarnessLoader } from '@angular/cdk/testing';
5
5
  import { SafeHtml, SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
@@ -14,8 +14,10 @@ import { Overlay } from '@angular/cdk/overlay';
14
14
  import { DialogConfig, DialogRef } from '@angular/cdk/dialog';
15
15
  import { ComponentType } from '@angular/cdk/portal';
16
16
 
17
- declare class TnAutocompleteComponent<T = unknown> implements ControlValueAccessor {
17
+ declare class TnAutocompleteComponent<T = unknown> implements ControlValueAccessor, OnDestroy {
18
18
  private readonly elementRef;
19
+ private readonly overlay;
20
+ private readonly viewContainerRef;
19
21
  /** Unique instance ID for ARIA linkage */
20
22
  protected readonly uid: string;
21
23
  /** All available options */
@@ -32,14 +34,31 @@ declare class TnAutocompleteComponent<T = unknown> implements ControlValueAccess
32
34
  filterFn: _angular_core.InputSignal<((option: T, searchTerm: string) => boolean) | undefined>;
33
35
  /** Text shown when no options match the search */
34
36
  noResultsText: _angular_core.InputSignal<string>;
35
- /** Maximum number of options to render */
37
+ /**
38
+ * Maximum number of options to render.
39
+ *
40
+ * Defaults to `Infinity` so browsing the open dropdown without a search term
41
+ * never silently truncates a long list. Pass an explicit cap if you want to
42
+ * limit how many filtered results are rendered at once.
43
+ */
36
44
  maxResults: _angular_core.InputSignal<number>;
45
+ /**
46
+ * Max height of the dropdown panel before it scrolls. Accepts a number
47
+ * (interpreted as `px`) or any CSS length string (e.g. `'320px'`,
48
+ * `'min(320px, 40vh)'`). Surfaced as the `--tn-autocomplete-panel-max-height`
49
+ * custom property so it can also be themed in CSS.
50
+ */
51
+ panelMaxHeight: _angular_core.InputSignal<string | number>;
37
52
  /** Test ID attribute */
38
53
  testId: _angular_core.InputSignal<string>;
39
54
  /** Emits when an option is selected */
40
55
  optionSelected: _angular_core.OutputEmitterRef<T>;
41
56
  /** Reference to the input element */
42
57
  inputEl: _angular_core.Signal<ElementRef<HTMLInputElement> | undefined>;
58
+ /** Template for the dropdown panel, portaled into a CDK overlay on open. */
59
+ private dropdownTemplate;
60
+ /** Normalized panel max-height as a CSS length string. */
61
+ protected panelMaxHeightValue: _angular_core.Signal<string>;
43
62
  /** Current search term typed by the user */
44
63
  protected searchTerm: _angular_core.WritableSignal<string>;
45
64
  /** Whether the dropdown is open */
@@ -58,7 +77,11 @@ declare class TnAutocompleteComponent<T = unknown> implements ControlValueAccess
58
77
  protected hasResults: _angular_core.Signal<boolean>;
59
78
  private onChange;
60
79
  private onTouched;
61
- constructor();
80
+ /** Live overlay holding the dropdown panel, or undefined when closed. */
81
+ private overlayRef?;
82
+ /** Subscriptions tied to the current overlay; torn down on close. */
83
+ private overlaySubs;
84
+ ngOnDestroy(): void;
62
85
  writeValue(value: T | null): void;
63
86
  registerOnChange(fn: (value: T | null) => void): void;
64
87
  registerOnTouched(fn: () => void): void;
@@ -69,10 +92,22 @@ declare class TnAutocompleteComponent<T = unknown> implements ControlValueAccess
69
92
  onOptionClick(option: T): void;
70
93
  onKeydown(event: KeyboardEvent): void;
71
94
  private selectOption;
95
+ private open;
72
96
  private close;
97
+ /**
98
+ * Attach the dropdown panel as a CDK overlay anchored to the input.
99
+ *
100
+ * Why an overlay (vs. an inline absolutely-positioned panel): the panel is
101
+ * appended to the overlay container on `document.body`, so it can never be
102
+ * clipped by an ancestor's `overflow: hidden`/`auto` (e.g. a surrounding
103
+ * card). CDK also flips the panel above the input near the viewport edge and
104
+ * matches its width to the input. Mirrors TnSelectComponent's approach.
105
+ */
106
+ private attachOverlay;
107
+ private detachOverlay;
73
108
  private scrollToHighlighted;
74
109
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnAutocompleteComponent<any>, never>;
75
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnAutocompleteComponent<any>, "tn-autocomplete", never, { "options": { "alias": "options"; "required": false; "isSignal": true; }; "displayWith": { "alias": "displayWith"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "requireSelection": { "alias": "requireSelection"; "required": false; "isSignal": true; }; "filterFn": { "alias": "filterFn"; "required": false; "isSignal": true; }; "noResultsText": { "alias": "noResultsText"; "required": false; "isSignal": true; }; "maxResults": { "alias": "maxResults"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; }, { "optionSelected": "optionSelected"; }, never, never, true, never>;
110
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnAutocompleteComponent<any>, "tn-autocomplete", never, { "options": { "alias": "options"; "required": false; "isSignal": true; }; "displayWith": { "alias": "displayWith"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "requireSelection": { "alias": "requireSelection"; "required": false; "isSignal": true; }; "filterFn": { "alias": "filterFn"; "required": false; "isSignal": true; }; "noResultsText": { "alias": "noResultsText"; "required": false; "isSignal": true; }; "maxResults": { "alias": "maxResults"; "required": false; "isSignal": true; }; "panelMaxHeight": { "alias": "panelMaxHeight"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; }, { "optionSelected": "optionSelected"; }, never, never, true, never>;
76
111
  }
77
112
 
78
113
  /**
@@ -2284,7 +2319,7 @@ declare class TnTabsComponent implements AfterContentInit, AfterViewInit, OnDest
2284
2319
  tabHeader: _angular_core.Signal<ElementRef<HTMLElement>>;
2285
2320
  selectedIndex: _angular_core.InputSignal<number>;
2286
2321
  orientation: _angular_core.InputSignal<"horizontal" | "vertical">;
2287
- highlightPosition: _angular_core.InputSignal<"left" | "right" | "top" | "bottom">;
2322
+ highlightPosition: _angular_core.InputSignal<"bottom" | "top" | "left" | "right">;
2288
2323
  /**
2289
2324
  * Test-id applied to the tablist root element. Rendered under whichever attribute name
2290
2325
  * is configured via `TN_TEST_ATTR` (default `data-testid`).
@@ -2926,6 +2961,10 @@ declare class TnFormFieldComponent implements AfterContentInit {
2926
2961
  required: _angular_core.InputSignal<boolean>;
2927
2962
  testId: _angular_core.InputSignal<string>;
2928
2963
  subscriptSizing: _angular_core.InputSignal<SubscriptSizing>;
2964
+ /** Optional tooltip shown via a help icon next to the label. */
2965
+ tooltip: _angular_core.InputSignal<string>;
2966
+ /** Placement of the tooltip relative to its help icon. */
2967
+ tooltipPosition: _angular_core.InputSignal<TooltipPosition>;
2929
2968
  control: _angular_core.Signal<NgControl | undefined>;
2930
2969
  protected hasError: _angular_core.WritableSignal<boolean>;
2931
2970
  protected errorMessage: _angular_core.WritableSignal<string>;
@@ -2936,7 +2975,7 @@ declare class TnFormFieldComponent implements AfterContentInit {
2936
2975
  showHint: _angular_core.Signal<boolean>;
2937
2976
  protected showSubscript: _angular_core.Signal<boolean>;
2938
2977
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnFormFieldComponent, never>;
2939
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnFormFieldComponent, "tn-form-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; "subscriptSizing": { "alias": "subscriptSizing"; "required": false; "isSignal": true; }; }, {}, ["control"], ["*"], true, never>;
2978
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnFormFieldComponent, "tn-form-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; "subscriptSizing": { "alias": "subscriptSizing"; "required": false; "isSignal": true; }; "tooltip": { "alias": "tooltip"; "required": false; "isSignal": true; }; "tooltipPosition": { "alias": "tooltipPosition"; "required": false; "isSignal": true; }; }, {}, ["control"], ["*"], true, never>;
2940
2979
  }
2941
2980
 
2942
2981
  /**
@@ -2970,6 +3009,7 @@ declare class TnFormFieldHarness extends ComponentHarness {
2970
3009
  private _label;
2971
3010
  private _error;
2972
3011
  private _hint;
3012
+ private _tooltip;
2973
3013
  /**
2974
3014
  * Gets a `HarnessPredicate` that can be used to search for a form field
2975
3015
  * with specific attributes.
@@ -3038,6 +3078,30 @@ declare class TnFormFieldHarness extends ComponentHarness {
3038
3078
  * ```
3039
3079
  */
3040
3080
  getHint(): Promise<string | null>;
3081
+ /**
3082
+ * Checks whether the form field has a tooltip help icon.
3083
+ *
3084
+ * @returns Promise resolving to true if the tooltip trigger is present.
3085
+ *
3086
+ * @example
3087
+ * ```typescript
3088
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Purpose' }));
3089
+ * expect(await field.hasTooltip()).toBe(true);
3090
+ * ```
3091
+ */
3092
+ hasTooltip(): Promise<boolean>;
3093
+ /**
3094
+ * Gets the tooltip message (read from the trigger's accessible label).
3095
+ *
3096
+ * @returns Promise resolving to the tooltip text, or null if no tooltip.
3097
+ *
3098
+ * @example
3099
+ * ```typescript
3100
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Purpose' }));
3101
+ * expect(await field.getTooltip()).toBe('What this share is used for');
3102
+ * ```
3103
+ */
3104
+ getTooltip(): Promise<string | null>;
3041
3105
  /**
3042
3106
  * Checks whether the form field is marked as required.
3043
3107
  *