@truenas/ui-components 0.1.75 → 0.1.76

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.75",
3
+ "version": "0.1.76",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public"
@@ -26,6 +26,7 @@
26
26
  "@types/svg-sprite": "~0.0.39",
27
27
  "@types/vinyl": "~2.0.12",
28
28
  "cheerio": "~1.0.0",
29
+ "filesize": "~11.0.17",
29
30
  "svg-sprite": "~2.0.4",
30
31
  "tslib": "^2.3.0",
31
32
  "tsx": "~4.19.1",
@@ -1148,9 +1148,52 @@ declare enum InputType {
1148
1148
  Email = "email",
1149
1149
  Number = "number",
1150
1150
  Password = "password",
1151
- PlainText = "text"
1151
+ PlainText = "text",
1152
+ /**
1153
+ * Data-size field: the form model holds a raw byte count (a number), while the
1154
+ * field displays/accepts a human-readable string (e.g. `2 GiB`, `500M`, `2 TB`).
1155
+ * See `tn-input`'s `sizeStandard` / `sizeDefaultUnit` inputs to tune formatting
1156
+ * and bare-number parsing.
1157
+ */
1158
+ Size = "size"
1152
1159
  }
1153
1160
 
1161
+ /**
1162
+ * Unit standard used to format and parse data sizes.
1163
+ *
1164
+ * - `iec` — base-2 with `KiB`/`MiB`/`GiB` symbols (1 KiB = 1024 B). The TrueNAS
1165
+ * convention and `tn-input`'s default.
1166
+ * - `si` — base-10 with `kB`/`MB`/`GB` symbols (1 kB = 1000 B).
1167
+ */
1168
+ type SizeStandard = 'iec' | 'si';
1169
+ /**
1170
+ * Formats a raw byte count into a human-readable string (e.g. `2 GiB`).
1171
+ *
1172
+ * Returns an empty string for `null`/`undefined`/empty/non-numeric input so the
1173
+ * field renders blank rather than `NaN`.
1174
+ *
1175
+ * @param bytes The byte count to format.
1176
+ * @param standard Unit standard (defaults to IEC base-2).
1177
+ * @param round Decimal places to round to (defaults to 2).
1178
+ */
1179
+ declare function formatSize(bytes: number | string | null | undefined, standard?: SizeStandard, round?: number): string;
1180
+ /**
1181
+ * Parses a human-readable size string into a raw byte count.
1182
+ *
1183
+ * Lenient by design: accepts IEC (`KiB`), short (`KB`), and human (`K`) unit
1184
+ * spellings, optional whitespace, and a bare number (which is interpreted using
1185
+ * `defaultUnit`). The chosen `standard` decides the multiplier — under `iec`,
1186
+ * `MB`/`M`/`MiB` are all treated as 1024-based; under `si` they are 1000-based.
1187
+ *
1188
+ * Returns `null` for empty, malformed, or unrecognized-unit input so callers can
1189
+ * map invalid entries to a null form-model value (never `0`).
1190
+ *
1191
+ * @param raw The human-readable string to parse.
1192
+ * @param defaultUnit Unit assumed when the input carries no unit (defaults to `MiB`).
1193
+ * @param standard Unit standard (defaults to IEC base-2).
1194
+ */
1195
+ declare function parseSize(raw: string | number | null | undefined, defaultUnit?: string, standard?: SizeStandard): number | null;
1196
+
1154
1197
  declare class TnInputComponent implements AfterViewInit, OnDestroy, ControlValueAccessor {
1155
1198
  inputEl: _angular_core.Signal<ElementRef<HTMLInputElement | HTMLTextAreaElement>>;
1156
1199
  inputType: _angular_core.InputSignal<InputType>;
@@ -1178,6 +1221,24 @@ declare class TnInputComponent implements AfterViewInit, OnDestroy, ControlValue
1178
1221
  * (e.g. `Validators.min`/`max`), which work because the control emits real numbers.
1179
1222
  */
1180
1223
  allowDecimals: _angular_core.InputSignal<boolean>;
1224
+ /**
1225
+ * Unit standard for the `Size` input type — `iec` (base-2, `KiB`/`MiB`) or
1226
+ * `si` (base-10, `kB`/`MB`). Drives both the formatted display and how bare
1227
+ * numbers are scaled when parsing. Ignored unless `inputType` is `Size`.
1228
+ */
1229
+ sizeStandard: _angular_core.InputSignal<SizeStandard>;
1230
+ /**
1231
+ * Unit assumed when a user types a bare number (no unit) into a `Size` field —
1232
+ * e.g. with the default `MiB`, typing `200` yields 200 MiB. Accepts IEC
1233
+ * (`KiB`), short (`KB`), or human (`K`) spellings. Ignored unless `inputType`
1234
+ * is `Size`.
1235
+ */
1236
+ sizeDefaultUnit: _angular_core.InputSignal<string>;
1237
+ /**
1238
+ * Decimal places used when formatting a `Size` field's value for display
1239
+ * (e.g. `1.5 GiB`). Ignored unless `inputType` is `Size`.
1240
+ */
1241
+ sizeRound: _angular_core.InputSignal<number>;
1181
1242
  prefixIcon: _angular_core.InputSignal<string | undefined>;
1182
1243
  prefixIconLibrary: _angular_core.InputSignal<IconLibraryType | undefined>;
1183
1244
  suffixIcon: _angular_core.InputSignal<string | undefined>;
@@ -1187,13 +1248,15 @@ declare class TnInputComponent implements AfterViewInit, OnDestroy, ControlValue
1187
1248
  hasPrefixIcon: _angular_core.Signal<boolean>;
1188
1249
  hasSuffixIcon: _angular_core.Signal<boolean>;
1189
1250
  isNumeric: _angular_core.Signal<boolean>;
1251
+ /** True when the field is in data-size mode (human-readable string ⇄ byte-count model). */
1252
+ isSize: _angular_core.Signal<boolean>;
1190
1253
  /** True when the field only accepts whole numbers (i.e. `allowDecimals` is false). */
1191
1254
  integerOnly: _angular_core.Signal<boolean>;
1192
- /** The `type` attribute actually rendered. Number mode uses a text input + inputmode to avoid the native type="number" footguns. */
1255
+ /** The `type` attribute actually rendered. Number and size modes use a text input: number avoids the native type="number" footguns, size must accept unit letters. */
1193
1256
  resolvedType: _angular_core.Signal<InputType>;
1194
- /** `inputmode` hint: numeric keypad for integers, decimal keypad otherwise. Null (omitted) when not in number mode. */
1257
+ /** `inputmode` hint: numeric keypad for integers, decimal keypad otherwise. Null (omitted) outside number mode size fields accept unit letters, so they keep the full keyboard. */
1195
1258
  numericInputMode: _angular_core.Signal<"numeric" | "decimal" | null>;
1196
- /** Number mode is always single-line; it wins over `multiline` if both are set. */
1259
+ /** Number and size modes are always single-line; they win over `multiline` if both are set. */
1197
1260
  showTextarea: _angular_core.Signal<boolean>;
1198
1261
  id: string;
1199
1262
  protected value: string;
@@ -1216,7 +1279,7 @@ declare class TnInputComponent implements AfterViewInit, OnDestroy, ControlValue
1216
1279
  /** Parses a sanitized string to a number, mapping empty/partial input to null (never 0). */
1217
1280
  private parseNumeric;
1218
1281
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TnInputComponent, never>;
1219
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnInputComponent, "tn-input", never, { "inputType": { "alias": "inputType"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "multiline": { "alias": "multiline"; "required": false; "isSignal": true; }; "rows": { "alias": "rows"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "allowDecimals": { "alias": "allowDecimals"; "required": false; "isSignal": true; }; "prefixIcon": { "alias": "prefixIcon"; "required": false; "isSignal": true; }; "prefixIconLibrary": { "alias": "prefixIconLibrary"; "required": false; "isSignal": true; }; "suffixIcon": { "alias": "suffixIcon"; "required": false; "isSignal": true; }; "suffixIconLibrary": { "alias": "suffixIconLibrary"; "required": false; "isSignal": true; }; "suffixIconAriaLabel": { "alias": "suffixIconAriaLabel"; "required": false; "isSignal": true; }; }, { "onSuffixAction": "onSuffixAction"; }, never, never, true, never>;
1282
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TnInputComponent, "tn-input", never, { "inputType": { "alias": "inputType"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "testId": { "alias": "testId"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "multiline": { "alias": "multiline"; "required": false; "isSignal": true; }; "rows": { "alias": "rows"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "allowDecimals": { "alias": "allowDecimals"; "required": false; "isSignal": true; }; "sizeStandard": { "alias": "sizeStandard"; "required": false; "isSignal": true; }; "sizeDefaultUnit": { "alias": "sizeDefaultUnit"; "required": false; "isSignal": true; }; "sizeRound": { "alias": "sizeRound"; "required": false; "isSignal": true; }; "prefixIcon": { "alias": "prefixIcon"; "required": false; "isSignal": true; }; "prefixIconLibrary": { "alias": "prefixIconLibrary"; "required": false; "isSignal": true; }; "suffixIcon": { "alias": "suffixIcon"; "required": false; "isSignal": true; }; "suffixIconLibrary": { "alias": "suffixIconLibrary"; "required": false; "isSignal": true; }; "suffixIconAriaLabel": { "alias": "suffixIconAriaLabel"; "required": false; "isSignal": true; }; }, { "onSuffixAction": "onSuffixAction"; }, never, never, true, never>;
1220
1283
  }
1221
1284
 
1222
1285
  /**
@@ -1473,6 +1536,20 @@ declare class TnInputHarness extends ComponentHarness {
1473
1536
  * @returns Promise resolving to the numeric value, or null.
1474
1537
  */
1475
1538
  getNumericValue(): Promise<number | null>;
1539
+ /**
1540
+ * Gets the displayed value of a `Size`-type input parsed into a byte count,
1541
+ * mirroring what the control emits to the form model.
1542
+ *
1543
+ * The harness reads only the DOM, so it can't see the component's configured
1544
+ * `sizeStandard`/`sizeDefaultUnit` — pass them here to match the field under
1545
+ * test. Defaults to IEC base-2 with a `MiB` default unit (the component
1546
+ * defaults). Empty/invalid input resolves to `null`.
1547
+ *
1548
+ * @param standard Unit standard the field uses (defaults to `'iec'`).
1549
+ * @param defaultUnit Unit assumed for bare numbers (defaults to `'MiB'`).
1550
+ * @returns Promise resolving to the byte count, or null.
1551
+ */
1552
+ getByteValue(standard?: SizeStandard, defaultUnit?: string): Promise<number | null>;
1476
1553
  /**
1477
1554
  * Gets the `inputmode` attribute (e.g. 'numeric' or 'decimal' in number mode).
1478
1555
  *
@@ -7332,5 +7409,5 @@ declare const TN_THEME_DEFINITIONS: readonly TnThemeDefinition[];
7332
7409
  */
7333
7410
  declare const THEME_MAP: Map<TnTheme, TnThemeDefinition>;
7334
7411
 
7335
- export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LIGHT_THEME, 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, kebabTestSegment, libIconMarker, registerLucideIcons, scopeTestId, setupLucideIntegration, tnIconMarker, writeTestId };
7336
- export type { AutocompleteHarnessFilters, BannerHarnessFilters, ButtonHarnessFilters, ButtonToggleHarnessFilters, CalendarCell, CheckboxHarnessFilters, ChipColor, CreateFolderEvent, DateInputHarnessFilters, DateRange, DateRangeInputHarnessFilters, DialogHarnessFilters, EmptyHarnessFilters, ExpansionPanelHarnessFilters, FilePickerCallbacks, FilePickerError, FilePickerMode, FileSystemItem, FormFieldHarnessFilters, IconButtonHarnessFilters, IconHarnessFilters, IconLibrary, IconLibraryType, IconResult, IconSize, IconSource, IconTestingMockOverrides, InputHarnessFilters, KeyCombination, LabelType, LucideIconOptions, MenuHarnessFilters, MockIconRegistry, MockSpriteLoader, PathSegment, PlatformType, ProgressBarMode, RadioHarnessFilters, ResolvedIcon, SelectHarnessFilters, ShortcutHandler, SidePanelHarnessFilters, SlideToggleColor, SlideToggleHarnessFilters, SpinnerMode, SpriteConfig, SubscriptSizing, TabChangeEvent, TabHarnessFilters, TabPanelHarnessFilters, TabsHarnessFilters, TnBannerType, TnButtonToggleType, TnCardAction, TnCardControl, TnCardFooterLink, TnCardHeaderStatus, 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 };
7412
+ export { CommonShortcuts, DEFAULT_THEME, DiskIconComponent, DiskType, FileSizePipe, InputType, LIGHT_THEME, 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, libIconMarker, parseSize, registerLucideIcons, scopeTestId, setupLucideIntegration, tnIconMarker, writeTestId };
7413
+ export type { AutocompleteHarnessFilters, BannerHarnessFilters, ButtonHarnessFilters, ButtonToggleHarnessFilters, CalendarCell, CheckboxHarnessFilters, ChipColor, CreateFolderEvent, DateInputHarnessFilters, DateRange, DateRangeInputHarnessFilters, DialogHarnessFilters, EmptyHarnessFilters, ExpansionPanelHarnessFilters, FilePickerCallbacks, FilePickerError, FilePickerMode, FileSystemItem, FormFieldHarnessFilters, IconButtonHarnessFilters, IconHarnessFilters, IconLibrary, IconLibraryType, IconResult, IconSize, IconSource, IconTestingMockOverrides, InputHarnessFilters, KeyCombination, LabelType, LucideIconOptions, MenuHarnessFilters, MockIconRegistry, MockSpriteLoader, PathSegment, PlatformType, ProgressBarMode, RadioHarnessFilters, ResolvedIcon, SelectHarnessFilters, ShortcutHandler, SidePanelHarnessFilters, SizeStandard, SlideToggleColor, SlideToggleHarnessFilters, SpinnerMode, SpriteConfig, SubscriptSizing, TabChangeEvent, TabHarnessFilters, TabPanelHarnessFilters, TabsHarnessFilters, TnBannerType, TnButtonToggleType, TnCardAction, TnCardControl, TnCardFooterLink, TnCardHeaderStatus, 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 };