@truenas/ui-components 0.3.0 → 0.3.1

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.
@@ -4207,6 +4207,164 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
4207
4207
  args: [{ selector: 'tn-chip', standalone: true, imports: [CommonModule, A11yModule, TnIconComponent, TnTestIdDirective, LabelMarkupPipe, LabelTextPipe], template: "<div\n #chipEl\n role=\"button\"\n tnTestIdType=\"chip\"\n [ngClass]=\"classes()\"\n [tnTestId]=\"testId()\"\n [attr.aria-label]=\"label() | tnLabelText\"\n [attr.aria-disabled]=\"disabled()\"\n [attr.tabindex]=\"disabled() ? -1 : 0\"\n (click)=\"handleClick($event)\"\n (keydown)=\"handleKeyDown($event)\"\n>\n @if (icon()) {\n <tn-icon class=\"tn-chip__icon\" size=\"sm\" [name]=\"icon()!\" />\n }\n <span class=\"tn-chip__label\" [innerHTML]=\"label() | tnLabelMarkup\"></span>\n @if (closable()) {\n <button\n type=\"button\"\n class=\"tn-chip__close\"\n [attr.aria-label]=\"'Remove ' + (label() | tnLabelText)\"\n [disabled]=\"disabled()\"\n (click)=\"handleClose($event)\"\n >\n <span class=\"tn-chip__close-icon\">\u00D7</span>\n </button>\n }\n</div>", styles: [".tn-chip{display:inline-flex;align-items:center;gap:6px;padding:6px 12px;border-radius:16px;font-family:var(--tn-font-family-body);font-size:14px;font-weight:500;line-height:1.2;cursor:pointer;transition:all .2s ease-in-out;border:1px solid transparent;outline:none;-webkit-user-select:none;user-select:none}.tn-chip:focus-visible{outline:2px solid var(--tn-primary);outline-offset:2px}.tn-chip:hover:not(.tn-chip--disabled){transform:translateY(-1px);box-shadow:0 2px 4px #0000001a}.tn-chip--primary{background-color:var(--tn-primary);color:var(--tn-primary-txt);border-color:var(--tn-primary)}.tn-chip--primary:hover:not(.tn-chip--disabled){background-color:var(--tn-blue);border-color:var(--tn-blue)}.tn-chip--secondary{background-color:var(--tn-alt-bg1);color:var(--tn-alt-fg2);border-color:var(--tn-alt-bg2)}.tn-chip--secondary:hover:not(.tn-chip--disabled){background-color:var(--tn-alt-bg2);border-color:var(--tn-accent)}.tn-chip--accent{background-color:var(--tn-accent);color:var(--tn-fg1);border-color:var(--tn-accent)}.tn-chip--accent:hover:not(.tn-chip--disabled){background-color:var(--tn-alt-bg2);border-color:var(--tn-alt-bg2)}.tn-chip--disabled{opacity:.5;cursor:not-allowed;pointer-events:none}.tn-chip--closable{padding-right:8px}.tn-chip__icon{display:flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:12px}.tn-chip__label ::ng-deep code{font-family:var(--tn-font-family-monospace, monospace);font-size:.875em;background:var(--tn-bg2, #f5f5f5);border:1px solid var(--tn-lines, #ccc);border-radius:4px;padding:.125em .45em}.tn-chip__label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:200px}.tn-chip__close{display:flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;margin:0;border:none;border-radius:50%;background-color:#fff3;color:inherit;cursor:pointer;transition:background-color .2s ease-in-out;outline:none}.tn-chip__close:hover:not(:disabled){background-color:#ffffff4d}.tn-chip__close:focus-visible{outline:1px solid currentColor;outline-offset:1px}.tn-chip__close:disabled{cursor:not-allowed;opacity:.5}.tn-chip__close-icon{font-size:14px;font-weight:700;line-height:1}.tn-dark .tn-chip--secondary .tn-chip__close{background-color:#0003}.tn-dark .tn-chip--secondary .tn-chip__close:hover:not(:disabled){background-color:#0000004d}.high-contrast .tn-chip{border-width:2px}.high-contrast .tn-chip:focus-visible{outline-width:3px}\n"] }]
