@truenas/ui-components 0.1.28 → 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.
@@ -4165,6 +4165,163 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
4165
4165
  args: [{ selector: 'tn-form-field', standalone: true, imports: [], template: "<div class=\"tn-form-field\" [attr.data-testid]=\"testId()\">\n <!-- Label -->\n @if (label()) {\n <label class=\"tn-form-field-label\" [class.required]=\"required()\">\n {{ label() }}\n @if (required()) {\n <span class=\"required-asterisk\" aria-label=\"required\">*</span>\n }\n </label>\n }\n\n <!-- Form Control Content -->\n <div class=\"tn-form-field-wrapper\">\n <ng-content />\n </div>\n\n <!-- Hint or Error Message -->\n <div class=\"tn-form-field-subscript\">\n @if (showError()) {\n <div\n class=\"tn-form-field-error\"\n role=\"alert\"\n aria-live=\"polite\">\n {{ errorMessage() }}\n </div>\n }\n @if (showHint()) {\n <div class=\"tn-form-field-hint\">\n {{ hint() }}\n </div>\n }\n </div>\n</div>", styles: [".tn-form-field{display:block;width:100%;margin-bottom:1rem;font-family:var(--tn-font-family-body, \"Inter\"),sans-serif}.tn-form-field-label{display:block;margin-bottom:.5rem;font-size:.875rem;font-weight:500;color:var(--tn-fg1, #333);line-height:1.4}.tn-form-field-label.required .required-asterisk{color:var(--tn-error, #dc3545);margin-left:.25rem}.tn-form-field-wrapper{position:relative;width:100%;overflow:visible}.tn-form-field-wrapper :ng-deep .tn-select-container,.tn-form-field-wrapper :ng-deep .tn-input-container{margin-bottom:0}.tn-form-field-wrapper :ng-deep .tn-select-label,.tn-form-field-wrapper :ng-deep .tn-input-label{display:none}.tn-form-field-wrapper :ng-deep .tn-select-error,.tn-form-field-wrapper :ng-deep .tn-input-error{display:none}.tn-form-field-wrapper :ng-deep .tn-select-dropdown{z-index:1000}.tn-form-field-subscript{min-height:1.25rem;margin-top:.25rem;font-size:.75rem;line-height:1.4}.tn-form-field-error{color:var(--tn-error, #dc3545);margin:0}.tn-form-field-hint{color:var(--tn-fg2, #6c757d);margin:0}.tn-form-field-wrapper:has(:focus-visible) .tn-form-field-label{color:var(--tn-primary, #007bff)}.tn-form-field-wrapper:has(.error) .tn-form-field-label{color:var(--tn-error, #dc3545)}@media(prefers-reduced-motion:reduce){.tn-form-field-label{transition:none}}@media(prefers-contrast:high){.tn-form-field-label,.tn-form-field-error{font-weight:600}}\n"] }]
4166
4166
  }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], testId: [{ type: i0.Input, args: [{ isSignal: true, alias: "testId", required: false }] }], control: [{ type: i0.ContentChild, args: [i0.forwardRef(() => NgControl), { isSignal: true }] }] } });
4167
4167
 
