@vuu-ui/vuu-utils 3.4.1 → 3.5.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 (107) hide show
  1. package/package.json +6 -6
  2. package/src/column-utils.js +21 -6
  3. package/src/component-registry.js +2 -1
  4. package/src/data-utils.js +1 -0
  5. package/src/datasource/BaseDataSource.js +5 -3
  6. package/src/date/EpochTimestamp.js +80 -0
  7. package/src/date/date-utils.js +50 -18
  8. package/src/date/dateTimePattern.js +17 -5
  9. package/src/date/formatter.js +54 -16
  10. package/src/date/index.js +5 -2
  11. package/src/date/temporal.js +131 -0
  12. package/src/date/time-zone.js +56 -0
  13. package/src/filters/filter-utils.js +12 -6
  14. package/src/filters/filterAsQuery.js +103 -45
  15. package/src/form-utils.js +38 -4
  16. package/src/formatting-utils.js +40 -25
  17. package/src/nanoid/index.js +3 -3
  18. package/types/column-utils.d.ts +41 -6
  19. package/types/datasource/BaseDataSource.d.ts +2 -2
  20. package/types/date/EpochTimestamp.d.ts +63 -0
  21. package/types/date/date-utils.d.ts +33 -7
  22. package/types/date/dateTimePattern.d.ts +9 -2
  23. package/types/date/formatter.d.ts +26 -1
  24. package/types/date/index.d.ts +5 -1
  25. package/types/date/temporal.d.ts +68 -0
  26. package/types/date/time-zone.d.ts +52 -0
  27. package/types/filters/filter-utils.d.ts +4 -0
  28. package/types/filters/filterAsQuery.d.ts +38 -0
  29. package/types/form-utils.d.ts +19 -0
  30. package/types/formatting-utils.d.ts +15 -0
  31. package/types/src/Clock.d.ts +0 -20
  32. package/types/src/PageVisibilityObserver.d.ts +0 -36
  33. package/types/src/ScaledDecimal.d.ts +0 -12
  34. package/types/src/ShellContext.d.ts +0 -11
  35. package/types/src/ThemeProvider.d.ts +0 -32
  36. package/types/src/array-utils.d.ts +0 -16
  37. package/types/src/box-utils.d.ts +0 -24
  38. package/types/src/broadcast-channel.d.ts +0 -16
  39. package/types/src/column-utils.d.ts +0 -243
  40. package/types/src/common-types.d.ts +0 -6
  41. package/types/src/component-registry.d.ts +0 -65
  42. package/types/src/context-definitions/DataContext.d.ts +0 -21
  43. package/types/src/context-definitions/DataProvider.d.ts +0 -7
  44. package/types/src/context-definitions/DataSourceProvider.d.ts +0 -12
  45. package/types/src/context-definitions/WorkspaceContext.d.ts +0 -17
  46. package/types/src/cookie-utils.d.ts +0 -9
  47. package/types/src/css-utils.d.ts +0 -1
  48. package/types/src/data-utils.d.ts +0 -33
  49. package/types/src/datasource/BaseDataSource.d.ts +0 -63
  50. package/types/src/datasource/datasource-action-utils.d.ts +0 -7
  51. package/types/src/datasource/datasource-filter-utils.d.ts +0 -2
  52. package/types/src/datasource/datasource-utils.d.ts +0 -61
  53. package/types/src/date/date-utils.d.ts +0 -39
  54. package/types/src/date/dateTimePattern.d.ts +0 -8
  55. package/types/src/date/formatter.d.ts +0 -9
  56. package/types/src/date/index.d.ts +0 -4
  57. package/types/src/date/types.d.ts +0 -29
  58. package/types/src/debug-utils.d.ts +0 -9
  59. package/types/src/edit-utils.d.ts +0 -2
  60. package/types/src/errors.d.ts +0 -2
  61. package/types/src/event-emitter.d.ts +0 -21
  62. package/types/src/feature-utils.d.ts +0 -110
  63. package/types/src/filters/filter-utils.d.ts +0 -75
  64. package/types/src/filters/filterAsQuery.d.ts +0 -8
  65. package/types/src/filters/index.d.ts +0 -2
  66. package/types/src/form-utils.d.ts +0 -37
  67. package/types/src/formatting-utils.d.ts +0 -14
  68. package/types/src/getUniqueId.d.ts +0 -1
  69. package/types/src/group-utils.d.ts +0 -10
  70. package/types/src/html-utils.d.ts +0 -21
  71. package/types/src/index.d.ts +0 -76
  72. package/types/src/input-utils.d.ts +0 -2
  73. package/types/src/invariant.d.ts +0 -1
  74. package/types/src/itemToString.d.ts +0 -2
  75. package/types/src/json-types.d.ts +0 -52
  76. package/types/src/json-utils.d.ts +0 -6
  77. package/types/src/keyboard-utils.d.ts +0 -15
  78. package/types/src/keyset.d.ts +0 -16
  79. package/types/src/layout-types.d.ts +0 -22
  80. package/types/src/list-utils.d.ts +0 -2
  81. package/types/src/local-storage-utils.d.ts +0 -4
  82. package/types/src/logging-utils.d.ts +0 -45
  83. package/types/src/module-utils.d.ts +0 -8
  84. package/types/src/nanoid/index.d.ts +0 -1
  85. package/types/src/perf-utils.d.ts +0 -5
  86. package/types/src/promise-utils.d.ts +0 -8
  87. package/types/src/protocol-message-utils.d.ts +0 -43
  88. package/types/src/range-utils.d.ts +0 -29
  89. package/types/src/react-utils.d.ts +0 -15
  90. package/types/src/round-decimal.d.ts +0 -4
  91. package/types/src/row-utils.d.ts +0 -28
  92. package/types/src/selection-utils.d.ts +0 -9
  93. package/types/src/shell-layout-types.d.ts +0 -15
  94. package/types/src/sort-utils.d.ts +0 -11
  95. package/types/src/table-schema-utils.d.ts +0 -5
  96. package/types/src/text-utils.d.ts +0 -10
  97. package/types/src/theme-utils.d.ts +0 -14
  98. package/types/src/tree-types.d.ts +0 -9
  99. package/types/src/tree-utils.d.ts +0 -9
  100. package/types/src/ts-utils.d.ts +0 -20
  101. package/types/src/typeahead-utils.d.ts +0 -1
  102. package/types/src/url-utils.d.ts +0 -3
  103. package/types/src/useId.d.ts +0 -1
  104. package/types/src/useLayoutEffectSkipFirst.d.ts +0 -2
  105. package/types/src/useResizeObserver.d.ts +0 -15
  106. package/types/src/useStateRef.d.ts +0 -2
  107. package/types/src/user-types.d.ts +0 -3