4208
4208
  }], propDecorators: { chipEl: [{ type: i0.ViewChild, args: ['chipEl', { isSignal: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], testId: [{ type: i0.Input, args: [{ isSignal: true, alias: "testId", required: false }] }], onClose: [{ type: i0.Output, args: ["onClose"] }], onClick: [{ type: i0.Output, args: ["onClick"] }] } });
4209
4209
 
4210
+ /**
4211
+ * Harness for interacting with tn-chip in tests.
4212
+ * Provides methods for reading chip state and simulating user interactions
4213
+ * (selecting the chip and dismissing a closable chip).
4214
+ *
4215
+ * @example
4216
+ * ```typescript
4217
+ * // Find a chip by label and click it
4218
+ * const chip = await loader.getHarness(TnChipHarness.with({ label: 'Active' }));
4219
+ * await chip.click();
4220
+ *
4221
+ * // Dismiss a closable chip
4222
+ * const filter = await loader.getHarness(TnChipHarness.with({ label: 'Has SSH Access' }));
4223
+ * if (await filter.isClosable()) {
4224
+ * await filter.close();
4225
+ * }
4226
+ * ```
4227
+ */
4228
+ class TnChipHarness extends ComponentHarness {
4229
+ /**
4230
+ * The selector for the host element of a `TnChipComponent` instance.
4231
+ */
4232
+ static hostSelector = 'tn-chip';
4233
+ _chip = this.locatorFor('.tn-chip');
4234
+ _label = this.locatorFor('.tn-chip__label');
4235
+ _icon = this.locatorForOptional('.tn-chip__icon');
4236
+ _closeButton = this.locatorForOptional('.tn-chip__close');
4237
+ /**
4238
+ * Gets a `HarnessPredicate` that can be used to search for a chip
4239
+ * with specific attributes.
4240
+ *
4241
+ * @param options Options for filtering which chip instances are considered a match.
4242
+ * @returns A `HarnessPredicate` configured with the given options.
4243
+ *
4244
+ * @example
4245
+ * ```typescript
4246
+ * // Find chip by exact label
4247
+ * const chip = await loader.getHarness(TnChipHarness.with({ label: 'Production' }));
4248
+ *
4249
+ * // Find chip with regex pattern
4250
+ * const chip = await loader.getHarness(TnChipHarness.with({ label: /access/i }));
4251
+ * ```
4252
+ */
4253
+ static with(options = {}) {
4254
+ return new HarnessPredicate(TnChipHarness, options)
4255
+ .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label));
4256
+ }
4257
+ /**
4258
+ * Gets the chip's label text.
4259
+ *
4260
+ * @returns Promise resolving to the chip's text content.
4261
+ *
4262
+ * @example
4263
+ * ```typescript
4264
+ * const chip = await loader.getHarness(TnChipHarness);
4265
+ * expect(await chip.getLabel()).toBe('Active');
4266
+ * ```
4267
+ */
4268
+ async getLabel() {
4269
+ const label = await this._label();
4270
+ return (await label.text()).trim();
4271
+ }
4272
+ /**
4273
+ * Gets the chip's color variant (`primary`, `secondary`, or `accent`).
4274
+ *
4275
+ * @returns Promise resolving to the chip's color.
4276
+ *
4277
+ * @example
4278
+ * ```typescript
4279
+ * const chip = await loader.getHarness(TnChipHarness);
4280
+ * expect(await chip.getColor()).toBe('primary');
4281
+ * ```
4282
+ */
4283
+ async getColor() {
4284
+ const chip = await this._chip();
4285
+ const classAttr = (await chip.getAttribute('class')) ?? '';
4286
+ const match = classAttr.match(/tn-chip--(primary|secondary|accent)/);
4287
+ return match?.[1] ?? 'primary';
4288
+ }
4289
+ /**
4290
+ * Checks whether the chip is disabled.
4291
+ *
4292
+ * @returns Promise resolving to true if the chip is disabled.
4293
+ *
4294
+ * @example
4295
+ * ```typescript
4296
+ * const chip = await loader.getHarness(TnChipHarness);
4297
+ * expect(await chip.isDisabled()).toBe(false);
4298
+ * ```
4299
+ */
4300
+ async isDisabled() {
4301
+ const chip = await this._chip();
4302
+ return (await chip.getAttribute('aria-disabled')) === 'true';
4303
+ }
4304
+ /**
4305
+ * Checks whether the chip renders a close (dismiss) button.
4306
+ *
4307
+ * @returns Promise resolving to true if the chip is closable.
4308
+ *
4309
+ * @example
4310
+ * ```typescript
4311
+ * const chip = await loader.getHarness(TnChipHarness);
4312
+ * expect(await chip.isClosable()).toBe(true);
4313
+ * ```
4314
+ */
4315
+ async isClosable() {
4316
+ return (await this._closeButton()) !== null;
4317
+ }
4318
+ /**
4319
+ * Checks whether the chip renders a leading icon.
4320
+ *
4321
+ * @returns Promise resolving to true if the chip has an icon.
4322
+ *
4323
+ * @example
4324
+ * ```typescript
4325
+ * const chip = await loader.getHarness(TnChipHarness);
4326
+ * expect(await chip.hasIcon()).toBe(true);
4327
+ * ```
4328
+ */
4329
+ async hasIcon() {
4330
+ return (await this._icon()) !== null;
4331
+ }
4332
+ /**
4333
+ * Clicks the chip body, triggering its `onClick` output.
4334
+ *
4335
+ * @returns Promise that resolves when the click action is complete.
4336
+ *
4337
+ * @example
4338
+ * ```typescript
4339
+ * const chip = await loader.getHarness(TnChipHarness.with({ label: 'Active' }));
4340
+ * await chip.click();
4341
+ * ```
4342
+ */
4343
+ async click() {
4344
+ const chip = await this._chip();
4345
+ return chip.click();
4346
+ }
4347
+ /**
4348
+ * Clicks the chip's close button, triggering its `onClose` output.
4349
+ * Throws if the chip is not closable.
4350
+ *
4351
+ * @returns Promise that resolves when the close action is complete.
4352
+ *
4353
+ * @example
4354
+ * ```typescript
4355
+ * const chip = await loader.getHarness(TnChipHarness.with({ label: 'Has SSH Access' }));
4356
+ * await chip.close();
4357
+ * ```
4358
+ */
4359
+ async close() {
4360
+ const closeButton = await this._closeButton();
4361
+ if (!closeButton) {
4362
+ throw new Error('Cannot close a chip that is not closable (no close button rendered).');
4363
+ }
4364
+ return closeButton.click();
4365
+ }
4366
+ }
4367
+
4210
4368
  class TnCardHeaderDirective {
4211
4369
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: TnCardHeaderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
4212
4370
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: TnCardHeaderDirective, isStandalone: true, selector: "[tnCardHeader]", ngImport: i0 });
@@ -16197,5 +16355,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
16197
16355
  * Generated bundle index. Do not edit.
