@kronor/dtv 13.0.2 → 13.0.3

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.
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { DataTable } from 'primereact/datatable';
3
- import { type ColumnDefinition } from '../framework/column-definition';
3
+ import type { ColumnDefinition } from '../framework/column-definition';
4
4
  import { NoRowsComponent, RowExpansionDefinition, type SimplifiedRow } from '../framework/view';
5
5
  import { FilterState } from '../framework/state';
6
6
  import { type FlattenedDataRow } from '../framework/data';
@@ -0,0 +1,11 @@
1
+ export declare const COUNTRY_CODES: {
2
+ label: string;
3
+ value: string;
4
+ }[];
5
+ export declare const DEFAULT_CODE: string;
6
+ export declare function splitCountryCode(value: string): {
7
+ code: string | null;
8
+ number: string;
9
+ };
10
+ export declare function isQueryablePhoneNumber(value: string): boolean;
11
+ export declare function phoneFilterValue(code: string, number: string): string;
@@ -16,9 +16,16 @@
16
16
  * view authors have a single import site.
17
17
  */
18
18
  import type { ReactNode } from "react";
19
- import { type FieldQuery, type DataFromFieldQueriesForRowSafe, type FieldQueryForRowSafe, type TableColumnDefinition, type VirtualColumnDefinition, type CellRenderer, type CellRendererProps, type OrderableFieldPath, type TableColumnDefinitionFooter } from "../framework/column-definition";
19
+ import { type FieldQuery, type DataFromFieldQueriesForRowSafe, type FieldQueryForRowSafe, type TableColumnDefinition, type VirtualColumnDefinition, type CellRenderer, type CellRendererProps, type TableColumnDefinitionFooter } from "../framework/column-definition";
20
+ import * as Orderable from "../framework/orderable";
20
21
  import type { ColumnFieldValue, FieldColumnData, FieldColumnOrderBy, FieldColumnSelect, ValidateColumnFieldType } from "./columnTyping";
21
22
  export { valueQuery, objectQuery, arrayQuery, rowType } from "@kronor/hasura-graphql";
23
+ /**
24
+ * `orderBy: Orderable.notOrderable` declares a column that cannot be sorted. Without it, a
25
+ * column whose data is a single scalar field is sorted by that field — also when sorting by
26
+ * it is useless, as for a JSON field.
27
+ */
28
+ export * as Orderable from "../framework/orderable";
22
29
  /**
23
30
  * Creates a renderable table column definition for a view over `Row`.
24
31
  * Convenience wrapper around the underlying TableColumnDefinition type.
@@ -29,7 +36,7 @@ export declare function column<Row, const FieldQueries extends readonly FieldQue
29
36
  name: string;
30
37
  data: FieldQueries & readonly FieldQueryForRowSafe<Row>[];
31
38
  footer?: TableColumnDefinitionFooter;
32
- orderBy?: OrderableFieldPath<FieldQueries>;
39
+ orderBy?: Orderable.OrderableFieldPath<FieldQueries> | Orderable.NotOrderable;
33
40
  cellRenderer: CellRenderer<DataFromFieldQueriesForRowSafe<Row, FieldQueries>>;
34
41
  }): TableColumnDefinition<FieldQueries, DataFromFieldQueriesForRowSafe<Row, FieldQueries>>;
35
42
  /** The props a `fieldColumn` renderer gets: the usual ones, plus the field's value. */
@@ -64,7 +71,8 @@ type FieldCellRenderer<Value> = (props: FieldCellRendererProps<Value>) => ReactN
64
71
  * selected inside the field follows from that type: nothing for a scalar,
65
72
  * `select: { object: [...] }` for an object, `select: { list: [...] }` for a
66
73
  * list, each checked against it. `orderBy` names the field itself for a
67
- * scalar, or a scalar inside it for an object.
74
+ * scalar, or a scalar inside it for an object; `Orderable.notOrderable` keeps a scalar
75
+ * field's column from being sorted by it.
68
76
  *
69
77
  * The column puts the field on the row DTV hands out (`SimplifiedRow`) with the type
70
78
  * its renderer takes.
@@ -77,7 +85,7 @@ export declare function fieldColumn<Row, const Field extends string, Value = Col
77
85
  id?: string;
78
86
  name: string;
79
87
  footer?: TableColumnDefinitionFooter;
