@vuu-ui/vuu-utils 3.5.0-beta.2 → 3.5.0-beta.4
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,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.5.0-beta.
|
|
2
|
+
"version": "3.5.0-beta.4",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@dnd-kit/react": "^0.1.21",
|
|
18
|
-
"@vuu-ui/vuu-data-types": "3.5.0-beta.
|
|
19
|
-
"@vuu-ui/vuu-table-types": "3.5.0-beta.
|
|
20
|
-
"@vuu-ui/vuu-filter-types": "3.5.0-beta.
|
|
21
|
-
"@vuu-ui/vuu-protocol-types": "3.5.0-beta.
|
|
18
|
+
"@vuu-ui/vuu-data-types": "3.5.0-beta.4",
|
|
19
|
+
"@vuu-ui/vuu-table-types": "3.5.0-beta.4",
|
|
20
|
+
"@vuu-ui/vuu-filter-types": "3.5.0-beta.4",
|
|
21
|
+
"@vuu-ui/vuu-protocol-types": "3.5.0-beta.4"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@internationalized/date": "^3.0.0",
|
|
25
|
-
"@vuu-ui/vuu-filter-parser": "3.5.0-beta.
|
|
25
|
+
"@vuu-ui/vuu-filter-parser": "3.5.0-beta.4",
|
|
26
26
|
"clsx": "^2.0.0",
|
|
27
27
|
"react": "^19.2.3",
|
|
28
28
|
"react-dom": "^19.2.3"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fromDateTimeFields, getDateTimeFields } from "./time-zone.js";
|
|
2
2
|
const NANOS_PER_MILLI = 1000000n;
|
|
3
3
|
const integerPattern = /^-?\d+$/;
|
|
4
|
+
const MAX_EPOCH_MILLIS = 8.64e15;
|
|
4
5
|
class EpochTimestamp {
|
|
5
6
|
epochMillis;
|
|
6
7
|
subMilliNanos;
|
|
@@ -32,6 +33,10 @@ class EpochTimestamp {
|
|
|
32
33
|
return null == value || "" === value || 0 === value || "0" === value || 0n === value;
|
|
33
34
|
}
|
|
34
35
|
static fromWire(value, encoding) {
|
|
36
|
+
const ts = EpochTimestamp.decode(value, encoding);
|
|
37
|
+
return void 0 !== ts && Math.abs(ts.epochMillis) <= MAX_EPOCH_MILLIS ? ts : void 0;
|
|
38
|
+
}
|
|
39
|
+
static decode(value, encoding) {
|
|
35
40
|
if (EpochTimestamp.isEmpty(value)) return;
|
|
36
41
|
if (value instanceof EpochTimestamp) return value;
|
|
37
42
|
if ("epochNanos" === encoding) {
|
|
@@ -5,14 +5,14 @@ import { getTemporalInfo } from "../date/temporal.js";
|
|
|
5
5
|
import { startOfDay } from "../date/time-zone.js";
|
|
6
6
|
import { getFractionalSecondDigits, temporalFormatter } from "../formatting-utils.js";
|
|
7
7
|
const pad2 = (n)=>`${n}`.padStart(2, "0");
|
|
8
|
-
const getTemporalCellFilter = (column, value,
|
|
8
|
+
const getTemporalCellFilter = (column, value, columnFilter = false)=>{
|
|
9
9
|
const temporalInfo = getTemporalInfo(column);
|
|
10
10
|
if (void 0 === temporalInfo) return;
|
|
11
11
|
const { encoding, kind, timeZone } = temporalInfo;
|
|
12
12
|
const ts = EpochTimestamp.fromWire(value, encoding);
|
|
13
13
|
if (void 0 === ts) return;
|
|
14
14
|
const pattern = dateTimePattern(column.type, kind);
|
|
15
|
-
if ("date" === kind ||
|
|
15
|
+
if ("date" === kind || columnFilter && "datetime" === kind || void 0 === pattern.time) {
|
|
16
16
|
const { date = defaultPatternsByType.date } = pattern;
|
|
17
17
|
const start = EpochTimestamp.fromMillis(startOfDay(ts.epochMillis, timeZone));
|
|
18
18
|
return {
|
|
@@ -25,12 +25,15 @@ const getTemporalCellFilter = (column, value, dateOnly = false)=>{
|
|
|
25
25
|
value: `${start.toWire(encoding)}`
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
const digits = Math.max(0, Math.min(9, getFractionalSecondDigits(column, temporalInfo)));
|
|
28
|
+
const digits = columnFilter ? "hh:mm:ss.ms" === pattern.time ? 3 : 0 : Math.max(0, Math.min(9, getFractionalSecondDigits(column, temporalInfo)));
|
|
29
29
|
const unit = "epochNanos" === encoding ? 1n : 1000000n;
|
|
30
30
|
const period = 10n ** BigInt(9 - digits);
|
|
31
31
|
const startNanos = ts.epochNanos - ts.epochNanos % period;
|
|
32
32
|
const start = EpochTimestamp.fromNanos(startNanos);
|
|
33
|
-
const label =
|
|
33
|
+
const label = columnFilter ? formatTimestamp(pattern, {
|
|
34
|
+
fractionalSecondDigits: digits,
|
|
35
|
+
timeZone
|
|
36
|
+
})(start) : temporalFormatter(column, temporalInfo)(start.toWire(encoding));
|
|
34
37
|
if ("time" === kind) {
|
|
35
38
|
const { hour, minute, second } = ts.getFields(timeZone);
|
|
36
39
|
const fraction = ts.fractionalSecond(digits);
|
|
@@ -32,9 +32,12 @@ export declare class EpochTimestamp {
|
|
|
32
32
|
static isEmpty(value: unknown): value is 0 | "" | "0" | 0n | null | undefined;
|
|
33
33
|
/**
|
|
34
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
|
|
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).
|
|
36
38
|
*/
|
|
37
39
|
static fromWire(value: unknown, encoding: TemporalEncoding): EpochTimestamp | undefined;
|
|
40
|
+
private static decode;
|
|
38
41
|
get epochNanos(): bigint;
|
|
39
42
|
toDate(): Date;
|
|
40
43
|
/**
|
|
@@ -9,7 +9,7 @@ export interface TemporalCellFilter {
|
|
|
9
9
|
* Describes a filter that matches a temporal value at the precision with which
|
|
10
10
|
* it is displayed by the given column descriptor, e.g. where the descriptor
|
|
11
11
|
* displays milliseconds, the filter matches the whole millisecond.
|
|
12
|
-
* - date
|
|
12
|
+
* - date => the whole day, as a start of day value
|
|
13
13
|
* - time => a time of day (TimeString), truncated to the displayed precision
|
|
14
14
|
* - datetime => a range, unless the displayed precision is that of the encoding
|
|
15
15
|
* The filter is suitable for FilterAggregator.add (with the same descriptor) and
|
|
@@ -17,8 +17,11 @@ export interface TemporalCellFilter {
|
|
|
17
17
|
*
|
|
18
18
|
* @param column the descriptor of the filter (or table cell) displaying the value
|
|
19
19
|
* @param value a value as received from the server
|
|
20
|
-
* @param
|
|
21
|
-
*
|
|
20
|
+
* @param columnFilter the value is displayed by a ColumnFilter, rather than a
|
|
21
|
+
* table cell. A ColumnFilter displays a 'datetime' value as a date (DatePicker,
|
|
22
|
+
* so the filter is the whole day) and a 'time' value to the second, or to the
|
|
23
|
+
* millisecond with the 'hh:mm:ss.ms' pattern (TimeInput supports no finer
|
|
24
|
+
* precision, whereas a table cell displays nanos by default).
|
|
22
25
|
* @returns undefined if value is empty or column is not temporal
|
|
23
26
|
*/
|
|
24
|
-
export declare const getTemporalCellFilter: (column: DataValueDescriptor, value: unknown,
|
|
27
|
+
export declare const getTemporalCellFilter: (column: DataValueDescriptor, value: unknown, columnFilter?: boolean) => TemporalCellFilter | undefined;
|