@@ -5,34 +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>): Hours | TimeUnitValue<T>;
21
- export declare function decrementTimeUnitValue<T extends TimeUnit>(unit: T, value: TimeUnitValue<T>): Hours | TimeUnitValue<T>;
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
54
  export declare const Time: {
33
- (timeString: TimeString): Time;
55
+ (timeString: TimeString | TimeStringMillis): Time;
34
56
  millisToTimeString(timestamp: number): TimeString;
35
- toString(hours: number, minutes: number, seconds: number): TimeString;
57
+ millisToTimeStringMillis(timestamp: number): TimeStringMillis;
58
+ toString: typeof timeToString;
36
59
  isDateInMillis(dtInMillis: string | number): boolean;
37
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;
38
64
  export {};
@@ -1,8 +1,15 @@
1
- import { DateTimeDataValueDescriptor } from "@vuu-ui/vuu-data-types";
1
+ import type { 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;
@@ -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";
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
2
  export { dateTimePattern, defaultPatternsByType, fallbackDateTimePattern, } 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;
@@ -72,5 +72,9 @@ export declare const stripFilterFromColumns: (columns: RuntimeColumnDescriptor[]
72
72
  type?: import("@vuu-ui/vuu-data-types").DataValueType;
73
73
  }[];
74
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];
75
79
  export declare const getColumnValueFromFilter: (column: ColumnDescriptor, operator: ColumnFilterOp, filter?: FilterContainerFilter) => ColumnFilterValue;
76
80
  export declare const filtersAreEqual: (f1: FilterContainerFilter | null | undefined, f2: FilterContainerFilter | null | undefined) => boolean;
@@ -1,8 +1,46 @@
1
+ import type { TableSchema } from "@vuu-ui/vuu-data-types";
2
+ import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
1
3
  import type { ColumnDescriptorsByName, Filter, SingleValueFilterClause } from "@vuu-ui/vuu-filter-types";
4
+ import { type TemporalInfo } from "../date/temporal";
5
+ import { type RelativeDate } from "../date/time-zone";
2
6
  export declare const filterAsQuery: (f: Filter, opts?: {
3
7
  columnsByName?: ColumnDescriptorsByName;
4
8
  }) => string;
5
9
  export declare const ONE_DAY_IN_MILLIS: number;
10
+ export interface TemporalFilterAsQueryOptions {
11
+ /**
12
+ * The date against which time of day (TimeString) values are resolved.
13
+ * Default is 'today', resolved at the time the query is created.
14
+ */
15
+ date?: RelativeDate;
16
+ }
17
+ /**
18
+ * Serialize a filter clause on a temporal column. Values are interpreted at
19
+ * the granularity implied by the value and the column 'kind':
20
+ * - day: column kind is 'date', or a 'datetime' value at the exact start of a
21
+ * day (in the column time zone), e.g as selected from a DatePicker. The clause
22
+ * applies to the whole day: '=' becomes a [startOfDay, startOfNextDay) range,
23
+ * '>' becomes '>= startOfNextDay' etc. Day boundaries are DST safe.
24
+ * - second: time of day values (TimeString or whole second 'time' values)
25
+ * - exact: all other values
26
+ * Values are encoded according to the column encoding (millis or nanos).
27
+ */
28
+ export declare function temporalFilterAsQuery(f: SingleValueFilterClause, temporalInfo: TemporalInfo, options?: TemporalFilterAsQueryOptions): string;
29
+ /**
30
+ * @deprecated use temporalFilterAsQuery
31
+ */
6
32
  export declare function dateFilterAsQuery(f: SingleValueFilterClause<number>, opts?: {
7
33
  columnsByName?: ColumnDescriptorsByName;
8
34
  }): string;
35
+ export declare const getColumnsByName: (columns: readonly ColumnDescriptor[]) => ColumnDescriptorsByName;
36
+ /**
37
+ * Build the columnsByName used to serialize a filter. Column descriptors
38
+ * provided by client take precedence over (are merged with) the schema columns.
39
+ */
40
+ export declare const getColumnsByNameForFilter: (tableSchema?: Pick<TableSchema, "columns">, columnsByName?: ColumnDescriptorsByName) => ColumnDescriptorsByName | undefined;
41
+ /**
42
+ * Returns true if the filter includes clauses whose meaning depends on the
43
+ * column type (temporal columns) or which serialize themselves. Such filters
44
+ * must be resolved (see resolveFilterQuery) before they can be evaluated locally.
45
+ */
46
+ export declare const filterRequiresResolution: (filter: Filter, columnsByName?: ColumnDescriptorsByName) => boolean;
@@ -1,7 +1,11 @@
1
1
  import { DataValueTypeSimple } from "@vuu-ui/vuu-data-types";
2
2
  import { VuuColumnDataType, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
3
  import { KeyboardEvent, SyntheticEvent } from "react";
4
+ import { EpochTimestamp } from "./date/EpochTimestamp";
5
+ import { type TemporalInfo } from "./date/temporal";
6
+ import type { DataValueDescriptor } from "@vuu-ui/vuu-data-types";
4
7
  import { ExtendedFilterOptions } from "@vuu-ui/vuu-filter-types";
8
+ import { type ScaledDecimal } from "./ScaledDecimal";
5
9
  export declare class DataValidationError extends Error {
6
10
  actualType: string;
7
11
  expectedType: string;
@@ -35,3 +39,18 @@ export declare function getTypedRange([value1, value2]: [string, string], dataTy
35
39
  */
36
40
  export declare function getTypedValue(value: string, type: VuuColumnDataType | DataValueTypeSimple, throwIfInvalid?: false, options?: ExtendedFilterOptions): VuuRowDataItemType | undefined;
37
41
  export declare function getTypedValue(value: string, type: VuuColumnDataType | DataValueTypeSimple, throwIfInvalid: true, options?: ExtendedFilterOptions): VuuRowDataItemType;
42
+ /**
43
+ * Convert a string value (from user input or a filter control) to the wire
44
+ * representation of a temporal value, using the column's TemporalInfo.
45
+ * - time kind: a TimeString is applied to today's date (in the column time zone)
46
+ * - any kind: canonical input (see parseTemporalInput) or raw epoch digits
47
+ * Values are returned in the column encoding (number for epochMillis, string
48
+ * for epochNanos).
49
+ */
50
+ export declare function getTypedTemporalValue(value: string, temporalInfo: TemporalInfo, throwIfInvalid?: boolean, baseValue?: EpochTimestamp): number | string | undefined;
51
+ /**
52
+ * Like getTypedValue, but takes a column (or form field) descriptor. Temporal
53
+ * values are handled according to getTemporalInfo, other values according to
54
+ * the type name, if there is one, otherwise the serverDataType.
55
+ */
56
+ export declare function getTypedValueForDescriptor(value: string, descriptor: DataValueDescriptor, throwIfInvalid?: boolean): VuuRowDataItemType | ScaledDecimal | bigint | undefined;
@@ -1,8 +1,23 @@
1
+ import { DataValueDescriptor } from "@vuu-ui/vuu-data-types";
1
2
  import { ColumnDescriptor, ValueFormatter } from "@vuu-ui/vuu-table-types";
2
3
  export type ValueFormatters = {
3
4
  [key: string]: ValueFormatter;
4
5
  };
5
6
  export declare const defaultValueFormatter: (value: unknown) => string;
7
+ /**
8
+ * Creates a formatter for a temporal value (see getTemporalInfo). Handles
9
+ * millisecond and nanosecond encodings, the configured (or default) pattern,
10
+ * time zone, locale and fractional second digits.
11
+ * Empty values (null, undefined, '', 0) are rendered as empty string.
12
+ */
13
+ export declare const temporalFormatter: (column: DataValueDescriptor, temporalInfo?: import("./date/temporal").TemporalInfo | undefined) => ValueFormatter;
14
+ /**
15
+ * Format a filter value on a temporal column for display (e.g. in a FilterPill
16
+ * tooltip or a list of filter clauses). Time of day (TimeString) values are
17
+ * displayed as is. A 'datetime' value at the start of a day (which the filter
18
+ * applies to the whole day, see temporalFilterAsQuery) is displayed as a date.
19
+ */
20
+ export declare const formatTemporalFilterValue: (value: unknown, column: DataValueDescriptor) => string;
6
21
  export declare const numericFormatter: ({ align, serverDataType, type, }: Partial<ColumnDescriptor>) => (value: unknown) => string;
7
22
  export declare const getValueFormatter: (column: ColumnDescriptor) => ValueFormatter;
8
23
  /**
@@ -1,20 +0,0 @@
1
- export interface ClockProps {
2
- year?: number;
3
- month?: number;
4
- day?: number;
5
- hours?: number;
6
- minutes?: number;
7
- seconds?: number;
8
- milliseconds?: number;
9
- }
10
- export type ClockTimeUnit = "minutes" | "seconds" | "ms";
11
- export declare class Clock {
12
- #private;
13
- constructor(props?: ClockProps);
14
- goBack(value: number, units?: ClockTimeUnit): this;
15
- advance(value: number, units?: ClockTimeUnit): this;
16
- set showCurrentTime(value: boolean);
17
- toString(): string;
18
- get now(): number;
19
- get date(): Date;
20
- }
@@ -1,36 +0,0 @@
1
- import { EventEmitter } from "./event-emitter";
2
- export type PageVisibilityEvents = {
3
- /**
4
- * emits when page has been hidden for this period of time
5
- */
6
- "inactive-timeout": () => void;
7
- /**
8
- * emits when page is hidden
9
- */
10
- hidden: () => void;
11
- /**
12
- * emits when page is made visible
13
- */
14
- visible: () => void;
15
- /**
16
- * emits when page visibility status changes
17
- */
18
- visibilityChange: (hidden: boolean) => void;
19
- };
20
- export interface PageVisibilityObserverConstructorProps {
21
- /**
22
- * timeout period in seconds. Defaults to zero which will never timeout
23
- */
24
- inactiveTimeout?: number;
25
- onHidden?: () => void;
26
- onInactiveTimeout?: () => void;
27
- onVisible?: () => void;
28
- onVisibilityChange?: () => void;
29
- }
30
- export declare class PageVisibilityObserver extends EventEmitter<PageVisibilityEvents> {
31
- #private;
32
- visibilityChangeHandler: () => void;
33
- constructor({ inactiveTimeout, onHidden, onInactiveTimeout, onVisibilityChange, onVisible, }?: PageVisibilityObserverConstructorProps);
34
- clear(): void;
35
- private set hidden(value);
36
- }
@@ -1,12 +0,0 @@
1
- export declare class ScaledDecimal {
2
- protected readonly value: string;
3
- private readonly decimals;
4
- constructor(value: string, decimals?: number);
5
- get asLong(): string;
6
- toJSON(): string;
7
- toString(): string;
8
- }
9
- export declare const ScaledDecimal2: (value: string) => ScaledDecimal;
10
- export declare const ScaledDecimal4: (value: string) => ScaledDecimal;
11
- export declare const ScaledDecimal6: (value: string) => ScaledDecimal;
12
- export declare const ScaledDecimal8: (value: string) => ScaledDecimal;
@@ -1,11 +0,0 @@
1
- import type { RpcResponseHandler } from "@vuu-ui/vuu-data-types";
2
- import type { DefaultColumnConfiguration, DefaultTableConfiguration } from "@vuu-ui/vuu-table-types";
3
- import { LookupTableProvider } from "./feature-utils";
4
- export interface ShellContextProps {
5
- getDefaultColumnConfig?: DefaultColumnConfiguration;
6
- getDefaultTableConfig?: DefaultTableConfiguration;
7
- getLookupValues?: LookupTableProvider;
8
- handleRpcResponse?: RpcResponseHandler;
9
- }
10
- export declare const ShellContext: import("react").Context<ShellContextProps>;
11
- export declare const useShellContext: () => ShellContextProps;
@@ -1,32 +0,0 @@
1
- import { type ReactNode } from "react";
2
- export declare const DEFAULT_DENSITY: Density;
3
- export declare const DEFAULT_THEME = "salt-theme";
4
- export declare const DEFAULT_THEME_MODE: ThemeMode;
5
- export type Density = "high" | "medium" | "low" | "touch";
6
- export type ThemeMode = "light" | "dark";
7
- export type TargetElement = "root" | "scope" | "child";
8
- export interface ThemeContextProps {
9
- density: Density;
10
- theme: string;
11
- themeMode: ThemeMode;
12
- }
13
- export declare const ThemeContext: import("react").Context<ThemeContextProps>;
14
- export type ThemeClasses = [string, string, ThemeMode];
15
- export type ThemeAttributes = {
16
- themeClass: string;
17
- densityClass: string;
18
- dataMode: ThemeMode;
19
- };
20
- export declare const useThemeAttributes: (themeAttributes?: ThemeAttributes) => [string, string, ThemeMode];
21
- interface ThemeProviderProps {
22
- applyThemeClasses?: boolean;
23
- children: ReactNode;
24
- density?: Density;
25
- theme?: string;
26
- themeMode?: ThemeMode;
27
- }
28
- export declare function ThemeProvider({ applyThemeClasses, children, theme: themeProp, themeMode: themeModeProp, density: densityProp, }: ThemeProviderProps): import("react").JSX.Element;
29
- export declare namespace ThemeProvider {
30
- var displayName: string;
31
- }
32
- export {};
@@ -1,16 +0,0 @@
1
- export type PartitionTest<T> = (value: T, index: number) => boolean;
2
- export declare function partition<T>(array: T[], test: PartitionTest<T>, pass?: T[], fail?: T[]): [T[], T[]];
3
- export declare function itemsChanged<T = unknown>(currentItems: T[], newItems: T[], identityProperty?: string): boolean;
4
- export declare function itemsOrOrderChanged<T = unknown>(currentItems: T[], newItems: T[], identityProperty?: string): boolean;
5
- export declare const moveItemDeprecated: <T = unknown>(items: T[], item: T, moveTo: number) => T[];
6
- export declare const moveItem: <T = unknown>(items: T[], fromIndex: number, toIndex: number) => T[];
7
- export declare const getAddedItems: <T>(values: undefined | T[], newValues: T[]) => T[];
8
- export declare const getMissingItems: <T, I>(sourceItems: T[], items: I[], identity: (s: T) => I) => I[];
9
- /**
10
- * Given an ordered list of item names, return items in same order
11
- */
12
- export declare const reorderItems: <T extends {
13
- name: string;
14
- } = {
15
- name: string;
16
- }>(originalItems: readonly T[], orderedNames: string[]) => T[];
@@ -1,24 +0,0 @@
1
- export interface rect {
2
- bottom: number;
3
- left: number;
4
- right: number;
5
- top: number;
6
- }
7
- export type rectTuple = [number, number, number, number];
8
- export type dimension = "width" | "height";
9
- export declare function boxContainsPoint(rect: rect, x: number, y: number): boolean | undefined;
10
- export type GridLayoutSplitDirection = "north" | "south" | "east" | "west";
11
- export type GridLayoutDropPosition = GridLayoutSplitDirection | "header" | "centre";
12
- export declare function getCenteredBox({ right, left, top, bottom }: rect, pctSize: number): {
13
- left: number;
14
- top: number;
15
- right: number;
16
- bottom: number;
17
- };
18
- export declare function pointPositionWithinRect(x: number, y: number, rect: rect, borderZone?: number): {
19
- pctX: number;
20
- pctY: number;
21
- closeToTheEdge: number;
22
- };
23
- export declare const isGridLayoutSplitDirection: (position: GridLayoutDropPosition) => position is GridLayoutSplitDirection;
24
- export declare function getPositionWithinBox(x: number, y: number, rect: rect, pctX: number, pctY: number): GridLayoutDropPosition;
@@ -1,16 +0,0 @@
1
- interface VuuBroadcastChannelEventMap<T> {
2
- message: MessageEvent<T>;
3
- messageerror: MessageEvent<T>;
4
- }
5
- export interface VuuBroadcastChannel<T> extends EventTarget {
6
- readonly name: string;
7
- onmessage: ((this: BroadcastChannel, evt: MessageEvent<T>) => void) | null;
8
- onmessageerror: ((this: BroadcastChannel, evt: MessageEvent<T>) => void) | null;
9
- close(): void;
10
- postMessage<M extends T = T>(message: M): void;
11
- addEventListener<K extends keyof VuuBroadcastChannelEventMap<T>>(type: K, listener: (this: BroadcastChannel, evt: VuuBroadcastChannelEventMap<T>[K]) => void, options?: boolean | AddEventListenerOptions): void;
12
- addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
13
- removeEventListener<K extends keyof VuuBroadcastChannelEventMap<T>>(type: K, listener: (this: BroadcastChannel, evt: VuuBroadcastChannelEventMap<T>[K]) => void, options?: boolean | EventListenerOptions): void;
14
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
15
- }
16
- export {};