@prorobotech/openapi-k8s-toolkit 1.2.0-alpha.20 → 1.2.0-alpha.21

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.
@@ -1,4 +1,6 @@
1
+ import { type TDateFormatOptions } from '../../../../../utils/converterDates';
1
2
  export declare const createValueFormatter: ({ formatter, unit, }: {
2
3
  formatter: 'bytes' | 'cores' | 'unit' | 'none';
3
4
  unit?: string | undefined;
4
5
  }) => ((value: unknown) => string) | undefined;
6
+ export declare const createDateFormatter: (options?: TDateFormatOptions) => ((value: unknown) => string) | undefined;
@@ -27,6 +27,8 @@ type TBaseTopNProps = {
27
27
  type TBaseFormatterProps = {
28
28
  /** optional formatter for value */
29
29
  formatValue?: (v: unknown) => string;
30
+ /** optional formatter for timestamp / date values */
31
+ formatTimestamp?: (v: unknown) => string;
30
32
  };
31
33
  export type TMatrixToLineSingleProps = TBaseContainerSizeProps & TBasePromQueryProps & TBaseRangeProps & TBaseFormatterProps;
32
34
  export type TMatrixToLineMultiProps = TBaseContainerSizeProps & TBasePromQueryProps & TBaseRangeProps & TBaseFormatterProps;
@@ -6,6 +6,7 @@ import type { TContentCardProps, TSpacerProps } from '../../atoms';
6
6
  import type { TManageableSidebarProviderProps, TEnrichedTableProviderProps } from '../../molecules';
7
7
  import type { TUnitInput } from '../../../localTypes/factories/converterBytes';
8
8
  import type { TCoreUnitInput } from '../../../localTypes/factories/converterCores';
9
+ import type { TDateFormatOptions } from '../../../utils/converterDates';
9
10
  export type TDynamicComponentsAppTypeMap = {
10
11
  DefaultDiv: {
11
12
  id: number | string;
@@ -450,5 +451,6 @@ export type TDynamicComponentsAppTypeMap = {
450
451
  topN?: number;
451
452
  formatter: 'bytes' | 'cores' | 'unit' | 'none';
452
453
  unit?: string;
454
+ dateFormatter?: TDateFormatOptions;
453
455
  };
454
456
  };
@@ -0,0 +1,33 @@
1
+ export type TDateFormatStyle = 'date' | 'time' | 'datetime' | 'timestamp' | 'full' | 'relative' | 'iso' | 'custom';
2
+ export type TDateInput = string | number | Date;
3
+ export type TDateFormatOptions = {
4
+ style?: TDateFormatStyle;
5
+ locale?: string;
6
+ timeZone?: string;
7
+ hour12?: boolean;
8
+ /**
9
+ * Precision / verbosity toggles used by presets
10
+ */
11
+ seconds?: boolean;
12
+ timeZoneName?: 'short' | 'long' | 'shortOffset' | 'longOffset' | 'shortGeneric' | 'longGeneric';
13
+ /**
14
+ * For relative formatting
15
+ */
16
+ relative?: {
17
+ unit?: Intl.RelativeTimeFormatUnit;
18
+ numeric?: 'always' | 'auto';
19
+ now?: TDateInput;
20
+ };
21
+ /**
22
+ * Only used when style === 'custom'
23
+ * Anything you pass here overrides the preset options.
24
+ */
25
+ intl?: Intl.DateTimeFormatOptions;
26
+ };
27
+ /**
28
+ * formatLocalDate upgraded:
29
+ * - supports styles: date/time/datetime/timestamp/full/relative/iso/custom
30
+ * - accepts ISO string | Date | epoch ms
31
+ * - configurable locale/timeZone/seconds/hour12
32
+ */
33
+ export declare const formatDateAuto: (input: TDateInput, options?: TDateFormatOptions) => string;
@@ -0,0 +1,2 @@
1
+ export { formatDateAuto } from './converterDates';
2
+ export type { TDateFormatOptions } from './converterDates';
@@ -25,3 +25,4 @@ export { includesArray } from './nestedStringsArrayInclude';
25
25
  export { getResourceLink, getNamespaceLink } from './getResourceLink';
26
26
  export { convertBytes, formatBytesAuto, toBytes, convertStorage, parseValueWithUnit } from './converterBytes';
27
27
  export { convertCores, formatCoresAuto, toCores, convertCompute, parseCoresWithUnit } from './converterCores';
28
+ export { formatDateAuto } from './converterDates';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prorobotech/openapi-k8s-toolkit",
3
- "version": "1.2.0-alpha.20",
3
+ "version": "1.2.0-alpha.21",
4
4
  "description": "ProRobotech OpenAPI k8s tools",
5
5
  "main": "dist/openapi-k8s-toolkit.cjs.js",
6
6
  "module": "dist/openapi-k8s-toolkit.es.js",