@vuu-ui/vuu-utils 4.0.0-alpha.8 → 4.0.0-beta.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.
Files changed (133) hide show
  1. package/package.json +10 -9
  2. package/src/array-utils.js +5 -4
  3. package/src/column-utils.js +33 -20
  4. package/src/component-registry.js +3 -2
  5. package/src/data-utils.js +1 -0
  6. package/src/datasource/BaseDataSource.js +5 -3
  7. package/src/date/EpochTimestamp.js +85 -0
  8. package/src/date/date-utils.js +50 -18
  9. package/src/date/dateTimePattern.js +33 -5
  10. package/src/date/formatter.js +54 -16
  11. package/src/date/index.js +5 -2
  12. package/src/date/temporal.js +131 -0
  13. package/src/date/time-zone.js +56 -0
  14. package/src/event-emitter.js +1 -3
  15. package/src/feature-utils.js +14 -8
  16. package/src/filters/filter-utils.js +13 -7
  17. package/src/filters/filterAsQuery.js +107 -45
  18. package/src/filters/index.js +1 -0
  19. package/src/filters/temporal-cell-filter.js +63 -0
  20. package/src/form-utils.js +44 -6
  21. package/src/formatting-utils.js +46 -25
  22. package/src/html-utils.js +35 -1
  23. package/src/index.js +0 -1
  24. package/src/keyset.js +15 -9
  25. package/src/react-utils.js +8 -2
  26. package/src/table-schema-utils.js +6 -5
  27. package/src/useResizeObserver.js +3 -3
  28. package/src/vendor/@preact/signals-core/dist/signals-core.js +1 -1
  29. package/src/vendor/@preact/signals-core/dist/signals-core.js.map +1 -1
  30. package/types/ThemeProvider.d.ts +1 -1
  31. package/types/array-utils.d.ts +3 -2
  32. package/types/column-utils.d.ts +45 -43
  33. package/types/context-definitions/DataProvider.d.ts +1 -1
  34. package/types/context-definitions/DataSourceProvider.d.ts +1 -1
  35. package/types/datasource/BaseDataSource.d.ts +2 -2
  36. package/types/date/EpochTimestamp.d.ts +66 -0
  37. package/types/date/date-utils.d.ts +34 -9
  38. package/types/date/dateTimePattern.d.ts +20 -2
  39. package/types/date/formatter.d.ts +26 -1
  40. package/types/date/index.d.ts +6 -2
  41. package/types/date/temporal.d.ts +68 -0
  42. package/types/date/time-zone.d.ts +52 -0
  43. package/types/feature-utils.d.ts +34 -30
  44. package/types/filters/filter-utils.d.ts +6 -1
  45. package/types/filters/filterAsQuery.d.ts +41 -0
  46. package/types/filters/index.d.ts +1 -0
  47. package/types/filters/temporal-cell-filter.d.ts +27 -0
  48. package/types/form-utils.d.ts +19 -0
  49. package/types/formatting-utils.d.ts +23 -1
  50. package/types/html-utils.d.ts +16 -0
  51. package/types/index.d.ts +0 -1
  52. package/types/keyset.d.ts +11 -1
  53. package/types/react-utils.d.ts +1 -1
  54. package/types/sort-utils.d.ts +2 -2
  55. package/types/table-schema-utils.d.ts +2 -2
  56. package/types/tree-types.d.ts +2 -0
  57. package/types/src/Clock.d.ts +0 -20
  58. package/types/src/PageVisibilityObserver.d.ts +0 -36
  59. package/types/src/ScaledDecimal.d.ts +0 -12
  60. package/types/src/ShellContext.d.ts +0 -11
  61. package/types/src/ThemeProvider.d.ts +0 -32
  62. package/types/src/array-utils.d.ts +0 -16
  63. package/types/src/box-utils.d.ts +0 -24
  64. package/types/src/broadcast-channel.d.ts +0 -16
  65. package/types/src/column-utils.d.ts +0 -243
  66. package/types/src/common-types.d.ts +0 -6
  67. package/types/src/component-registry.d.ts +0 -65
  68. package/types/src/context-definitions/DataContext.d.ts +0 -21
  69. package/types/src/context-definitions/DataProvider.d.ts +0 -7
  70. package/types/src/context-definitions/DataSourceProvider.d.ts +0 -12
  71. package/types/src/context-definitions/WorkspaceContext.d.ts +0 -17
  72. package/types/src/cookie-utils.d.ts +0 -9
  73. package/types/src/css-utils.d.ts +0 -1
  74. package/types/src/data-utils.d.ts +0 -33
  75. package/types/src/datasource/BaseDataSource.d.ts +0 -63
  76. package/types/src/datasource/datasource-action-utils.d.ts +0 -7
  77. package/types/src/datasource/datasource-filter-utils.d.ts +0 -2
  78. package/types/src/datasource/datasource-utils.d.ts +0 -61
  79. package/types/src/date/date-utils.d.ts +0 -39
  80. package/types/src/date/dateTimePattern.d.ts +0 -8
  81. package/types/src/date/formatter.d.ts +0 -9
  82. package/types/src/date/index.d.ts +0 -4
  83. package/types/src/date/types.d.ts +0 -29
  84. package/types/src/debug-utils.d.ts +0 -9
  85. package/types/src/edit-utils.d.ts +0 -2
  86. package/types/src/errors.d.ts +0 -2
  87. package/types/src/event-emitter.d.ts +0 -21
  88. package/types/src/feature-utils.d.ts +0 -110
  89. package/types/src/filters/filter-utils.d.ts +0 -75
  90. package/types/src/filters/filterAsQuery.d.ts +0 -8
  91. package/types/src/filters/index.d.ts +0 -2
  92. package/types/src/form-utils.d.ts +0 -37
  93. package/types/src/formatting-utils.d.ts +0 -14
  94. package/types/src/getUniqueId.d.ts +0 -1
  95. package/types/src/group-utils.d.ts +0 -10
  96. package/types/src/html-utils.d.ts +0 -21
  97. package/types/src/index.d.ts +0 -76
  98. package/types/src/input-utils.d.ts +0 -2
  99. package/types/src/invariant.d.ts +0 -1
  100. package/types/src/itemToString.d.ts +0 -2
  101. package/types/src/json-types.d.ts +0 -52
  102. package/types/src/json-utils.d.ts +0 -6
  103. package/types/src/keyboard-utils.d.ts +0 -15
  104. package/types/src/keyset.d.ts +0 -16
  105. package/types/src/layout-types.d.ts +0 -22
  106. package/types/src/list-utils.d.ts +0 -2
  107. package/types/src/local-storage-utils.d.ts +0 -4
  108. package/types/src/logging-utils.d.ts +0 -45
  109. package/types/src/module-utils.d.ts +0 -8
  110. package/types/src/nanoid/index.d.ts +0 -1
  111. package/types/src/perf-utils.d.ts +0 -5
  112. package/types/src/promise-utils.d.ts +0 -8
  113. package/types/src/protocol-message-utils.d.ts +0 -43
  114. package/types/src/range-utils.d.ts +0 -29
  115. package/types/src/react-utils.d.ts +0 -15
  116. package/types/src/round-decimal.d.ts +0 -4
  117. package/types/src/row-utils.d.ts +0 -28
  118. package/types/src/selection-utils.d.ts +0 -9
  119. package/types/src/shell-layout-types.d.ts +0 -15
  120. package/types/src/sort-utils.d.ts +0 -11
  121. package/types/src/table-schema-utils.d.ts +0 -5
  122. package/types/src/text-utils.d.ts +0 -10
  123. package/types/src/theme-utils.d.ts +0 -14
  124. package/types/src/tree-types.d.ts +0 -9
  125. package/types/src/tree-utils.d.ts +0 -9
  126. package/types/src/ts-utils.d.ts +0 -20
  127. package/types/src/typeahead-utils.d.ts +0 -1
  128. package/types/src/url-utils.d.ts +0 -3
  129. package/types/src/useId.d.ts +0 -1
  130. package/types/src/useLayoutEffectSkipFirst.d.ts +0 -2
  131. package/types/src/useResizeObserver.d.ts +0 -15
  132. package/types/src/useStateRef.d.ts +0 -2
  133. package/types/src/user-types.d.ts +0 -3
