@truenas/ui-components 0.1.4 → 0.1.6

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.
@@ -16,7 +16,6 @@ import { TemplatePortal, PortalModule, ComponentPortal } from '@angular/cdk/port
16
16
  import { CdkMenu, CdkMenuItem, CdkMenuTrigger } from '@angular/cdk/menu';
17
17
  import { trigger, state, transition, style, animate } from '@angular/animations';
18
18
  import { SPACE, ENTER, END, HOME, DOWN_ARROW, UP_ARROW, RIGHT_ARROW, LEFT_ARROW } from '@angular/cdk/keycodes';
19
- import { jest } from '@jest/globals';
20
19
  import { DataSource } from '@angular/cdk/collections';
21
20
  import * as i1$2 from '@angular/cdk/tree';
22
21
  import { CdkTree, CdkTreeModule, CdkTreeNode, CDK_TREE_NODE_OUTLET_NODE, CdkTreeNodeOutlet, CdkNestedTreeNode } from '@angular/cdk/tree';
@@ -947,6 +946,173 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
947
946
  args: [{ selector: 'tn-icon-button', standalone: true, imports: [CommonModule, TnIconComponent], template: "<button\n type=\"button\"\n [ngClass]=\"classes()\"\n [disabled]=\"disabled()\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n [attr.title]=\"tooltip()\"\n (click)=\"onClick.emit($event)\"\n>\n <tn-icon\n [name]=\"name()\"\n [size]=\"size()\"\n [color]=\"color()\"\n [library]=\"library()\"\n [ariaLabel]=\"effectiveAriaLabel()\" />\n</button>\n", styles: [":host{display:inline-block;width:fit-content}.tn-icon-button{display:inline-flex;align-items:center;justify-content:center;cursor:pointer;border:none;background:transparent;padding:8px;border-radius:4px;transition:background-color .2s ease,color .2s ease;color:var(--tn-fg2, #6b7280)}.tn-icon-button:hover:not(:disabled){background-color:var(--tn-bg3, #f3f4f6);color:var(--tn-fg1, #1f2937)}.tn-icon-button:active:not(:disabled){background-color:var(--tn-bg3, #e5e7eb)}.tn-icon-button:focus-visible{outline:2px solid var(--tn-primary, #2563eb);outline-offset:2px}.tn-icon-button:disabled{opacity:.5;cursor:not-allowed;pointer-events:none}\n"] }]
948
947
  }], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], tooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltip", required: false }] }], library: [{ type: i0.Input, args: [{ isSignal: true, alias: "library", required: false }] }], onClick: [{ type: i0.Output, args: ["onClick"] }] } });
949
948
 
