@truenas/ui-components 0.1.23 → 0.1.24

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.23",
3
+ "version": "0.1.24",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public"
@@ -1,8 +1,8 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { ElementRef, AfterViewInit, OnDestroy, AfterContentInit, TemplateRef, Provider, ChangeDetectorRef, PipeTransform, OnInit, ViewContainerRef, AfterViewChecked } from '@angular/core';
3
+ import { ControlValueAccessor, NgControl } from '@angular/forms';
3
4
  import { ComponentHarness, BaseHarnessFilters, HarnessPredicate, HarnessLoader } from '@angular/cdk/testing';
4
5
  import { SafeHtml, SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
5
- import { ControlValueAccessor, NgControl } from '@angular/forms';
6
6
  import { DataSource } from '@angular/cdk/collections';
7
7
  import * as i1 from '@angular/cdk/tree';
8
8
  import { CdkTree, FlatTreeControl, CdkTreeNode, CdkNestedTreeNode } from '@angular/cdk/tree';
@@ -13,6 +13,246 @@ import { DialogConfig, DialogRef } from '@angular/cdk/dialog';
13
13
  import { ComponentType } from '@angular/cdk/portal';
14
14
  import { ComponentFixture } from '@angular/core/testing';
15
15
 
16
+ declare class TnAutocompleteComponent<T = unknown> implements ControlValueAccessor {
17
+ private readonly elementRef;
18
+ /** Unique instance ID for ARIA linkage */
19
+ protected readonly uid: string;
20
+ /** All available options */
21
+ options: _angular_core.InputSignal<T[]>;
22
+ /** Transform a value to its display string */
23
+ displayWith: _angular_core.InputSignal<(value: T) => string>;
24
+ /** Placeholder text for the input */
25
+ placeholder: _angular_core.InputSignal<string>;
26
+ /** Whether the input is disabled */
27
+ disabled: _angular_core.InputSignal<boolean>;
28
+ /** Require the user to select from the dropdown — reverts on blur if no match */
29
+ requireSelection: _angular_core.InputSignal<boolean>;
30
+ /** Custom filter function. Defaults to case-insensitive includes on displayWith text */
31
+ filterFn: _angular_core.InputSignal<((option: T, searchTerm: string) => boolean) | undefined>;
32
+ /** Text shown when no options match the search */
33
+ noResultsText: _angular_core.InputSignal<string>;
34
+ /** Maximum number of options to render */
35
+ maxResults: _angular_core.InputSignal<number>;
36
+ /** Test ID attribute */
37
+ testId: _angular_core.InputSignal<string>;
38
+ /** Emits when an option is selected */
39
+ optionSelected: _angular_core.OutputEmitterRef<T>;
40
+ /** Reference to the input element */
41
+ inputEl: _angular_core.Signal<ElementRef<HTMLInputElement> | undefined>;
42
+ /** Current search term typed by the user */
43
+ protected searchTerm: _angular_core.WritableSignal<string>;
44
+ /** Whether the dropdown is open */
45
+ protected isOpen: _angular_core.WritableSignal<boolean>;
46
+ /** Index of the currently highlighted option for keyboard nav */
47
+ protected highlightedIndex: _angular_core.WritableSignal<number>;
48
+ /** The currently selected value */
49
+ private selectedValue;
50
+ /** CVA disabled state from the form */
51
+ private formDisabled;
52
+ /** Combined disabled state */
53
+ isDisabled: _angular_core.Signal<boolean>;
54
+ /** Filtered and capped options */
55
+ protected filteredOptions: _angular_core.Signal<T[]>;
56
+ /** Whether there are any results to show */
57
+ protected hasResults: _angular_core.Signal<boolean>;
58
+ private onChange;
59
+ private onTouched;
60
+ constructor();
61
+ writeValue(value: T | null): void;
62
+ registerOnChange(fn: (value: T | null) => void): void;
63
+ registerOnTouched(fn: () => void): void;
64
+ setDisabledState(isDisabled: boolean): void;
65
+ onInput(event: Event): void;
66
+ onFocus(): void;
67
+ onBlur(): void;
68
+ onOptionClick(option: T): void;
69
+ onKeydown(event: KeyboardEvent): void;
70
+ private selectOption;
71
+ private close;
72
+ private scrollToHighlighted;
73
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnAutocompleteComponent<any>, never>;
74
+ 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>;
75
+ }
76
+
77
+ /**
78
+ * Harness for interacting with tn-autocomplete in tests.
79
+ * Provides methods for querying state, typing search text, and selecting options.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * // Find and select an option
84
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
85
+ * await ac.selectOption('United States');
86
+ *
87
+ * // Type to filter, then read options
88
+ * await ac.setInputValue('Can');
89
+ * const options = await ac.getOptions();
90
+ * expect(options).toEqual(['Canada']);
91
+ *
92
+ * // Filter by placeholder
93
+ * const countryAc = await loader.getHarness(
94
+ * TnAutocompleteHarness.with({ placeholder: 'Search countries...' })
95
+ * );
96
+ * ```
97
+ */
98
+ declare class TnAutocompleteHarness extends ComponentHarness {
99
+ /**
100
+ * The selector for the host element of a `TnAutocompleteComponent` instance.
101
+ */
102
+ static hostSelector: string;
103
+ private _input;
104
+ /**
105
+ * Gets a `HarnessPredicate` that can be used to search for an autocomplete
106
+ * with specific attributes.
107
+ *
108
+ * @param options Options for filtering which autocomplete instances are considered a match.
109
+ * @returns A `HarnessPredicate` configured with the given options.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * // Find by exact placeholder
114
+ * const ac = await loader.getHarness(
115
+ * TnAutocompleteHarness.with({ placeholder: 'Search countries...' })
116
+ * );
117
+ * ```
118
+ */
119
+ static with(options?: AutocompleteHarnessFilters): HarnessPredicate<TnAutocompleteHarness>;
120
+ /**
121
+ * Gets the current value of the input field.
122
+ *
123
+ * @returns Promise resolving to the input value.
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
128
+ * await ac.selectOption('Canada');
129
+ * expect(await ac.getInputValue()).toBe('Canada');
130
+ * ```
131
+ */
132
+ getInputValue(): Promise<string>;
133
+ /**
134
+ * Sets the value of the input by clearing and typing.
135
+ * This triggers filtering of the dropdown options.
136
+ *
137
+ * @param value The text to type into the input.
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
142
+ * await ac.setInputValue('Can');
143
+ * const options = await ac.getOptions();
144
+ * expect(options).toEqual(['Canada']);
145
+ * ```
146
+ */
147
+ setInputValue(value: string): Promise<void>;
148
+ /**
149
+ * Gets the placeholder text of the input.
150
+ *
151
+ * @returns Promise resolving to the placeholder string, or null.
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
156
+ * expect(await ac.getPlaceholder()).toBe('Type to search...');
157
+ * ```
158
+ */
159
+ getPlaceholder(): Promise<string | null>;
160
+ /**
161
+ * Checks whether the dropdown is currently open.
162
+ *
163
+ * @returns Promise resolving to true if the dropdown is visible.
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
168
+ * expect(await ac.isOpen()).toBe(false);
169
+ * await ac.focus();
170
+ * expect(await ac.isOpen()).toBe(true);
171
+ * ```
172
+ */
173
+ isOpen(): Promise<boolean>;
174
+ /**
175
+ * Checks whether the autocomplete input is disabled.
176
+ *
177
+ * @returns Promise resolving to true if the input is disabled.
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
182
+ * expect(await ac.isDisabled()).toBe(false);
183
+ * ```
184
+ */
185
+ isDisabled(): Promise<boolean>;
186
+ /**
187
+ * Gets the labels of all visible options in the dropdown.
188
+ * Opens the dropdown via focus if not already open.
189
+ *
190
+ * @returns Promise resolving to an array of option label strings.
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
195
+ * await ac.setInputValue('C');
196
+ * const options = await ac.getOptions();
197
+ * expect(options).toContain('Canada');
198
+ * ```
199
+ */
200
+ getOptions(): Promise<string[]>;
201
+ /**
202
+ * Selects an option by its label text. Opens the dropdown via focus if needed.
203
+ *
204
+ * @param filter The text to match against option labels. Supports string or RegExp.
205
+ * @returns Promise that resolves when the option has been selected.
206
+ * @throws Error if no matching option is found.
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
211
+ *
212
+ * // Select by exact text
213
+ * await ac.selectOption('Canada');
214
+ *
215
+ * // Select by regex
216
+ * await ac.selectOption(/united/i);
217
+ * ```
218
+ */
219
+ selectOption(filter: string | RegExp): Promise<void>;
220
+ /**
221
+ * Focuses the autocomplete input, which opens the dropdown.
222
+ *
223
+ * @returns Promise that resolves when the input is focused.
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
228
+ * await ac.focus();
229
+ * expect(await ac.isOpen()).toBe(true);
230
+ * ```
231
+ */
232
+ focus(): Promise<void>;
233
+ /**
234
+ * Blurs the autocomplete input, which closes the dropdown.
235
+ *
236
+ * @returns Promise that resolves when the input is blurred.
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const ac = await loader.getHarness(TnAutocompleteHarness);
241
+ * await ac.focus();
242
+ * await ac.blur();
243
+ * expect(await ac.isOpen()).toBe(false);
244
+ * ```
245
+ */
246
+ blur(): Promise<void>;
247
+ }
248
+ /**
249
+ * A set of criteria that can be used to filter a list of `TnAutocompleteHarness` instances.
250
+ */
251
+ interface AutocompleteHarnessFilters extends BaseHarnessFilters {
252
+ /** Filters by placeholder text. */
253
+ placeholder?: string;
254
+ }
255
+
16
256
  declare enum DiskType {
17
257
  Hdd = "HDD",
18
258
  Ssd = "SSD"
@@ -4179,5 +4419,5 @@ declare const TN_THEME_DEFINITIONS: readonly TnThemeDefinition[];
4179
4419
  */
4180
4420
  declare const THEME_MAP: Map<TnTheme, TnThemeDefinition>;
4181
4421
 
4182
- export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LIGHT_THEME, LinuxModifierKeys, LinuxShortcuts, ModifierKeys, QuickShortcuts, ShortcutBuilder, StripMntPrefixPipe, THEME_MAP, THEME_STORAGE_KEY, TN_THEME_DEFINITIONS, TnBannerActionDirective, TnBannerComponent, TnBannerHarness, TnBrandedSpinnerComponent, TnButtonComponent, TnButtonHarness, TnButtonToggleComponent, TnButtonToggleGroupComponent, TnCalendarComponent, TnCalendarHeaderComponent, TnCardComponent, TnCellDefDirective, TnCheckboxComponent, TnChipComponent, TnConfirmDialogComponent, TnDateInputComponent, TnDateRangeInputComponent, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnHeaderCellDefDirective, TnIconButtonComponent, TnIconButtonHarness, TnIconComponent, TnIconHarness, TnIconRegistryService, TnIconTesting, TnInputComponent, TnInputDirective, TnInputHarness, TnKeyboardShortcutComponent, TnKeyboardShortcutService, TnListAvatarDirective, TnListComponent, TnListIconDirective, TnListItemComponent, TnListItemLineDirective, TnListItemPrimaryDirective, TnListItemSecondaryDirective, TnListItemTitleDirective, TnListItemTrailingDirective, TnListOptionComponent, TnListSubheaderComponent, TnMenuActivateHoverDirective, TnMenuComponent, TnMenuTriggerDirective, TnMonthViewComponent, TnMultiYearViewComponent, TnNestedTreeNodeComponent, TnParticleProgressBarComponent, TnProgressBarComponent, TnRadioComponent, TnSelectComponent, TnSelectHarness, TnSelectionListComponent, TnSidePanelActionDirective, TnSidePanelComponent, TnSidePanelHarness, TnSidePanelHeaderActionDirective, TnSlideToggleComponent, TnSliderComponent, TnSliderThumbDirective, TnSliderWithLabelDirective, TnSpinnerComponent, TnSpriteLoaderService, TnStepComponent, TnStepperComponent, TnTabComponent, TnTabHarness, TnTabPanelComponent, TnTabPanelHarness, TnTableColumnDirective, TnTableComponent, TnTabsComponent, TnTabsHarness, TnTheme, TnThemeService, TnTimeInputComponent, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, libIconMarker, registerLucideIcons, setupLucideIntegration, tnIconMarker };
4183
- export type { BannerHarnessFilters, ButtonHarnessFilters, CalendarCell, ChipColor, CreateFolderEvent, DateRange, DialogHarnessFilters, EmptyHarnessFilters, FilePickerCallbacks, FilePickerError, FilePickerMode, FileSystemItem, IconButtonHarnessFilters, IconHarnessFilters, IconLibrary, IconLibraryType, IconResult, IconSize, IconSource, IconTestingMockOverrides, InputHarnessFilters, KeyCombination, LabelType, LucideIconOptions, MockIconRegistry, MockSpriteLoader, PathSegment, PlatformType, ProgressBarMode, ResolvedIcon, SelectHarnessFilters, ShortcutHandler, SidePanelHarnessFilters, SlideToggleColor, SpinnerMode, SpriteConfig, TabChangeEvent, TabHarnessFilters, TabPanelHarnessFilters, TabsHarnessFilters, TnBannerType, TnButtonToggleType, TnCardAction, TnCardControl, TnCardFooterLink, TnCardHeaderStatus, TnConfirmDialogData, TnDialogDefaults, TnDialogOpenTarget, TnEmptySize, TnFlatTreeNode, TnMenuItem, TnSelectOption, TnSelectOptionGroup, TnSelectionChange, TnTableDataSource, TnThemeDefinition, TooltipPosition, YearCell };
4422
+ export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LIGHT_THEME, LinuxModifierKeys, LinuxShortcuts, ModifierKeys, QuickShortcuts, ShortcutBuilder, StripMntPrefixPipe, THEME_MAP, THEME_STORAGE_KEY, TN_THEME_DEFINITIONS, TnAutocompleteComponent, TnAutocompleteHarness, TnBannerActionDirective, TnBannerComponent, TnBannerHarness, TnBrandedSpinnerComponent, TnButtonComponent, TnButtonHarness, TnButtonToggleComponent, TnButtonToggleGroupComponent, TnCalendarComponent, TnCalendarHeaderComponent, TnCardComponent, TnCellDefDirective, TnCheckboxComponent, TnChipComponent, TnConfirmDialogComponent, TnDateInputComponent, TnDateRangeInputComponent, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnHeaderCellDefDirective, TnIconButtonComponent, TnIconButtonHarness, TnIconComponent, TnIconHarness, TnIconRegistryService, TnIconTesting, TnInputComponent, TnInputDirective, TnInputHarness, TnKeyboardShortcutComponent, TnKeyboardShortcutService, TnListAvatarDirective, TnListComponent, TnListIconDirective, TnListItemComponent, TnListItemLineDirective, TnListItemPrimaryDirective, TnListItemSecondaryDirective, TnListItemTitleDirective, TnListItemTrailingDirective, TnListOptionComponent, TnListSubheaderComponent, TnMenuActivateHoverDirective, TnMenuComponent, TnMenuTriggerDirective, TnMonthViewComponent, TnMultiYearViewComponent, TnNestedTreeNodeComponent, TnParticleProgressBarComponent, TnProgressBarComponent, TnRadioComponent, TnSelectComponent, TnSelectHarness, TnSelectionListComponent, TnSidePanelActionDirective, TnSidePanelComponent, TnSidePanelHarness, TnSidePanelHeaderActionDirective, TnSlideToggleComponent, TnSliderComponent, TnSliderThumbDirective, TnSliderWithLabelDirective, TnSpinnerComponent, TnSpriteLoaderService, TnStepComponent, TnStepperComponent, TnTabComponent, TnTabHarness, TnTabPanelComponent, TnTabPanelHarness, TnTableColumnDirective, TnTableComponent, TnTabsComponent, TnTabsHarness, TnTheme, TnThemeService, TnTimeInputComponent, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, libIconMarker, registerLucideIcons, setupLucideIntegration, tnIconMarker };
4423
+ export type { AutocompleteHarnessFilters, BannerHarnessFilters, ButtonHarnessFilters, CalendarCell, ChipColor, CreateFolderEvent, DateRange, DialogHarnessFilters, EmptyHarnessFilters, FilePickerCallbacks, FilePickerError, FilePickerMode, FileSystemItem, IconButtonHarnessFilters, IconHarnessFilters, IconLibrary, IconLibraryType, IconResult, IconSize, IconSource, IconTestingMockOverrides, InputHarnessFilters, KeyCombination, LabelType, LucideIconOptions, MockIconRegistry, MockSpriteLoader, PathSegment, PlatformType, ProgressBarMode, ResolvedIcon, SelectHarnessFilters, ShortcutHandler, SidePanelHarnessFilters, SlideToggleColor, SpinnerMode, SpriteConfig, TabChangeEvent, TabHarnessFilters, TabPanelHarnessFilters, TabsHarnessFilters, TnBannerType, TnButtonToggleType, TnCardAction, TnCardControl, TnCardFooterLink, TnCardHeaderStatus, TnConfirmDialogData, TnDialogDefaults, TnDialogOpenTarget, TnEmptySize, TnFlatTreeNode, TnMenuItem, TnSelectOption, TnSelectOptionGroup, TnSelectionChange, TnTableDataSource, TnThemeDefinition, TooltipPosition, YearCell };