@truenas/ui-components 0.1.27 → 0.1.29

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.27",
3
+ "version": "0.1.29",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public"
@@ -2134,6 +2134,140 @@ declare class TnFormFieldComponent implements AfterContentInit {
2134
2134
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnFormFieldComponent, "tn-form-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "hint": { "alias": "hint"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; }, {}, ["control"], ["*"], true, never>;
2135
2135
  }
2136
2136
 
2137
+ /**
2138
+ * Harness for interacting with `tn-form-field` in tests.
2139
+ * Provides methods for querying label, hint, error state, and accessing
2140
+ * the projected form control.
2141
+ *
2142
+ * @example
2143
+ * ```typescript
2144
+ * // Find a form field by label
2145
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Email' }));
2146
+ * expect(await field.getLabel()).toBe('Email');
2147
+ *
2148
+ * // Check for validation errors
2149
+ * expect(await field.hasError()).toBe(true);
2150
+ * expect(await field.getErrorMessage()).toBe('This field is required');
2151
+ *
2152
+ * // Check hint text
2153
+ * const hinted = await loader.getHarness(TnFormFieldHarness.with({ label: 'Port' }));
2154
+ * expect(await hinted.getHint()).toBe('Default port is 443');
2155
+ *
2156
+ * // Find by testId
2157
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ testId: 'email-field' }));
2158
+ * ```
2159
+ */
2160
+ declare class TnFormFieldHarness extends ComponentHarness {
2161
+ /**
2162
+ * The selector for the host element of a `TnFormFieldComponent` instance.
2163
+ */
2164
+ static hostSelector: string;
2165
+ private _label;
2166
+ private _error;
2167
+ private _hint;
2168
+ /**
2169
+ * Gets a `HarnessPredicate` that can be used to search for a form field
2170
+ * with specific attributes.
2171
+ *
2172
+ * @param options Options for filtering which form field instances are considered a match.
2173
+ * @returns A `HarnessPredicate` configured with the given options.
2174
+ *
2175
+ * @example
2176
+ * ```typescript
2177
+ * // Find by label text
2178
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Name' }));
2179
+ *
2180
+ * // Find by label regex
2181
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: /email/i }));
2182
+ *
2183
+ * // Find by testId
2184
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ testId: 'name-field' }));
2185
+ * ```
2186
+ */
2187
+ static with(options?: FormFieldHarnessFilters): HarnessPredicate<TnFormFieldHarness>;
2188
+ /**
2189
+ * Gets the form field label text.
2190
+ *
2191
+ * @returns Promise resolving to the label text, or empty string if no label.
2192
+ *
2193
+ * @example
2194
+ * ```typescript
2195
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Name' }));
2196
+ * expect(await field.getLabel()).toBe('Name');
2197
+ * ```
2198
+ */
2199
+ getLabel(): Promise<string>;
2200
+ /**
2201
+ * Gets the error message text, if visible.
2202
+ *
2203
+ * @returns Promise resolving to the error message, or null if no error is shown.
2204
+ *
2205
+ * @example
2206
+ * ```typescript
2207
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Email' }));
2208
+ * expect(await field.getErrorMessage()).toBe('Please enter a valid email address');
2209
+ * ```
2210
+ */
2211
+ getErrorMessage(): Promise<string | null>;
2212
+ /**
2213
+ * Checks whether the form field is currently showing an error.
2214
+ *
2215
+ * @returns Promise resolving to true if an error message is visible.
2216
+ *
2217
+ * @example
2218
+ * ```typescript
2219
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Email' }));
2220
+ * expect(await field.hasError()).toBe(true);
2221
+ * ```
2222
+ */
2223
+ hasError(): Promise<boolean>;
2224
+ /**
2225
+ * Gets the hint text, if visible.
2226
+ *
2227
+ * @returns Promise resolving to the hint text, or null if no hint is shown.
2228
+ *
2229
+ * @example
2230
+ * ```typescript
2231
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Port' }));
2232
+ * expect(await field.getHint()).toBe('Default port is 443');
2233
+ * ```
2234
+ */
2235
+ getHint(): Promise<string | null>;
2236
+ /**
2237
+ * Checks whether the form field is marked as required.
2238
+ *
2239
+ * @returns Promise resolving to true if the required asterisk is present.
2240
+ *
2241
+ * @example
2242
+ * ```typescript
2243
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Name' }));
2244
+ * expect(await field.isRequired()).toBe(true);
2245
+ * ```
2246
+ */
2247
+ isRequired(): Promise<boolean>;
2248
+ /**
2249
+ * Gets the test ID attribute value.
2250
+ *
2251
+ * @returns Promise resolving to the data-testid string, or null.
2252
+ *
2253
+ * @example
2254
+ * ```typescript
2255
+ * const field = await loader.getHarness(TnFormFieldHarness);
2256
+ * expect(await field.getTestId()).toBe('email-field');
2257
+ * ```
2258
+ */
2259
+ getTestId(): Promise<string | null>;
2260
+ }
2261
+ /**
2262
+ * A set of criteria that can be used to filter a list of `TnFormFieldHarness` instances.
2263
+ */
2264
+ interface FormFieldHarnessFilters extends BaseHarnessFilters {
2265
+ /** Filters by label text. Supports string or regex matching. */
2266
+ label?: string | RegExp;
2267
+ /** Filters by data-testid attribute. */
2268
+ testId?: string;
2269
+ }
2270
+
2137
2271
  interface TnSelectOption<T = unknown> {
2138
2272
  value: T;
2139
2273
  label: string;
@@ -4745,5 +4879,5 @@ declare const TN_THEME_DEFINITIONS: readonly TnThemeDefinition[];
4745
4879
  */
4746
4880
  declare const THEME_MAP: Map<TnTheme, TnThemeDefinition>;
4747
4881
 
4748
- 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, 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 };
4749
- export type { AutocompleteHarnessFilters, BannerHarnessFilters, ButtonHarnessFilters, CalendarCell, CheckboxHarnessFilters, ChipColor, CreateFolderEvent, DateRange, DialogHarnessFilters, EmptyHarnessFilters, FilePickerCallbacks, FilePickerError, FilePickerMode, FileSystemItem, 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 };
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 };