949
+ /**
950
+ * Harness for interacting with tn-icon-button in tests.
951
+ * Provides filtering by icon properties and methods for querying state and simulating interactions.
952
+ *
953
+ * @example
954
+ * ```typescript
955
+ * // Find icon button by name
956
+ * const closeBtn = await loader.getHarness(
957
+ * TnIconButtonHarness.with({ name: 'close' })
958
+ * );
959
+ *
960
+ * // Click an icon button
961
+ * const settingsBtn = await loader.getHarness(
962
+ * TnIconButtonHarness.with({ name: 'settings' })
963
+ * );
964
+ * await settingsBtn.click();
965
+ *
966
+ * // Check if disabled
967
+ * const deleteBtn = await loader.getHarness(
968
+ * TnIconButtonHarness.with({ name: 'delete' })
969
+ * );
970
+ * expect(await deleteBtn.isDisabled()).toBe(false);
971
+ * ```
972
+ */
973
+ class TnIconButtonHarness extends ComponentHarness {
974
+ /**
975
+ * The selector for the host element of a `TnIconButtonComponent` instance.
976
+ */
977
+ static hostSelector = 'tn-icon-button';
978
+ button = this.locatorFor('button');
979
+ /**
980
+ * Gets a `HarnessPredicate` that can be used to search for an icon button
981
+ * with specific attributes.
982
+ *
983
+ * @param options Options for filtering which icon button instances are considered a match.
984
+ * @returns A `HarnessPredicate` configured with the given options.
985
+ *
986
+ * @example
987
+ * ```typescript
988
+ * // Find icon button by name
989
+ * const button = await loader.getHarness(
990
+ * TnIconButtonHarness.with({ name: 'menu' })
991
+ * );
992
+ *
993
+ * // Find icon button by library
994
+ * const customButton = await loader.getHarness(
995
+ * TnIconButtonHarness.with({ library: 'mdi' })
996
+ * );
997
+ *
998
+ * // Find icon button with specific size
999
+ * const largeButton = await loader.getHarness(
1000
+ * TnIconButtonHarness.with({ size: 'lg' })
1001
+ * );
1002
+ * ```
1003
+ */
1004
+ static with(options = {}) {
1005
+ return new HarnessPredicate(TnIconButtonHarness, options)
1006
+ .addOption('name', options.name, async (harness, name) => {
1007
+ return (await harness.getName()) === name;
1008
+ })
1009
+ .addOption('library', options.library, async (harness, library) => {
1010
+ return (await harness.getLibrary()) === library;
1011
+ })
1012
+ .addOption('size', options.size, async (harness, size) => {
1013
+ return (await harness.getSize()) === size;
1014
+ });
1015
+ }
1016
+ /**
1017
+ * Gets the icon name.
1018
+ *
1019
+ * @returns Promise resolving to the icon name.
1020
+ *
1021
+ * @example
1022
+ * ```typescript
1023
+ * const button = await loader.getHarness(TnIconButtonHarness);
1024
+ * const name = await button.getName();
1025
+ * expect(name).toBe('settings');
1026
+ * ```
1027
+ */
1028
+ async getName() {
1029
+ const icon = await this.locatorFor('tn-icon')();
1030
+ return icon.getAttribute('name');
1031
+ }
1032
+ /**
1033
+ * Gets the icon library.
1034
+ *
1035
+ * @returns Promise resolving to the icon library.
1036
+ *
1037
+ * @example
1038
+ * ```typescript
1039
+ * const button = await loader.getHarness(TnIconButtonHarness);
1040
+ * const library = await button.getLibrary();
1041
+ * expect(library).toBe('mdi');
1042
+ * ```
1043
+ */
1044
+ async getLibrary() {
1045
+ const icon = await this.locatorFor('tn-icon')();
1046
+ return icon.getAttribute('library');
1047
+ }
1048
+ /**
1049
+ * Gets the icon size.
1050
+ *
1051
+ * @returns Promise resolving to the icon size.
1052
+ *
1053
+ * @example
1054
+ * ```typescript
1055
+ * const button = await loader.getHarness(TnIconButtonHarness);
1056
+ * const size = await button.getSize();
1057
+ * expect(size).toBe('lg');
1058
+ * ```
1059
+ */
1060
+ async getSize() {
1061
+ const icon = await this.locatorFor('tn-icon')();
1062
+ return icon.getAttribute('size');
1063
+ }
1064
+ /**
1065
+ * Gets the icon color.
1066
+ *
1067
+ * @returns Promise resolving to the icon color.
1068
+ *
1069
+ * @example
1070
+ * ```typescript
1071
+ * const button = await loader.getHarness(TnIconButtonHarness);
1072
+ * const color = await button.getColor();
1073
+ * expect(color).toBe('primary');
1074
+ * ```
1075
+ */
1076
+ async getColor() {
1077
+ const icon = await this.locatorFor('tn-icon')();
1078
+ return icon.getAttribute('color');
1079
+ }
1080
+ /**
1081
+ * Checks whether the icon button is disabled.
1082
+ *
1083
+ * @returns Promise resolving to true if the button is disabled.
1084
+ *
1085
+ * @example
1086
+ * ```typescript
1087
+ * const button = await loader.getHarness(
1088
+ * TnIconButtonHarness.with({ name: 'delete' })
1089
+ * );
1090
+ * expect(await button.isDisabled()).toBe(false);
1091
+ * ```
1092
+ */
1093
+ async isDisabled() {
1094
+ const button = await this.button();
1095
+ return (await button.getProperty('disabled')) ?? false;
1096
+ }
1097
+ /**
1098
+ * Clicks the icon button.
1099
+ *
1100
+ * @returns Promise that resolves when the click action is complete.
1101
+ *
1102
+ * @example
1103
+ * ```typescript
1104
+ * const button = await loader.getHarness(
1105
+ * TnIconButtonHarness.with({ name: 'close' })
1106
+ * );
1107
+ * await button.click();
1108
+ * ```
1109
+ */
1110
+ async click() {
1111
+ const button = await this.button();
1112
+ return button.click();
1113
+ }
1114
+ }
1115
+
950
1116
  var InputType;