4168
+ /**
4169
+ * Harness for interacting with `tn-form-field` in tests.
4170
+ * Provides methods for querying label, hint, error state, and accessing
4171
+ * the projected form control.
4172
+ *
4173
+ * @example
4174
+ * ```typescript
4175
+ * // Find a form field by label
4176
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Email' }));
4177
+ * expect(await field.getLabel()).toBe('Email');
4178
+ *
4179
+ * // Check for validation errors
4180
+ * expect(await field.hasError()).toBe(true);
4181
+ * expect(await field.getErrorMessage()).toBe('This field is required');
4182
+ *
4183
+ * // Check hint text
4184
+ * const hinted = await loader.getHarness(TnFormFieldHarness.with({ label: 'Port' }));
4185
+ * expect(await hinted.getHint()).toBe('Default port is 443');
4186
+ *
4187
+ * // Find by testId
4188
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ testId: 'email-field' }));
4189
+ * ```
4190
+ */
4191
+ class TnFormFieldHarness extends ComponentHarness {
4192
+ /**
4193
+ * The selector for the host element of a `TnFormFieldComponent` instance.
4194
+ */
4195
+ static hostSelector = 'tn-form-field';
4196
+ _label = this.locatorForOptional('.tn-form-field-label');
4197
+ _error = this.locatorForOptional('.tn-form-field-error');
4198
+ _hint = this.locatorForOptional('.tn-form-field-hint');
4199
+ /**
4200
+ * Gets a `HarnessPredicate` that can be used to search for a form field
4201
+ * with specific attributes.
4202
+ *
4203
+ * @param options Options for filtering which form field instances are considered a match.
4204
+ * @returns A `HarnessPredicate` configured with the given options.
4205
+ *
4206
+ * @example
4207
+ * ```typescript
4208
+ * // Find by label text
4209
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Name' }));
4210
+ *
4211
+ * // Find by label regex
4212
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: /email/i }));
4213
+ *
4214
+ * // Find by testId
4215
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ testId: 'name-field' }));
4216
+ * ```
4217
+ */
4218
+ static with(options = {}) {
4219
+ return new HarnessPredicate(TnFormFieldHarness, options)
4220
+ .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))
4221
+ .addOption('testId', options.testId, async (harness, testId) => {
4222
+ return (await harness.getTestId()) === testId;
4223
+ });
4224
+ }
4225
+ /**
4226
+ * Gets the form field label text.
4227
+ *
4228
+ * @returns Promise resolving to the label text, or empty string if no label.
4229
+ *
4230
+ * @example
4231
+ * ```typescript
4232
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Name' }));
4233
+ * expect(await field.getLabel()).toBe('Name');
4234
+ * ```
4235
+ */
4236
+ async getLabel() {
4237
+ const label = await this._label();
4238
+ if (!label) {
4239
+ return '';
4240
+ }
4241
+ const text = await label.text();
4242
+ // Strip the required asterisk from the label text
4243
+ return text.replace(/\s*\*\s*$/, '').trim();
4244
+ }
4245
+ /**
4246
+ * Gets the error message text, if visible.
4247
+ *
4248
+ * @returns Promise resolving to the error message, or null if no error is shown.
4249
+ *
4250
+ * @example
4251
+ * ```typescript
4252
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Email' }));
4253
+ * expect(await field.getErrorMessage()).toBe('Please enter a valid email address');
4254
+ * ```
4255
+ */
4256
+ async getErrorMessage() {
4257
+ const error = await this._error();
4258
+ return error ? (await error.text()).trim() : null;
4259
+ }
4260
+ /**
4261
+ * Checks whether the form field is currently showing an error.
4262
+ *
4263
+ * @returns Promise resolving to true if an error message is visible.
4264
+ *
4265
+ * @example
4266
+ * ```typescript
4267
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Email' }));
4268
+ * expect(await field.hasError()).toBe(true);
4269
+ * ```
4270
+ */
4271
+ async hasError() {
4272
+ const error = await this._error();
4273
+ return error !== null;
4274
+ }
4275
+ /**
4276
+ * Gets the hint text, if visible.
4277
+ *
4278
+ * @returns Promise resolving to the hint text, or null if no hint is shown.
4279
+ *
4280
+ * @example
4281
+ * ```typescript
4282
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Port' }));
4283
+ * expect(await field.getHint()).toBe('Default port is 443');
4284
+ * ```
4285
+ */
4286
+ async getHint() {
4287
+ const hint = await this._hint();
4288
+ return hint ? (await hint.text()).trim() : null;
4289
+ }
4290
+ /**
4291
+ * Checks whether the form field is marked as required.
4292
+ *
4293
+ * @returns Promise resolving to true if the required asterisk is present.
4294
+ *
4295
+ * @example
4296
+ * ```typescript
4297
+ * const field = await loader.getHarness(TnFormFieldHarness.with({ label: 'Name' }));
4298
+ * expect(await field.isRequired()).toBe(true);
4299
+ * ```
4300
+ */
4301
+ async isRequired() {
4302
+ const label = await this._label();
4303
+ if (!label) {
4304
+ return false;
4305
+ }
4306
+ return label.hasClass('required');
4307
+ }
4308
+ /**
4309
+ * Gets the test ID attribute value.
4310
+ *
4311
+ * @returns Promise resolving to the data-testid string, or null.
4312
+ *
4313
+ * @example
4314
+ * ```typescript
4315
+ * const field = await loader.getHarness(TnFormFieldHarness);
4316
+ * expect(await field.getTestId()).toBe('email-field');
4317
+ * ```
4318
+ */
4319
+ async getTestId() {
4320
+ const root = await this.locatorFor('.tn-form-field')();
4321
+ return root.getAttribute('data-testid');
4322
+ }
4323
+ }
4324
+
4168
4325
  class TnSelectComponent {
4169
4326
  options = input([], ...(ngDevMode ? [{ debugName: "options" }] : []));
4170
4327
  optionGroups = input([], ...(ngDevMode ? [{ debugName: "optionGroups" }] : []));
@@ -10892,5 +11049,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
10892
11049
  * Generated bundle index. Do not edit.
10893
11050
  */
10894
11051
 
10895
- 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 };
11052
+ 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 };
10896
11053
  //# sourceMappingURL=truenas-ui-components.mjs.map