@xh/hoist 73.0.0-SNAPSHOT.1738003189230 → 73.0.0-SNAPSHOT.1738073624805

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.
@@ -5,23 +5,41 @@
5
5
  * Copyright © 2025 Extremely Heavy Industries Inc.
6
6
  */
7
7
 
8
+ import {startCase} from 'lodash';
8
9
  import {toolbar, toolbarSep} from '@xh/hoist/desktop/cmp/toolbar';
9
10
  import {errorMessage} from '@xh/hoist/cmp/error';
10
- import {JsonBlobModel} from '@xh/hoist/admin/tabs/userData/jsonblob/JsonBlobModel';
11
- import {grid, gridCountLabel} from '@xh/hoist/cmp/grid';
11
+ import {grid, GridConfig, gridCountLabel} from '@xh/hoist/cmp/grid';
12
12
  import {a, box, filler, h4, hframe, label, li, span, ul, vbox} from '@xh/hoist/cmp/layout';
13
- import {hoistCmp, useLocalModel} from '@xh/hoist/core';
13
+ import {hoistCmp, SelectOption, useLocalModel} from '@xh/hoist/core';
14
14
  import {button} from '@xh/hoist/desktop/cmp/button';
15
- import {buttonGroupInput, jsonInput, textInput} from '@xh/hoist/desktop/cmp/input';
15
+ import {buttonGroupInput, jsonInput, select, textInput} from '@xh/hoist/desktop/cmp/input';
16
16
  import {panel} from '@xh/hoist/desktop/cmp/panel';
17
17
  import {Icon} from '@xh/hoist/icon';
18
18
  import {popover} from '@xh/hoist/kit/blueprint';
19
19
  import {clipboardButton} from '@xh/hoist/desktop/cmp/clipboard';
20
- import {startCase} from 'lodash';
21
-
22
20
  import {JsonSearchPanelImplModel} from './impl/JsonSearchPanelImplModel';
23
21
 
