@xh/hoist 80.0.0-SNAPSHOT.1768415875152 → 80.0.0-SNAPSHOT.1768600489622
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/build/types/cmp/grid/Grid.d.ts +1 -1
- package/build/types/cmp/grid/GridModel.d.ts +8 -10
- package/build/types/cmp/grid/Types.d.ts +22 -12
- package/build/types/cmp/grid/columns/ColumnGroup.d.ts +3 -3
- package/build/types/cmp/grid/filter/GridFilterModel.d.ts +3 -3
- package/build/types/cmp/grid/impl/Utils.d.ts +3 -3
- package/build/types/cmp/tab/TabContainerModel.d.ts +1 -1
- package/build/types/data/Field.d.ts +2 -0
- package/build/types/data/cube/Cube.d.ts +7 -6
- package/cmp/grid/GridModel.ts +88 -85
- package/cmp/grid/Types.ts +27 -13
- package/cmp/grid/columns/ColumnGroup.ts +3 -7
- package/cmp/grid/filter/GridFilterModel.ts +12 -6
- package/cmp/grid/impl/Utils.ts +3 -5
- package/cmp/tab/TabContainerModel.ts +2 -2
- package/data/Field.ts +5 -0
- package/data/cube/Cube.ts +11 -7
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/cmp/grid/Types.ts
CHANGED
|
@@ -7,23 +7,23 @@
|
|
|
7
7
|
|
|
8
8
|
import {GridFilterFieldSpecConfig} from '@xh/hoist/cmp/grid/filter/GridFilterFieldSpec';
|
|
9
9
|
import {HSide, PersistOptions, Some} from '@xh/hoist/core';
|
|
10
|
-
import {Store, StoreRecord
|
|
11
|
-
import {ReactElement, ReactNode} from 'react';
|
|
12
|
-
import {Column} from './columns/Column';
|
|
13
|
-
import {ColumnGroup} from './columns/ColumnGroup';
|
|
14
|
-
import {GridModel} from './GridModel';
|
|
10
|
+
import {FilterBindTarget, FilterValueSource, Store, StoreRecord} from '@xh/hoist/data';
|
|
15
11
|
|
|
16
12
|
import type {
|
|
17
13
|
CellClassParams,
|
|
14
|
+
CustomCellEditorProps,
|
|
18
15
|
HeaderClassParams,
|
|
19
16
|
HeaderValueGetterParams,
|
|
20
17
|
ICellRendererParams,
|
|
21
18
|
IRowNode,
|
|
22
19
|
ITooltipParams,
|
|
23
20
|
RowClassParams,
|
|
24
|
-
ValueSetterParams
|
|
25
|
-
CustomCellEditorProps
|
|
21
|
+
ValueSetterParams
|
|
26
22
|
} from '@xh/hoist/kit/ag-grid';
|
|
23
|
+
import type {ReactElement, ReactNode} from 'react';
|
|
24
|
+
import type {Column, ColumnSpec} from './columns/Column';
|
|
25
|
+
import type {ColumnGroup, ColumnGroupSpec} from './columns/ColumnGroup';
|
|
26
|
+
import type {GridModel} from './GridModel';
|
|
27
27
|
|
|
28
28
|
export interface ColumnState {
|
|
29
29
|
colId: string;
|
|
@@ -87,10 +87,11 @@ export interface GridModelPersistOptions extends PersistOptions {
|
|
|
87
87
|
|
|
88
88
|
export interface GridFilterModelConfig {
|
|
89
89
|
/**
|
|
90
|
-
* Store
|
|
91
|
-
*
|
|
90
|
+
* Target (typically a {@link Store} or Cube {@link View}) to be filtered as column filters
|
|
91
|
+
* are applied and used as a source for unique values displayed in the filtering UI when
|
|
92
|
+
* applicable. Defaulted to the gridModel's store.
|
|
92
93
|
*/
|
|
93
|
-
bind?:
|
|
94
|
+
bind?: GridFilterBindTarget;
|
|
94
95
|
|
|
95
96
|
/**
|
|
96
97
|
* True to update filters immediately after each change made in the column-based filter UI.
|
|
@@ -100,8 +101,8 @@ export interface GridFilterModelConfig {
|
|
|
100
101
|
|
|
101
102
|
/**
|
|
102
103
|
* Specifies the fields this model supports for filtering. Should be configs for
|
|
103
|
-
* {@link GridFilterFieldSpec}, string names to match with Fields in bound Store/View, or
|
|
104
|
-
* entirely to indicate that all fields should be filter-enabled.
|
|
104
|
+
* {@link GridFilterFieldSpec}, string names to match with Fields in bound Store/View, or
|
|
105
|
+
* omitted entirely to indicate that all fields should be filter-enabled.
|
|
105
106
|
*/
|
|
106
107
|
fieldSpecs?: Array<string | GridFilterFieldSpecConfig>;
|
|
107
108
|
|
|
@@ -109,6 +110,12 @@ export interface GridFilterModelConfig {
|
|
|
109
110
|
fieldSpecDefaults?: Omit<GridFilterFieldSpecConfig, 'field'>;
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
/**
|
|
114
|
+
* {@link GridFilterModel} currently accepts a single `bind` target that also provides available
|
|
115
|
+
* values. Note that both `Store` and `View` satisfy this intersection.
|
|
116
|
+
*/
|
|
117
|
+
export interface GridFilterBindTarget extends FilterBindTarget, FilterValueSource {}
|
|
118
|
+
|
|
112
119
|
/**
|
|
113
120
|
* Renderer for a group row
|
|
114
121
|
* @param context - The group renderer params from ag-Grid
|
|
@@ -142,6 +149,13 @@ export interface ColChooserConfig {
|
|
|
142
149
|
height?: string | number;
|
|
143
150
|
}
|
|
144
151
|
|
|
152
|
+
export type ColumnOrGroup = Column | ColumnGroup;
|
|
153
|
+
export type ColumnOrGroupSpec = ColumnSpec | ColumnGroupSpec;
|
|
154
|
+
|
|
155
|
+
export function isColumnSpec(spec: ColumnOrGroupSpec): spec is ColumnSpec {
|
|
156
|
+
return !('children' in spec);
|
|
157
|
+
}
|
|
158
|
+
|
|
145
159
|
/**
|
|
146
160
|
* Sort comparator function for a grid column. Note that this comparator will also be called if
|
|
147
161
|
* agGrid-provided column filtering is enabled: it is used to sort values shown for set filter
|
|
@@ -248,7 +262,7 @@ export type ColumnTooltipFn<T = any> = (
|
|
|
248
262
|
* @returns CSS class(es) to use.
|
|
249
263
|
*/
|
|
250
264
|
export type ColumnHeaderClassFn = (context: {
|
|
251
|
-
column:
|
|
265
|
+
column: ColumnOrGroup;
|
|
252
266
|
gridModel: GridModel;
|
|
253
267
|
agParams: HeaderClassParams;
|
|
254
268
|
}) => Some<string>;
|
|
@@ -13,7 +13,7 @@ import {throwIf, withDefault} from '@xh/hoist/utils/js';
|
|
|
13
13
|
import {clone, isEmpty, isFunction, isString, keysIn} from 'lodash';
|
|
14
14
|
import {ReactNode} from 'react';
|
|
15
15
|
import {GridModel} from '../GridModel';
|
|
16
|
-
import {ColumnHeaderClassFn, ColumnHeaderNameFn} from '../Types';
|
|
16
|
+
import {ColumnHeaderClassFn, ColumnHeaderNameFn, ColumnOrGroup} from '../Types';
|
|
17
17
|
import {Column, ColumnSpec} from './Column';
|
|
18
18
|
|
|
19
19
|
export interface ColumnGroupSpec {
|
|
@@ -51,7 +51,7 @@ export interface ColumnGroupSpec {
|
|
|
51
51
|
* Provided to GridModels as plain configuration objects.
|
|
52
52
|
*/
|
|
53
53
|
export class ColumnGroup {
|
|
54
|
-
readonly children:
|
|
54
|
+
readonly children: ColumnOrGroup[];
|
|
55
55
|
readonly gridModel: GridModel;
|
|
56
56
|
readonly groupId: string;
|
|
57
57
|
readonly headerName: ReactNode | ColumnHeaderNameFn;
|
|
@@ -79,11 +79,7 @@ export class ColumnGroup {
|
|
|
79
79
|
*
|
|
80
80
|
* @internal
|
|
81
81
|
*/
|
|
82
|
-
constructor(
|
|
83
|
-
config: ColumnGroupSpec,
|
|
84
|
-
gridModel: GridModel,
|
|
85
|
-
children: Array<Column | ColumnGroup>
|
|
86
|
-
) {
|
|
82
|
+
constructor(config: ColumnGroupSpec, gridModel: GridModel, children: ColumnOrGroup[]) {
|
|
87
83
|
const {
|
|
88
84
|
children: childrenSpecs,
|
|
89
85
|
groupId,
|
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
GridFilterBindTarget,
|
|
10
|
+
GridFilterFieldSpec,
|
|
11
|
+
GridFilterFieldSpecConfig,
|
|
12
|
+
GridFilterModelConfig
|
|
13
|
+
} from '@xh/hoist/cmp/grid';
|
|
9
14
|
import {HoistModel, managed} from '@xh/hoist/core';
|
|
10
15
|
import {
|
|
11
16
|
CompoundFilter,
|
|
@@ -13,8 +18,6 @@ import {
|
|
|
13
18
|
Filter,
|
|
14
19
|
FilterLike,
|
|
15
20
|
flattenFilter,
|
|
16
|
-
Store,
|
|
17
|
-
View,
|
|
18
21
|
withFilterByField,
|
|
19
22
|
withFilterByTypes
|
|
20
23
|
} from '@xh/hoist/data';
|
|
@@ -31,7 +34,7 @@ export class GridFilterModel extends HoistModel {
|
|
|
31
34
|
override xhImpl = true;
|
|
32
35
|
|
|
33
36
|
gridModel: GridModel;
|
|
34
|
-
bind:
|
|
37
|
+
bind: GridFilterBindTarget;
|
|
35
38
|
@bindable commitOnChange: boolean;
|
|
36
39
|
@managed fieldSpecs: GridFilterFieldSpec[] = [];
|
|
37
40
|
|
|
@@ -66,7 +69,7 @@ export class GridFilterModel extends HoistModel {
|
|
|
66
69
|
setColumnFilters(field: string, filter: FilterLike) {
|
|
67
70
|
// If current bound filter is a CompoundFilter for a single column, wrap it
|
|
68
71
|
// in an 'AND' CompoundFilter so new columns get 'ANDed' alongside it.
|
|
69
|
-
let currFilter = this.filter
|
|
72
|
+
let currFilter: FilterLike = this.filter;
|
|
70
73
|
if (currFilter instanceof CompoundFilter && currFilter.field) {
|
|
71
74
|
currFilter = {filters: [currFilter], op: 'AND'};
|
|
72
75
|
}
|
|
@@ -144,7 +147,10 @@ export class GridFilterModel extends HoistModel {
|
|
|
144
147
|
//--------------------------------
|
|
145
148
|
// Implementation
|
|
146
149
|
//--------------------------------
|
|
147
|
-
private parseFieldSpecs(
|
|
150
|
+
private parseFieldSpecs(
|
|
151
|
+
specs: Array<string | GridFilterFieldSpecConfig>,
|
|
152
|
+
fieldSpecDefaults: Omit<GridFilterFieldSpecConfig, 'field'>
|
|
153
|
+
) {
|
|
148
154
|
const {bind} = this;
|
|
149
155
|
|
|
150
156
|
// If no specs provided, include all source fields.
|
package/cmp/grid/impl/Utils.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {Column,
|
|
8
|
-
import {HeaderClassParams} from '@xh/hoist/kit/ag-grid';
|
|
7
|
+
import {Column, ColumnOrGroup, ColumnRenderer, GroupRowRenderer} from '@xh/hoist/cmp/grid';
|
|
8
|
+
import type {HeaderClassParams} from '@xh/hoist/kit/ag-grid';
|
|
9
9
|
import {logWarn} from '@xh/hoist/utils/js';
|
|
10
10
|
import {castArray, isFunction} from 'lodash';
|
|
11
11
|
|
|
@@ -31,9 +31,7 @@ export function managedRenderer<T extends ColumnRenderer | GroupRowRenderer>(
|
|
|
31
31
|
*
|
|
32
32
|
* @internal
|
|
33
33
|
*/
|
|
34
|
-
export function getAgHeaderClassFn(
|
|
35
|
-
column: Column | ColumnGroup
|
|
36
|
-
): (params: HeaderClassParams) => string[] {
|
|
34
|
+
export function getAgHeaderClassFn(column: ColumnOrGroup): (params: HeaderClassParams) => string[] {
|
|
37
35
|
const {headerClass, headerAlign, gridModel} = column;
|
|
38
36
|
|
|
39
37
|
return agParams => {
|
|
@@ -123,7 +123,7 @@ export class TabContainerModel extends HoistModel {
|
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* @param config - TabContainer configuration.
|
|
126
|
-
* @param
|
|
126
|
+
* @param depth - Depth in hierarchy of nested TabContainerModels. Not for application use.
|
|
127
127
|
*/
|
|
128
128
|
constructor(
|
|
129
129
|
{
|
|
@@ -138,7 +138,7 @@ export class TabContainerModel extends HoistModel {
|
|
|
138
138
|
xhImpl = false,
|
|
139
139
|
switcher = {mode: 'static'}
|
|
140
140
|
}: TabContainerConfig,
|
|
141
|
-
depth = 0
|
|
141
|
+
depth: number = 0
|
|
142
142
|
) {
|
|
143
143
|
super();
|
|
144
144
|
makeObservable(this);
|
package/data/Field.ts
CHANGED
|
@@ -181,3 +181,8 @@ export function genDisplayName(fieldName: string): string {
|
|
|
181
181
|
// Handle common cases of "id" -> "ID" and "foo_id" -> "Foo ID" (vs "Foo Id")
|
|
182
182
|
return startCase(fieldName).replace(/(^| )Id\b/g, '$1ID');
|
|
183
183
|
}
|
|
184
|
+
|
|
185
|
+
/** Convenience function to return the name of a field from one of several common inputs. */
|
|
186
|
+
export function getFieldName(field: string | Field | FieldSpec): string {
|
|
187
|
+
return field ? (isString(field) ? field : field.name) : null;
|
|
188
|
+
}
|
package/data/cube/Cube.ts
CHANGED
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
import {HoistBase, managed, PlainObject, Some} from '@xh/hoist/core';
|
|
9
9
|
import {action, makeObservable, observable} from '@xh/hoist/mobx';
|
|
10
10
|
import {forEachAsync} from '@xh/hoist/utils/async';
|
|
11
|
-
import {
|
|
12
|
-
import {ViewRowData} from './ViewRowData';
|
|
13
|
-
import {Query, QueryConfig} from './Query';
|
|
14
|
-
import {View} from './View';
|
|
11
|
+
import {defaultsDeep, isEmpty} from 'lodash';
|
|
15
12
|
import {Store, StoreRecordIdSpec, StoreTransaction} from '../Store';
|
|
16
13
|
import {StoreRecord} from '../StoreRecord';
|
|
14
|
+
import {BucketSpec} from './BucketSpec';
|
|
15
|
+
import {CubeField, CubeFieldSpec} from './CubeField';
|
|
16
|
+
import {Query, QueryConfig} from './Query';
|
|
17
17
|
import {AggregateRow} from './row/AggregateRow';
|
|
18
|
-
import {BucketRow} from './row/BucketRow';
|
|
19
18
|
import {BaseRow} from './row/BaseRow';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
19
|
+
import {BucketRow} from './row/BucketRow';
|
|
20
|
+
import {View} from './View';
|
|
21
|
+
import {ViewRowData} from './ViewRowData';
|
|
22
22
|
|
|
23
23
|
export interface CubeConfig {
|
|
24
24
|
fields: CubeField[] | CubeFieldSpec[];
|
|
@@ -160,6 +160,10 @@ export class Cube extends HoistBase {
|
|
|
160
160
|
return this._connectedViews.size;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
getField(name: string): CubeField {
|
|
164
|
+
return this.store.getField(name) as CubeField;
|
|
165
|
+
}
|
|
166
|
+
|
|
163
167
|
//------------------
|
|
164
168
|
// Querying API
|
|
165
169
|
//-----------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "80.0.0-SNAPSHOT.
|
|
3
|
+
"version": "80.0.0-SNAPSHOT.1768600489622",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|