@truenas/ui-components 0.3.13 → 0.3.15

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.3.13",
3
+ "version": "0.3.15",
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 { InjectionToken, Renderer2, OnDestroy, ElementRef, AfterViewInit, OnInit, TemplateRef, AfterContentInit, Provider, ChangeDetectorRef, Signal, PipeTransform, ViewContainerRef, AfterViewChecked, ComponentRef } from '@angular/core';
2
+ import { Signal, InjectionToken, Renderer2, OnDestroy, ElementRef, AfterViewInit, OnInit, TemplateRef, AfterContentInit, Provider, ChangeDetectorRef, PipeTransform, ViewContainerRef, AfterViewChecked, ComponentRef } from '@angular/core';
3
3
  import { ControlValueAccessor, NgControl, AbstractControl } from '@angular/forms';
4
4
  import { ComponentHarness, BaseHarnessFilters, HarnessPredicate, TestKey, HarnessLoader } from '@angular/cdk/testing';
5
5
  import { SafeHtml, SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
@@ -82,6 +82,42 @@ declare function scopeTestId(base: TnTestIdValue, ...suffix: (string | number |
82
82
  */
83
83
  declare function composeTestId(type: string | null | undefined, value: TnTestIdValue): string;
84
84
 
85
+ /**
86
+ * Resolve a form control's test-id base, falling back to the bound control's
87
+ * name (`formControlName`, a named `[formControl]`, or `ngModel`) when the
88
+ * consumer provides no explicit `testId`.
89
+ *
90
+ * Call from a form control's field initializer and bind the result on the
91
+ * element that represents the control:
92
+ *
93
+ * ```ts
94
+ * protected resolvedTestId = controlTestId(this.testId);
95
+ * ```
96
+ * ```html
97
+ * <input tnTestIdType="input" [tnTestId]="resolvedTestId()" />
98
+ * ```
99
+ *
100
+ * The element-type prefix (`tnTestIdType`) still applies, so a
101
+ * `<tn-input formControlName="sshPort">` with no `testId` emits
102
+ * `input-ssh-port` — exactly what a consumer would otherwise hand-write as
103
+ * `testId="ssh-port"`. An explicit `testId` always wins.
104
+ *
105
+ * Two deliberate constraints make this safe inside a `ControlValueAccessor`:
106
+ *
107
+ * - **`self`-scoped**: the lookup reads only the `NgControl` on the component's
108
+ * OWN host element, never an ancestor's. A composite control whose template
109
+ * embeds child controls therefore can't leak its own name onto those children
110
+ * (which would make their ids collide).
111
+ * - **lazy**: the `NgControl` is resolved on first read, not in the injection
112
+ * context. Eagerly injecting `NgControl` into a component that provides
113
+ * `NG_VALUE_ACCESSOR` is circular (the control needs the value accessor, the
114
+ * accessor would need the control); reading it after construction is not.
115
+ *
116
+ * Must be called within an injection context (a field initializer or
117
+ * constructor).
118
+ */
119
+ declare function controlTestId(testId: Signal<TnTestIdValue>): Signal<TnTestIdValue>;
120
+
85
121
  /**
86
122
  * Test-id attribute names supported by the library.
87
123
  *
@@ -118,6 +154,10 @@ declare const TN_TEST_ATTR: InjectionToken<TnTestAttrName>;
118
154
  * {@link composeTestId}). When no `tnTestIdType` is set the value is written
119
155
  * verbatim, so existing call sites are unaffected.
120
156
  *
157
+ * Form controls derive an unset base from the bound control's name via
158
+ * {@link controlTestId} before passing it here, so a control stays targetable by
159
+ * automation without the consumer repeating the name as a `testId`.
160
+ *
121
161
  * @example
122
162
  * ```html
123
163
  * <!-- component-owned prefix: emits data-testid="button-save" -->
@@ -200,6 +240,8 @@ declare class TnSelectComponent<T = unknown> implements ControlValueAccessor, On
200
240
  emptyLabel: _angular_core.InputSignal<string>;
201
241
  disabled: _angular_core.InputSignal<boolean>;
202
242
  testId: _angular_core.InputSignal<TnTestIdValue>;
243
+ /** Test-id base, falling back to the bound control name when `testId` is unset. */
244
+ protected resolvedTestId: _angular_core.Signal<TnTestIdValue>;
203
245
  multiple: _angular_core.InputSignal<boolean>;
204
246
  /**
205
247
  * Optional extractor for the per-option test-id discriminator. Defaults to
@@ -245,8 +287,9 @@ declare class TnSelectComponent<T = unknown> implements ControlValueAccessor, On
245
287
  private instanceId;
246
288
  /**
247
289
  * Id namespace used by all DOM ids the template emits (dropdown panel,
248
- * option rows, group labels). Prefers `testId` when set so tests can target
249
- * specific instances; otherwise falls back to a per-instance counter so two
290
+ * option rows, group labels). Prefers the resolved test-id base (explicit
291
+ * `testId`, else the bound control name) so tests can target specific
292
+ * instances; otherwise falls back to a per-instance counter so two
250
293
  * `<tn-select>`s on the same page never collide on `aria-controls`/group ids.
251
294
  */
252
295
  protected idNamespace: _angular_core.Signal<string>;
@@ -279,11 +322,11 @@ declare class TnSelectComponent<T = unknown> implements ControlValueAccessor, On
279
322
  isOptionFocused(option: TnSelectOption<T>): boolean;
280
323
  /**
281
324
  * Test-id segments for an option row, consumed by `[tnTestId]` with
282
- * `tnTestIdType="option"`. The select's `testId` scopes each option so ids
283
- * stay unique across selects: base `quick-filters` + option value `ssd`
284
- * `option-quick-filters-ssd`; with no base → `option-ssd`. The discriminator
285
- * comes from `optionTestIdKey` when provided, else the option's primitive
286
- * `value`, else its `label`.
325
+ * `tnTestIdType="option"`. The select's resolved base (explicit `testId`, else
326
+ * the bound control name) scopes each option so ids stay unique across selects:
327
+ * base `quick-filters` + option value `ssd` → `option-quick-filters-ssd`; with
328
+ * no base → `option-ssd`. The discriminator comes from `optionTestIdKey` when
329
+ * provided, else the option's primitive `value`, else its `label`.
287
330
  */
288
331
  protected optionTestIdParts(option: TnSelectOption<T>): (string | number | null | undefined)[];
289
332
  private onChange;
@@ -951,7 +994,13 @@ declare class TnBannerComponent {
951
994
  private actionContent;
952
995
  /** Signal indicating whether action content has been projected */
953
996
  protected hasAction: _angular_core.Signal<boolean>;
954
- heading: _angular_core.InputSignal<string>;
997
+ /**
998
+ * Signal indicating whether the built-in structured layout (icon + heading/message)
999
+ * should be rendered. When neither heading nor message is provided, the banner
1000
+ * instead renders arbitrary projected content from the default slot.
1001
+ */
1002
+ protected hasStructuredContent: _angular_core.Signal<boolean>;
1003
+ heading: _angular_core.InputSignal<string | undefined>;
955
1004
  message: _angular_core.InputSignal<string | undefined>;
956
1005
  type: _angular_core.InputSignal<TnBannerType>;
957
1006
  bordered: _angular_core.InputSignal<boolean>;
@@ -976,7 +1025,7 @@ declare class TnBannerComponent {
976
1025
  */
977
1026
  classes: _angular_core.Signal<string[]>;
978
1027
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnBannerComponent, never>;
979
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnBannerComponent, "tn-banner", never, { "heading": { "alias": "heading"; "required": true; "isSignal": true; }; "message": { "alias": "message"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "bordered": { "alias": "bordered"; "required": false; "isSignal": true; }; }, {}, ["actionContent"], ["[tnBannerAction]"], true, never>;
1028
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnBannerComponent, "tn-banner", never, { "heading": { "alias": "heading"; "required": false; "isSignal": true; }; "message": { "alias": "message"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "bordered": { "alias": "bordered"; "required": false; "isSignal": true; }; }, {}, ["actionContent"], ["*", "[tnBannerAction]"], true, never>;
980
1029
  }
981
1030
 
982
1031
  /**
@@ -1602,6 +1651,8 @@ declare class TnInputComponent implements AfterViewInit, OnDestroy, ControlValue
1602
1651
  inputType: _angular_core.InputSignal<InputType>;
1603
1652
  placeholder: _angular_core.InputSignal<string>;
1604
1653
  testId: _angular_core.InputSignal<TnTestIdValue>;
1654
+ /** Test-id base, falling back to the bound control name when `testId` is unset. */
1655
+ protected resolvedTestId: _angular_core.Signal<TnTestIdValue>;
1605
1656
  disabled: _angular_core.InputSignal<boolean>;
1606
1657
  multiline: _angular_core.InputSignal<boolean>;
1607
1658
  rows: _angular_core.InputSignal<number>;
@@ -3234,6 +3285,8 @@ declare class TnCheckboxComponent implements AfterViewInit, OnDestroy, ControlVa
3234
3285
  required: _angular_core.InputSignal<boolean>;
3235
3286
  indeterminate: _angular_core.InputSignal<boolean>;
3236
3287
  testId: _angular_core.InputSignal<TnTestIdValue>;
3288
+ /** Test-id base, falling back to the bound control name when `testId` is unset. */
3289
+ protected resolvedTestId: _angular_core.Signal<TnTestIdValue>;
3237
3290
  error: _angular_core.InputSignal<string | null>;
3238
3291
  checked: _angular_core.InputSignal<boolean>;
3239
3292
  change: _angular_core.OutputEmitterRef<boolean>;
@@ -3443,6 +3496,8 @@ declare class TnRadioComponent implements AfterViewInit, OnDestroy, ControlValue
3443
3496
  disabled: _angular_core.InputSignal<boolean>;
3444
3497
  required: _angular_core.InputSignal<boolean>;
3445
3498
  testId: _angular_core.InputSignal<TnTestIdValue>;
3499
+ /** Test-id base, falling back to the bound control name when `testId` is unset. */
3500
+ protected resolvedTestId: _angular_core.Signal<TnTestIdValue>;
3446
3501
  error: _angular_core.InputSignal<string | null>;
3447
3502
  change: _angular_core.OutputEmitterRef<unknown>;
3448
3503
  id: string;
@@ -3586,6 +3641,8 @@ declare class TnSlideToggleComponent implements AfterViewInit, OnDestroy, Contro
3586
3641
  required: _angular_core.InputSignal<boolean>;
3587
3642
  color: _angular_core.InputSignal<SlideToggleColor>;
3588
3643
  testId: _angular_core.InputSignal<TnTestIdValue>;
3644
+ /** Test-id base, falling back to the bound control name when `testId` is unset. */
3645
+ protected resolvedTestId: _angular_core.Signal<TnTestIdValue>;
3589
3646
  ariaLabel: _angular_core.InputSignal<string | undefined>;
3590
3647
  ariaLabelledby: _angular_core.InputSignal<string | undefined>;
3591
3648
  checked: _angular_core.InputSignal<boolean>;
@@ -8672,5 +8729,5 @@ declare const TN_THEME_DEFINITIONS: readonly TnThemeDefinition[];
8672
8729
  */
8673
8730
  declare const THEME_MAP: Map<TnTheme, TnThemeDefinition>;
8674
8731
 
8675
- export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LIGHT_THEME, LabelMarkupPipe, LabelTextPipe, LinuxModifierKeys, LinuxShortcuts, ModifierKeys, QuickShortcuts, ShortcutBuilder, StripMntPrefixPipe, THEME_MAP, THEME_STORAGE_KEY, TN_FORM_FIELD_ERRORS, TN_TABLE_PAGER_DEFAULT_LABELS, TN_TABLE_PAGER_LABELS, TN_TEST_ATTR, TN_THEME_DEFINITIONS, TnAutocompleteComponent, TnAutocompleteHarness, TnBannerActionDirective, TnBannerComponent, TnBannerHarness, TnBrandedSpinnerComponent, TnButtonComponent, TnButtonHarness, TnButtonToggleComponent, TnButtonToggleGroupComponent, TnButtonToggleGroupHarness, TnButtonToggleHarness, TnCalendarComponent, TnCalendarHeaderComponent, TnCardComponent, TnCardFooterActionsDirective, TnCardHeaderActionsDirective, TnCardHeaderDirective, TnCellDefDirective, TnCheckboxComponent, TnCheckboxHarness, TnCheckboxLabelDirective, TnChipComponent, TnChipHarness, TnChipInputComponent, TnChipInputHarness, TnConfirmDialogComponent, TnDateInputComponent, TnDateInputHarness, TnDateRangeInputComponent, TnDateRangeInputHarness, TnDetailRowDefDirective, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnDrawerComponent, TnDrawerContainerComponent, TnDrawerContainerHarness, TnDrawerContentComponent, TnDrawerHarness, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnExpansionPanelHarness, TnFileInputComponent, TnFileInputHarness, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnFormFieldHarness, TnFormSectionComponent, TnFormSectionHarness, 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, TnMenuItemComponent, TnMenuTesting, TnMenuTriggerDirective, TnMonthViewComponent, TnMultiYearViewComponent, TnNestedTreeNodeComponent, TnParticleProgressBarComponent, TnProgressBarComponent, TnRadioComponent, TnRadioHarness, TnSelectComponent, TnSelectHarness, TnSelectionListComponent, TnSidePanelActionDirective, TnSidePanelComponent, TnSidePanelHarness, TnSidePanelHeaderActionDirective, TnSlideToggleComponent, TnSlideToggleHarness, TnSliderComponent, TnSliderThumbDirective, TnSliderWithLabelDirective, TnSpinnerComponent, TnSpriteLoaderService, TnStepComponent, TnStepperComponent, TnTabComponent, TnTabHarness, TnTabPanelComponent, TnTabPanelHarness, TnTableColumnDirective, TnTableComponent, TnTableHarness, TnTablePagerComponent, TnTablePagerHarness, TnTabsComponent, TnTabsHarness, TnTestIdDirective, TnTheme, TnThemeService, TnTimeInputComponent, TnToastComponent, TnToastMock, TnToastPosition, TnToastRef, TnToastService, TnToastTesting, TnToastType, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, composeTestId, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, formatSize, kebabTestSegment, labelMarkupToHtml, labelMarkupToText, libIconMarker, parseLabelMarkup, parseSize, registerLucideIcons, scopeTestId, setupLucideIntegration, tnIconMarker, writeTestId };
8732
+ export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LIGHT_THEME, LabelMarkupPipe, LabelTextPipe, LinuxModifierKeys, LinuxShortcuts, ModifierKeys, QuickShortcuts, ShortcutBuilder, StripMntPrefixPipe, THEME_MAP, THEME_STORAGE_KEY, TN_FORM_FIELD_ERRORS, TN_TABLE_PAGER_DEFAULT_LABELS, TN_TABLE_PAGER_LABELS, TN_TEST_ATTR, TN_THEME_DEFINITIONS, TnAutocompleteComponent, TnAutocompleteHarness, TnBannerActionDirective, TnBannerComponent, TnBannerHarness, TnBrandedSpinnerComponent, TnButtonComponent, TnButtonHarness, TnButtonToggleComponent, TnButtonToggleGroupComponent, TnButtonToggleGroupHarness, TnButtonToggleHarness, TnCalendarComponent, TnCalendarHeaderComponent, TnCardComponent, TnCardFooterActionsDirective, TnCardHeaderActionsDirective, TnCardHeaderDirective, TnCellDefDirective, TnCheckboxComponent, TnCheckboxHarness, TnCheckboxLabelDirective, TnChipComponent, TnChipHarness, TnChipInputComponent, TnChipInputHarness, TnConfirmDialogComponent, TnDateInputComponent, TnDateInputHarness, TnDateRangeInputComponent, TnDateRangeInputHarness, TnDetailRowDefDirective, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnDrawerComponent, TnDrawerContainerComponent, TnDrawerContainerHarness, TnDrawerContentComponent, TnDrawerHarness, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnExpansionPanelHarness, TnFileInputComponent, TnFileInputHarness, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnFormFieldHarness, TnFormSectionComponent, TnFormSectionHarness, 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, TnMenuItemComponent, TnMenuTesting, TnMenuTriggerDirective, TnMonthViewComponent, TnMultiYearViewComponent, TnNestedTreeNodeComponent, TnParticleProgressBarComponent, TnProgressBarComponent, TnRadioComponent, TnRadioHarness, TnSelectComponent, TnSelectHarness, TnSelectionListComponent, TnSidePanelActionDirective, TnSidePanelComponent, TnSidePanelHarness, TnSidePanelHeaderActionDirective, TnSlideToggleComponent, TnSlideToggleHarness, TnSliderComponent, TnSliderThumbDirective, TnSliderWithLabelDirective, TnSpinnerComponent, TnSpriteLoaderService, TnStepComponent, TnStepperComponent, TnTabComponent, TnTabHarness, TnTabPanelComponent, TnTabPanelHarness, TnTableColumnDirective, TnTableComponent, TnTableHarness, TnTablePagerComponent, TnTablePagerHarness, TnTabsComponent, TnTabsHarness, TnTestIdDirective, TnTheme, TnThemeService, TnTimeInputComponent, TnToastComponent, TnToastMock, TnToastPosition, TnToastRef, TnToastService, TnToastTesting, TnToastType, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, composeTestId, controlTestId, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, formatSize, kebabTestSegment, labelMarkupToHtml, labelMarkupToText, libIconMarker, parseLabelMarkup, parseSize, registerLucideIcons, scopeTestId, setupLucideIntegration, tnIconMarker, writeTestId };
8676
8733
  export type { AutocompleteHarnessFilters, BannerHarnessFilters, ButtonHarnessFilters, ButtonToggleHarnessFilters, CalendarCell, CheckboxHarnessFilters, ChipColor, ChipHarnessFilters, CreateFolderEvent, DateInputHarnessFilters, DateRange, DateRangeInputHarnessFilters, DialogHarnessFilters, EmptyHarnessFilters, ExpansionPanelHarnessFilters, FileInputHarnessFilters, FilePickerCallbacks, FilePickerError, FilePickerMode, FileSystemItem, FormFieldHarnessFilters, FormSectionHarnessFilters, IconButtonHarnessFilters, IconHarnessFilters, IconLibrary, IconLibraryType, IconResult, IconSize, IconSource, IconTestingMockOverrides, InputHarnessFilters, KeyCombination, LabelMarkupSegment, LabelMarkupSegmentType, LabelType, LucideIconOptions, MenuHarnessFilters, MockIconRegistry, MockSpriteLoader, PathSegment, PlatformType, ProgressBarMode, RadioHarnessFilters, ResolvedIcon, SelectHarnessFilters, ShortcutHandler, SidePanelHarnessFilters, SizeStandard, SlideToggleColor, SlideToggleHarnessFilters, SpinnerMode, SpriteConfig, SubscriptSizing, TabChangeEvent, TabHarnessFilters, TabPanelHarnessFilters, TabsHarnessFilters, TnAutocompleteOption, TnBannerType, TnButtonToggleType, TnCardAction, TnCardControl, TnCardFooterLink, TnCardHeaderStatus, TnChipInputHarnessFilters, TnChipInputOption, TnConfirmDialogData, TnDialogDefaults, TnDialogOpenTarget, TnDrawerMode, TnDrawerPosition, TnEmptySize, TnFlatTreeNode, TnFormFieldErrorMessage, TnFormFieldErrorMessages, TnFormFieldErrorResolver, TnMenuItem, TnSelectOption, TnSelectOptionGroup, TnSelectionChange, TnSortEvent, TnTableDataProvider, TnTableDataSource, TnTableHarnessFilters, TnTablePagerHarnessFilters, TnTablePagerLabels, TnTablePagination, TnTestAttrName, TnTestIdValue, TnThemeDefinition, TnToastCall, TnToastConfig, TooltipPosition, YearCell };