24
- export const [JsonSearchPanel, jsonSearchPanel] = hoistCmp.withFactory<JsonBlobModel>({
22
+ export interface JsonSearchPanelProps {
23
+ /** Url to endpoint for searching for matching JSON documents */
24
+ docSearchUrl: string;
25
+
26
+ /** Url to endpoint for listing matching JSON nodes */
27
+ matchingNodesUrl: string;
28
+
29
+ /**
30
+ * Config for GridModel used to display search results.
31
+ */
32
+ gridModelConfig: GridConfig;
33
+
34
+ /**
35
+ * Names of field(s) that can be used to group by.
36
+ */
37
+ groupByOptions: SelectOption[];
38
+ }
39
+
40
+ export const [JsonSearchPanel, jsonSearchPanel] = hoistCmp.withFactory({
41
+ displayName: 'JsonSearchPanel',
42
+
25
43
  render() {
26
44
  const impl = useLocalModel(JsonSearchPanelImplModel),
27
45
  {error} = impl;
@@ -80,6 +98,14 @@ const searchTbar = hoistCmp.factory<JsonSearchPanelImplModel>(({model}) => {
80
98
  pathField({model}),
81
99
  helpButton(),
82
100
  toolbarSep(),
101
+ span('Group by:'),
102
+ select({
103
+ bind: 'groupBy',
104
+ options: model.groupByOptions,
105
+ width: 160,
106
+ enableFilter: false
107
+ }),
108
+ toolbarSep(),
83
109
  gridCountLabel({
84
110
  gridModel: model.gridModel,
85
111
  unit: 'document'
@@ -6,8 +6,9 @@
6
6
  */
7
7
 
8
8
  import {GridModel} from '@xh/hoist/cmp/grid';
9
+ import {GroupingChooserModel} from '@xh/hoist/cmp/grouping';
9
10
  import {HoistModel, managed, TaskObserver, XH} from '@xh/hoist/core';
10
- import {bindable, makeObservable} from '@xh/hoist/mobx';
11
+ import {action, bindable, makeObservable, observable} from '@xh/hoist/mobx';
11
12
  import {isEmpty} from 'lodash';
12
13
 
13
14
  /**
@@ -17,9 +18,12 @@ export class JsonSearchPanelImplModel extends HoistModel {
17
18
  override xhImpl = true;
18
19
 
19
20
  @managed gridModel: GridModel;
21
+ @managed groupingChooserModel: GroupingChooserModel;
20
22
  @managed docLoadTask: TaskObserver = TaskObserver.trackLast();
21
23
  @managed nodeLoadTask: TaskObserver = TaskObserver.trackLast();
22
24
 
25
+ @observable groupBy: string = null;
26
+
23
27
  @bindable.ref error = null;
24
28
  @bindable path: string = '';
25
29
  @bindable readerContentType: 'document' | 'paths' | 'values' = 'values';
@@ -51,6 +55,10 @@ export class JsonSearchPanelImplModel extends HoistModel {
51
55
  return this.componentProps.gridModelConfig;
52
56
  }
53
57
 
58
+ get groupByOptions() {
59
+ return [...this.componentProps.groupByOptions, {value: null, label: 'None'}];
60
+ }
61
+
54
62
  constructor() {
55
63
  super();
56
64
  makeObservable(this);
@@ -138,4 +146,14 @@ export class JsonSearchPanelImplModel extends HoistModel {
138
146
  .replaceAll(/'?]\['?/g, '/')
139
147
  .replaceAll(/'?]$/g, '');
140
148
  }
149
+
150
+ @action
151
+ private setGroupBy(groupBy: string) {
152
+ this.groupBy = groupBy;
153
+
154
+ // Always select first when regrouping.
155
+ const groupByArr = groupBy ? groupBy.split(',') : [];
156
+ this.gridModel.setGroupBy(groupByArr);
157
+ this.gridModel.preSelectFirstAsync();
158
+ }
141
159
  }
@@ -34,14 +34,13 @@ export const jsonBlobPanel = hoistCmp.factory({
34
34
  })
35
35
  }),
36
36
  jsonSearchPanel({
37
- docSearchUrl: 'jsonBlobSearchAdmin/searchByJsonPath',
38
- matchingNodesUrl: 'jsonBlobSearchAdmin/getMatchingNodes',
37
+ docSearchUrl: 'jsonSearch/searchBlobs',
38
+ matchingNodesUrl: 'jsonSearch/getMatchingNodes',
39
39
  gridModelConfig: {
40
40
  sortBy: ['owner', 'name'],
41
41
  store: {
42
42
  idSpec: 'token'
43
43
  },
44
- groupBy: 'type',
45
44
  columns: [
46
45
  {
47
46
  field: {name: 'token', type: 'string'},
@@ -63,7 +62,8 @@ export const jsonBlobPanel = hoistCmp.factory({
63
62
  },
64
63
  {...Col.lastUpdated}
65
64
  ]
66
- }
65
+ },
66
+ groupByOptions: ['owner', 'type', 'name']
67
67
  }),
68
68
  differ({omit: !model.differModel})
69
69
  );
@@ -37,11 +37,10 @@ export const userPreferencePanel = hoistCmp.factory({
37
37
  mask: 'onLoad'
38
38
  }),
39
39
  jsonSearchPanel({
40
- docSearchUrl: 'preferenceJsonSearchAdmin/searchByJsonPath',
41
- matchingNodesUrl: 'preferenceJsonSearchAdmin/getMatchingNodes',
40
+ docSearchUrl: 'jsonSearch/searchUserPreferences',
41
+ matchingNodesUrl: 'jsonSearch/getMatchingNodes',
42
42
  gridModelConfig: {
43
43
  sortBy: ['name'],
44
- groupBy: 'groupName',
45
44
  columns: [
46
45
  {
47
46
  field: {name: 'owner', type: 'string'},
@@ -55,7 +54,8 @@ export const userPreferencePanel = hoistCmp.factory({
55
54
  },
56
55
  {...Col.lastUpdated}
57
56
  ]
58
- }
57
+ },
58
+ groupByOptions: ['owner', 'groupName', 'name']
59
59
  })
60
60
  );
61
61
  }
@@ -1,3 +1,18 @@
1
1
  /// <reference types="react" />
2
- import { JsonBlobModel } from '@xh/hoist/admin/tabs/userData/jsonblob/JsonBlobModel';
3
- export declare const JsonSearchPanel: import("react").FC<import("@xh/hoist/core").DefaultHoistProps<JsonBlobModel>>, jsonSearchPanel: import("@xh/hoist/core").ElementFactory<import("@xh/hoist/core").DefaultHoistProps<JsonBlobModel>>;
2
+ import { GridConfig } from '@xh/hoist/cmp/grid';
3
+ import { SelectOption } from '@xh/hoist/core';
4
+ export interface JsonSearchPanelProps {
5
+ /** Url to endpoint for searching for matching JSON documents */
6
+ docSearchUrl: string;
7
+ /** Url to endpoint for listing matching JSON nodes */
8
+ matchingNodesUrl: string;
9
+ /**
10
+ * Config for GridModel used to display search results.
11
+ */
12
+ gridModelConfig: GridConfig;
13
+ /**
14
+ * Names of field(s) that can be used to group by.
15
+ */
16
+ groupByOptions: SelectOption[];
17
+ }
18
+ export declare const JsonSearchPanel: import("react").FC<import("@xh/hoist/core").DefaultHoistProps<import("@xh/hoist/core").HoistModel>>, jsonSearchPanel: import("@xh/hoist/core").ElementFactory<import("@xh/hoist/core").DefaultHoistProps<import("@xh/hoist/core").HoistModel>>;
@@ -1,4 +1,5 @@
1
1
  import { GridModel } from '@xh/hoist/cmp/grid';
2
+ import { GroupingChooserModel } from '@xh/hoist/cmp/grouping';
2
3
  import { HoistModel, TaskObserver } from '@xh/hoist/core';
3
4
  /**
4
5
  * @internal
@@ -6,8 +7,10 @@ import { HoistModel, TaskObserver } from '@xh/hoist/core';
6
7
  export declare class JsonSearchPanelImplModel extends HoistModel {
7
8
  xhImpl: boolean;
8
9
  gridModel: GridModel;
10
+ groupingChooserModel: GroupingChooserModel;
9
11
  docLoadTask: TaskObserver;
10
12
  nodeLoadTask: TaskObserver;
13
+ groupBy: string;
11
14
  error: any;
12
15
  path: string;
13
16
  readerContentType: 'document' | 'paths' | 'values';
@@ -20,9 +23,11 @@ export declare class JsonSearchPanelImplModel extends HoistModel {
20
23
  get matchingNodesUrl(): string;
21
24
  get selectedRecord(): import("../../../data").StoreRecord;
22
25
  get gridModelConfig(): any;
26
+ get groupByOptions(): any[];
23
27
  constructor();
24
28
  onLinked(): void;
25
29
  loadJsonDocsAsync(): Promise<void>;
26
30
  private loadreaderContentTypeAsync;
27
31
  private convertToPath;
32
+ private setGroupBy;
28
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "73.0.0-SNAPSHOT.1738003189230",
3
+ "version": "73.0.0-SNAPSHOT.1738073624805",
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",