@xh/hoist 75.0.0-SNAPSHOT.1753458616250 → 75.0.0-SNAPSHOT.1753474244586
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/appcontainer/AppContainerModel.ts +3 -4
- package/build/types/cmp/grid/Grid.d.ts +1 -1
- package/build/types/utils/js/LangUtils.d.ts +10 -0
- package/cmp/grid/Grid.ts +2 -5
- package/cmp/grid/GridModel.ts +22 -7
- package/core/impl/InstallServices.ts +2 -3
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/utils/js/LangUtils.ts +13 -0
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
TrackService,
|
|
41
41
|
WebSocketService
|
|
42
42
|
} from '@xh/hoist/svc';
|
|
43
|
-
import {checkMinVersion, throwIf} from '@xh/hoist/utils/js';
|
|
43
|
+
import {checkMinVersion, createSingleton, throwIf} from '@xh/hoist/utils/js';
|
|
44
44
|
import {compact, isEmpty} from 'lodash';
|
|
45
45
|
import {AboutDialogModel} from './AboutDialogModel';
|
|
46
46
|
import {BannerSourceModel} from './BannerSourceModel';
|
|
@@ -197,7 +197,7 @@ export class AppContainerModel extends HoistModel {
|
|
|
197
197
|
|
|
198
198
|
// Check auth, locking out, or showing login if possible
|
|
199
199
|
this.setAppState('AUTHENTICATING');
|
|
200
|
-
XH.authModel =
|
|
200
|
+
XH.authModel = createSingleton(this.appSpec.authModelClass);
|
|
201
201
|
const isAuthenticated = await XH.authModel.completeAuthAsync();
|
|
202
202
|
if (!isAuthenticated) {
|
|
203
203
|
throwIf(
|
|
@@ -287,8 +287,7 @@ export class AppContainerModel extends HoistModel {
|
|
|
287
287
|
await wait(XH.isDevelopmentMode ? 300 : 1);
|
|
288
288
|
|
|
289
289
|
this.setAppState('INITIALIZING_APP');
|
|
290
|
-
|
|
291
|
-
this.appModel = modelClass.instance = new modelClass();
|
|
290
|
+
this.appModel = createSingleton(this.appSpec.modelClass);
|
|
292
291
|
await this.appModel.initAsync();
|
|
293
292
|
this.startRouter();
|
|
294
293
|
this.startOptionsDialog();
|
|
@@ -119,7 +119,7 @@ export declare class GridLocalModel extends HoistModel {
|
|
|
119
119
|
nodeA: any;
|
|
120
120
|
nodeB: any;
|
|
121
121
|
}) => number;
|
|
122
|
-
doWithPreservedState({
|
|
122
|
+
doWithPreservedState({ filters }: PlainObject, fn: any): void;
|
|
123
123
|
readFilterState(): import("@ag-grid-community/core").FilterModel;
|
|
124
124
|
writeFilterState(filterState: any): void;
|
|
125
125
|
processCellForClipboard: ({ value, node, column }: ProcessCellForExportParams) => any;
|
|
@@ -44,6 +44,16 @@ export declare function warnIf(condition: any, message: any): void;
|
|
|
44
44
|
* Log an error to the console if a condition evaluates as truthy.
|
|
45
45
|
*/
|
|
46
46
|
export declare function errorIf(condition: any, message: any): void;
|
|
47
|
+
/**
|
|
48
|
+
* Instantiate a singleton object of a class, and place a reference to the created
|
|
49
|
+
* object in a static property on the class.
|
|
50
|
+
*
|
|
51
|
+
* This pattern is useful to allow gaining typed references to the singleton via import
|
|
52
|
+
* and is used for creating the singleton HoistServices, AuthModel, and AppModel.
|
|
53
|
+
*
|
|
54
|
+
* @param clazz -- Class (i.e. Constructor) of singleton object to be created.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createSingleton<T>(clazz: new () => T): T;
|
|
47
57
|
export interface APIWarnOptions {
|
|
48
58
|
/**
|
|
49
59
|
* If provided and undefined, this method will be a no-op.
|
package/cmp/grid/Grid.ts
CHANGED
|
@@ -767,12 +767,9 @@ export class GridLocalModel extends HoistModel {
|
|
|
767
767
|
return gridModel.groupSortFn(nodeA.key, nodeB.key, nodeA.field, {gridModel, nodeA, nodeB});
|
|
768
768
|
};
|
|
769
769
|
|
|
770
|
-
doWithPreservedState({
|
|
771
|
-
const
|
|
772
|
-
expandState = expansion ? agGridModel.getExpandState() : null,
|
|
773
|
-
filterState = filters ? this.readFilterState() : null;
|
|
770
|
+
doWithPreservedState({filters}: PlainObject, fn) {
|
|
771
|
+
const filterState = filters ? this.readFilterState() : null;
|
|
774
772
|
fn();
|
|
775
|
-
if (expandState) agGridModel.setExpandState(expandState);
|
|
776
773
|
if (filterState) this.writeFilterState(filterState);
|
|
777
774
|
}
|
|
778
775
|
|
package/cmp/grid/GridModel.ts
CHANGED
|
@@ -645,13 +645,6 @@ export class GridModel extends HoistModel {
|
|
|
645
645
|
debounce: 500
|
|
646
646
|
});
|
|
647
647
|
|
|
648
|
-
this.addReaction({
|
|
649
|
-
track: () => [this.expandLevel, this.isReady],
|
|
650
|
-
run: () => {
|
|
651
|
-
this.agApi?.setGridOption('groupDefaultExpanded', this.expandLevel);
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
|
|
655
648
|
if (!isEmpty(rest)) {
|
|
656
649
|
const keys = keysIn(rest);
|
|
657
650
|
throw XH.exception(
|
|
@@ -1043,6 +1036,28 @@ export class GridModel extends HoistModel {
|
|
|
1043
1036
|
@action
|
|
1044
1037
|
expandToLevel(level: number) {
|
|
1045
1038
|
this.expandLevel = level;
|
|
1039
|
+
|
|
1040
|
+
// 0) Not rendered, we are done.
|
|
1041
|
+
const {agApi} = this;
|
|
1042
|
+
if (!agApi) return;
|
|
1043
|
+
|
|
1044
|
+
// 1) Update rendered grid.
|
|
1045
|
+
if (agApi.getGridOption('groupDefaultExpanded') != level) {
|
|
1046
|
+
// If the ag default is *not* set to this level just set it. This somewhat
|
|
1047
|
+
// mysteriously (but efficiently) changes the currently rendered rows as well.
|
|
1048
|
+
agApi.setGridOption('groupDefaultExpanded', level);
|
|
1049
|
+
} else if (level == 0 || level >= this.maxDepth) {
|
|
1050
|
+
// otherwise api methods available.
|
|
1051
|
+
level == 0 ? agApi.collapseAll() : agApi.expandAll();
|
|
1052
|
+
} else {
|
|
1053
|
+
// Otherwise, *toggle* the default.
|
|
1054
|
+
// Surprisingly, this appears to be the only efficient way to do the bulk operation.
|
|
1055
|
+
agApi.setGridOption('groupDefaultExpanded', 0);
|
|
1056
|
+
agApi.setGridOption('groupDefaultExpanded', level);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
// 2) Finally, be sure to update our state snapshot.
|
|
1060
|
+
this.noteAgExpandStateChange();
|
|
1046
1061
|
}
|
|
1047
1062
|
|
|
1048
1063
|
/**
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import {HoistService, HoistServiceClass, Some, XH} from '@xh/hoist/core';
|
|
8
8
|
import {instanceManager} from '@xh/hoist/core/impl/InstanceManager';
|
|
9
|
-
import {throwIf} from '@xh/hoist/utils/js';
|
|
9
|
+
import {createSingleton, throwIf} from '@xh/hoist/utils/js';
|
|
10
10
|
import {camelCase, castArray} from 'lodash';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -30,7 +30,7 @@ export async function installServicesAsync(serviceClasses: Some<HoistServiceClas
|
|
|
30
30
|
const notSvc = serviceClasses.find((it: any) => !it.isHoistService);
|
|
31
31
|
throwIf(notSvc, `Cannot initialize ${notSvc?.name} - does not extend HoistService`);
|
|
32
32
|
|
|
33
|
-
const svcs = serviceClasses.map(
|
|
33
|
+
const svcs = serviceClasses.map(c => createSingleton(c));
|
|
34
34
|
await initServicesInternalAsync(svcs);
|
|
35
35
|
|
|
36
36
|
svcs.forEach(svc => {
|
|
@@ -43,7 +43,6 @@ export async function installServicesAsync(serviceClasses: Some<HoistServiceClas
|
|
|
43
43
|
install the same service twice.`
|
|
44
44
|
);
|
|
45
45
|
XH[name] = svc;
|
|
46
|
-
(clazz as any).instance = svc;
|
|
47
46
|
instanceManager.registerService(svc);
|
|
48
47
|
});
|
|
49
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "75.0.0-SNAPSHOT.
|
|
3
|
+
"version": "75.0.0-SNAPSHOT.1753474244586",
|
|
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",
|