@truenas/ui-components 0.1.30 → 0.1.32

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.30",
3
+ "version": "0.1.32",
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, AfterContentInit, TemplateRef, Provider, ChangeDetectorRef, PipeTransform, OnInit, ViewContainerRef, AfterViewChecked } from '@angular/core';
2
+ import { ElementRef, OnDestroy, AfterViewInit, AfterContentInit, TemplateRef, Provider, ChangeDetectorRef, PipeTransform, OnInit, 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';
@@ -7,6 +7,7 @@ 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';
9
9
  export { FlatTreeControl } from '@angular/cdk/tree';
10
+ import * as rxjs from 'rxjs';
10
11
  import { Observable } from 'rxjs';
11
12
  import { Overlay } from '@angular/cdk/overlay';
12
13
  import { DialogConfig, DialogRef } from '@angular/cdk/dialog';
@@ -2284,9 +2285,14 @@ declare class TnSelectComponent<T = unknown> implements ControlValueAccessor {
2284
2285
  placeholder: _angular_core.InputSignal<string>;
2285
2286
  disabled: _angular_core.InputSignal<boolean>;
2286
2287
  testId: _angular_core.InputSignal<string>;
2288
+ multiple: _angular_core.InputSignal<boolean>;
2289
+ compareWith: _angular_core.InputSignal<((a: T | null, b: T | null) => boolean) | undefined>;
2287
2290
  selectionChange: _angular_core.OutputEmitterRef<T>;
2291
+ /** Emits the full array of selected values after each toggle in multiple mode. */
2292
+ multiSelectionChange: _angular_core.OutputEmitterRef<T[]>;
2288
2293
  protected isOpen: _angular_core.WritableSignal<boolean>;
2289
2294
  protected selectedValue: _angular_core.WritableSignal<T | null>;
2295
+ protected selectedValues: _angular_core.WritableSignal<T[]>;
2290
2296
  private formDisabled;
2291
2297
  isDisabled: _angular_core.Signal<boolean>;
2292
2298
  private onChange;
@@ -2294,22 +2300,23 @@ declare class TnSelectComponent<T = unknown> implements ControlValueAccessor {
2294
2300
  private elementRef;
2295
2301
  private cdr;
2296
2302
  constructor();
2297
- writeValue(value: T | null): void;
2298
- registerOnChange(fn: (value: T | null) => void): void;
2303
+ writeValue(value: T | T[] | null): void;
2304
+ registerOnChange(fn: (value: T | T[] | null) => void): void;
2299
2305
  registerOnTouched(fn: () => void): void;
2300
2306
  setDisabledState(isDisabled: boolean): void;
2301
2307
  toggleDropdown(): void;
2302
2308
  closeDropdown(): void;
2303
- onOptionClick(option: TnSelectOption<T>): void;
2309
+ onOptionClick(option: TnSelectOption<T>, groupDisabled?: boolean): void;
2304
2310
  selectOption(option: TnSelectOption<T>): void;
2305
- isSelected: _angular_core.Signal<(option: TnSelectOption<T>) => boolean>;
2306
- getDisplayText: _angular_core.Signal<string | (T & {})>;
2311
+ private toggleOption;
2312
+ isOptionSelected(option: TnSelectOption<T>): boolean;
2313
+ getDisplayText: _angular_core.Signal<string>;
2307
2314
  private findOptionByValue;
2308
2315
  hasAnyOptions: _angular_core.Signal<boolean>;
2309
2316
  private compareValues;
2310
2317
  onKeydown(event: KeyboardEvent): void;
2311
2318
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnSelectComponent<any>, never>;
2312
- 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>;
2319
+ 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>;
2313
2320
  }
2314
2321
 
2315
2322
  /**
@@ -4596,6 +4603,159 @@ interface EmptyHarnessFilters extends BaseHarnessFilters {
4596
4603
  title?: string | RegExp;
4597
4604
  }
4598
4605
 
4606
+ declare enum TnToastType {
4607
+ Info = "info",
4608
+ Success = "success",
4609
+ Warning = "warning",
4610
+ Error = "error"
4611
+ }
4612
+ declare enum TnToastPosition {
4613
+ Top = "top",
4614
+ Bottom = "bottom"
4615
+ }
4616
+ interface TnToastConfig {
4617
+ /** Auto-dismiss duration in milliseconds. Default: 4000. Set to 0 to disable. */
4618
+ duration?: number;
4619
+ /** Visual style of the toast. Default: TnToastType.Info. */
4620
+ type?: TnToastType;
4621
+ /** Vertical position. Default: TnToastPosition.Bottom. */
4622
+ position?: TnToastPosition;
4623
+ }
4624
+
4625
+ declare class TnToastComponent {
4626
+ message: _angular_core.WritableSignal<string>;
4627
+ action: _angular_core.WritableSignal<string | null>;
4628
+ type: _angular_core.WritableSignal<TnToastType>;
4629
+ position: _angular_core.WritableSignal<TnToastPosition>;
4630
+ visible: _angular_core.WritableSignal<boolean>;
4631
+ icon: _angular_core.Signal<string>;
4632
+ onAction: () => void;
4633
+ onDismiss: () => void;
4634
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnToastComponent, never>;
4635
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnToastComponent, "tn-toast", never, {}, {}, never, never, true, never>;
4636
+ }
4637
+
4638
+ declare class TnToastRef {
4639
+ private readonly _onAction;
4640
+ private readonly _afterDismissed;
4641
+ private _dismissed;
4642
+ /** @internal */
4643
+ _componentRef?: ComponentRef<TnToastComponent>;
4644
+ /** Observable that emits when the action button is clicked. */
4645
+ onAction(): rxjs.Observable<void>;
4646
+ /** Observable that emits when the toast is dismissed (by action, duration, or programmatically). */
4647
+ afterDismissed(): rxjs.Observable<void>;
4648
+ /** Programmatically dismiss the toast. */
4649
+ dismiss(): void;
4650
+ /** @internal */
4651
+ _triggerAction(): void;
4652
+ }
4653
+ declare class TnToastService {
4654
+ private appRef;
4655
+ private injector;
4656
+ private activeRef;
4657
+ /**
4658
+ * Opens a toast notification.
4659
+ *
4660
+ * @param message The message to display.
4661
+ * @param actionOrConfig Optional action button text, or config object.
4662
+ * @param config Optional config when action is provided as second arg.
4663
+ * @returns A TnToastRef that can be used to dismiss the toast or listen for events.
4664
+ *
4665
+ * @example
4666
+ * ```typescript
4667
+ * // Simple notification
4668
+ * this.toast.open('Changes saved');
4669
+ *
4670
+ * // With action button
4671
+ * const ref = this.toast.open('Item deleted', 'Undo');
4672
+ * ref.onAction().subscribe(() => this.undoDelete());
4673
+ *
4674
+ * // With config
4675
+ * this.toast.open('Error occurred', { type: 'error', duration: 6000 });
4676
+ *
4677
+ * // Action + config
4678
+ * this.toast.open('Failed to save', 'Retry', { type: 'error' });
4679
+ * ```
4680
+ */
4681
+ open(message: string, actionOrConfig?: string | TnToastConfig, config?: TnToastConfig): TnToastRef;
4682
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnToastService, never>;
4683
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<TnToastService>;
4684
+ }
4685
+
4686
+ /**
4687
+ * A recorded toast call for test assertions.
4688
+ */
4689
+ interface TnToastCall {
4690
+ message: string;
4691
+ action?: string;
4692
+ config: TnToastConfig;
4693
+ ref: TnToastRef;
4694
+ }
4695
+ /**
4696
+ * A mock implementation of TnToastService for unit testing.
4697
+ *
4698
+ * Records all `open()` calls so tests can assert on toast messages,
4699
+ * types, and actions without rendering actual toast components.
4700
+ *
4701
+ * @example
4702
+ * ```typescript
4703
+ * import { TnToastTesting } from '@truenas/ui-components';
4704
+ *
4705
+ * let toastMock: TnToastMock;
4706
+ *
4707
+ * beforeEach(() => {
4708
+ * toastMock = new TnToastMock();
4709
+ * TestBed.configureTestingModule({
4710
+ * providers: [TnToastTesting.providers(toastMock)],
4711
+ * });
4712
+ * });
4713
+ *
4714
+ * it('should show success toast', () => {
4715
+ * // ... trigger action that opens a toast
4716
+ * expect(toastMock.calls.length).toBe(1);
4717
+ * expect(toastMock.lastCall?.message).toBe('Saved successfully');
4718
+ * expect(toastMock.lastCall?.config.type).toBe(TnToastType.Success);
4719
+ * });
4720
+ *
4721
+ * it('should handle action click', () => {
4722
+ * // ... trigger action that opens a toast with action
4723
+ * toastMock.lastCall?.ref._triggerAction();
4724
+ * // ... assert retry behavior
4725
+ * });
4726
+ * ```
4727
+ */
4728
+ declare class TnToastMock {
4729
+ /** All recorded toast open() calls. */
4730
+ calls: TnToastCall[];
4731
+ /** The most recent toast call, or undefined if none. */
4732
+ get lastCall(): TnToastCall | undefined;
4733
+ /** Clears all recorded calls. */
4734
+ reset(): void;
4735
+ open(message: string, actionOrConfig?: string | TnToastConfig, config?: TnToastConfig): TnToastRef;
4736
+ }
4737
+ /**
4738
+ * Test utilities for TnToastService.
4739
+ *
4740
+ * Provides a mock that records toast calls without rendering components,
4741
+ * making tests fast and deterministic.
4742
+ *
4743
+ * @example
4744
+ * ```typescript
4745
+ * const toastMock = new TnToastMock();
4746
+ *
4747
+ * TestBed.configureTestingModule({
4748
+ * providers: [TnToastTesting.providers(toastMock)],
4749
+ * });
4750
+ * ```
4751
+ */
4752
+ declare class TnToastTesting {
4753
+ /**
4754
+ * Returns providers that replace TnToastService with the given mock.
4755
+ */
4756
+ static providers(mock: TnToastMock): Provider[];
4757
+ }
4758
+
4599
4759
  interface KeyCombination {
4600
4760
  ctrlKey: boolean;
4601
4761
  altKey: boolean;
@@ -4879,5 +5039,5 @@ declare const TN_THEME_DEFINITIONS: readonly TnThemeDefinition[];
4879
5039
  */
4880
5040
  declare const THEME_MAP: Map<TnTheme, TnThemeDefinition>;
4881
5041
 
4882
- 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, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, libIconMarker, registerLucideIcons, setupLucideIntegration, tnIconMarker };
4883
- 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, TooltipPosition, YearCell };
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 };