@vuu-ui/vuu-utils 4.0.0-alpha.22 → 4.0.0-alpha.23

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": "4.0.0-alpha.22",
2
+ "version": "4.0.0-alpha.23",
3
3
  "author": "heswell",
4
4
  "main": "./src/index.js",
5
5
  "license": "Apache-2.0",
@@ -16,14 +16,14 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@dnd-kit/react": "^0.1.21",
19
- "@vuu-ui/vuu-data-types": "4.0.0-alpha.22",
20
- "@vuu-ui/vuu-table-types": "4.0.0-alpha.22",
21
- "@vuu-ui/vuu-filter-types": "4.0.0-alpha.22",
22
- "@vuu-ui/vuu-protocol-types": "4.0.0-alpha.22"
19
+ "@vuu-ui/vuu-data-types": "4.0.0-alpha.23",
20
+ "@vuu-ui/vuu-table-types": "4.0.0-alpha.23",
21
+ "@vuu-ui/vuu-filter-types": "4.0.0-alpha.23",
22
+ "@vuu-ui/vuu-protocol-types": "4.0.0-alpha.23"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@internationalized/date": "^3.0.0",
26
- "@vuu-ui/vuu-filter-parser": "4.0.0-alpha.22",
26
+ "@vuu-ui/vuu-filter-parser": "4.0.0-alpha.23",
27
27
  "clsx": "^2.0.0",
28
28
  "react": "^19.2.3",
29
29
  "react-dom": "^19.2.3"
@@ -0,0 +1,58 @@
1
+ import type { ExtendedFilterOptions, ScaledDecimalFilterOptions, SingleValueFilterClause } from "@vuu-ui/vuu-filter-types";
2
+ import type { DataValueDescriptor } from "@vuu-ui/vuu-data-types";
3
+ export type ScaledDecimalScale = ScaledDecimalFilterOptions["scale"];
4
+ export declare const getScaledDecimalScale: (serverDataType?: string) => ScaledDecimalScale | undefined;
5
+ export declare const isValidDecimalString: (value: string) => boolean;
6
+ export declare const isScaledDecimalFilterOptions: (options?: ExtendedFilterOptions) => options is ScaledDecimalFilterOptions;
7
+ /**
8
+ * A decimal (not exponential) string representation of a filter value.
9
+ */
10
+ export declare const toDecimalString: (value: unknown, scale: ScaledDecimalScale) => string;
11
+ /**
12
+ * Convert a decimal string to its scaled integer representation. Digits beyond
13
+ * the scale are truncated, as the Vuu server does.
14
+ */
15
+ export declare const toScaledInteger: (value: string, scale: ScaledDecimalScale) => bigint;
16
+ /**
17
+ * Convert a scaled integer to a decimal string with 'scale' decimal places,
18
+ * the literal form in which scaled decimals are expressed in a filter query.
19
+ */
20
+ export declare const fromScaledInteger: (value: bigint, scale: ScaledDecimalScale) => string;
21
+ /**
22
+ * The filter options for a clause on a scaled decimal column, describing the
23
+ * precision with which the column displays values. These mirror the formatting
24
+ * rules of numericFormatter: a column with no type descriptor displays the full
25
+ * value, a type descriptor with no decimals displays 4 decimal places.
26
+ */
27
+ export declare const getScaledDecimalFilterOptions: (column: Pick<DataValueDescriptor, "serverDataType" | "type">) => ScaledDecimalFilterOptions | undefined;
28
+ /**
29
+ * The range of scaled integer values, inclusive at both ends, matched by a
30
+ * filter value. A value with no more decimal places than are displayed matches
31
+ * every value that displays as that value, e.g 1.23, displayed with 2 decimals,
32
+ * rounded, matches [1.225, 1.235). Display rounding applies to the magnitude,
33
+ * so -1.23 matches (-1.235, -1.225]. A value with more decimal places than are
34
+ * displayed is matched at its own precision, by the same rounding rule, e.g
35
+ * 1.234 matches [1.2335, 1.2345). A value with as many decimal places as the
36
+ * column holds, or any value where every decimal is displayed, is matched exactly.
37
+ */
38
+ export declare const getScaledDecimalMatchRange: (value: string, { scale, decimals, roundingRule }: ScaledDecimalFilterOptions) => [bigint, bigint];
39
+ /**
40
+ * Serialize a filter clause on a scaled decimal column. Where the value matches
41
+ * a range of values (see getScaledDecimalMatchRange), each operator applies to
42
+ * that range, e.g '>' matches values greater than every value in the range.
43
+ * Note: '!=' on a range is expressed as '< from or > to', which, unlike an
44
+ * exact '!=', does not match a null value.
45
+ */
46
+ export declare const scaledDecimalFilterAsQuery: ({ column, op, value, }: Pick<SingleValueFilterClause, "column" | "op" | "value">, options: ScaledDecimalFilterOptions) => string;
47
+ export interface ScaledDecimalCellFilter {
48
+ /** The value as displayed */
49
+ label: string;
50
+ op: "=";
51
+ value: string;
52
+ }
53
+ /**
54
+ * The filter for a cell value on a scaled decimal column, matching the value as
55
+ * displayed, e.g a cell displaying 1.23 (underlying value 1.234567) creates a
56
+ * filter matching every value that displays as 1.23.
57
+ */
58
+ export declare const getScaledDecimalCellFilter: (column: Pick<DataValueDescriptor, "serverDataType" | "type">, value: unknown) => ScaledDecimalCellFilter | undefined;