951
1117
  (function (InputType) {
952
1118
  InputType["Email"] = "email";
@@ -2417,7 +2583,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
2417
2583
 
2418
2584
  /**
2419
2585
  * Harness for interacting with tn-icon in tests.
2420
- * Provides filtering by icon name and library for existence checks.
2586
+ * Provides filtering by icon name and library for existence checks, as well as click interaction.
2421
2587
  *
2422
2588
  * @example
2423
2589
  * ```typescript
@@ -2438,6 +2604,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
2438
2604
  * const hasIcon = await loader.hasHarness(
2439
2605
  * TnIconHarness.with({ name: 'check' })
2440
2606
  * );
2607
+ *
2608
+ * // Click an icon
2609
+ * const closeIcon = await loader.getHarness(
2610
+ * TnIconHarness.with({ name: 'close' })
2611
+ * );
2612
+ * await closeIcon.click();
2441
2613
  * ```
2442
2614
  */
2443
2615
  class TnIconHarness extends ComponentHarness {
@@ -2546,6 +2718,21 @@ class TnIconHarness extends ComponentHarness {
2546
2718
  const host = await this.host();
2547
2719
  return host.getAttribute('color');
2548
2720
  }
2721
+ /**
2722
+ * Clicks the icon.
2723
+ *
2724
+ * @returns Promise that resolves when the click action is complete.
2725
+ *
2726
+ * @example
2727
+ * ```typescript
2728
+ * const icon = await loader.getHarness(TnIconHarness.with({ name: 'close' }));
2729
+ * await icon.click();
2730
+ * ```
2731
+ */
2732
+ async click() {
2733
+ const host = await this.host();
2734
+ return host.click();
2735
+ }
2549
2736
  }
2550
2737
 
2551
2738
  /**
@@ -2623,6 +2810,7 @@ function libIconMarker(iconName) {
2623
2810
  return iconName;
2624
2811
  }
2625
2812
 
2813
+ /// <reference types="jest" />
2626
2814
  /**
2627
2815
  * Creates default mock implementation of TnSpriteLoaderService.
2628
2816
  * All methods return safe default values.
@@ -8287,5 +8475,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
8287
8475
  * Generated bundle index. Do not edit.
8288
8476
  */
8289
8477
 
8290
- export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LinuxModifierKeys, LinuxShortcuts, ModifierKeys, QuickShortcuts, ShortcutBuilder, StripMntPrefixPipe, THEME_MAP, THEME_STORAGE_KEY, TN_THEME_DEFINITIONS, TnBannerActionDirective, TnBannerComponent, TnBannerHarness, TnBrandedSpinnerComponent, TnButtonComponent, TnButtonHarness, TnButtonToggleComponent, TnButtonToggleGroupComponent, TnCalendarComponent, TnCalendarHeaderComponent, TnCardComponent, TnCellDefDirective, TnCheckboxComponent, TnChipComponent, TnConfirmDialogComponent, TnDateInputComponent, TnDateRangeInputComponent, TnDialog, TnDialogShellComponent, TnDividerComponent, TnDividerDirective, TnExpansionPanelComponent, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnHeaderCellDefDirective, TnIconButtonComponent, TnIconComponent, TnIconHarness, TnIconRegistryService, TnIconTesting, TnInputComponent, TnInputDirective, TnKeyboardShortcutComponent, TnKeyboardShortcutService, TnListAvatarDirective, TnListComponent, TnListIconDirective, TnListItemComponent, TnListItemLineDirective, TnListItemPrimaryDirective, TnListItemSecondaryDirective, TnListItemTitleDirective, TnListItemTrailingDirective, TnListOptionComponent, TnListSubheaderComponent, TnMenuComponent, TnMenuTriggerDirective, TnMonthViewComponent, TnMultiYearViewComponent, TnNestedTreeNodeComponent, TnParticleProgressBarComponent, TnProgressBarComponent, TnRadioComponent, TnSelectComponent, TnSelectionListComponent, TnSlideToggleComponent, TnSliderComponent, TnSliderThumbDirective, TnSliderWithLabelDirective, TnSpinnerComponent, TnSpriteLoaderService, TnStepComponent, TnStepperComponent, TnTabComponent, TnTabPanelComponent, TnTableColumnDirective, TnTableComponent, TnTabsComponent, TnTheme, TnThemeService, TnTimeInputComponent, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, libIconMarker, registerLucideIcons, setupLucideIntegration, tnIconMarker };
8478
+ export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LinuxModifierKeys, LinuxShortcuts, ModifierKeys, QuickShortcuts, ShortcutBuilder, StripMntPrefixPipe, THEME_MAP, THEME_STORAGE_KEY, TN_THEME_DEFINITIONS, TnBannerActionDirective, TnBannerComponent, TnBannerHarness, TnBrandedSpinnerComponent, TnButtonComponent, TnButtonHarness, TnButtonToggleComponent, TnButtonToggleGroupComponent, TnCalendarComponent, TnCalendarHeaderComponent, TnCardComponent, TnCellDefDirective, TnCheckboxComponent, TnChipComponent, TnConfirmDialogComponent, TnDateInputComponent, TnDateRangeInputComponent, TnDialog, TnDialogShellComponent, TnDividerComponent, TnDividerDirective, TnExpansionPanelComponent, TnFilePickerComponent, TnFilePickerPopupComponent, TnFormFieldComponent, TnHeaderCellDefDirective, TnIconButtonComponent, TnIconButtonHarness, TnIconComponent, TnIconHarness, TnIconRegistryService, TnIconTesting, TnInputComponent, TnInputDirective, TnKeyboardShortcutComponent, TnKeyboardShortcutService, TnListAvatarDirective, TnListComponent, TnListIconDirective, TnListItemComponent, TnListItemLineDirective, TnListItemPrimaryDirective, TnListItemSecondaryDirective, TnListItemTitleDirective, TnListItemTrailingDirective, TnListOptionComponent, TnListSubheaderComponent, TnMenuComponent, TnMenuTriggerDirective, TnMonthViewComponent, TnMultiYearViewComponent, TnNestedTreeNodeComponent, TnParticleProgressBarComponent, TnProgressBarComponent, TnRadioComponent, TnSelectComponent, TnSelectionListComponent, TnSlideToggleComponent, TnSliderComponent, TnSliderThumbDirective, TnSliderWithLabelDirective, TnSpinnerComponent, TnSpriteLoaderService, TnStepComponent, TnStepperComponent, TnTabComponent, TnTabPanelComponent, TnTableColumnDirective, TnTableComponent, TnTabsComponent, TnTheme, TnThemeService, TnTimeInputComponent, TnTooltipComponent, TnTooltipDirective, TnTreeComponent, TnTreeFlatDataSource, TnTreeFlattener, TnTreeNodeComponent, TnTreeNodeOutletDirective, TruncatePathPipe, WindowsModifierKeys, WindowsShortcuts, createLucideLibrary, createShortcut, defaultSpriteBasePath, defaultSpriteConfigPath, libIconMarker, registerLucideIcons, setupLucideIntegration, tnIconMarker };
8291
8479
  //# sourceMappingURL=truenas-ui-components.mjs.map