@truenas/ui-components 0.1.31 → 0.1.33

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.31",
3
+ "version": "0.1.33",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public"
@@ -3,6 +3,7 @@ import { ElementRef, OnDestroy, AfterViewInit, AfterContentInit, TemplateRef, Pr
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';
6
+ import { ComponentFixture } from '@angular/core/testing';
6
7
  import { DataSource } from '@angular/cdk/collections';
7
8
  import * as i1 from '@angular/cdk/tree';
8
9
  import { CdkTree, FlatTreeControl, CdkTreeNode, CdkNestedTreeNode } from '@angular/cdk/tree';
@@ -12,7 +13,6 @@ import { Observable } from 'rxjs';
12
13
  import { Overlay } from '@angular/cdk/overlay';
13
14
  import { DialogConfig, DialogRef } from '@angular/cdk/dialog';
14
15
  import { ComponentType } from '@angular/cdk/portal';
15
- import { ComponentFixture } from '@angular/core/testing';
16
16
 
17
17
  declare class TnAutocompleteComponent<T = unknown> implements ControlValueAccessor {
18
18
  private readonly elementRef;
@@ -2075,6 +2075,141 @@ declare class TnMenuTriggerDirective {
2075
2075
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<TnMenuTriggerDirective, "[tnMenuTriggerFor]", ["tnMenuTrigger"], { "menu": { "alias": "tnMenuTriggerFor"; "required": true; "isSignal": true; }; "tnMenuPosition": { "alias": "tnMenuPosition"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
2076
2076
  }
2077
2077
 
2078
+ /**
2079
+ * Harness for interacting with `tn-menu` in tests.
2080
+ *
2081
+ * Menus render in a CDK overlay **outside** the component tree, so a regular
2082
+ * `TestbedHarnessEnvironment.loader(fixture)` won't find them. Use
2083
+ * `TnMenuTesting.rootLoader(fixture)` instead — it searches the entire document.
2084
+ *
2085
+ * ## Test Setup
2086
+ *
2087
+ * ```typescript
2088
+ * import {
2089
+ * TnMenuHarness,
2090
+ * TnMenuTesting,
2091
+ * TnIconButtonHarness,
2092
+ * } from '@truenas/ui-components';
2093
+ *
2094
+ * let loader: HarnessLoader; // for components
2095
+ * let rootLoader: HarnessLoader; // for overlays (menus, dialogs)
2096
+ *
2097
+ * beforeEach(() => {
2098
+ * spectator = createComponent();
2099
+ * loader = TestbedHarnessEnvironment.loader(spectator.fixture);
2100
+ * rootLoader = TnMenuTesting.rootLoader(spectator.fixture);
2101
+ * });
2102
+ * ```
2103
+ *
2104
+ * ## Opening a Menu
2105
+ *
2106
+ * Click the trigger element to open the menu before querying it:
2107
+ *
2108
+ * ```typescript
2109
+ * // Via harness (if trigger is a tn-icon-button)
2110
+ * const trigger = await loader.getHarness(
2111
+ * TnIconButtonHarness.with({ name: 'more_vert' })
2112
+ * );
2113
+ * await trigger.click();
2114
+ *
2115
+ * // Or via DOM
2116
+ * spectator.click('[tnMenuTriggerFor]');
2117
+ * ```
2118
+ *
2119
+ * ## Querying and Clicking Items
2120
+ *
2121
+ * ```typescript
2122
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2123
+ * expect(await menu.getItemLabels()).toEqual(['Edit', 'Delete']);
2124
+ * await menu.clickItem({ label: 'Edit' });
2125
+ * await menu.clickItem({ label: /del/i }); // regex match
2126
+ * expect(await menu.isItemDisabled({ label: 'Delete' })).toBe(false);
2127
+ * ```
2128
+ */
2129
+ declare class TnMenuHarness extends ComponentHarness {
2130
+ static hostSelector: string;
2131
+ private _items;
2132
+ /**
2133
+ * Gets a `HarnessPredicate` that can be used to search for a menu.
2134
+ */
2135
+ static with(options?: MenuHarnessFilters): HarnessPredicate<TnMenuHarness>;
2136
+ /**
2137
+ * Gets the labels of all menu items.
2138
+ *
2139
+ * @example
2140
+ * ```typescript
2141
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2142
+ * expect(await menu.getItemLabels()).toEqual(['Edit', 'Delete']);
2143
+ * ```
2144
+ */
2145
+ getItemLabels(): Promise<string[]>;
2146
+ /**
2147
+ * Clicks a menu item by its label text.
2148
+ *
2149
+ * @param filter Object with `label` to match (string or RegExp).
2150
+ *
2151
+ * @example
2152
+ * ```typescript
2153
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2154
+ * await menu.clickItem({ label: 'Delete' });
2155
+ * ```
2156
+ */
2157
+ clickItem(filter: {
2158
+ label: string | RegExp;
2159
+ }): Promise<void>;
2160
+ /**
2161
+ * Checks if a menu item is disabled.
2162
+ *
2163
+ * @param filter Object with `label` to match (string or RegExp).
2164
+ * @returns Promise resolving to true if the item is disabled.
2165
+ *
2166
+ * @example
2167
+ * ```typescript
2168
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2169
+ * expect(await menu.isItemDisabled({ label: 'Delete' })).toBe(true);
2170
+ * ```
2171
+ */
2172
+ isItemDisabled(filter: {
2173
+ label: string | RegExp;
2174
+ }): Promise<boolean>;
2175
+ /**
2176
+ * Gets the number of menu items (excluding separators).
2177
+ */
2178
+ getItemCount(): Promise<number>;
2179
+ }
2180
+ /**
2181
+ * A set of criteria that can be used to filter `TnMenuHarness` instances.
2182
+ */
2183
+ interface MenuHarnessFilters extends BaseHarnessFilters {
2184
+ }
2185
+
2186
+ /**
2187
+ * Test utilities for TnMenu.
2188
+ *
2189
+ * Provides a document-root `HarnessLoader` that can find menus rendered
2190
+ * in CDK overlays. Use this alongside `TnDialogTesting.rootLoader()` if
2191
+ * your tests also open dialogs.
2192
+ *
2193
+ * @example
2194
+ * ```typescript
2195
+ * import { TnMenuTesting, TnMenuHarness } from '@truenas/ui-components';
2196
+ *
2197
+ * const rootLoader = TnMenuTesting.rootLoader(spectator.fixture);
2198
+ *
2199
+ * // Open the menu trigger, then query the overlay
2200
+ * spectator.click('[tnMenuTriggerFor]');
2201
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2202
+ * await menu.clickItem({ label: 'Edit' });
2203
+ * ```
2204
+ */
2205
+ declare class TnMenuTesting {
2206
+ /**
2207
+ * Creates a `HarnessLoader` that searches the entire document,
2208
+ * including CDK overlays where menus are rendered.
2209
+ */
2210
+ static rootLoader(fixture: ComponentFixture<unknown>): HarnessLoader;
2211
+ }
2212
+
2078
2213
  declare enum ModifierKeys {
2079
2214
  COMMAND = "\u2318",
2080
2215
  CMD = "\u2318",
@@ -2285,9 +2420,14 @@ declare class TnSelectComponent<T = unknown> implements ControlValueAccessor {
2285
2420
  placeholder: _angular_core.InputSignal<string>;
2286
2421
  disabled: _angular_core.InputSignal<boolean>;
2287
2422
  testId: _angular_core.InputSignal<string>;
2423
+ multiple: _angular_core.InputSignal<boolean>;
2424
+ compareWith: _angular_core.InputSignal<((a: T | null, b: T | null) => boolean) | undefined>;
2288
2425
  selectionChange: _angular_core.OutputEmitterRef<T>;
2426
+ /** Emits the full array of selected values after each toggle in multiple mode. */
2427
+ multiSelectionChange: _angular_core.OutputEmitterRef<T[]>;
2289
2428
  protected isOpen: _angular_core.WritableSignal<boolean>;
2290
2429
  protected selectedValue: _angular_core.WritableSignal<T | null>;
2430
+ protected selectedValues: _angular_core.WritableSignal<T[]>;
2291
2431
  private formDisabled;
2292
2432
  isDisabled: _angular_core.Signal<boolean>;
2293
2433
  private onChange;
@@ -2295,22 +2435,23 @@ declare class TnSelectComponent<T = unknown> implements ControlValueAccessor {
2295
2435
  private elementRef;
2296
2436
  private cdr;
2297
2437
  constructor();
2298
- writeValue(value: T | null): void;
2299
- registerOnChange(fn: (value: T | null) => void): void;
2438
+ writeValue(value: T | T[] | null): void;
2439
+ registerOnChange(fn: (value: T | T[] | null) => void): void;
2300
2440
  registerOnTouched(fn: () => void): void;
2301
2441
  setDisabledState(isDisabled: boolean): void;
2302
2442
  toggleDropdown(): void;
2303
2443
  closeDropdown(): void;
2304
- onOptionClick(option: TnSelectOption<T>): void;
2444
+ onOptionClick(option: TnSelectOption<T>, groupDisabled?: boolean): void;
2305
2445
  selectOption(option: TnSelectOption<T>): void;
2306
- isSelected: _angular_core.Signal<(option: TnSelectOption<T>) => boolean>;
2307
- getDisplayText: _angular_core.Signal<string | (T & {})>;
2446
+ private toggleOption;
2447
+ isOptionSelected(option: TnSelectOption<T>): boolean;
2448
+ getDisplayText: _angular_core.Signal<string>;
2308
2449
  private findOptionByValue;
2309
2450
  hasAnyOptions: _angular_core.Signal<boolean>;
2310
2451
  private compareValues;
2311
2452
  onKeydown(event: KeyboardEvent): void;
2312
2453
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnSelectComponent<any>, never>;
2313
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnSelectComponent<any>, "tn-select", never, { "options": { "alias": "options"; "required": false; "isSignal": true; }; "optionGroups": { "alias": "optionGroups"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; }, { "selectionChange": "selectionChange"; }, never, never, true, never>;
2454
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnSelectComponent<any>, "tn-select", never, { "options": { "alias": "options"; "required": false; "isSignal": true; }; "optionGroups": { "alias": "optionGroups"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "compareWith": { "alias": "compareWith"; "required": false; "isSignal": true; }; }, { "selectionChange": "selectionChange"; "multiSelectionChange": "multiSelectionChange"; }, never, never, true, never>;
2314
2455
  }
2315
2456
 
2316
2457
  /**
@@ -5033,5 +5174,5 @@ declare const TN_THEME_DEFINITIONS: readonly TnThemeDefinition[];
5033
5174
  */
5034
5175
  declare const THEME_MAP: Map<TnTheme, TnThemeDefinition>;
5035
5176
 
5036
- 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, TnCheckboxHarness, TnCheckboxLabelDirective, TnChipComponent, TnConfirmDialogComponent, TnDateInputComponent, TnDateRangeInputComponent, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnDrawerComponent, TnDrawerContainerComponent, TnDrawerContainerHarness, TnDrawerContentComponent, TnDrawerHarness, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnFormFieldHarness, 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, TnToastComponent, TnToastMock, TnToastPosition, TnToastRef, TnToastService, TnToastTesting, TnToastType, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, libIconMarker, registerLucideIcons, setupLucideIntegration, tnIconMarker };
5037
- export type { AutocompleteHarnessFilters, BannerHarnessFilters, ButtonHarnessFilters, CalendarCell, CheckboxHarnessFilters, ChipColor, CreateFolderEvent, DateRange, DialogHarnessFilters, EmptyHarnessFilters, FilePickerCallbacks, FilePickerError, FilePickerMode, FileSystemItem, FormFieldHarnessFilters, 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, TnDrawerMode, TnDrawerPosition, TnEmptySize, TnFlatTreeNode, TnMenuItem, TnSelectOption, TnSelectOptionGroup, TnSelectionChange, TnTableDataSource, TnThemeDefinition, TnToastCall, TnToastConfig, TooltipPosition, YearCell };
5177
+ 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, TnCheckboxHarness, TnCheckboxLabelDirective, TnChipComponent, TnConfirmDialogComponent, TnDateInputComponent, TnDateRangeInputComponent, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnDrawerComponent, TnDrawerContainerComponent, TnDrawerContainerHarness, TnDrawerContentComponent, TnDrawerHarness, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnFormFieldHarness, 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, TnMenuHarness, TnMenuTesting, 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, TnToastComponent, TnToastMock, TnToastPosition, TnToastRef, TnToastService, TnToastTesting, TnToastType, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, libIconMarker, registerLucideIcons, setupLucideIntegration, tnIconMarker };
5178
+ export type { AutocompleteHarnessFilters, BannerHarnessFilters, ButtonHarnessFilters, CalendarCell, CheckboxHarnessFilters, ChipColor, CreateFolderEvent, DateRange, DialogHarnessFilters, EmptyHarnessFilters, FilePickerCallbacks, FilePickerError, FilePickerMode, FileSystemItem, FormFieldHarnessFilters, IconButtonHarnessFilters, IconHarnessFilters, IconLibrary, IconLibraryType, IconResult, IconSize, IconSource, IconTestingMockOverrides, InputHarnessFilters, KeyCombination, LabelType, LucideIconOptions, MenuHarnessFilters, 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, TnDrawerMode, TnDrawerPosition, TnEmptySize, TnFlatTreeNode, TnMenuItem, TnSelectOption, TnSelectOptionGroup, TnSelectionChange, TnTableDataSource, TnThemeDefinition, TnToastCall, TnToastConfig, TooltipPosition, YearCell };