@@ -1,8 +1,8 @@
1
1
  import type { DataSourceRow, DataValueDescriptor, DataValueType, DataValueTypeSimple, DateTimeDataValueDescriptor, SchemaColumn, TableSchema, TimeDataValueDescriptor } from "@vuu-ui/vuu-data-types";
2
2
  import type { VuuAggType, VuuAggregation, VuuColumnDataType, VuuDataRowDto, VuuGroupBy, VuuSort } from "@vuu-ui/vuu-protocol-types";
3
+ import { TableModel } from "@vuu-ui/vuu-table";
3
4
  import type { ColumnAlignment, ColumnDescriptor, ColumnLayout, ColumnTypeFormatting, ColumnTypeRendering, ColumnTypeWithValidationRules, DataRow, DataValueTypeDescriptor, DefaultColumnConfiguration, GroupColumnDescriptor, LookupRenderer, MappedValueTypeRenderer, PinLocation, RuntimeColumnDescriptor, TableCellRendererProps, TableConfig, TableHeadings, ValueListRenderer } from "@vuu-ui/vuu-table-types";
4
- import type { CSSProperties } from "react";
5
- import type { TableModel } from "@vuu-ui/vuu-table";
5
+ import { type CSSProperties } from "react";
6
6
  /**
7
7
  * ColumnMap provides a lookup of the index position of a data item within a row
8
8
  * by column name.
@@ -13,7 +13,6 @@ export interface ColumnMap {
13
13
  export interface ReverseColumnMap {
14
14
  [columnIndex: number]: string;
15
15
  }
16
- export declare const NO_HEADINGS: TableHeadings;
17
16
  export type SortCriteriaItem = string | [string, "asc"];
18
17
  export declare const AggregationType: {
19
18
  [key: string]: VuuAggType;
@@ -33,13 +32,48 @@ export type CalculatedColumn = {
33
32
  };
34
33
  export declare const isVuuColumnDataType: (value: string | undefined | null) => value is VuuColumnDataType;
35
34
  export declare const fromServerDataType: (serverDataType: VuuColumnDataType) => DataValueTypeSimple;
35
+ /**
36
+ * Returns true if serverDataType is epochtimestampnano. Note: prefer
37
+ * getTemporalInfo, which describes encoding, kind and time zone.
38
+ */
36
39
  export declare const isNanoTimestampColumn: ({ serverDataType, }: DataValueDescriptor) => boolean;
