@xh/hoist 80.0.0-SNAPSHOT.1768517142984 → 80.0.0-SNAPSHOT.1768603318265
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/GridModel.d.ts +2 -4
- package/build/types/cmp/grid/Types.d.ts +6 -1
- package/build/types/data/Field.d.ts +2 -0
- package/build/types/data/Store.d.ts +2 -1
- package/build/types/data/cube/View.d.ts +2 -1
- package/cmp/grid/GridModel.ts +19 -40
- package/cmp/grid/Types.ts +6 -2
- package/data/Field.ts +5 -0
- package/data/Store.ts +5 -1
- package/data/cube/View.ts +5 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgGridModel } from '@xh/hoist/cmp/ag-grid';
|
|
2
2
|
import { Column, ColumnGroup, ColumnOrGroup, ColumnOrGroupSpec, ColumnSpec, GridAutosizeMode, GridFilterModelConfig, GridGroupSortFn, TreeStyle } from '@xh/hoist/cmp/grid';
|
|
3
3
|
import { GridFilterModel } from '@xh/hoist/cmp/grid/filter/GridFilterModel';
|
|
4
|
-
import { Awaitable, HoistModel, HSide, PlainObject, SizingMode, Some, TaskObserver, Thunkable, VSide } from '@xh/hoist/core';
|
|
4
|
+
import { Awaitable, HoistModel, HSide, LoadSpec, PlainObject, SizingMode, Some, TaskObserver, Thunkable, VSide } from '@xh/hoist/core';
|
|
5
5
|
import { Store, StoreConfig, StoreRecord, StoreRecordId, StoreRecordOrId, StoreSelectionConfig, StoreSelectionModel, StoreTransaction } from '@xh/hoist/data';
|
|
6
6
|
import { AgColumnState, CellClickedEvent, CellContextMenuEvent, CellDoubleClickedEvent, CellEditingStartedEvent, CellEditingStoppedEvent, RowClickedEvent, RowDoubleClickedEvent } from '@xh/hoist/kit/ag-grid';
|
|
7
7
|
import { ExportOptions } from '@xh/hoist/svc/GridExportService';
|
|
@@ -471,7 +471,7 @@ export declare class GridModel extends HoistModel {
|
|
|
471
471
|
* This method is a no-op if provided any sorters without a corresponding column.
|
|
472
472
|
*/
|
|
473
473
|
setSortBy(sorters: Some<GridSorterLike>): void;
|
|
474
|
-
doLoadAsync(loadSpec:
|
|
474
|
+
doLoadAsync(loadSpec: LoadSpec): Promise<any>;
|
|
475
475
|
/** Load the underlying store. */
|
|
476
476
|
loadData(rawData: any[], rawSummaryData?: Some<PlainObject>): void;
|
|
477
477
|
/** Update the underlying store. */
|
|
@@ -601,8 +601,6 @@ export declare class GridModel extends HoistModel {
|
|
|
601
601
|
private collectIds;
|
|
602
602
|
private formatValuesForExport;
|
|
603
603
|
private parseAndSetColumnsAndStore;
|
|
604
|
-
private validateStoreConfig;
|
|
605
|
-
private validateColConfigs;
|
|
606
604
|
private validateColumns;
|
|
607
605
|
private cleanColumnState;
|
|
608
606
|
private enhanceColConfigsFromStore;
|
|
@@ -76,7 +76,12 @@ export interface GridFilterModelConfig {
|
|
|
76
76
|
/** Default properties to be assigned to all fieldSpecs created by this model. */
|
|
77
77
|
fieldSpecDefaults?: Omit<GridFilterFieldSpecConfig, 'field'>;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
/**
|
|
80
|
+
* {@link GridFilterModel} currently accepts a single `bind` target that also provides available
|
|
81
|
+
* values. Note that both `Store` and `View` satisfy this intersection.
|
|
82
|
+
*/
|
|
83
|
+
export interface GridFilterBindTarget extends FilterBindTarget, FilterValueSource {
|
|
84
|
+
}
|
|
80
85
|
/**
|
|
81
86
|
* Renderer for a group row
|
|
82
87
|
* @param context - The group renderer params from ag-Grid
|
|
@@ -80,3 +80,5 @@ export type FieldType = (typeof FieldType)[keyof typeof FieldType];
|
|
|
80
80
|
* @returns fieldName transformed into user-facing / longer name for display.
|
|
81
81
|
*/
|
|
82
82
|
export declare function genDisplayName(fieldName: string): string;
|
|
83
|
+
/** Convenience function to return the name of a field from one of several common inputs. */
|
|
84
|
+
export declare function getFieldName(field: string | Field | FieldSpec): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GridFilterBindTarget } from '@xh/hoist/cmp/grid';
|
|
1
2
|
import { HoistBase, PlainObject, Some } from '@xh/hoist/core';
|
|
2
3
|
import { Field, FieldSpec, Filter, FilterBindTarget, FilterLike, FilterValueSource, StoreRecord, StoreRecordId, StoreRecordOrId, StoreValidationMessagesMap, StoreValidationResultsMap, ValidationResult } from '@xh/hoist/data';
|
|
3
4
|
import { StoreValidator } from '@xh/hoist/data/impl/StoreValidator';
|
|
@@ -124,7 +125,7 @@ export type StoreRecordIdSpec = string | ((data: PlainObject) => StoreRecordId);
|
|
|
124
125
|
/**
|
|
125
126
|
* A managed and observable set of local, in-memory Records.
|
|
126
127
|
*/
|
|
127
|
-
export declare class Store extends HoistBase implements FilterBindTarget, FilterValueSource {
|
|
128
|
+
export declare class Store extends HoistBase implements FilterBindTarget, FilterValueSource, GridFilterBindTarget {
|
|
128
129
|
static isStore(obj: unknown): obj is Store;
|
|
129
130
|
readonly isFilterValueSource = true;
|
|
130
131
|
fields: Field[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GridFilterBindTarget } from '@xh/hoist/cmp/grid';
|
|
1
2
|
import { HoistBase, PlainObject, Some } from '@xh/hoist/core';
|
|
2
3
|
import { Cube, CubeField, Filter, FilterBindTarget, FilterLike, FilterValueSource, Query, QueryConfig, Store, StoreChangeLog, StoreRecordId } from '@xh/hoist/data';
|
|
3
4
|
import { ViewRowData } from '@xh/hoist/data/cube/ViewRowData';
|
|
@@ -33,7 +34,7 @@ export interface DimensionValue {
|
|
|
33
34
|
* Primary interface for consuming grouped and aggregated data from the cube.
|
|
34
35
|
* Applications should create via the {@link Cube.createView} factory.
|
|
35
36
|
*/
|
|
36
|
-
export declare class View extends HoistBase implements FilterBindTarget, FilterValueSource {
|
|
37
|
+
export declare class View extends HoistBase implements FilterBindTarget, FilterValueSource, GridFilterBindTarget {
|
|
37
38
|
static isView(obj: unknown): obj is View;
|
|
38
39
|
readonly isFilterValueSource = true;
|
|
39
40
|
/** Query defining this View. Update via {@link updateQuery}. */
|
package/cmp/grid/GridModel.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
Awaitable,
|
|
26
26
|
HoistModel,
|
|
27
27
|
HSide,
|
|
28
|
+
LoadSpec,
|
|
28
29
|
managed,
|
|
29
30
|
PlainObject,
|
|
30
31
|
SizingMode,
|
|
@@ -37,6 +38,7 @@ import {
|
|
|
37
38
|
import {
|
|
38
39
|
Field,
|
|
39
40
|
FieldSpec,
|
|
41
|
+
getFieldName,
|
|
40
42
|
Store,
|
|
41
43
|
StoreConfig,
|
|
42
44
|
StoreRecord,
|
|
@@ -91,7 +93,6 @@ import {
|
|
|
91
93
|
isEmpty,
|
|
92
94
|
isFunction,
|
|
93
95
|
isNil,
|
|
94
|
-
isPlainObject,
|
|
95
96
|
isString,
|
|
96
97
|
isUndefined,
|
|
97
98
|
keysIn,
|
|
@@ -1150,7 +1151,7 @@ export class GridModel extends HoistModel {
|
|
|
1150
1151
|
this.sortBy = newSorters;
|
|
1151
1152
|
}
|
|
1152
1153
|
|
|
1153
|
-
override async doLoadAsync(loadSpec) {
|
|
1154
|
+
override async doLoadAsync(loadSpec: LoadSpec) {
|
|
1154
1155
|
// Delegate to any store that has load support
|
|
1155
1156
|
return (this.store as any).loadSupport?.loadAsync(loadSpec);
|
|
1156
1157
|
}
|
|
@@ -1172,7 +1173,6 @@ export class GridModel extends HoistModel {
|
|
|
1172
1173
|
|
|
1173
1174
|
@action
|
|
1174
1175
|
setColumns(colConfigs: ColumnOrGroupSpec[]) {
|
|
1175
|
-
this.validateColConfigs(colConfigs);
|
|
1176
1176
|
colConfigs = this.enhanceColConfigsFromStore(colConfigs);
|
|
1177
1177
|
|
|
1178
1178
|
const columns = compact(colConfigs.map(c => this.buildColumn(c)));
|
|
@@ -1614,9 +1614,7 @@ export class GridModel extends HoistModel {
|
|
|
1614
1614
|
if (this.isGroupSpec(config)) {
|
|
1615
1615
|
if (config.borders !== false) borderedGroup = config;
|
|
1616
1616
|
const children = compact(config.children.map(c => this.buildColumn(c, borderedGroup)));
|
|
1617
|
-
return !isEmpty(children)
|
|
1618
|
-
? new ColumnGroup(config as ColumnGroupSpec, this, children)
|
|
1619
|
-
: null;
|
|
1617
|
+
return !isEmpty(children) ? new ColumnGroup(config, this, children) : null;
|
|
1620
1618
|
}
|
|
1621
1619
|
|
|
1622
1620
|
if (borderedGroup) {
|
|
@@ -1694,45 +1692,26 @@ export class GridModel extends HoistModel {
|
|
|
1694
1692
|
// in this case GridModel should work out the required Store fields from column definitions.
|
|
1695
1693
|
private parseAndSetColumnsAndStore(
|
|
1696
1694
|
colConfigs: ColumnOrGroupSpec[],
|
|
1697
|
-
|
|
1695
|
+
storeOrConfig: Store | StoreConfig = {}
|
|
1698
1696
|
) {
|
|
1699
|
-
//
|
|
1700
|
-
this.
|
|
1701
|
-
this.validateColConfigs(colConfigs);
|
|
1697
|
+
// Enhance colConfigs with field-level metadata provided by store, if any.
|
|
1698
|
+
colConfigs = this.enhanceColConfigsFromStore(colConfigs, storeOrConfig);
|
|
1702
1699
|
|
|
1703
|
-
//
|
|
1704
|
-
colConfigs = this.enhanceColConfigsFromStore(colConfigs, store);
|
|
1705
|
-
|
|
1706
|
-
// 3) Create and set columns with (possibly) enhanced configs.
|
|
1700
|
+
// Create and set columns with (possibly) enhanced configs.
|
|
1707
1701
|
this.setColumns(colConfigs);
|
|
1708
1702
|
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
if (
|
|
1712
|
-
store =
|
|
1713
|
-
newStore = new Store({loadTreeData: this.treeMode, ...store});
|
|
1714
|
-
newStore.xhImpl = this.xhImpl;
|
|
1715
|
-
this.markManaged(newStore);
|
|
1703
|
+
// Set or create Store as needed.
|
|
1704
|
+
let store: Store;
|
|
1705
|
+
if (storeOrConfig instanceof Store) {
|
|
1706
|
+
store = storeOrConfig;
|
|
1716
1707
|
} else {
|
|
1717
|
-
|
|
1708
|
+
storeOrConfig = this.enhanceStoreConfigFromColumns(storeOrConfig);
|
|
1709
|
+
store = new Store({loadTreeData: this.treeMode, ...storeOrConfig});
|
|
1710
|
+
store.xhImpl = this.xhImpl;
|
|
1711
|
+
this.markManaged(store);
|
|
1718
1712
|
}
|
|
1719
1713
|
|
|
1720
|
-
this.store =
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
|
-
private validateStoreConfig(store: Store | StoreConfig) {
|
|
1724
|
-
throwIf(
|
|
1725
|
-
!(store instanceof Store || isPlainObject(store)),
|
|
1726
|
-
'GridModel.store config must be either an instance of a Store or a config to create one.'
|
|
1727
|
-
);
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
private validateColConfigs(colConfigs: ColumnOrGroupSpec[]) {
|
|
1731
|
-
throwIf(!isArray(colConfigs), 'GridModel.columns config must be an array.');
|
|
1732
|
-
throwIf(
|
|
1733
|
-
colConfigs.some(c => !isPlainObject(c)),
|
|
1734
|
-
'GridModel.columns config only accepts plain objects for Column or ColumnGroup configs.'
|
|
1735
|
-
);
|
|
1714
|
+
this.store = store;
|
|
1736
1715
|
}
|
|
1737
1716
|
|
|
1738
1717
|
private validateColumns(cols: ColumnOrGroup[]) {
|
|
@@ -1833,7 +1812,7 @@ export class GridModel extends HoistModel {
|
|
|
1833
1812
|
};
|
|
1834
1813
|
}
|
|
1835
1814
|
|
|
1836
|
-
const colFieldName =
|
|
1815
|
+
const colFieldName = getFieldName(col.field),
|
|
1837
1816
|
field = fieldsByName[colFieldName];
|
|
1838
1817
|
|
|
1839
1818
|
if (!field) return col;
|
|
@@ -1863,7 +1842,7 @@ export class GridModel extends HoistModel {
|
|
|
1863
1842
|
// config object, not an instance.
|
|
1864
1843
|
private enhanceStoreConfigFromColumns(storeConfig: StoreConfig) {
|
|
1865
1844
|
const fields = storeConfig.fields ?? [],
|
|
1866
|
-
storeFieldNames = fields.map(it => (
|
|
1845
|
+
storeFieldNames = fields.map(it => getFieldName(it)),
|
|
1867
1846
|
leafColsByFieldName = this.leafColsByFieldName();
|
|
1868
1847
|
|
|
1869
1848
|
const newFields: FieldSpec[] = [];
|
package/cmp/grid/Types.ts
CHANGED
|
@@ -110,7 +110,11 @@ export interface GridFilterModelConfig {
|
|
|
110
110
|
fieldSpecDefaults?: Omit<GridFilterFieldSpecConfig, 'field'>;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
|
|
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 {}
|
|
114
118
|
|
|
115
119
|
/**
|
|
116
120
|
* Renderer for a group row
|
|
@@ -149,7 +153,7 @@ export type ColumnOrGroup = Column | ColumnGroup;
|
|
|
149
153
|
export type ColumnOrGroupSpec = ColumnSpec | ColumnGroupSpec;
|
|
150
154
|
|
|
151
155
|
export function isColumnSpec(spec: ColumnOrGroupSpec): spec is ColumnSpec {
|
|
152
|
-
return !(
|
|
156
|
+
return !('children' in spec);
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
/**
|
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/Store.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type {GridFilterBindTarget} from '@xh/hoist/cmp/grid';
|
|
8
9
|
import {HoistBase, managed, PlainObject, Some, XH} from '@xh/hoist/core';
|
|
9
10
|
import {
|
|
10
11
|
Field,
|
|
@@ -191,7 +192,10 @@ export type StoreRecordIdSpec = string | ((data: PlainObject) => StoreRecordId);
|
|
|
191
192
|
/**
|
|
192
193
|
* A managed and observable set of local, in-memory Records.
|
|
193
194
|
*/
|
|
194
|
-
export class Store
|
|
195
|
+
export class Store
|
|
196
|
+
extends HoistBase
|
|
197
|
+
implements FilterBindTarget, FilterValueSource, GridFilterBindTarget
|
|
198
|
+
{
|
|
195
199
|
static isStore(obj: unknown): obj is Store {
|
|
196
200
|
return obj instanceof Store;
|
|
197
201
|
}
|
package/data/cube/View.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type {GridFilterBindTarget} from '@xh/hoist/cmp/grid';
|
|
8
9
|
import {HoistBase, PlainObject, Some} from '@xh/hoist/core';
|
|
9
10
|
import {
|
|
10
11
|
Cube,
|
|
@@ -66,7 +67,10 @@ export interface DimensionValue {
|
|
|
66
67
|
* Primary interface for consuming grouped and aggregated data from the cube.
|
|
67
68
|
* Applications should create via the {@link Cube.createView} factory.
|
|
68
69
|
*/
|
|
69
|
-
export class View
|
|
70
|
+
export class View
|
|
71
|
+
extends HoistBase
|
|
72
|
+
implements FilterBindTarget, FilterValueSource, GridFilterBindTarget
|
|
73
|
+
{
|
|
70
74
|
static isView(obj: unknown): obj is View {
|
|
71
75
|
return obj instanceof View;
|
|
72
76
|
}
|
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.1768603318265",
|
|
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",
|