@contember/bindx-dataview 0.1.52 → 0.1.53
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/dist/DataGrid.d.ts.map +1 -1
- package/dist/HasManyDataGrid.d.ts.map +1 -1
- package/dist/columnLeaf.d.ts +5 -0
- package/dist/columnLeaf.d.ts.map +1 -1
- package/dist/columns.d.ts +14 -8
- package/dist/columns.d.ts.map +1 -1
- package/dist/createColumn.d.ts +10 -4
- package/dist/createColumn.d.ts.map +1 -1
- package/dist/createRelationColumn.d.ts +3 -1
- package/dist/createRelationColumn.d.ts.map +1 -1
- package/dist/select/SelectDataView.d.ts.map +1 -1
- package/dist/useDataViewState.d.ts +7 -1
- package/dist/useDataViewState.d.ts.map +1 -1
- package/dist/usePagingTotalCount.d.ts +19 -0
- package/dist/usePagingTotalCount.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/DataGrid.tsx +8 -11
- package/src/HasManyDataGrid.tsx +18 -12
- package/src/columnLeaf.ts +5 -0
- package/src/columns.tsx +11 -2
- package/src/createColumn.ts +13 -6
- package/src/createRelationColumn.tsx +4 -1
- package/src/select/SelectDataView.tsx +8 -9
- package/src/useDataGridSetup.ts +3 -3
- package/src/useDataViewState.ts +38 -15
- package/src/usePagingTotalCount.ts +90 -0
package/dist/DataGrid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGrid.d.ts","sourceRoot":"","sources":["../src/DataGrid.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAQ,KAAK,YAAY,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AAClH,OAAO,KAAK,EACX,SAAS,EACT,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAQ3D,OAAO,EAAoB,iB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BAAkB,CAAA;IAC5C,6CAA6C;IAC7C,qBAAqB,CAAC,EAAE,kBAAkB,CAAA;IAC1C,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAMD,iBAAS,YAAY,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAC9D,MAAM,EACN,QAAQ,EACR,cAAc,EACd,YAAiB,EACjB,MAAM,EAAE,YAAY,EACpB,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,qBAAqB,EACrB,UAAU,GACV,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,YAAY,GAAG,IAAI,CA8G/C;AAMD,eAAO,MAAM,QAAQ,EAAoC,OAAO,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyDataGrid.d.ts","sourceRoot":"","sources":["../src/HasManyDataGrid.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAQ,KAAK,YAAY,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AAClH,OAAO,KAAK,EACX,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,MAAM,kBAAkB,CAAA;AAQzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"HasManyDataGrid.d.ts","sourceRoot":"","sources":["../src/HasManyDataGrid.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAQ,KAAK,YAAY,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AAClH,OAAO,KAAK,EACX,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,MAAM,kBAAkB,CAAA;AAQzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAc3D,M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;
|
|
24
24
|
readonly filterName: string | null;
|
|
25
25
|
readonly filterHandler: FilterHandler<FilterArtifact> | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Where the filter starts when nothing is stored for it. Defaults to the
|
|
28
|
+
* handler's (inactive) default artifact.
|
|
29
|
+
*/
|
|
30
|
+
readonly filterInitialArtifact?: FilterArtifact;
|
|
26
31
|
readonly isTextSearchable: boolean;
|
|
27
32
|
/**
|
|
28
33
|
* The leaf exists only to register its field — for full-text search, or to
|
package/dist/columnLeaf.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnLeaf.d.ts","sourceRoot":"","sources":["../src/columnLeaf.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAU/F,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAE3K,MAAM,WAAW,eAAe;IAE/B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;IAC3C,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,SAAS,CAAA;IACj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E,GAAG,cAAc,EAAE,CAkBvF;AAcD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,sDAAsD;IACtD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAAA;IAC7D,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAAA;CACzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAChD,sBAAsB,CAiBxB;AAqBD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,eAAe,EAAE,CAEhF"}
|
package/dist/columns.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Relation/action/generic columns use manual `staticRender`.
|
|
10
10
|
*/
|
|
11
11
|
import React, { ReactNode } from 'react';
|
|
12
|
-
import type { FieldRef, HasOneRef, HasManyRef, FilterHandler, FilterArtifact, EntityAccessor } from '@contember/bindx';
|
|
12
|
+
import type { FieldRef, HasOneRef, HasManyRef, FilterHandler, FilterArtifact, EntityAccessor, EnumFilterArtifact, EnumListFilterArtifact } from '@contember/bindx';
|
|
13
13
|
import { type RelationColumnProps } from './createRelationColumn.jsx';
|
|
14
14
|
import { type ColumnLeafProps } from './columnLeaf.js';
|
|
15
15
|
export type ColumnMeta = ColumnLeafProps;
|
|
@@ -38,22 +38,26 @@ interface EnumExtraProps<T extends string> {
|
|
|
38
38
|
options: readonly T[] | Record<T, ReactNode>;
|
|
39
39
|
}
|
|
40
40
|
export interface DataGridEnumColumnProps<T extends string> extends DataGridScalarColumnPropsBase<T>, EnumExtraProps<NoInfer<T>> {
|
|
41
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to no value picked. */
|
|
42
|
+
filterInitialArtifact?: EnumFilterArtifact<NoInfer<T>>;
|
|
41
43
|
}
|
|
42
44
|
export interface DataGridEnumListColumnProps<T extends string> extends DataGridScalarColumnPropsBase<T>, EnumExtraProps<NoInfer<T>> {
|
|
45
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to no value picked. */
|
|
46
|
+
filterInitialArtifact?: EnumListFilterArtifact<NoInfer<T>>;
|
|
43
47
|
}
|
|
44
|
-
export declare const DataGridTextColumn: import("./createColumn.js").ColumnComponent<object>;
|
|
45
|
-
export declare const DataGridNumberColumn: import("./createColumn.js").ColumnComponent<object>;
|
|
46
|
-
export declare const DataGridDateColumn: import("./createColumn.js").ColumnComponent<object>;
|
|
47
|
-
export declare const DataGridDateTimeColumn: import("./createColumn.js").ColumnComponent<object>;
|
|
48
|
-
export declare const DataGridBooleanColumn: import("./createColumn.js").ColumnComponent<object>;
|
|
48
|
+
export declare const DataGridTextColumn: import("./createColumn.js").ColumnComponent<object, import("@contember/bindx").TextFilterArtifact>;
|
|
49
|
+
export declare const DataGridNumberColumn: import("./createColumn.js").ColumnComponent<object, import("@contember/bindx").NumberRangeFilterArtifact>;
|
|
50
|
+
export declare const DataGridDateColumn: import("./createColumn.js").ColumnComponent<object, import("@contember/bindx").DateFilterArtifact>;
|
|
51
|
+
export declare const DataGridDateTimeColumn: import("./createColumn.js").ColumnComponent<object, import("@contember/bindx").DateFilterArtifact>;
|
|
52
|
+
export declare const DataGridBooleanColumn: import("./createColumn.js").ColumnComponent<object, import("@contember/bindx").BooleanFilterArtifact>;
|
|
49
53
|
export declare const DataGridEnumColumn: (<TValue extends string>(_props: DataGridEnumColumnProps<TValue>) => null) & {
|
|
50
54
|
staticRender: (props: Record<string, unknown>) => React.ReactNode;
|
|
51
55
|
};
|
|
52
56
|
export declare const DataGridEnumListColumn: (<TValue extends string>(_props: DataGridEnumListColumnProps<TValue>) => null) & {
|
|
53
57
|
staticRender: (props: Record<string, unknown>) => React.ReactNode;
|
|
54
58
|
};
|
|
55
|
-
export declare const DataGridUuidColumn: import("./createColumn.js").ColumnComponent<object>;
|
|
56
|
-
export declare const DataGridIsDefinedColumn: import("./createColumn.js").ColumnComponent<object>;
|
|
59
|
+
export declare const DataGridUuidColumn: import("./createColumn.js").ColumnComponent<object, import("@contember/bindx").TextFilterArtifact>;
|
|
60
|
+
export declare const DataGridIsDefinedColumn: import("./createColumn.js").ColumnComponent<object, import("@contember/bindx").IsDefinedFilterArtifact>;
|
|
57
61
|
export interface DataGridHasOneColumnProps<TEntity, TSelected> extends RelationColumnProps<TEntity, TSelected> {
|
|
58
62
|
field: HasOneRef<TEntity, TSelected>;
|
|
59
63
|
}
|
|
@@ -91,6 +95,8 @@ export interface DataGridColumnProps<T> {
|
|
|
91
95
|
sortable?: boolean;
|
|
92
96
|
filter?: boolean;
|
|
93
97
|
filterHandler?: FilterHandler<FilterArtifact>;
|
|
98
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to the handler's inactive artifact. */
|
|
99
|
+
filterInitialArtifact?: FilterArtifact;
|
|
94
100
|
/** Register the field without showing a column (e.g. to make it full-text searchable). */
|
|
95
101
|
virtual?: boolean;
|
|
96
102
|
children?: (value: T | null, accessor: EntityAccessor<object>) => React.ReactNode;
|
package/dist/columns.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../src/columns.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../src/columns.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE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C,KAAG,KAAK,CAAC,SAAS;CAuBhE,CAAA;AAMD,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;IACnB,8HAA8H;IAC9H,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,aAAa,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC7C,mHAAmH;IACnH,qBAAqB,CAAC,EAAE,cAAc,CAAA;IACtC,0FAA0F;IAC1F,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,SAAS,CAAA;CACjF;AAED,eAAO,MAAM,cAAc,IACF,CAAC,UAAU,mBAAmB,CAAC,CAAC,CAAC,KAAG,IAAI;0BAIzC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,KAAK,CAAC,SAAS;CAoChE,CAAA"}
|
package/dist/createColumn.d.ts
CHANGED
|
@@ -24,19 +24,25 @@ export interface CreateColumnConfig<TValue, TFilterArtifact extends FilterArtifa
|
|
|
24
24
|
readonly renderCell: (props: ColumnRenderProps<TValue>) => React.ReactNode;
|
|
25
25
|
readonly renderFilter?: (props: FilterRenderProps<TFilterArtifact>) => React.ReactNode;
|
|
26
26
|
}
|
|
27
|
-
export interface ColumnComponentProps<TValue = unknown> {
|
|
27
|
+
export interface ColumnComponentProps<TValue = unknown, TFilterArtifact extends FilterArtifact = FilterArtifact> {
|
|
28
28
|
field: FieldRef<TValue>;
|
|
29
29
|
/** Column identity. Defaults to the bound field name — pass it when two columns bind one field. */
|
|
30
30
|
name?: string;
|
|
31
31
|
header?: React.ReactNode;
|
|
32
32
|
sortable?: boolean;
|
|
33
33
|
filter?: boolean;
|
|
34
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to the handler's inactive artifact. */
|
|
35
|
+
filterInitialArtifact?: TFilterArtifact;
|
|
34
36
|
/** Register the field without showing a column (e.g. to make it full-text searchable). */
|
|
35
37
|
virtual?: boolean;
|
|
36
38
|
children?: (value: TValue | null, accessor: EntityAccessor<object>) => React.ReactNode;
|
|
37
39
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
/**
|
|
41
|
+
* `TFilterArtifact` defaults to `never`: a column whose artifact type is not known takes no
|
|
42
|
+
* `filterInitialArtifact`, and every column `createColumn` builds is assignable to it.
|
|
43
|
+
*/
|
|
44
|
+
export interface ColumnComponent<TExtraProps = object, TFilterArtifact extends FilterArtifact = never> {
|
|
45
|
+
<T>(props: ColumnComponentProps<T, TFilterArtifact> & TExtraProps): null;
|
|
40
46
|
staticRender: (props: Record<string, unknown>) => React.ReactNode;
|
|
41
47
|
}
|
|
42
48
|
/**
|
|
@@ -47,5 +53,5 @@ export interface ColumnComponent<TExtraProps = object> {
|
|
|
47
53
|
* static render via `Object.assign`.
|
|
48
54
|
*/
|
|
49
55
|
export declare function createColumnStaticRender<TValue, TFilterArtifact extends FilterArtifact>(columnType: ColumnTypeDef<TValue, TFilterArtifact>, config: CreateColumnConfig<TValue, TFilterArtifact>): (props: Record<string, unknown>) => React.ReactNode;
|
|
50
|
-
export declare function createColumn<TValue, TFilterArtifact extends FilterArtifact, TExtraProps = object>(columnType: ColumnTypeDef<TValue, TFilterArtifact>, config: CreateColumnConfig<TValue, TFilterArtifact>): ColumnComponent<TExtraProps>;
|
|
56
|
+
export declare function createColumn<TValue, TFilterArtifact extends FilterArtifact, TExtraProps = object>(columnType: ColumnTypeDef<TValue, TFilterArtifact>, config: CreateColumnConfig<TValue, TFilterArtifact>): ColumnComponent<TExtraProps, TFilterArtifact>;
|
|
51
57
|
//# sourceMappingURL=createColumn.d.ts.map
|
|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E,eAAe,CAAC,EAClD,MAAM,EAAE,kBAAkB,CAAC,MAAM,EAAE,eAAe,CAAC,GACjD,eAAe,CAAC,WAAW,EAAE,eAAe,CAAC,CAM/C"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* UI layers provide renderFilter and renderCellWrapper via config.
|
|
11
11
|
*/
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import type { FieldRef, FilterArtifact, EntityAccessor, SelectionMeta } from '@contember/bindx';
|
|
13
|
+
import type { FieldRef, FilterArtifact, EntityAccessor, RelationFilterArtifact, SelectionMeta } from '@contember/bindx';
|
|
14
14
|
import type { ColumnTypeDef } from './columnTypes.js';
|
|
15
15
|
import { type ColumnLeafProps } from './columnLeaf.js';
|
|
16
16
|
export interface RelationColumnConfig {
|
|
@@ -38,6 +38,8 @@ export interface RelationColumnProps<TEntity, TSelected> {
|
|
|
38
38
|
name?: string;
|
|
39
39
|
header?: React.ReactNode;
|
|
40
40
|
filter?: boolean;
|
|
41
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to no related row picked. */
|
|
42
|
+
filterInitialArtifact?: RelationFilterArtifact;
|
|
41
43
|
/** Register the relation without showing a column. */
|
|
42
44
|
virtual?: boolean;
|
|
43
45
|
renderCellWrapper?: (content: React.ReactNode, item: EntityAccessor<object>) => React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRelationColumn.d.ts","sourceRoot":"","sources":["../src/createRelationColumn.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAiB,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"createRelationColumn.d.ts","sourceRoot":"","sources":["../src/createRelationColumn.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAA;A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AC,MAAM,EAAE,OAAO,CAAC,KAAK,eAAe,CAAA;CAC9D;AAMD,eAAO,MAAM,gBAAgB,EAAE,kBAS9B,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,kBAgB/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectDataView.d.ts","sourceRoot":"","sources":["../../src/select/SelectDataView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAQ,KAAK,YAAY,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AAClH,OAAO,KAAK,EACX,cAAc,EAGd,cAAc,EAEd,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"SelectDataView.d.ts","sourceRoot":"","sources":["../../src/select/SelectDataView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAQ,KAAK,YAAY,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AAClH,OAAO,KAAK,EACX,cAAc,EAGd,cAAc,EAEd,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAehD,MAAM,WAAW,mBAAmB;IACnC,oDAAoD;IACpD,QAAQ,EAAE,SAAS,CAAA;IACnB,yEAAyE;IACzE,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,SAAS,CAAA;IACrD,gCAAgC;IAChC,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,MAAM,EAAE,CAAA;IAC/D,yBAAyB;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;IACxD,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAID,iBAAS,kBAAkB,CAAC,EAC3B,QAAQ,EACR,SAAS,EAAE,gBAAgB,EAC3B,UAAU,EACV,cAAc,EACd,MAAM,EAAE,YAAY,EACpB,YAAiB,GACjB,EAAE,mBAAmB,GAAG,YAAY,GAAG,IAAI,CA4K3C;AAED,eAAO,MAAM,cAAc,EAA0C,OAAO,kBAAkB,CAAA"}
|
|
@@ -15,12 +15,18 @@ export interface RegisteredFilter {
|
|
|
15
15
|
export type FilterArtifactUpdate = FilterArtifact | ((current: FilterArtifact | undefined) => FilterArtifact | undefined);
|
|
16
16
|
export interface FilteringState {
|
|
17
17
|
readonly filters: ReadonlyMap<string, RegisteredFilter>;
|
|
18
|
+
/** The filter's current artifact: the stored one, else its initial artifact. `undefined` only for an unregistered filter. */
|
|
18
19
|
getArtifact(name: string): FilterArtifact | undefined;
|
|
19
20
|
/** An updater sees the live artifact, not a render snapshot; returning `undefined` resets the filter to its default. */
|
|
20
21
|
setArtifact(name: string, artifact: FilterArtifactUpdate): void;
|
|
21
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Replaces the whole artifact record at once — for restoring a saved filter preset.
|
|
24
|
+
* A registered filter the record does not name reads as its initial artifact.
|
|
25
|
+
*/
|
|
22
26
|
setAllArtifacts(artifacts: Record<string, FilterArtifact>): void;
|
|
27
|
+
/** Clears one filter: sets it to its handler's default (inactive) artifact. */
|
|
23
28
|
resetFilter(name: string): void;
|
|
29
|
+
/** Puts every filter back where it starts: its initial artifact, else the handler default. */
|
|
24
30
|
resetAll(): void;
|
|
25
31
|
readonly hasActiveFilters: boolean;
|
|
26
32
|
readonly resolvedWhere: Record<string, unknown> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDataViewState.d.ts","sourceRoot":"","sources":["../src/useDataViewState.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,QAAQ,EACR,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAO3E,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC/C,QAAQ,EAAE,cAAc,CAAA;CACxB;AAED,uEAAuE;AACvE,MAAM,MAAM,oBAAoB,GAC7B,cAAc,GACd,CAAC,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,KAAK,cAAc,GAAG,SAAS,CAAC,CAAA;AAExE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IACvD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAA;IACrD,wHAAwH;IACxH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAA;IAC/D
|
|
1
|
+
{"version":3,"file":"useDataViewState.d.ts","sourceRoot":"","sources":["../src/useDataViewState.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,QAAQ,EACR,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;A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CAAC,OAAO,GAAE,mBAAwB,GAAG,oBAAoB,CAiCzF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PagingStateResult } from './useDataViewState.js';
|
|
2
|
+
export interface PagingTotalSource {
|
|
3
|
+
/** Total reported by the data source, or null when it reports none. */
|
|
4
|
+
readonly countedTotal: number | null;
|
|
5
|
+
/** Identifies the counted row set (the filter); bounds learned for another row set are dropped. */
|
|
6
|
+
readonly countKey: string;
|
|
7
|
+
/** Whether the loaded rows answer the current query: filter, order, limit and offset. */
|
|
8
|
+
readonly isPageCurrent: boolean;
|
|
9
|
+
readonly pageItemCount: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Feeds the paging state its total: the counted total when the data source reports one,
|
|
13
|
+
* otherwise the total the loaded pages prove. Only a page that answers the current query counts.
|
|
14
|
+
*
|
|
15
|
+
* A page shorter than the limit ends the list. An empty page past offset 0 only bounds the total
|
|
16
|
+
* from above, so the grid bisects between the bounds, one page per query, until a page ends the list.
|
|
17
|
+
*/
|
|
18
|
+
export declare function usePagingTotalCount(paging: PagingStateResult, source: PagingTotalSource): void;
|
|
19
|
+
//# sourceMappingURL=usePagingTotalCount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePagingTotalCount.d.ts","sourceRoot":"","sources":["../src/usePagingTotalCount.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAE9D,MAAM,WAAW,iBAAiB;IACjC,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,mGAAmG;IACnG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,yFAAyF;IACzF,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC9B;AAqBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI,CA4B9F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/bindx-dataview",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.53",
|
|
4
4
|
"description": "Headless DataGrid and DataView components for bindx",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"react": ">=18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@contember/bindx": "0.1.
|
|
19
|
-
"@contember/bindx-react": "0.1.
|
|
18
|
+
"@contember/bindx": "0.1.53",
|
|
19
|
+
"@contember/bindx-react": "0.1.53",
|
|
20
20
|
"@radix-ui/primitive": "^1.1.3",
|
|
21
21
|
"@radix-ui/react-slot": "^1.2.4"
|
|
22
22
|
},
|
package/src/DataGrid.tsx
CHANGED
|
@@ -24,6 +24,7 @@ import { useDataViewKey } from './DataViewKeyProvider.js'
|
|
|
24
24
|
import { DataViewProvider, type DataViewContextValue, type DataViewLoaderState } from './DataViewContext.js'
|
|
25
25
|
import { useDataGridSetup, QUERY_FILTER_NAME } from './useDataGridSetup.js'
|
|
26
26
|
import { useListFetchAllData } from './useListFetchAllData.js'
|
|
27
|
+
import { usePagingTotalCount } from './usePagingTotalCount.js'
|
|
27
28
|
|
|
28
29
|
export { QUERY_FILTER_NAME }
|
|
29
30
|
|
|
@@ -128,17 +129,13 @@ function DataGridImpl<TRoleMap extends Record<string, object>>({
|
|
|
128
129
|
}
|
|
129
130
|
}, [result.$status])
|
|
130
131
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
} else if (result.$status === 'ready' && setup.paging.queryLimit !== undefined && setup.paging.queryOffset !== undefined && itemCount < setup.paging.queryLimit) {
|
|
139
|
-
setup.paging.setTotalCount(setup.paging.queryOffset + itemCount)
|
|
140
|
-
}
|
|
141
|
-
}, [totalCount, result.$status, itemCount, setup.paging.queryLimit, setup.paging.queryOffset, setup.paging.setTotalCount])
|
|
132
|
+
const countKey = useMemo(() => JSON.stringify(setup.combinedFilter ?? {}), [setup.combinedFilter])
|
|
133
|
+
usePagingTotalCount(setup.paging, {
|
|
134
|
+
countedTotal: totalCount,
|
|
135
|
+
countKey,
|
|
136
|
+
isPageCurrent: result.$status === 'ready' && !result.$isRefetching,
|
|
137
|
+
pageItemCount: itemCount,
|
|
138
|
+
})
|
|
142
139
|
|
|
143
140
|
// ---- Reload ----
|
|
144
141
|
const [, setReloadCounter] = useState(0)
|
package/src/HasManyDataGrid.tsx
CHANGED
|
@@ -42,6 +42,7 @@ import { useDataViewKey } from './DataViewKeyProvider.js'
|
|
|
42
42
|
import { DataViewProvider, type DataViewContextValue, type DataViewFetchAllData, type DataViewLoaderState } from './DataViewContext.js'
|
|
43
43
|
import { useDataGridSetup } from './useDataGridSetup.js'
|
|
44
44
|
import { buildHasManyRelationQuery, extractHasManyRelationRows } from './hasManyRelationQuery.js'
|
|
45
|
+
import { usePagingTotalCount } from './usePagingTotalCount.js'
|
|
45
46
|
|
|
46
47
|
// ============================================================================
|
|
47
48
|
// Props
|
|
@@ -80,6 +81,8 @@ interface ListState {
|
|
|
80
81
|
status: 'loading' | 'error' | 'ready'
|
|
81
82
|
items: Array<{ id: string; data: object }>
|
|
82
83
|
totalCount?: number
|
|
84
|
+
/** The query options the items were loaded for. */
|
|
85
|
+
optionsKey?: string
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
const INITIAL_LIST_STATE: ListState = { status: 'loading', items: [] }
|
|
@@ -185,18 +188,19 @@ function HasManyDataGridImpl<TEntity extends object>({
|
|
|
185
188
|
|
|
186
189
|
const relation = extractHasManyRelationRows(result.data, { alias, fieldName })
|
|
187
190
|
if (!relation) {
|
|
188
|
-
setListState({ status: 'ready', items: [] })
|
|
191
|
+
setListState({ status: 'ready', items: [], optionsKey })
|
|
189
192
|
return
|
|
190
193
|
}
|
|
191
194
|
|
|
192
|
-
|
|
195
|
+
store.indexServerResponse(targetEntityType, relation.rows, setup.selection, schemaRegistry)
|
|
196
|
+
const items = relation.rows.map(data => ({ id: getRowId(targetEntityType, data), data: store.resolveServerOccurrence(data) }))
|
|
193
197
|
store.batchNotifications(() => {
|
|
194
198
|
for (const item of items) {
|
|
195
199
|
dispatcher.dispatch(setEntityData(targetEntityType, item.id, item.data, true))
|
|
196
200
|
}
|
|
197
201
|
})
|
|
198
202
|
|
|
199
|
-
setListState({ status: 'ready', items, totalCount: relation.totalCount })
|
|
203
|
+
setListState({ status: 'ready', items, totalCount: relation.totalCount, optionsKey })
|
|
200
204
|
} catch (error) {
|
|
201
205
|
if (abortController.signal.aborted) return
|
|
202
206
|
setListState({ status: 'error', items: [] })
|
|
@@ -208,7 +212,7 @@ function HasManyDataGridImpl<TEntity extends object>({
|
|
|
208
212
|
return () => {
|
|
209
213
|
abortController.abort()
|
|
210
214
|
}
|
|
211
|
-
}, [parentEntityType, parentEntityId, fieldName, targetEntityType, optionsKey, setup.selection, batcher, dispatcher, store])
|
|
215
|
+
}, [parentEntityType, parentEntityId, fieldName, targetEntityType, optionsKey, setup.selection, batcher, dispatcher, store, schemaRegistry])
|
|
212
216
|
|
|
213
217
|
// ---- Build items from state ----
|
|
214
218
|
const items = useMemo((): EntityAccessor<TEntity>[] => {
|
|
@@ -238,14 +242,16 @@ function HasManyDataGridImpl<TEntity extends object>({
|
|
|
238
242
|
}
|
|
239
243
|
}, [listState.status])
|
|
240
244
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
245
|
+
const countKey = useMemo(
|
|
246
|
+
() => JSON.stringify([parentEntityType, parentEntityId, fieldName, setup.combinedFilter ?? {}]),
|
|
247
|
+
[parentEntityType, parentEntityId, fieldName, setup.combinedFilter],
|
|
248
|
+
)
|
|
249
|
+
usePagingTotalCount(setup.paging, {
|
|
250
|
+
countedTotal: listState.totalCount ?? null,
|
|
251
|
+
countKey,
|
|
252
|
+
isPageCurrent: listState.status === 'ready' && listState.optionsKey === optionsKey,
|
|
253
|
+
pageItemCount: itemCount,
|
|
254
|
+
})
|
|
249
255
|
|
|
250
256
|
// ---- Reload ----
|
|
251
257
|
const [, setReloadCounter] = useState(0)
|
package/src/columnLeaf.ts
CHANGED
|
@@ -35,6 +35,11 @@ export interface ColumnLeafProps {
|
|
|
35
35
|
readonly sortingField: string | null
|
|
36
36
|
readonly filterName: string | null
|
|
37
37
|
readonly filterHandler: FilterHandler<FilterArtifact> | undefined
|
|
38
|
+
/**
|
|
39
|
+
* Where the filter starts when nothing is stored for it. Defaults to the
|
|
40
|
+
* handler's (inactive) default artifact.
|
|
41
|
+
*/
|
|
42
|
+
readonly filterInitialArtifact?: FilterArtifact
|
|
38
43
|
readonly isTextSearchable: boolean
|
|
39
44
|
/**
|
|
40
45
|
* The leaf exists only to register its field — for full-text search, or to
|
package/src/columns.tsx
CHANGED
|
@@ -99,9 +99,15 @@ interface EnumExtraProps<T extends string> {
|
|
|
99
99
|
options: readonly T[] | Record<T, ReactNode>
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
export interface DataGridEnumColumnProps<T extends string> extends DataGridScalarColumnPropsBase<T>, EnumExtraProps<NoInfer<T>> {
|
|
102
|
+
export interface DataGridEnumColumnProps<T extends string> extends DataGridScalarColumnPropsBase<T>, EnumExtraProps<NoInfer<T>> {
|
|
103
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to no value picked. */
|
|
104
|
+
filterInitialArtifact?: EnumFilterArtifact<NoInfer<T>>
|
|
105
|
+
}
|
|
103
106
|
|
|
104
|
-
export interface DataGridEnumListColumnProps<T extends string> extends DataGridScalarColumnPropsBase<T>, EnumExtraProps<NoInfer<T>> {
|
|
107
|
+
export interface DataGridEnumListColumnProps<T extends string> extends DataGridScalarColumnPropsBase<T>, EnumExtraProps<NoInfer<T>> {
|
|
108
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to no value picked. */
|
|
109
|
+
filterInitialArtifact?: EnumListFilterArtifact<NoInfer<T>>
|
|
110
|
+
}
|
|
105
111
|
|
|
106
112
|
// ============================================================================
|
|
107
113
|
// Scalar Columns via createColumn()
|
|
@@ -233,6 +239,8 @@ export interface DataGridColumnProps<T> {
|
|
|
233
239
|
sortable?: boolean
|
|
234
240
|
filter?: boolean
|
|
235
241
|
filterHandler?: FilterHandler<FilterArtifact>
|
|
242
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to the handler's inactive artifact. */
|
|
243
|
+
filterInitialArtifact?: FilterArtifact
|
|
236
244
|
/** Register the field without showing a column (e.g. to make it full-text searchable). */
|
|
237
245
|
virtual?: boolean
|
|
238
246
|
children?: (value: T | null, accessor: EntityAccessor<object>) => React.ReactNode
|
|
@@ -262,6 +270,7 @@ export const DataGridColumn = Object.assign(
|
|
|
262
270
|
filterHandler: filterEnabled && fieldName
|
|
263
271
|
? (customHandler ?? textColumnDef.createFilterHandler(fieldName) as FilterHandler<FilterArtifact>)
|
|
264
272
|
: undefined,
|
|
273
|
+
filterInitialArtifact: props['filterInitialArtifact'] as FilterArtifact | undefined,
|
|
265
274
|
isTextSearchable: false,
|
|
266
275
|
header,
|
|
267
276
|
renderCell: (accessor: EntityAccessor<object>) => {
|
package/src/createColumn.ts
CHANGED
|
@@ -43,13 +43,15 @@ export interface CreateColumnConfig<TValue, TFilterArtifact extends FilterArtifa
|
|
|
43
43
|
// Column Component Props
|
|
44
44
|
// ============================================================================
|
|
45
45
|
|
|
46
|
-
export interface ColumnComponentProps<TValue = unknown> {
|
|
46
|
+
export interface ColumnComponentProps<TValue = unknown, TFilterArtifact extends FilterArtifact = FilterArtifact> {
|
|
47
47
|
field: FieldRef<TValue>
|
|
48
48
|
/** Column identity. Defaults to the bound field name — pass it when two columns bind one field. */
|
|
49
49
|
name?: string
|
|
50
50
|
header?: React.ReactNode
|
|
51
51
|
sortable?: boolean
|
|
52
52
|
filter?: boolean
|
|
53
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to the handler's inactive artifact. */
|
|
54
|
+
filterInitialArtifact?: TFilterArtifact
|
|
53
55
|
/** Register the field without showing a column (e.g. to make it full-text searchable). */
|
|
54
56
|
virtual?: boolean
|
|
55
57
|
children?: (value: TValue | null, accessor: EntityAccessor<object>) => React.ReactNode
|
|
@@ -59,8 +61,12 @@ export interface ColumnComponentProps<TValue = unknown> {
|
|
|
59
61
|
// Factory
|
|
60
62
|
// ============================================================================
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
/**
|
|
65
|
+
* `TFilterArtifact` defaults to `never`: a column whose artifact type is not known takes no
|
|
66
|
+
* `filterInitialArtifact`, and every column `createColumn` builds is assignable to it.
|
|
67
|
+
*/
|
|
68
|
+
export interface ColumnComponent<TExtraProps = object, TFilterArtifact extends FilterArtifact = never> {
|
|
69
|
+
<T>(props: ColumnComponentProps<T, TFilterArtifact> & TExtraProps): null
|
|
64
70
|
staticRender: (props: Record<string, unknown>) => React.ReactNode
|
|
65
71
|
}
|
|
66
72
|
|
|
@@ -119,6 +125,7 @@ export function createColumnStaticRender<TValue, TFilterArtifact extends FilterA
|
|
|
119
125
|
filterHandler: filterEnabled && fieldName
|
|
120
126
|
? columnType.createFilterHandler(fieldName) as FilterHandler<FilterArtifact>
|
|
121
127
|
: undefined,
|
|
128
|
+
filterInitialArtifact: props['filterInitialArtifact'] as FilterArtifact | undefined,
|
|
122
129
|
isTextSearchable: columnType.isTextSearchable,
|
|
123
130
|
columnType: columnType.name as ColumnLeafProps['columnType'],
|
|
124
131
|
enumName,
|
|
@@ -140,10 +147,10 @@ export function createColumnStaticRender<TValue, TFilterArtifact extends FilterA
|
|
|
140
147
|
export function createColumn<TValue, TFilterArtifact extends FilterArtifact, TExtraProps = object>(
|
|
141
148
|
columnType: ColumnTypeDef<TValue, TFilterArtifact>,
|
|
142
149
|
config: CreateColumnConfig<TValue, TFilterArtifact>,
|
|
143
|
-
): ColumnComponent<TExtraProps> {
|
|
144
|
-
function Column(_props: ColumnComponentProps<unknown> & TExtraProps): null {
|
|
150
|
+
): ColumnComponent<TExtraProps, TFilterArtifact> {
|
|
151
|
+
function Column(_props: ColumnComponentProps<unknown, TFilterArtifact> & TExtraProps): null {
|
|
145
152
|
return null
|
|
146
153
|
}
|
|
147
154
|
Column.staticRender = createColumnStaticRender(columnType, config)
|
|
148
|
-
return Column as ColumnComponent<TExtraProps>
|
|
155
|
+
return Column as ColumnComponent<TExtraProps, TFilterArtifact>
|
|
149
156
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import React from 'react'
|
|
14
|
-
import type { FieldRef, FilterArtifact, FilterHandler, EntityAccessor, SelectionMeta } from '@contember/bindx'
|
|
14
|
+
import type { FieldRef, FilterArtifact, FilterHandler, EntityAccessor, RelationFilterArtifact, SelectionMeta } from '@contember/bindx'
|
|
15
15
|
import { SelectionScope } from '@contember/bindx'
|
|
16
16
|
import { createCollectorProxy, collectSelection as collectJsxSelection, SCOPE_REF } from '@contember/bindx-react'
|
|
17
17
|
import type { ColumnTypeDef } from './columnTypes.js'
|
|
@@ -64,6 +64,8 @@ export interface RelationColumnProps<TEntity, TSelected> {
|
|
|
64
64
|
name?: string
|
|
65
65
|
header?: React.ReactNode
|
|
66
66
|
filter?: boolean
|
|
67
|
+
/** Where the column's filter starts when nothing is stored for it. Defaults to no related row picked. */
|
|
68
|
+
filterInitialArtifact?: RelationFilterArtifact
|
|
67
69
|
/** Register the relation without showing a column. */
|
|
68
70
|
virtual?: boolean
|
|
69
71
|
renderCellWrapper?: (content: React.ReactNode, item: EntityAccessor<object>) => React.ReactNode
|
|
@@ -162,6 +164,7 @@ export function createRelationColumn<TFilterArtifact extends FilterArtifact>(
|
|
|
162
164
|
filterHandler: filterName
|
|
163
165
|
? columnType.createFilterHandler(fieldName!) as FilterHandler<FilterArtifact>
|
|
164
166
|
: undefined,
|
|
167
|
+
filterInitialArtifact: props['filterInitialArtifact'] as FilterArtifact | undefined,
|
|
165
168
|
isTextSearchable: false,
|
|
166
169
|
columnType: columnType.name as ColumnLeafProps['columnType'],
|
|
167
170
|
relatedEntityName,
|
|
@@ -46,6 +46,7 @@ import { useSelectOptions } from './selectContext.js'
|
|
|
46
46
|
import { DataViewProvider, type DataViewContextValue, type DataViewLoaderState } from '../DataViewContext.js'
|
|
47
47
|
import { useFilteringState, useSortingState, usePagingState, useSelectionState } from '../useDataViewState.js'
|
|
48
48
|
import { useListFetchAllData } from '../useListFetchAllData.js'
|
|
49
|
+
import { usePagingTotalCount } from '../usePagingTotalCount.js'
|
|
49
50
|
|
|
50
51
|
export interface SelectDataViewProps {
|
|
51
52
|
/** Children rendered inside the DataView context */
|
|
@@ -185,15 +186,13 @@ function SelectDataViewImpl({
|
|
|
185
186
|
}
|
|
186
187
|
}, [result.$status])
|
|
187
188
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
}, [totalCount, result.$status, itemCount, paging.queryLimit, paging.queryOffset, paging.setTotalCount])
|
|
189
|
+
const countKey = useMemo(() => JSON.stringify(combinedFilter ?? {}), [combinedFilter])
|
|
190
|
+
usePagingTotalCount(paging, {
|
|
191
|
+
countedTotal: totalCount,
|
|
192
|
+
countKey,
|
|
193
|
+
isPageCurrent: result.$status === 'ready' && !result.$isRefetching,
|
|
194
|
+
pageItemCount: itemCount,
|
|
195
|
+
})
|
|
197
196
|
|
|
198
197
|
// ---- Reload ----
|
|
199
198
|
const [, setReloadCounter] = useState(0)
|
package/src/useDataGridSetup.ts
CHANGED
|
@@ -199,12 +199,12 @@ export function useDataGridSetup<TEntity extends object>({
|
|
|
199
199
|
}, [entityType, schemaRegistry, children, layouts])
|
|
200
200
|
|
|
201
201
|
// ---- Phase 2: State management ----
|
|
202
|
-
const filterDefs = useMemo((): ReadonlyMap<string, { handler: FilterHandler<FilterArtifact
|
|
203
|
-
const map = new Map<string, { handler: FilterHandler<FilterArtifact
|
|
202
|
+
const filterDefs = useMemo((): ReadonlyMap<string, { handler: FilterHandler<FilterArtifact>; initialArtifact?: FilterArtifact }> => {
|
|
203
|
+
const map = new Map<string, { handler: FilterHandler<FilterArtifact>; initialArtifact?: FilterArtifact }>()
|
|
204
204
|
const textFieldPaths: string[] = []
|
|
205
205
|
for (const col of columns) {
|
|
206
206
|
if (col.filterName && col.filterHandler) {
|
|
207
|
-
map.set(col.filterName, { handler: col.filterHandler })
|
|
207
|
+
map.set(col.filterName, { handler: col.filterHandler, initialArtifact: col.filterInitialArtifact })
|
|
208
208
|
}
|
|
209
209
|
if (col.isTextSearchable && col.fieldName) {
|
|
210
210
|
textFieldPaths.push(col.fieldName)
|
package/src/useDataViewState.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* for persisting state across navigations.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { useState, useCallback, useMemo } from 'react'
|
|
8
|
+
import { useState, useCallback, useEffect, useMemo } from 'react'
|
|
9
9
|
import type {
|
|
10
10
|
FilterHandler,
|
|
11
11
|
FilterArtifact,
|
|
@@ -40,12 +40,18 @@ export type FilterArtifactUpdate =
|
|
|
40
40
|
|
|
41
41
|
export interface FilteringState {
|
|
42
42
|
readonly filters: ReadonlyMap<string, RegisteredFilter>
|
|
43
|
+
/** The filter's current artifact: the stored one, else its initial artifact. `undefined` only for an unregistered filter. */
|
|
43
44
|
getArtifact(name: string): FilterArtifact | undefined
|
|
44
45
|
/** An updater sees the live artifact, not a render snapshot; returning `undefined` resets the filter to its default. */
|
|
45
46
|
setArtifact(name: string, artifact: FilterArtifactUpdate): void
|
|
46
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Replaces the whole artifact record at once — for restoring a saved filter preset.
|
|
49
|
+
* A registered filter the record does not name reads as its initial artifact.
|
|
50
|
+
*/
|
|
47
51
|
setAllArtifacts(artifacts: Record<string, FilterArtifact>): void
|
|
52
|
+
/** Clears one filter: sets it to its handler's default (inactive) artifact. */
|
|
48
53
|
resetFilter(name: string): void
|
|
54
|
+
/** Puts every filter back where it starts: its initial artifact, else the handler default. */
|
|
49
55
|
resetAll(): void
|
|
50
56
|
readonly hasActiveFilters: boolean
|
|
51
57
|
readonly resolvedWhere: Record<string, unknown> | undefined
|
|
@@ -62,7 +68,7 @@ export interface UseFilteringOptions {
|
|
|
62
68
|
export function useFilteringState(options: UseFilteringOptions): FilteringState {
|
|
63
69
|
const { filters: filterDefs, stateStorage = 'null', storageKey = 'dataview' } = options
|
|
64
70
|
|
|
65
|
-
const
|
|
71
|
+
const initialArtifacts = useMemo((): Record<string, FilterArtifact> => {
|
|
66
72
|
const result: Record<string, FilterArtifact> = {}
|
|
67
73
|
for (const [name, def] of filterDefs) {
|
|
68
74
|
result[name] = def.initialArtifact ?? def.handler.defaultArtifact()
|
|
@@ -70,10 +76,18 @@ export function useFilteringState(options: UseFilteringOptions): FilteringState
|
|
|
70
76
|
return result
|
|
71
77
|
}, [filterDefs])
|
|
72
78
|
|
|
73
|
-
const [
|
|
79
|
+
const [storedArtifacts, setArtifacts] = useStoredState<Record<string, FilterArtifact>>(
|
|
74
80
|
stateStorage,
|
|
75
81
|
[storageKey, 'filters'],
|
|
76
|
-
(stored) => stored ??
|
|
82
|
+
(stored) => stored ?? initialArtifacts,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
// A registered filter the record does not name (a record stored before the filter
|
|
86
|
+
// existed, or a restored preset that omits it) is where it would start with nothing
|
|
87
|
+
// stored. Every view below reads this one record, so the UI and the query agree.
|
|
88
|
+
const artifacts = useMemo(
|
|
89
|
+
(): Record<string, FilterArtifact> => ({ ...initialArtifacts, ...storedArtifacts }),
|
|
90
|
+
[initialArtifacts, storedArtifacts],
|
|
77
91
|
)
|
|
78
92
|
|
|
79
93
|
const getArtifact = useCallback(
|
|
@@ -85,12 +99,12 @@ export function useFilteringState(options: UseFilteringOptions): FilteringState
|
|
|
85
99
|
const setArtifact = useCallback(
|
|
86
100
|
(name: string, artifact: FilterArtifactUpdate): void => {
|
|
87
101
|
setArtifacts(current => {
|
|
88
|
-
const next = typeof artifact === 'function' ? artifact(current[name]) : artifact
|
|
102
|
+
const next = typeof artifact === 'function' ? artifact(current[name] ?? initialArtifacts[name]) : artifact
|
|
89
103
|
const resolved = next ?? filterDefs.get(name)?.handler.defaultArtifact()
|
|
90
104
|
return resolved === undefined ? current : { ...current, [name]: resolved }
|
|
91
105
|
})
|
|
92
106
|
},
|
|
93
|
-
[filterDefs, setArtifacts],
|
|
107
|
+
[filterDefs, initialArtifacts, setArtifacts],
|
|
94
108
|
)
|
|
95
109
|
|
|
96
110
|
const resetFilter = useCallback(
|
|
@@ -103,8 +117,8 @@ export function useFilteringState(options: UseFilteringOptions): FilteringState
|
|
|
103
117
|
)
|
|
104
118
|
|
|
105
119
|
const resetAll = useCallback((): void => {
|
|
106
|
-
setArtifacts(
|
|
107
|
-
}, [
|
|
120
|
+
setArtifacts(initialArtifacts)
|
|
121
|
+
}, [initialArtifacts, setArtifacts])
|
|
108
122
|
|
|
109
123
|
const hasActiveFilters = useMemo((): boolean => {
|
|
110
124
|
for (const [name, def] of filterDefs) {
|
|
@@ -135,6 +149,7 @@ export function useFilteringState(options: UseFilteringOptions): FilteringState
|
|
|
135
149
|
map.set(name, {
|
|
136
150
|
name,
|
|
137
151
|
handler: def.handler,
|
|
152
|
+
// Stored JSON is not validated, so a `null` entry falls back to the handler default.
|
|
138
153
|
artifact: artifacts[name] ?? def.handler.defaultArtifact(),
|
|
139
154
|
})
|
|
140
155
|
}
|
|
@@ -304,7 +319,7 @@ export function usePagingState(options: UsePagingOptions = {}): PagingStateResul
|
|
|
304
319
|
storageKey = 'dataview',
|
|
305
320
|
} = options
|
|
306
321
|
|
|
307
|
-
const [
|
|
322
|
+
const [requestedPageIndex, setPageIndex] = useStoredState<number>(
|
|
308
323
|
currentPageStateStorage,
|
|
309
324
|
[storageKey, 'pageIndex'],
|
|
310
325
|
(stored) => stored ?? 0,
|
|
@@ -316,11 +331,6 @@ export function usePagingState(options: UsePagingOptions = {}): PagingStateResul
|
|
|
316
331
|
(stored) => stored ?? initialItemsPerPage,
|
|
317
332
|
)
|
|
318
333
|
|
|
319
|
-
const state = useMemo((): PagingState => ({
|
|
320
|
-
pageIndex,
|
|
321
|
-
itemsPerPage: itemsPerPage ?? 0,
|
|
322
|
-
}), [pageIndex, itemsPerPage])
|
|
323
|
-
|
|
324
334
|
const [totalCount, setTotalCount] = useState<number | null>(null)
|
|
325
335
|
const [refreshCounter, setRefreshCounter] = useState(0)
|
|
326
336
|
|
|
@@ -329,6 +339,19 @@ export function usePagingState(options: UsePagingOptions = {}): PagingStateResul
|
|
|
329
339
|
return Math.max(1, Math.ceil(totalCount / itemsPerPage))
|
|
330
340
|
}, [totalCount, itemsPerPage])
|
|
331
341
|
|
|
342
|
+
// A requested page past the end (the total shrank, or a stored index outlived its result set)
|
|
343
|
+
// reads as the last page, so the query offset never points past the rows.
|
|
344
|
+
const pageIndex = totalPages === null ? requestedPageIndex : Math.min(requestedPageIndex, totalPages - 1)
|
|
345
|
+
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
if (pageIndex !== requestedPageIndex) setPageIndex(pageIndex)
|
|
348
|
+
}, [pageIndex, requestedPageIndex, setPageIndex])
|
|
349
|
+
|
|
350
|
+
const state = useMemo((): PagingState => ({
|
|
351
|
+
pageIndex,
|
|
352
|
+
itemsPerPage: itemsPerPage ?? 0,
|
|
353
|
+
}), [pageIndex, itemsPerPage])
|
|
354
|
+
|
|
332
355
|
const info: PagingInfo = useMemo(() => ({
|
|
333
356
|
totalCount,
|
|
334
357
|
totalPages,
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
import type { PagingStateResult } from './useDataViewState.js'
|
|
3
|
+
|
|
4
|
+
export interface PagingTotalSource {
|
|
5
|
+
/** Total reported by the data source, or null when it reports none. */
|
|
6
|
+
readonly countedTotal: number | null
|
|
7
|
+
/** Identifies the counted row set (the filter); bounds learned for another row set are dropped. */
|
|
8
|
+
readonly countKey: string
|
|
9
|
+
/** Whether the loaded rows answer the current query: filter, order, limit and offset. */
|
|
10
|
+
readonly isPageCurrent: boolean
|
|
11
|
+
readonly pageItemCount: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** What the loaded pages prove about the total: `atLeast <= total <= atMost`. */
|
|
15
|
+
interface TotalBounds {
|
|
16
|
+
readonly atLeast: number
|
|
17
|
+
readonly atMost: number | null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface LoadedPage {
|
|
21
|
+
readonly offset: number
|
|
22
|
+
readonly limit: number
|
|
23
|
+
readonly itemCount: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type PageOutcome =
|
|
27
|
+
| { readonly type: 'total'; readonly totalCount: number }
|
|
28
|
+
| { readonly type: 'probe'; readonly bounds: TotalBounds; readonly pageIndex: number }
|
|
29
|
+
| { readonly type: 'unknown'; readonly bounds: TotalBounds }
|
|
30
|
+
|
|
31
|
+
const NO_BOUNDS: TotalBounds = { atLeast: 0, atMost: null }
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Feeds the paging state its total: the counted total when the data source reports one,
|
|
35
|
+
* otherwise the total the loaded pages prove. Only a page that answers the current query counts.
|
|
36
|
+
*
|
|
37
|
+
* A page shorter than the limit ends the list. An empty page past offset 0 only bounds the total
|
|
38
|
+
* from above, so the grid bisects between the bounds, one page per query, until a page ends the list.
|
|
39
|
+
*/
|
|
40
|
+
export function usePagingTotalCount(paging: PagingStateResult, source: PagingTotalSource): void {
|
|
41
|
+
const { setTotalCount, goTo, queryLimit, queryOffset } = paging
|
|
42
|
+
const { countedTotal, countKey, isPageCurrent, pageItemCount } = source
|
|
43
|
+
const boundsRef = useRef<{ countKey: string; bounds: TotalBounds }>({ countKey, bounds: NO_BOUNDS })
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (boundsRef.current.countKey !== countKey || countedTotal !== null) {
|
|
47
|
+
boundsRef.current = { countKey, bounds: NO_BOUNDS }
|
|
48
|
+
}
|
|
49
|
+
if (countedTotal !== null) {
|
|
50
|
+
setTotalCount(countedTotal)
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
if (!isPageCurrent || queryLimit === undefined || queryOffset === undefined) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const outcome = inferTotalFromPage(boundsRef.current.bounds, { offset: queryOffset, limit: queryLimit, itemCount: pageItemCount })
|
|
58
|
+
if (outcome.type === 'total') {
|
|
59
|
+
boundsRef.current = { countKey, bounds: NO_BOUNDS }
|
|
60
|
+
setTotalCount(outcome.totalCount)
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
boundsRef.current = { countKey, bounds: outcome.bounds }
|
|
64
|
+
if (outcome.type === 'probe') {
|
|
65
|
+
goTo(outcome.pageIndex)
|
|
66
|
+
}
|
|
67
|
+
}, [countedTotal, countKey, isPageCurrent, pageItemCount, queryLimit, queryOffset, setTotalCount, goTo])
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function inferTotalFromPage(bounds: TotalBounds, { offset, limit, itemCount }: LoadedPage): PageOutcome {
|
|
71
|
+
const isEmptyPastStart = itemCount === 0 && offset > 0
|
|
72
|
+
if (itemCount < limit && !isEmptyPastStart) {
|
|
73
|
+
return { type: 'total', totalCount: offset + itemCount }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const narrowed: TotalBounds = isEmptyPastStart
|
|
77
|
+
? { atLeast: bounds.atLeast, atMost: Math.min(bounds.atMost ?? offset, offset) }
|
|
78
|
+
: { atLeast: Math.max(bounds.atLeast, offset + limit), atMost: bounds.atMost }
|
|
79
|
+
|
|
80
|
+
if (narrowed.atMost === null) {
|
|
81
|
+
return { type: 'unknown', bounds: narrowed }
|
|
82
|
+
}
|
|
83
|
+
if (narrowed.atLeast >= narrowed.atMost) {
|
|
84
|
+
return { type: 'total', totalCount: narrowed.atMost }
|
|
85
|
+
}
|
|
86
|
+
// The page holding the middle row starts below `atMost` and ends above `atLeast`,
|
|
87
|
+
// so whatever it returns halves the interval.
|
|
88
|
+
const middleRow = Math.floor((narrowed.atLeast + narrowed.atMost) / 2)
|
|
89
|
+
return { type: 'probe', bounds: narrowed, pageIndex: Math.floor(middleRow / limit) }
|
|
90
|
+
}
|