@vuu-ui/vuu-utils 3.3.5 → 3.3.7
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.3.
|
|
2
|
+
"version": "3.3.7",
|
|
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.3.
|
|
19
|
-
"@vuu-ui/vuu-table-types": "3.3.
|
|
20
|
-
"@vuu-ui/vuu-filter-types": "3.3.
|
|
21
|
-
"@vuu-ui/vuu-protocol-types": "3.3.
|
|
18
|
+
"@vuu-ui/vuu-data-types": "3.3.7",
|
|
19
|
+
"@vuu-ui/vuu-table-types": "3.3.7",
|
|
20
|
+
"@vuu-ui/vuu-filter-types": "3.3.7",
|
|
21
|
+
"@vuu-ui/vuu-protocol-types": "3.3.7"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@internationalized/date": "^3.0.0",
|
|
25
|
-
"@vuu-ui/vuu-filter-parser": "3.3.
|
|
25
|
+
"@vuu-ui/vuu-filter-parser": "3.3.7",
|
|
26
26
|
"clsx": "^2.0.0",
|
|
27
27
|
"react": "^19.2.3",
|
|
28
28
|
"react-dom": "^19.2.3"
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { isDateTimeDataValue } from "../column-utils.js";
|
|
2
|
+
import { stringIsValidLong } from "../data-utils.js";
|
|
2
3
|
import { isMultiClauseFilter, isMultiValueFilter, isSerializableFilter } from "./filter-utils.js";
|
|
3
4
|
import { ScaledDecimal } from "../ScaledDecimal.js";
|
|
4
|
-
const filterValue = (value)=>
|
|
5
|
+
const filterValue = (value, columnType)=>{
|
|
6
|
+
if ("string" == typeof value) {
|
|
7
|
+
if (void 0 !== columnType) {
|
|
8
|
+
const isNumericType = [
|
|
9
|
+
"int",
|
|
10
|
+
"long",
|
|
11
|
+
"double"
|
|
12
|
+
].includes(columnType);
|
|
13
|
+
return isNumericType ? value : `"${value}"`;
|
|
14
|
+
}
|
|
15
|
+
return stringIsValidLong(value) ? value : `"${value}"`;
|
|
16
|
+
}
|
|
17
|
+
return value instanceof ScaledDecimal || "bigint" == typeof value ? value.toString() : value;
|
|
18
|
+
};
|
|
5
19
|
const quotedStrings = (value)=>"string" == typeof value ? `"${value}"` : value;
|
|
6
20
|
const removeOuterMostParentheses = (s)=>s.replace(/^\((.*)\)$/, "$1");
|
|
7
21
|
const filterAsQuery = (f, opts)=>removeOuterMostParentheses(filterAsQueryCore(f, opts));
|
|
@@ -17,12 +31,12 @@ function singleValueFilterAsQuery(f, opts) {
|
|
|
17
31
|
if (isSerializableFilter(f)) return f.asQuery();
|
|
18
32
|
{
|
|
19
33
|
const column = opts?.columnsByName?.[f.column];
|
|
20
|
-
if (column && isDateTimeDataValue(column)) return dateFilterAsQuery(f);
|
|
21
|
-
return defaultSingleValueFilterAsQuery(f);
|
|
34
|
+
if (column && isDateTimeDataValue(column)) return dateFilterAsQuery(f, opts);
|
|
35
|
+
return defaultSingleValueFilterAsQuery(f, opts);
|
|
22
36
|
}
|
|
23
37
|
}
|
|
24
38
|
const ONE_DAY_IN_MILLIS = 86400000;
|
|
25
|
-
function dateFilterAsQuery(f) {
|
|
39
|
+
function dateFilterAsQuery(f, opts) {
|
|
26
40
|
switch(f.op){
|
|
27
41
|
case "=":
|
|
28
42
|
{
|
|
@@ -41,7 +55,7 @@ function dateFilterAsQuery(f) {
|
|
|
41
55
|
return filterAsQueryCore({
|
|
42
56
|
op: "and",
|
|
43
57
|
filters
|
|
44
|
-
});
|
|
58
|
+
}, opts);
|
|
45
59
|
}
|
|
46
60
|
case "!=":
|
|
47
61
|
{
|
|
@@ -60,11 +74,14 @@ function dateFilterAsQuery(f) {
|
|
|
60
74
|
return filterAsQueryCore({
|
|
61
75
|
op: "or",
|
|
62
76
|
filters
|
|
63
|
-
});
|
|
77
|
+
}, opts);
|
|
64
78
|
}
|
|
65
79
|
default:
|
|
66
|
-
return defaultSingleValueFilterAsQuery(f);
|
|
80
|
+
return defaultSingleValueFilterAsQuery(f, opts);
|
|
67
81
|
}
|
|
68
82
|
}
|
|
69
|
-
const defaultSingleValueFilterAsQuery = (f)
|
|
83
|
+
const defaultSingleValueFilterAsQuery = (f, opts)=>{
|
|
84
|
+
const columnType = opts?.columnsByName?.[f.column]?.serverDataType;
|
|
85
|
+
return `${f.column} ${f.op} ${filterValue(f.value, columnType)}`;
|
|
86
|
+
};
|
|
70
87
|
export { ONE_DAY_IN_MILLIS, dateFilterAsQuery, filterAsQuery };
|
package/src/form-utils.js
CHANGED
|
@@ -40,7 +40,7 @@ function getTypedValue(value, type, throwIfInvalid = false, options) {
|
|
|
40
40
|
if (!throwIfInvalid) return;
|
|
41
41
|
throw Error(`value ${value} is not a valid ${type}`);
|
|
42
42
|
case "long":
|
|
43
|
-
if (stringIsValidLong(value)) return
|
|
43
|
+
if (stringIsValidLong(value)) return value;
|
|
44
44
|
if (!throwIfInvalid) return;
|
|
45
45
|
throw Error(`value ${value} is not a valid ${type}`);
|
|
46
46
|
case "scaleddecimal2":
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ColumnDescriptorsByName, Filter, SingleValueFilterClause } from "@vuu-ui/vuu-filter-types";
|
|
1
|
+
import type { ColumnDescriptorsByName, Filter, SingleValueFilterClause } from "@vuu-ui/vuu-filter-types";
|
|
2
2
|
export declare const filterAsQuery: (f: Filter, opts?: {
|
|
3
3
|
columnsByName?: ColumnDescriptorsByName;
|
|
4
4
|
}) => string;
|
|
5
5
|
export declare const ONE_DAY_IN_MILLIS: number;
|
|
6
|
-
export declare function dateFilterAsQuery(f: SingleValueFilterClause<number
|
|
6
|
+
export declare function dateFilterAsQuery(f: SingleValueFilterClause<number>, opts?: {
|
|
7
|
+
columnsByName?: ColumnDescriptorsByName;
|
|
8
|
+
}): string;
|