37
- export declare const isTimestampColumn: (column: ColumnDescriptor) => boolean;
38
- export declare const isNumericColumn: ({ serverDataType, type }: ColumnDescriptor) => boolean;
39
- export declare const isDateTimeDataType: (column: ColumnDescriptor) => column is DateTimeDataValueDescriptor;
40
- export declare const isTimeDataType: (column: ColumnDescriptor) => column is TimeDataValueDescriptor;
41
- export declare const isDateTimeDataValue: (column: ColumnDescriptor) => boolean;
42
- export declare const isTimeDataValue: (column?: ColumnDescriptor) => column is TimeDataValueDescriptor;
40
+ /**
41
+ * Returns true if serverDataType is epochtimestamp or epochtimestampnano.
42
+ * Note: this does not recognise legacy columns (long with a date/time type),
43
+ * use isTemporalColumn for that.
44
+ */
45
+ export declare const isTimestampColumn: (column: DataValueDescriptor) => boolean;
46
+ /**
47
+ * Returns true for any column holding a temporal value, see getTemporalInfo.
48
+ */
49
+ export declare const isTemporalColumn: (column?: DataValueDescriptor) => boolean;
50
+ /**
51
+ * Numeric columns, excluding those that hold temporal values.
52
+ */
53
+ export declare const isNumericColumn: (column: ColumnDescriptor) => boolean;
54
+ /**
55
+ * Checks the 'type' only, returns true for 'date/time' (or 'date').
56
+ * @deprecated use getTemporalInfo or isDateTimeDataValue
57
+ */
58
+ export declare const isDateTimeDataType: (column: DataValueDescriptor) => column is DateTimeDataValueDescriptor;
59
+ /**
60
+ * Checks the 'type' only, returns true for 'time'.
61
+ * @deprecated use getTemporalInfo or isTimeDataValue
62
+ */
63
+ export declare const isTimeDataType: (column: DataValueDescriptor) => column is TimeDataValueDescriptor;
64
+ /**
65
+ * Temporal value of kind 'datetime' or 'date' (i.e has a meaningful date component)
66
+ */
67
+ export declare const isDateTimeDataValue: (column?: DataValueDescriptor) => boolean;
68
+ /**
69
+ * Temporal value of kind 'time' (time of day)
70
+ */
71
+ export declare const isTimeDataValue: (column?: DataValueDescriptor) => column is TimeDataValueDescriptor;
72
+ /**
73
+ * A time column is edited/filtered with millisecond precision if its
74
+ * formatting pattern includes milliseconds.
75
+ */
76
+ export declare const isTimeDataValueWithMilliseconds: (column?: ColumnDescriptor) => column is TimeDataValueDescriptor;
43
77
  export declare const isPinned: (column: ColumnDescriptor) => boolean;
44
78
  export declare const hasHeadings: (column: ColumnDescriptor) => boolean;
45
79
  export declare const isResizing: (column: RuntimeColumnDescriptor) => boolean | undefined;
@@ -95,7 +129,7 @@ export declare const measurePinnedColumns: (columns: RuntimeColumnDescriptor[],
95
129
  pinnedWidthRight: number;
96
130
  unpinnedWidth: number;
97
131
  };
98
- export declare const getTableHeadings: (columns: RuntimeColumnDescriptor[], selectionBookendWidth?: number) => TableHeadings;
132
+ export declare const getTableHeadings: (columns: RuntimeColumnDescriptor[]) => TableHeadings;
99
133
  export declare const getColumnStyle: ({ pin, pinnedOffset, pinnedWidth, width, }: RuntimeColumnDescriptor) => CSSProperties;
100
134
  export declare const getAllCellsInColumn: (container: HTMLElement | null, colIndex: number) => HTMLDivElement[];
101
135
  export type PinState = {
@@ -171,39 +205,7 @@ export declare const setCalculatedColumnType: (column: ColumnDescriptor, serverD
171
205
  export declare const setCalculatedColumnExpression: (column: ColumnDescriptor, expression: string) => ColumnDescriptor;
172
206
  export declare const moveColumnTo: (columns: ColumnDescriptor[], column: ColumnDescriptor, newIndex: number) => ColumnDescriptor[];
173
207
  export declare function replaceColumn<C extends ColumnDescriptor = RuntimeColumnDescriptor>(columns: readonly C[], column: C): C[];
174
- export declare const applyDefaultColumnConfig: ({ columns: columnsProp, table }: TableSchema, getDefaultColumnConfig?: DefaultColumnConfiguration, includeVuuDefaultColumns?: boolean) => (SchemaColumn | {
175
- aggregate?: VuuAggType;
176
- align?: ColumnAlignment;
177
- allowColumnHeaderMenu?: false;
178
- className?: string;
179
- colHeaderContentRenderer?: string;
180
- colHeaderLabelRenderer?: string;
181
- exportFormatter?: (value: unknown) => string;
182
- flex?: number;
183
- getIcon?: (row: DataRow) => string | undefined;
184
- groupable?: boolean;
185
- heading?: string[];
186
- hidden?: boolean;
187
- isSystemColumn?: boolean;
188
- locked?: Exclude<PinLocation, "left"> | false;
189
- maxWidth?: number;
190
- minWidth?: number;
191
- pin?: PinLocation | false;
192
- removeable?: boolean;
193
- resizeable?: boolean;
194
- selected?: boolean;
195
- sortable?: boolean;
196
- source?: "client" | "server";
197
- status?: import("@salt-ds/core").ValidationStatus;
198
- width?: number;
199
- editableBulk?: import("@vuu-ui/vuu-data-types").BulkEdit;
200
- label?: string;
201
- required?: boolean;
202
- type?: DataValueType;
203
- editable?: import("@vuu-ui/vuu-data-types").DataEditable | undefined;
204
- name: string;
205
- serverDataType: VuuColumnDataType;
206
- })[] | readonly SchemaColumn[];
208
+ export declare const applyDefaultColumnConfig: ({ columns: columnsProp, table }: TableSchema, getDefaultColumnConfig?: DefaultColumnConfiguration, includeVuuDefaultColumns?: boolean) => readonly SchemaColumn[];
207
209
  export type columnOptions = {
208
210
  availableWidth?: number;
209
211
  columnLayout?: ColumnLayout;
@@ -3,5 +3,5 @@ import { DataContextProps } from "./DataContext";
3
3
  export declare const DataProvider: ({ children, getServerAPI, isLocalData, VuuDataSource, }: Omit<DataContextProps, "isLocalData"> & {
4
4
  children: ReactNode;
5
5
  isLocalData?: boolean;
6
- }) => import("react").JSX.Element;
6
+ }) => import("react/jsx-runtime").JSX.Element;
7
7
  export declare const useData: () => DataContextProps;
@@ -7,6 +7,6 @@ export declare const DataSourceContext: import("react").Context<DataSourceContex
7
7
  export declare const DataSourceProvider: ({ children, dataSource, }: {
8
8
  children: ReactNode;
9
9
  dataSource: DataSource;
10
- }) => import("react").JSX.Element;
10
+ }) => import("react/jsx-runtime").JSX.Element;
11
11
  export declare function useDataSource(throwIfNoDataSource: true): DataSource;