80
- orderBy?: NoInfer<FieldColumnOrderBy<Field, Value>>;
88
+ orderBy?: NoInfer<FieldColumnOrderBy<Field, Value>> | Orderable.NotOrderable;
81
89
  cellRenderer: FieldCellRenderer<Value>;
82
90
  } & NoInfer<FieldColumnSelect<Value>>): TableColumnDefinition<readonly FieldQuery[], FieldColumnData<Row, Field, NoInfer<Value>>>;
83
91
  /**
@@ -9,10 +9,11 @@ import type { ColumnProps } from "primereact/column";
9
9
  import type { FilterState } from "./state";
10
10
  import type { FilterFormState } from "./filter-form-state";
11
11
  import type { FilterId } from "./filters";
12
+ import type * as Orderable from "./orderable";
12
13
  import type { FieldQuery } from "@kronor/hasura-graphql";
13
- import type { DataFromFieldQueriesSafe, OrderableFieldPath } from "@kronor/hasura-graphql";
14
- export type { OrderByConfig, FieldAlias, ValueQuery, ObjectQuery, ArrayQuery, Query, FieldQuery, OrderableFieldPath, DataFromQuery, DataFromFieldQuery, DataFromSelectionSet, DataFromFieldQueries, DataFromFieldQueriesSafe, DataFromQueryForRow, DataFromFieldQueryForRow, DataFromSelectionSetForRow, DataFromFieldQueriesForRow, DataFromFieldQueriesForRowSafe, ValueQueryForRow, ObjectQueryForRow, ArrayQueryForRow, QueryForRow, QueryForRowSafe, FieldAliasForRow, FieldQueryForRow, FieldQueryForRowSafe, ValidateFieldQueriesForRow, } from "@kronor/hasura-graphql";
15
- export { fieldAlias, getOrderableFieldPaths, orderByIsSelectedField } from "@kronor/hasura-graphql";
14
+ import type { DataFromFieldQueriesSafe } from "@kronor/hasura-graphql";
15
+ export type { OrderByConfig, FieldAlias, ValueQuery, ObjectQuery, ArrayQuery, Query, FieldQuery, DataFromQuery, DataFromFieldQuery, DataFromSelectionSet, DataFromFieldQueries, DataFromFieldQueriesSafe, DataFromQueryForRow, DataFromFieldQueryForRow, DataFromSelectionSetForRow, DataFromFieldQueriesForRow, DataFromFieldQueriesForRowSafe, ValueQueryForRow, ObjectQueryForRow, ArrayQueryForRow, QueryForRow, QueryForRowSafe, FieldAliasForRow, FieldQueryForRow, FieldQueryForRowSafe, ValidateFieldQueriesForRow, } from "@kronor/hasura-graphql";
16
+ export { fieldAlias } from "@kronor/hasura-graphql";
16
17
  export type CellRendererProps<Data extends object = Record<string, unknown>> = {
17
18
  data: Data;
18
19
  setFilterState: (updater: (currentState: FilterState) => FilterState) => void;
@@ -49,7 +50,7 @@ export type TableColumnDefinition<FieldQueries extends readonly FieldQuery[] = r
49
50
  data: FieldQueries;
50
51
  name: string;
51
52
  footer?: TableColumnDefinitionFooter;
52
- orderBy?: OrderableFieldPath<FieldQueries>;
53
+ orderBy?: Orderable.OrderableFieldPath<FieldQueries> | Orderable.NotOrderable;
53
54
  cellRenderer: CellRenderer<CellData>;
54
55
  };
55
56
  export type VirtualColumnDefinition<FieldQueries extends readonly FieldQuery[] = readonly FieldQuery[], Data extends object = DataFromFieldQueriesSafe<FieldQueries>> = {
@@ -63,4 +64,3 @@ export type VirtualColumnDefinition<FieldQueries extends readonly FieldQuery[] =
63
64
  rowData?: Data;
64
65
  };
65
66
  export type ColumnDefinition = TableColumnDefinition | VirtualColumnDefinition;
66
- export declare function getColumnOrderBy(column: TableColumnDefinition): string | undefined;
@@ -33,5 +33,11 @@ export declare const filterTransforms: {
33
33
  };
34
34
  };
35
35
  hasuraCustomOperator: import("../filters").ConditionOnlyTransform;
36
+ phoneNumber: {
37
+ toQuery: (input: unknown) => {
38
+ field?: import("../filters").FilterField;
39
+ value: FilterValue.FilterValue;
40
+ };
41
+ };
36
42
  };
37
43
  export declare const nativeRuntime: NativeRuntime;
@@ -0,0 +1,10 @@
1
+ import type { TableColumnDefinition } from "./column-definition";
2
+ export type { OrderableFieldPath } from "@kronor/hasura-graphql";
3
+ export { getOrderableFieldPaths, orderByIsSelectedField } from "@kronor/hasura-graphql";
4
+ export declare const notOrderable: {
5
+ readonly type: "notOrderable";
6
+ };
7
+ export type NotOrderable = typeof notOrderable;
8
+ export declare function isNotOrderable(orderBy: unknown): orderBy is NotOrderable;
9
+ /** The field a column orders by when its header is sorted, or undefined when it cannot be sorted. */
10
+ export declare function getColumnOrderBy(column: TableColumnDefinition): string | undefined;
@@ -1,4 +1,5 @@
1
1
  import { type FieldQuery, type FieldAlias } from './column-definition';
