@truenas/ui-components 0.1.32 → 0.1.34

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.32",
3
+ "version": "0.1.34",
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;
@@ -1614,6 +1614,85 @@ declare class TnSlideToggleComponent implements AfterViewInit, OnDestroy, Contro
1614
1614
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnSlideToggleComponent, "tn-slide-toggle", never, { "labelPosition": { "alias": "labelPosition"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "ariaLabelledby"; "required": false; "isSignal": true; }; "checked": { "alias": "checked"; "required": false; "isSignal": true; }; }, { "change": "change"; "toggleChange": "toggleChange"; }, never, never, true, never>;
1615
1615
  }
1616
1616
 
1617
+ /**
1618
+ * Harness for interacting with `tn-slide-toggle` in tests.
1619
+ *
1620
+ * @example
1621
+ * ```typescript
1622
+ * const toggle = await loader.getHarness(
1623
+ * TnSlideToggleHarness.with({ label: 'Enable notifications' })
1624
+ * );
1625
+ * await toggle.toggle();
1626
+ * expect(await toggle.isChecked()).toBe(true);
1627
+ * ```
1628
+ */
1629
+ declare class TnSlideToggleHarness extends ComponentHarness {
1630
+ static hostSelector: string;
1631
+ private _input;
1632
+ private _label;
1633
+ /**
1634
+ * Gets a `HarnessPredicate` that can be used to search for a slide toggle
1635
+ * with specific attributes.
1636
+ */
1637
+ static with(options?: SlideToggleHarnessFilters): HarnessPredicate<TnSlideToggleHarness>;
1638
+ /**
1639
+ * Gets the label text of the slide toggle.
1640
+ *
1641
+ * @example
1642
+ * ```typescript
1643
+ * expect(await toggle.getLabelText()).toBe('Enable notifications');
1644
+ * ```
1645
+ */
1646
+ getLabelText(): Promise<string>;
1647
+ /**
1648
+ * Checks whether the slide toggle is currently checked.
1649
+ *
1650
+ * @example
1651
+ * ```typescript
1652
+ * expect(await toggle.isChecked()).toBe(false);
1653
+ * ```
1654
+ */
1655
+ isChecked(): Promise<boolean>;
1656
+ /**
1657
+ * Checks whether the slide toggle is disabled.
1658
+ */
1659
+ isDisabled(): Promise<boolean>;
1660
+ /**
1661
+ * Checks whether the slide toggle is required.
1662
+ */
1663
+ isRequired(): Promise<boolean>;
1664
+ /**
1665
+ * Gets the test ID attribute value.
1666
+ */
1667
+ getTestId(): Promise<string | null>;
1668
+ /**
1669
+ * Toggles the slide toggle by clicking the input element.
1670
+ *
1671
+ * @example
1672
+ * ```typescript
1673
+ * await toggle.toggle();
1674
+ * ```
1675
+ */
1676
+ toggle(): Promise<void>;
1677
+ /**
1678
+ * Checks the slide toggle. No-op if already checked.
1679
+ */
1680
+ check(): Promise<void>;
1681
+ /**
1682
+ * Unchecks the slide toggle. No-op if already unchecked.
1683
+ */
1684
+ uncheck(): Promise<void>;
1685
+ }
1686
+ /**
1687
+ * Filters for finding `TnSlideToggleHarness` instances.
1688
+ */
1689
+ interface SlideToggleHarnessFilters extends BaseHarnessFilters {
1690
+ /** Filters by label text. Supports string or regex matching. */
1691
+ label?: string | RegExp;
1692
+ /** Filters by data-testid attribute. */
1693
+ testId?: string;
1694
+ }
1695
+
1617
1696
  declare class TnTabComponent implements AfterContentInit {
1618
1697
  label: _angular_core.InputSignal<string>;
1619
1698
  disabled: _angular_core.InputSignal<boolean>;
@@ -2075,6 +2154,141 @@ declare class TnMenuTriggerDirective {
2075
2154
  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
2155
  }
2077
2156
 
2157
+ /**
2158
+ * Harness for interacting with `tn-menu` in tests.
2159
+ *
2160
+ * Menus render in a CDK overlay **outside** the component tree, so a regular
2161
+ * `TestbedHarnessEnvironment.loader(fixture)` won't find them. Use
2162
+ * `TnMenuTesting.rootLoader(fixture)` instead — it searches the entire document.
2163
+ *
2164
+ * ## Test Setup
2165
+ *
2166
+ * ```typescript
2167
+ * import {
2168
+ * TnMenuHarness,
2169
+ * TnMenuTesting,
2170
+ * TnIconButtonHarness,
2171
+ * } from '@truenas/ui-components';
2172
+ *
2173
+ * let loader: HarnessLoader; // for components
2174
+ * let rootLoader: HarnessLoader; // for overlays (menus, dialogs)
2175
+ *
2176
+ * beforeEach(() => {
2177
+ * spectator = createComponent();
2178
+ * loader = TestbedHarnessEnvironment.loader(spectator.fixture);
2179
+ * rootLoader = TnMenuTesting.rootLoader(spectator.fixture);
2180
+ * });
2181
+ * ```
2182
+ *
2183
+ * ## Opening a Menu
2184
+ *
2185
+ * Click the trigger element to open the menu before querying it:
2186
+ *
2187
+ * ```typescript
2188
+ * // Via harness (if trigger is a tn-icon-button)
2189
+ * const trigger = await loader.getHarness(
2190
+ * TnIconButtonHarness.with({ name: 'more_vert' })
2191
+ * );
2192
+ * await trigger.click();
2193
+ *
2194
+ * // Or via DOM
2195
+ * spectator.click('[tnMenuTriggerFor]');
2196
+ * ```
2197
+ *
2198
+ * ## Querying and Clicking Items
2199
+ *
2200
+ * ```typescript
2201
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2202
+ * expect(await menu.getItemLabels()).toEqual(['Edit', 'Delete']);
2203
+ * await menu.clickItem({ label: 'Edit' });
2204
+ * await menu.clickItem({ label: /del/i }); // regex match
2205
+ * expect(await menu.isItemDisabled({ label: 'Delete' })).toBe(false);
2206
+ * ```
2207
+ */
2208
+ declare class TnMenuHarness extends ComponentHarness {
2209
+ static hostSelector: string;
2210
+ private _items;
2211
+ /**
2212
+ * Gets a `HarnessPredicate` that can be used to search for a menu.
2213
+ */
2214
+ static with(options?: MenuHarnessFilters): HarnessPredicate<TnMenuHarness>;
2215
+ /**
2216
+ * Gets the labels of all menu items.
2217
+ *
2218
+ * @example
2219
+ * ```typescript
2220
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2221
+ * expect(await menu.getItemLabels()).toEqual(['Edit', 'Delete']);
2222
+ * ```
2223
+ */
2224
+ getItemLabels(): Promise<string[]>;
2225
+ /**
2226
+ * Clicks a menu item by its label text.
2227
+ *
2228
+ * @param filter Object with `label` to match (string or RegExp).
2229
+ *
2230
+ * @example
2231
+ * ```typescript
2232
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2233
+ * await menu.clickItem({ label: 'Delete' });
2234
+ * ```
2235
+ */
2236
+ clickItem(filter: {
2237
+ label: string | RegExp;
2238
+ }): Promise<void>;
2239
+ /**
2240
+ * Checks if a menu item is disabled.
2241
+ *
2242
+ * @param filter Object with `label` to match (string or RegExp).
2243
+ * @returns Promise resolving to true if the item is disabled.
2244
+ *
2245
+ * @example
2246
+ * ```typescript
2247
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2248
+ * expect(await menu.isItemDisabled({ label: 'Delete' })).toBe(true);
2249
+ * ```
2250
+ */
2251
+ isItemDisabled(filter: {
2252
+ label: string | RegExp;
2253
+ }): Promise<boolean>;
2254
+ /**
2255
+ * Gets the number of menu items (excluding separators).
2256
+ */
2257
+ getItemCount(): Promise<number>;
2258
+ }
2259
+ /**
2260
+ * A set of criteria that can be used to filter `TnMenuHarness` instances.
2261
+ */
2262
+ interface MenuHarnessFilters extends BaseHarnessFilters {
2263
+ }
2264
+
2265
+ /**
2266
+ * Test utilities for TnMenu.
2267
+ *
2268
+ * Provides a document-root `HarnessLoader` that can find menus rendered
2269
+ * in CDK overlays. Use this alongside `TnDialogTesting.rootLoader()` if
2270
+ * your tests also open dialogs.
2271
+ *
2272
+ * @example
2273
+ * ```typescript
2274
+ * import { TnMenuTesting, TnMenuHarness } from '@truenas/ui-components';
2275
+ *
2276
+ * const rootLoader = TnMenuTesting.rootLoader(spectator.fixture);
2277
+ *
2278
+ * // Open the menu trigger, then query the overlay
2279
+ * spectator.click('[tnMenuTriggerFor]');
2280
+ * const menu = await rootLoader.getHarness(TnMenuHarness);
2281
+ * await menu.clickItem({ label: 'Edit' });
2282
+ * ```
2283
+ */
2284
+ declare class TnMenuTesting {
2285
+ /**
2286
+ * Creates a `HarnessLoader` that searches the entire document,
2287
+ * including CDK overlays where menus are rendered.
2288
+ */
2289
+ static rootLoader(fixture: ComponentFixture<unknown>): HarnessLoader;
2290
+ }
2291
+
2078
2292
  declare enum ModifierKeys {
2079
2293
  COMMAND = "\u2318",
2080
2294
  CMD = "\u2318",
@@ -5039,5 +5253,5 @@ declare const TN_THEME_DEFINITIONS: readonly TnThemeDefinition[];
5039
5253
  */
5040
5254
  declare const THEME_MAP: Map<TnTheme, TnThemeDefinition>;
5041
5255
 
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 };
5256
+ 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, TnSlideToggleHarness, 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 };
5257
+ 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, SlideToggleHarnessFilters, 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 };