12
12
  export declare function useDataSource(throwIfNoDataSource: false | undefined): DataSource | undefined;
@@ -1,4 +1,4 @@
1
- import type { DataSource, DataSourceConstructorProps, DataSourceEvents, DataSourceFilter, DataSourceSubscribeCallback, DataSourceSubscribeProps, DataSourceSuspenseProps, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
1
+ import type { DataSource, DataSourceConstructorProps, DataSourceEvents, DataSourceFilter, DataSourceSubscribeCallback, DataSourceSubscribeProps, DataSourceSuspenseProps, SetFilterOptions, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
2
2
  import { LinkDescriptorWithLabel, VuuAggregation, VuuRange, VuuSort } from "@vuu-ui/vuu-protocol-types";
3
3
  import { EventEmitter } from "../event-emitter";
4
4
  import { Range } from "../range-utils";
@@ -28,7 +28,7 @@ export declare abstract class BaseDataSource extends EventEmitter<DataSourceEven
28
28
  set columns(columns: string[]);
29
29
  get filter(): DataSourceFilter;
30
30
  set filter(filter: DataSourceFilter);
31
- setFilter(filter: Filter): void;
31
+ setFilter(filter: Filter, options?: SetFilterOptions): void;
32
32
  clearFilter(): void;
33
33
  get isAwaitingConfirmationOfConfigChange(): boolean;
34
34
  protected confirmConfigChange(): void;
@@ -0,0 +1,66 @@
1
+ import { type DateTimeFields, type TimeZoneSpec } from "./time-zone";
2
+ /**
3
+ * How a temporal value is encoded on the wire (i.e in rows received from,
4
+ * and values sent to, the server).
5
+ * - epochMillis, a number (epochtimestamp, or legacy long with a date/time type)
6
+ * - epochNanos, a string of digits (epochtimestampnano). Nanosecond values
7
+ * cannot be represented safely as JavaScript numbers. A bigint is also
8
+ * accepted where values are generated locally.
9
+ */
10
+ export type TemporalEncoding = "epochMillis" | "epochNanos";
11
+ /**
12
+ * A timestamp with nanosecond precision. Internally represented as epoch
13
+ * millis (floored) plus nanos within the milli, so the common millisecond
14
+ * case requires no bigint arithmetic.
15
+ *
16
+ * Note: an empty value (null, undefined, '', 0, '0') is treated as 'no value'
17
+ * by fromWire. The Vuu server uses 0 to represent an unset timestamp, so
18
+ * the epoch itself (1970-01-01T00:00:00.000Z) cannot be represented.
19
+ */
20
+ export declare class EpochTimestamp {
21
+ readonly epochMillis: number;
22
+ /** nanoseconds within the millisecond, 0 - 999,999 */
23
+ readonly subMilliNanos: number;
24
+ private constructor();
25
+ static fromMillis(epochMillis: number, subMilliNanos?: number): EpochTimestamp;
26
+ static fromNanos(epochNanos: bigint | string | number): EpochTimestamp;
27
+ static fromDate(date: Date): EpochTimestamp;
28
+ static fromFields(fields: Partial<DateTimeFields> & Pick<DateTimeFields, "year" | "month" | "day">, timeZone?: TimeZoneSpec, subMilliNanos?: number): EpochTimestamp;
29
+ /**
30
+ * Returns true if value represents 'no value'.
31
+ */
32
+ static isEmpty(value: unknown): value is "" | "0" | 0 | 0n | null | undefined;
33
+ /**
34
+ * Decode a value as received from the server, or held in a filter,
35
+ * in the given encoding. Returns undefined for an empty or invalid value,
36
+ * including a value outside the range of a JavaScript Date (e.g. a nanos
37
+ * value decoded as millis).
38
+ */
39
+ static fromWire(value: unknown, encoding: TemporalEncoding): EpochTimestamp | undefined;
40
+ private static decode;
41
+ get epochNanos(): bigint;
42
+ toDate(): Date;
43
+ /**
44
+ * Fraction of second, truncated to the requested number of digits
45
+ */
46
+ fractionalSecond(digits: number): string;
47
+ getFields(timeZone?: TimeZoneSpec): DateTimeFields;
48
+ /**
49
+ * Encode for the wire. epochMillis => number, epochNanos => string
50
+ */
51
+ toWire(encoding: "epochMillis"): number;
52
+ toWire(encoding: "epochNanos"): string;
53
+ toWire(encoding: TemporalEncoding): number | string;
54
+ /**
55
+ * Encode as a literal in a filter query (never quoted)
56
+ */
57
+ toLiteral(encoding: TemporalEncoding): string;
58
+ /**
59
+ * Add a number of the smallest unit for the encoding, i.e 1 milli or 1 nano.
60
+ * Useful to convert inclusive to exclusive bounds.
61
+ */
62
+ addUnits(units: number, encoding: TemporalEncoding): EpochTimestamp;
63
+ compare(other: EpochTimestamp): number;
64
+ equals(other?: EpochTimestamp): boolean;
65
+ toString(): string;
66
+ }
@@ -5,35 +5,60 @@ export type zeroToFive = 0 | oneToFive;
5
5
  export type sixToNine = 6 | 7 | 8 | 9;
6
6
  export type zeroToNine = zeroToFive | sixToNine;
7
7
  export type oneToNine = oneToFive | sixToNine;
8
- export type TimeUnit = "hours" | "minutes" | "seconds";
8
+ export type TimeUnit = "hours" | "minutes" | "seconds" | "milliseconds";
9
9
  export type Hours = `${0 | 1}${zeroToNine}` | `2${0 | 1 | 2 | 3}`;
10
10
  export type Minutes = `${zeroToFive}${zeroToNine}`;
11
11
  export type Seconds = `${zeroToFive}${zeroToNine}`;
12
- export type TimeUnitValue<T extends TimeUnit> = T extends "hours" ? Hours : T extends "minutes" ? Minutes : Seconds;
12
+ export type Milliseconds = `${zeroToNine}${zeroToNine}${zeroToNine}`;
13
+ export type TimeUnitValue<T extends TimeUnit> = T extends "hours" ? Hours : T extends "minutes" ? Minutes : T extends "seconds" ? Seconds : Milliseconds;
13
14
  export type TimeString = `${number}${number}:${number}${number}:${number}${number}`;
15
+ /**
16
+ * A TimeString with millisecond precision, hh:mm:ss.SSS
17
+ */
18
+ export type TimeStringMillis = `${TimeString}.${number}${number}${number}`;
14
19
  type YYYY = `19${zeroToNine}${zeroToNine}` | `20${zeroToNine}${zeroToNine}`;
15
20
  type MM = `0${oneToNine}` | `1${0 | 1 | 2}`;
16
21
  type DD = `${0}${oneToNine}` | `${1 | 2}${zeroToNine}` | `3${0 | 1}`;
17
22
  export type DateStringISO = `${YYYY}-${MM}-${DD}`;
18
23
  export declare const zeroTime: TimeString;
24
+ export declare const zeroTimeMillis: TimeStringMillis;
19
25
  export declare const zeroTimeUnit: TimeUnitValue<TimeUnit>;
20
- export declare function incrementTimeUnitValue<T extends TimeUnit>(unit: T, value: TimeUnitValue<T>): TimeUnitValue<T> | Hours;
21
- export declare function decrementTimeUnitValue<T extends TimeUnit>(unit: T, value: TimeUnitValue<T>): TimeUnitValue<T> | Hours;
22
- export declare function updateTimeString<T extends TimeUnit>(timeString: TimeString, unit: T, value: TimeUnitValue<T>): TimeString;
26
+ export declare function incrementTimeUnitValue<T extends TimeUnit>(unit: T, value: TimeUnitValue<T>): TimeUnitValue<T>;
27
+ export declare function decrementTimeUnitValue<T extends TimeUnit>(unit: T, value: TimeUnitValue<T>): TimeUnitValue<T>;
28
+ export declare function updateTimeString<S extends TimeString | TimeStringMillis, T extends TimeUnit>(timeString: S, unit: T, value: TimeUnitValue<T>): S;
23
29
  export declare const isValidTimeString: (value: unknown) => value is TimeString;
30
+ export declare const isValidTimeStringMillis: (value: unknown) => value is TimeStringMillis;
31
+ /**
32
+ * Convert a valid TimeString or TimeStringMillis to the required precision.
33
+ * Milliseconds are added (as 000) or removed as necessary. Returns undefined
34
+ * if value is not a valid time.
35
+ */
36
+ export declare function normaliseTimeString(value: unknown, milliseconds: true): TimeStringMillis | undefined;
37
+ export declare function normaliseTimeString(value: unknown, milliseconds?: false): TimeString | undefined;
38
+ export declare function normaliseTimeString(value: unknown, milliseconds?: boolean): TimeString | TimeStringMillis | undefined;
24
39
  export declare function asTimeString(value: unknown, allowUndefined: false): TimeString;
25
40
  export declare function asTimeString(value: unknown, allowUndefined?: true): TimeString | undefined;
41
+ /**
42
+ * Millisecond precision equivalent of asTimeString. Accepts a TimeString,
43
+ * TimeStringMillis or a timestamp (millis since epoch, number or string).
44
+ */
45
+ export declare function asTimeStringMillis(value: unknown, allowUndefined: false): TimeStringMillis;
46
+ export declare function asTimeStringMillis(value: unknown, allowUndefined?: true): TimeStringMillis | undefined;
26
47
  export interface Time {
27
48
  hours: number;
28
49
  minutes: number;
29
50
  seconds: number;
51
+ milliseconds: number;
30
52
  asDate: (date?: Date | DateStringISO) => Date;
31
53
  }
32
- export declare function Time(timeString: TimeString): Time;
54
+ export declare function Time(timeString: TimeString | TimeStringMillis): Time;
33
55
  export declare namespace Time {
34
- export var millisToTimeString: (timestamp: number) => TimeString;
35
- var _a: (hours: number, minutes: number, seconds: number) => TimeString;
36
- export { _a as toString };
56
+ var millisToTimeString: (timestamp: number) => TimeString;
57
+ var millisToTimeStringMillis: (timestamp: number) => TimeStringMillis;
58
+ export { timeToString as toString };
37
59
  export var isDateInMillis: (dtInMillis: string | number) => boolean;
38
60
  }
61
+ declare function timeToString(hours: number, minutes: number, seconds: number): TimeString;
62
+ declare function timeToString(hours: number, minutes: number, seconds: number, milliseconds: number): TimeStringMillis;
63
+ declare function timeToString(hours: number, minutes: number, seconds: number, milliseconds?: number): TimeString | TimeStringMillis;
39
64
  export {};
@@ -1,8 +1,26 @@
1
- import { DateTimeDataValueDescriptor } from "@vuu-ui/vuu-data-types";
1
+ import type { DataValueDescriptor, DataValueType, DateTimeDataValueDescriptor } from "@vuu-ui/vuu-data-types";
2
+ import { type TemporalKind } from "./temporal";
2
3
  import { DateTimePattern } from "./types";
3
4
  export declare const defaultPatternsByType: {
4
5
  readonly time: "hh:mm:ss";
5
6
  readonly date: "dd.mm.yyyy";
6
7
  };
7
8
  export declare const fallbackDateTimePattern: DateTimePattern;
8
- export declare function dateTimePattern(type: DateTimeDataValueDescriptor["type"]): DateTimePattern;
9
+ export declare const defaultDateTimePatternByKind: Record<TemporalKind, DateTimePattern>;
10
+ /**
11
+ * Returns the DateTimePattern configured on the type (formatting.pattern), if
12
+ * there is one. Otherwise, the default pattern for the temporal kind. If kind
13
+ * is not provided, it is inferred from type name.
14
+ */
15
+ export declare function dateTimePattern(type?: DataValueType | DateTimeDataValueDescriptor["type"], kind?: TemporalKind | undefined): DateTimePattern;
16
+ /**
17
+ * Returns a copy of a temporal descriptor, with its type replaced so that the
18
+ * value is displayed (or edited) using the given pattern. The type name follows
19
+ * the pattern: 'date/time' if both date and time are specified, else 'date' or
20
+ * 'time'. Other formatting (e.g. timeZone, locale) is preserved. The descriptor
21
+ * is returned unchanged if no pattern is provided or the descriptor is not
22
+ * temporal.
23
+ * Use this to present a column differently in different contexts, e.g. a
24
+ * ColumnFilter using a different pattern to the Table.
25
+ */
26
+ export declare const withDateTimePattern: <T extends DataValueDescriptor>(descriptor: T, pattern?: DateTimePattern) => T;
@@ -1,9 +1,34 @@
1
1
  import { DateFormatter } from "@internationalized/date";
2
+ import type { FractionalSecondDigits } from "@vuu-ui/vuu-table-types";
3
+ import { EpochTimestamp } from "./EpochTimestamp";
4
+ import { type TimeZoneSpec } from "./time-zone";
2
5
  import { DateTimePattern } from "./types";
3
6
  type DateTimeFormatConfig = {
4
7
  locale: string;
5
8
  options: Intl.DateTimeFormatOptions;
6
9
  };
10
+ export interface DateTimeFormatOptions {
11
+ /**
12
+ * Number of sub-second digits to display, when pattern includes time. If
13
+ * not specified, 3 is used for the 'hh:mm:ss.ms' pattern, otherwise 0.
14
+ */
15
+ fractionalSecondDigits?: FractionalSecondDigits;
16
+ /**
17
+ * Override the locale implied by the pattern. Pattern then determines the
18
+ * style of each field, locale determines order and language.
19
+ */
20
+ locale?: string;
21
+ timeZone?: TimeZoneSpec;
22
+ }
23
+ type TimestampFormatter = (ts: EpochTimestamp) => string;
24
+ /**
25
+ * Create a formatter for EpochTimestamp values. This is the most general
26
+ * formatter, it supports nanosecond precision.
27
+ */
28
+ export declare function formatTimestamp({ date, time }: DateTimePattern, { fractionalSecondDigits, locale, timeZone, }?: DateTimeFormatOptions): TimestampFormatter;
29
+ /**
30
+ * Create a formatter for Date values.
31
+ */
32
+ export declare function formatDate(pattern: DateTimePattern, options?: DateTimeFormatOptions): (d: Date) => string;
7
33
  export declare function getDateFormatter({ locale, options }: DateTimeFormatConfig): DateFormatter;
8
- export declare function formatDate(pattern: DateTimePattern): (d: Date) => string;
9
34
  export {};
@@ -1,4 +1,8 @@
1
- export { asTimeString, decrementTimeUnitValue, incrementTimeUnitValue, isValidTimeString, Time, toCalendarDate, type DateStringISO, type Hours, type Minutes, type Seconds, type TimeString, type TimeUnit, type TimeUnitValue, updateTimeString, zeroTime, zeroTimeUnit, } from "./date-utils";
2
- export { dateTimePattern, defaultPatternsByType, fallbackDateTimePattern, } from "./dateTimePattern";
1
+ export { asTimeString, asTimeStringMillis, decrementTimeUnitValue, incrementTimeUnitValue, isValidTimeString, isValidTimeStringMillis, normaliseTimeString, Time, toCalendarDate, type DateStringISO, type Hours, type Milliseconds, type Minutes, type Seconds, type TimeString, type TimeStringMillis, type TimeUnit, type TimeUnitValue, updateTimeString, zeroTime, zeroTimeMillis, zeroTimeUnit, } from "./date-utils";
2
+ export { dateTimePattern, defaultPatternsByType, fallbackDateTimePattern, withDateTimePattern, } from "./dateTimePattern";
3
3
  export * from "./formatter";
4
4
  export { dateTimeLabelByType, isDatePattern, isTimePattern, supportedDateTimePatterns, type DatePattern, type DateTimePattern, type TimePattern, } from "./types";
5
+ export { defaultDateTimePatternByKind } from "./dateTimePattern";
6
+ export { EpochTimestamp, type TemporalEncoding } from "./EpochTimestamp";
7
+ export * from "./temporal";
8
+ export * from "./time-zone";
@@ -0,0 +1,68 @@
1
+ import type { DataValueDescriptor, TemporalDataValueTypeSimple } from "@vuu-ui/vuu-data-types";
2
+ import type { FractionalSecondDigits } from "@vuu-ui/vuu-table-types";
3
+ import { EpochTimestamp, type TemporalEncoding } from "./EpochTimestamp";
4
+ import { type TimeZoneSpec } from "./time-zone";
5
+ /**
6
+ * What a temporal value represents, from the user's perspective
7
+ * - datetime: a point in time, date and time of day are both meaningful
8
+ * - date: a calendar date, time of day is not meaningful
9
+ * - time: a time of day, the date is not meaningful (typically 'today')
10
+ */
11
+ export type TemporalKind = "datetime" | "date" | "time";
12
+ /**
13
+ * The finest resolution that the encoding can represent.
14
+ */
15
+ export type TemporalPrecision = "ms" | "ns";
16
+ export interface TemporalInfo {
17
+ kind: TemporalKind;
18
+ encoding: TemporalEncoding;
19
+ precision: TemporalPrecision;
20
+ timeZone: TimeZoneSpec;
21
+ }
22
+ export declare const isTemporalTypeName: (typeName?: string) => typeName is TemporalDataValueTypeSimple;
23
+ type TemporalDescriptor = Pick<DataValueDescriptor, "serverDataType" | "type">;
24
+ /**
25
+ * The single source of truth for whether (and how) a column or form field
26
+ * holds a temporal value. Rules:
27
+ *
28
+ * - encoding is determined by serverDataType
29
+ * - epochtimestamp => epochMillis
30
+ * - epochtimestampnano => epochNanos
31
+ * - long, int, double (or unspecified) => epochMillis, but only when the
32
+ * 'type' is a temporal type. This legacy usage (pre epochtimestamp) is
33
+ * DEPRECATED and supported only for backward compatibility. Timestamps
34
+ * should be described by the server as epochtimestamp or epochtimestampnano.
35
+ * - kind is determined by 'type' ('date/time', 'date', 'time'), default 'datetime'.
36
+ * An explicit type of 'number' opts an epochtimestamp column out of temporal
37
+ * treatment altogether.
38
+ * - timeZone from type.formatting.timeZone, falling back to the default time zone
39
+ *
40
+ * @returns TemporalInfo or undefined if value is not temporal
41
+ */
42
+ export declare const getTemporalInfo: (descriptor?: TemporalDescriptor) => TemporalInfo | undefined;
43
+ export declare const isTemporal: (descriptor?: TemporalDescriptor) => boolean;
44
+ export declare const defaultFractionalSecondDigits: (info: Pick<TemporalInfo, "precision">) => FractionalSecondDigits;
45
+ /**
46
+ * Format a timestamp as a canonical, locale independent, editable string:
47
+ * - date: yyyy-mm-dd
48
+ * - datetime: yyyy-mm-dd hh:mm:ss[.fffffffff]
49
+ * - time: hh:mm:ss[.fffffffff]
50
+ * Sub-second digits are included only when non zero, up to the precision of
51
+ * the encoding, so they round-trip unchanged through an edit.
52
+ */
53
+ export declare const formatTemporalInput: (value: EpochTimestamp | undefined, { kind, precision, timeZone }: Omit<TemporalInfo, "encoding">) => string;
54
+ /**
55
+ * Parse user input. Accepts the canonical formats produced by
56
+ * formatTemporalInput as well as raw epoch values (in the encoding of the
57
+ * column). Where the input does not include a component (e.g the date for a
58
+ * 'time' value), it is taken from baseValue if provided, otherwise today
59
+ * (date) or midnight (time).
60
+ *
61
+ * @returns EpochTimestamp, or undefined if input is not valid
62
+ */
63
+ export declare const parseTemporalInput: (input: string, { kind, encoding, precision, timeZone }: TemporalInfo, baseValue?: EpochTimestamp) => EpochTimestamp | undefined;
64
+ /**
65
+ * Placeholder text describing the canonical input format for a kind.
66
+ */
67
+ export declare const temporalInputPlaceholder: (kind: TemporalKind) => "hh:mm:ss" | "yyyy-mm-dd" | "yyyy-mm-dd hh:mm:ss";
68
+ export {};
@@ -0,0 +1,52 @@
1
+ import { CalendarDate } from "@internationalized/date";
2
+ import type { DateStringISO, TimeString } from "./date-utils";
3
+ /**
4
+ * 'local' (browser time zone), 'UTC' or any IANA time zone identifier.
5
+ */
6
+ export type TimeZoneSpec = "local" | "UTC" | (string & {});
7
+ /**
8
+ * Set the time zone used for temporal values where a column does not
9
+ * specify one explicitly (formatting.timeZone). Default is 'local'.
10
+ */
11
+ export declare const setDefaultTimeZone: (timeZone: TimeZoneSpec) => void;
12
+ export declare const getDefaultTimeZone: () => TimeZoneSpec;
13
+ /**
14
+ * Resolve a TimeZoneSpec to an IANA time zone identifier.
15
+ */
16
+ export declare const resolveTimeZone: (timeZone?: TimeZoneSpec) => string;
17
+ export interface DateTimeFields {
18
+ year: number;
19
+ month: number;
20
+ day: number;
21
+ hour: number;
22
+ minute: number;
23
+ second: number;
24
+ millisecond: number;
25
+ }
26
+ export declare const getDateTimeFields: (epochMillis: number, timeZone?: TimeZoneSpec) => DateTimeFields;
27
+ /**
28
+ * Convert wall clock fields in the given time zone to epoch millis. Where the
29
+ * wall clock time is ambiguous or does not exist (DST transitions), the
30
+ * 'compatible' disambiguation strategy is used (same as Temporal / JS Date).
31
+ */
32
+ export declare const fromDateTimeFields: ({ year, month, day, hour, minute, second, millisecond, }: Partial<DateTimeFields> & Pick<DateTimeFields, "year" | "month" | "day">, timeZone?: TimeZoneSpec) => number;
33
+ /**
34
+ * Epoch millis of the start of the calendar day (in timeZone) that contains epochMillis.
35
+ */
36
+ export declare const startOfDay: (epochMillis: number, timeZone?: TimeZoneSpec) => number;
37
+ /**
38
+ * Epoch millis of the start of the calendar day (in timeZone) following the day that
39
+ * contains epochMillis. This is DST safe, the day may be 23, 24 or 25 hours long.
40
+ */
41
+ export declare const startOfNextDay: (epochMillis: number, timeZone?: TimeZoneSpec) => number;
42
+ export declare const isStartOfDay: (epochMillis: number, timeZone?: TimeZoneSpec) => boolean;
43
+ /**
44
+ * A date to which a time of day can be applied. 'today' and 'yesterday' are
45
+ * resolved at the point of use, so filters that use them remain relative.
46
+ */
47
+ export type RelativeDate = "today" | "yesterday" | DateStringISO;
48
+ export declare const resolveRelativeDate: (date?: RelativeDate | Date, timeZone?: TimeZoneSpec) => CalendarDate;
49
+ /**
50
+ * Epoch millis of the given time of day on the given date, in timeZone.
51
+ */
52
+ export declare const timeOfDayToEpochMillis: (timeString: TimeString | `${TimeString}.${string}`, date?: RelativeDate | Date, timeZone?: TimeZoneSpec) => number;
@@ -1,9 +1,9 @@
1
- import type { RemoteModuleConnection, TableSchema } from "@vuu-ui/vuu-data-types";
1
+ import type { TableSchema } from "@vuu-ui/vuu-data-types";
2
2
  import type { VuuTable } from "@vuu-ui/vuu-protocol-types";
3
3
  import type { ListOption } from "@vuu-ui/vuu-table-types";
4
- import { type ReactElement } from "react";
4
+ import React, { type ReactElement } from "react";
5
5
  export type PathMap = {
6
- [key: string]: string;
6
+ [key: string]: Pick<DynamicFeatureDescriptor, "css" | "url">;
7
7
  };
8
8
  export type Environment = "development" | "production";
9
9
  export declare const env: Environment;
@@ -21,41 +21,46 @@ export interface DynamicFeatureProps<P extends object | undefined = object> {
21
21
  ViewProps?: ViewConfig;
22
22
  css?: string;
23
23
  height?: number;
24
- mfComponent: string;
25
- mfScope: string;
26
- mfUrl: string;
27
- vuu?: RemoteModuleConnection;
28
24
  title?: string;
25
+ /**
26
+ The url of javascript bundle to lazily load. Bundle must provide a default export
27
+ and that export must be a React component.
28
+ */
29
+ url: string;
29
30
  width?: number;
30
31
  }
32
+ export type FeatureModule = {
33
+ default: React.ComponentType<object>;
34
+ };
35
+ export type FeatureImporter = (url: string) => Promise<FeatureModule>;
36
+ declare const importFeatureByUrl: FeatureImporter;
37
+ /**
38
+ * By default, a dynamic feature is loaded from its url with a native
39
+ * dynamic import. An application that bundles its features can install
40
+ * an importer that resolves feature urls to bundled modules. Use
41
+ * `importFeatureByUrl` as a fallback for unknown urls.
42
+ */
43
+ export declare const setFeatureImporter: (importer: FeatureImporter) => void;
44
+ export declare const importFeature: (url: string) => Promise<FeatureModule>;
45
+ export { importFeatureByUrl };
31
46
  declare global {
32
47
  const vuuConfig: Promise<VuuConfig>;
33
48
  }
34
49
  export interface DynamicFeatureDescriptor {
35
- description: string;
50
+ /**
51
+ * url for css file for feature
52
+ */
53
+ css?: string;
36
54
  featureProps?: {
37
55
  vuuTables?: "*" | VuuTable[];
38
56
  };
39
- id: string;
40
- leftNavLocation?: "vuu-features" | "vuu-tables";
41
- location: string;
57
+ leftNavLocation: "vuu-features" | "vuu-tables";
42
58
  name: string;
59
+ title: string;
43
60
  /**
44
- * Module federation - the name of remote component to be imported
45
- */
46
- mfComponent: string;
47
- /**
48
- * Module federation - the identifier of remote module
49
- */
50
- mfScope: string;
51
- /**
52
- * Module federation - the url of remote module manifest
61
+ * url for javascript bundle to load feature
53
62
  */
54
- mfUrl: string;
55
- path: string;
56
- title: string;
57
- vuu?: RemoteModuleConnection;
58
- version: number;
63
+ url: string;
59
64
  viewProps?: ViewConfig;
60
65
  }
61
66
  export interface StaticFeatureDescriptor {
@@ -74,11 +79,10 @@ export declare function featureFromJson({ type }: {
74
79
  type: string;
75
80
  }): ReactElement;
76
81
  export interface VuuConfig {
77
- authUrl: string;
78
- moduleRegistryUrl: string;
79
- restUrl: string;
80
- ssl: boolean;
82
+ features: DynamicFeatures;
83
+ authUrl?: string;
81
84
  websocketUrl: string;
85
+ ssl: boolean;
82
86
  }
83
87
  /**
84
88
  * We currently categorize 'features' simply by the leftNavLocation
@@ -92,7 +96,7 @@ export interface FeaturePropsWithFilterTableFeature extends Omit<DynamicFeatureP
92
96
  ComponentProps: FilterTableFeatureProps;
93
97
  }
94
98
  export declare const hasFilterTableFeatureProps: (props: DynamicFeatureProps) => props is FeaturePropsWithFilterTableFeature;
95
- export declare const isSameTable: (t1: VuuTable, t2: VuuTable) => boolean;
99
+ export declare const isSameTable: (t1: VuuTable, t2: VuuTable) => void;
96
100
  export declare const byModule: (schema1: TableSchema, schema2: TableSchema) => -1 | 0 | 1;
97
101
  export type GetFeaturePaths = (params: {
98
102
  env: Environment;
@@ -26,7 +26,8 @@ export declare const stripFilterFromColumns: (columns: RuntimeColumnDescriptor[]
26
26
  allowColumnHeaderMenu?: false;
27
27
  colHeaderContentRenderer?: string;
28
28
  colHeaderLabelRenderer?: string;
29
- exportFormatter?: (value: unknown) => string;
29
+ exportable?: boolean;
30
+ exportFormatter?: (value: unknown, row: import("@vuu-ui/vuu-table-types").RowAccessor) => string;
30
31
  getIcon?: (row: import("@vuu-ui/vuu-table-types").DataRow) => string | undefined;
31
32
  groupable?: boolean;
32
33
  hidden?: boolean;
@@ -71,5 +72,9 @@ export declare const stripFilterFromColumns: (columns: RuntimeColumnDescriptor[]
71
72
  type?: import("@vuu-ui/vuu-data-types").DataValueType;
72
73
  }[];
73
74
  export declare const extractFilterForColumn: (filter: Filter | undefined, columnName: string) => Filter | undefined;
75
+ /**
76
+ * The full-day range used as default value of a time range filter.
77
+ */
78
+ export declare const getDefaultTimeRange: (column: ColumnDescriptor) => [string, string];
74
79
  export declare const getColumnValueFromFilter: (column: ColumnDescriptor, operator: ColumnFilterOp, filter?: FilterContainerFilter) => ColumnFilterValue;
75
80
  export declare const filtersAreEqual: (f1: FilterContainerFilter | null | undefined, f2: FilterContainerFilter | null | undefined) => boolean;