2
+ import * as Orderable from './orderable';
2
3
  import type { FilterControl, FilterExpr, FilterFieldGroup, FilterGroups } from './filters';
3
4
  import { View } from './view';
4
5
  import type { Runtime } from './runtime';
@@ -181,7 +182,7 @@ export type TableColumnDefinitionJson = {
181
182
  data: FieldQueryJson[];
182
183
  name: string;
183
184
  footer?: RuntimeReference;
184
- orderBy?: string;
185
+ orderBy?: string | Orderable.NotOrderable;
185
186
  cellRenderer: RuntimeReference;
186
187
  };
187
188
  export type VirtualColumnDefinitionJson = {
@@ -19,6 +19,7 @@ export type { FilterState } from '../framework/state';
19
19
  export type { CustomOperatorOption, FilterSchema, FilterField, FilterValueFormatter, FilterValueFormatContext, QueryTransformContext, SuggestionFetcher, TransformConditionResult } from '../framework/filters';
20
20
  export { TransformResult } from '../framework/filters';
21
21
  export * as FilterValue from '../framework/filterValue';
22
+ export * as Orderable from '../framework/orderable';
22
23
  export { FilterExpr } from '../dsl/filterExpr';
23
24
  export { FilterControl } from '../dsl/filterControl';
24
25
  export { CellRenderer } from '../dsl/cellRenderer';
@@ -48,6 +48,7 @@ Add additional docs here for transforms, custom filters, etc. as needed.
48
48
  - A table column with exactly one simple `valueQuery` automatically orders by that field.
49
49
  - For rendered or composite columns, set `orderBy` on the table column JSON to one of the scalar GraphQL fields selected by `data` to enable sorting.
50
50
  - `orderBy` may be a dot-separated path for nested order fields, such as `customer.profile.status`.
51
+ - A column that must not be sorted, although its data is a single `valueQuery`, sets `orderBy` to `{ "type": "notOrderable" }` (`orderBy: DTV.Orderable.notOrderable` in the DSL). A JSON field is the usual case: GraphQL can order by it, but the order means nothing, and a keyset-paginated export cannot page through it.
51
52
  - Users can order by one sortable header at a time. Clicking a sorted header a third time removes the header ordering.
52
53
  - A view's `staticOrdering` always applies: the sorted header leads and static entries trail it as tie-breakers, so an unsorted table orders by `staticOrdering` alone. An entry for the field the user sorted by is dropped, since their direction supersedes it. A unique `paginationKey` ordering closes the list.
53
54
 
@@ -94,6 +94,8 @@ accountColumn(InvoicesRowType, 'memo', 'Memo');
94
94
  (`orderBy: 'memo'`), or a scalar inside it for an object
95
95
  (`orderBy: 'arAccount.accountNr'`); a list cannot be ordered by. The path has
96
96
  to be one the selection includes, which is checked when the column is built.
97
+ `orderBy: Orderable.notOrderable` keeps a scalar field's column from being sorted by it,
98
+ as `column` does for a single `valueQuery`.
97
99
  - **Forwarding.** The field has to be a literal path, or a field branded as
98
100
  above. A plain `string`, or a helper's own `Field` that nothing has checked, is
99
101
  rejected, since nothing could check it. A helper that takes the field from its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronor/dtv",
3
- "version": "13.0.2",
3
+ "version": "13.0.3",
4
4
  "description": "Schema-driven, declarative table views with advanced filtering, data fetching and AI-assisted filter generation.",
5
5
  "repository": {
6
6
  "type": "git",