@truenas/ui-components 0.1.32 → 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
|
@@ -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",
|
|
@@ -5039,5 +5174,5 @@ declare const TN_THEME_DEFINITIONS: readonly TnThemeDefinition[];
|
|
|
5039
5174
|
*/
|
|
5040
5175
|
declare const THEME_MAP: Map<TnTheme, TnThemeDefinition>;
|
|
5041
5176
|
|
|
5042
|
-
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 };
|
|
5043
|
-
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 };
|