16198
16356
  */
16199
16357
 
16200
- 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, TnCardHeaderDirective, TnCellDefDirective, TnCheckboxComponent, TnCheckboxHarness, TnCheckboxLabelDirective, TnChipComponent, TnConfirmDialogComponent, TnDateInputComponent, TnDateInputHarness, TnDateRangeInputComponent, TnDateRangeInputHarness, TnDetailRowDefDirective, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnDrawerComponent, TnDrawerContainerComponent, TnDrawerContainerHarness, TnDrawerContentComponent, TnDrawerHarness, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnExpansionPanelHarness, 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, 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 };
16358
+ 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, TnCardHeaderDirective, TnCellDefDirective, TnCheckboxComponent, TnCheckboxHarness, TnCheckboxLabelDirective, TnChipComponent, TnChipHarness, TnConfirmDialogComponent, TnDateInputComponent, TnDateInputHarness, TnDateRangeInputComponent, TnDateRangeInputHarness, TnDetailRowDefDirective, TnDialog, TnDialogHarness, TnDialogShellComponent, TnDialogTesting, TnDividerComponent, TnDividerDirective, TnDrawerComponent, TnDrawerContainerComponent, TnDrawerContainerHarness, TnDrawerContentComponent, TnDrawerHarness, TnEmptyComponent, TnEmptyHarness, TnExpansionPanelComponent, TnExpansionPanelHarness, 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, 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 };
16201
16359
  //# sourceMappingURL=truenas-ui-components.mjs.map