@xh/hoist 73.0.0-SNAPSHOT.1747146913330 → 73.0.0-SNAPSHOT.1747155067044

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/CHANGELOG.md CHANGED
@@ -35,6 +35,12 @@
35
35
  allow the client to do a potentially interactive popup login during the session to re-establish
36
36
  the login. This is especially useful to allow recovery from expired or invalidated refresh
37
37
  tokens.
38
+ * New utility method `XH.openWindow()` for ensuring that new windows/tabs are opened without
39
+ an unintended `opener` relationship with the original window.
40
+ * Improvements to Grid columns `HeaderFilter` component:
41
+ * `GridFilterModel` `commitOnChage` now set to `false` by default
42
+ * Addition of ability to append terms to active filter **only** when `commitOnChage:false`
43
+ * Grid column header filtering functionality now similar to Excel on Windows
38
44
 
39
45
  ### 🐞 Bug Fixes
40
46
 
package/admin/AppModel.ts CHANGED
@@ -155,7 +155,8 @@ export class AppModel extends HoistAppModel {
155
155
 
156
156
  /** Open the primary business-facing application, typically 'app'. */
157
157
  openPrimaryApp() {
158
- window.open(`/${this.getPrimaryAppCode()}`);
158
+ const appCode = this.getPrimaryAppCode();
159
+ XH.openWindow(`/${appCode}`, appCode);
159
160
  }
160
161
 
161
162
  getPrimaryAppCode() {
@@ -60,7 +60,10 @@ export interface GridFilterModelConfig {
60
60
  * gridModel's store.
61
61
  */
62
62
  bind?: Store | View;
63
- /** True (default) to update filters immediately after each change made in the column-based filter UI.*/
63
+ /**
64
+ * True to update filters immediately after each change made in the column-based filter UI.
65
+ * Defaults to False.
66
+ */
64
67
  commitOnChange?: boolean;
65
68
  /**
66
69
  * Specifies the fields this model supports for filtering. Should be configs for
@@ -11,9 +11,8 @@ export interface StoreFilterFieldProps extends DefaultHoistProps {
11
11
  autoApply?: boolean;
12
12
  /**
13
13
  * Field on optional model to which this component should bind its raw (text) value to persist
14
- * across renders. Specify this field to control the state of this component directly or if
15
- * deliberately not connecting this component to a Store/GridModel. These are both advanced
16
- * use-cases - this prop is typically left unset.
14
+ * across renders. Specify this field to control the state of this component directly from a model.
15
+ * These are both advanced use-cases - this prop is typically left unset.
17
16
  */
18
17
  bind?: string;
19
18
  /** Names of field(s) to exclude from search. Cannot be used with `includeFields`. */
@@ -218,6 +218,14 @@ export declare class XHApi {
218
218
  * {@link reloadApp} instead.
219
219
  */
220
220
  refreshAppAsync(): Promise<void>;
221
+ /**
222
+ * Open a url in an external browser window/tab.
223
+ *
224
+ * Unlike a simple call to `open`, this method ensures the "opener" method on the
225
+ * new window is null. This ensures that the new page will not share sessionState with
226
+ * this page. See https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
227
+ */
228
+ openWindow(url: string, target?: string): void;
221
229
  /**
222
230
  * Flags for controlling experimental, hotfix, or otherwise provisional features.
223
231
  *
@@ -11,6 +11,7 @@ export declare class ValuesTabModel extends HoistModel {
11
11
  pendingValues: any[];
12
12
  /** Bound search term for `StoreFilterField` */
13
13
  filterText: string;
14
+ combineCurrentFilters: boolean;
14
15
  /** FieldFilter output by this model. */
15
16
  get filter(): FieldFilterSpec;
16
17
  get allVisibleRecsChecked(): boolean;
@@ -26,6 +27,8 @@ export declare class ValuesTabModel extends HoistModel {
26
27
  reset(): void;
27
28
  setRecsChecked(isChecked: boolean, values: any[]): void;
28
29
  toggleAllRecsChecked(): void;
30
+ private onFilterTextChange;
31
+ private onCombineCurrentFiltersToggle;
29
32
  private getFilter;
30
33
  private doSyncWithFilter;
31
34
  private syncGrid;
package/cmp/grid/Types.ts CHANGED
@@ -90,7 +90,10 @@ export interface GridFilterModelConfig {
90
90
  */
91
91
  bind?: Store | View;
92
92
 
93
- /** True (default) to update filters immediately after each change made in the column-based filter UI.*/
93
+ /**
94
+ * True to update filters immediately after each change made in the column-based filter UI.
95
+ * Defaults to False.
96
+ */
94
97
  commitOnChange?: boolean;
95
98
 
96
99
  /**
@@ -46,7 +46,7 @@ export class GridFilterModel extends HoistModel {
46
46
  static BLANK_PLACEHOLDER = '[blank]';
47
47
 
48
48
  constructor(
49
- {bind, commitOnChange = true, fieldSpecs, fieldSpecDefaults}: GridFilterModelConfig,
49
+ {bind, commitOnChange = false, fieldSpecs, fieldSpecDefaults}: GridFilterModelConfig,
50
50
  gridModel: GridModel
51
51
  ) {
52
52
  super();
@@ -21,9 +21,8 @@ export interface StoreFilterFieldProps extends DefaultHoistProps {
21
21
 
22
22
  /**
23
23
  * Field on optional model to which this component should bind its raw (text) value to persist
24
- * across renders. Specify this field to control the state of this component directly or if
25
- * deliberately not connecting this component to a Store/GridModel. These are both advanced
26
- * use-cases - this prop is typically left unset.
24
+ * across renders. Specify this field to control the state of this component directly from a model.
25
+ * These are both advanced use-cases - this prop is typically left unset.
27
26
  */
28
27
  bind?: string;
29
28
 
package/core/XH.ts CHANGED
@@ -442,6 +442,17 @@ export class XHApi {
442
442
  return this.refreshContextModel.refreshAsync();
443
443
  }
444
444
 
445
+ /**
446
+ * Open a url in an external browser window/tab.
447
+ *
448
+ * Unlike a simple call to `open`, this method ensures the "opener" method on the
449
+ * new window is null. This ensures that the new page will not share sessionState with
450
+ * this page. See https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
451
+ */
452
+ openWindow(url: string, target?: string) {
453
+ window.open(url, target ?? '_blank', 'noopener=true');
454
+ }
455
+
445
456
  /**
446
457
  * Flags for controlling experimental, hotfix, or otherwise provisional features.
447
458
  *
@@ -55,7 +55,7 @@ export const versionBar = hoistCmp.factory({
55
55
  Icon.wrench({
56
56
  omit: isAdminApp || !XH.getUser().isHoistAdminReader,
57
57
  title: 'Open Admin Console',
58
- onClick: () => window.open('/admin')
58
+ onClick: () => XH.openWindow('/admin', 'xhAdmin')
59
59
  })
60
60
  ]
61
61
  });
@@ -143,7 +143,7 @@ function buildMenuItems(props: AppMenuButtonProps) {
143
143
  omit: hideAdminItem,
144
144
  text: 'Admin',
145
145
  icon: Icon.wrench(),
146
- actionFn: () => window.open('/admin')
146
+ actionFn: () => XH.openWindow('/admin', 'xhAdmin')
147
147
  },
148
148
  {
149
149
  omit: hideImpersonateItem,
@@ -25,7 +25,7 @@ export const [LaunchAdminButton, launchAdminButton] = hoistCmp.withFactory<Launc
25
25
  ref,
26
26
  icon: Icon.wrench(),
27
27
  title: 'Launch admin client...',
28
- onClick: () => window.open('/admin'),
28
+ onClick: () => XH.openWindow('/admin', 'xhAdmin'),
29
29
  ...props
30
30
  });
31
31
  }
@@ -1,4 +1,18 @@
1
1
  .xh-values-filter-tab {
2
+ .store-filter-header {
3
+ padding: 5px 7px;
4
+ border-bottom: 1px solid var(--xh-grid-header-border-color);
5
+ row-gap: 5px;
6
+ .bp5-control-indicator {
7
+ font-size: 1em;
8
+ }
9
+ label {
10
+ font-size: var(--xh-grid-compact-header-font-size-px);
11
+ color: var(--xh-grid-header-text-color);
12
+ cursor: pointer;
13
+ }
14
+ }
15
+
2
16
  &__hidden-values-message {
3
17
  display: flex;
4
18
  padding: var(--xh-pad-half-px);
@@ -4,11 +4,13 @@
4
4
  *
5
5
  * Copyright © 2025 Extremely Heavy Industries Inc.
6
6
  */
7
+ import {isEmpty} from 'lodash';
7
8
  import {grid} from '@xh/hoist/cmp/grid';
8
- import {div, placeholder, vframe} from '@xh/hoist/cmp/layout';
9
+ import {div, hframe, placeholder, label, vbox, vframe} from '@xh/hoist/cmp/layout';
9
10
  import {storeFilterField} from '@xh/hoist/cmp/store';
10
- import {hoistCmp, uses} from '@xh/hoist/core';
11
+ import {XH, hoistCmp, uses} from '@xh/hoist/core';
11
12
  import {button} from '@xh/hoist/desktop/cmp/button';
13
+ import {checkbox} from '@xh/hoist/desktop/cmp/input';
12
14
  import {panel} from '@xh/hoist/desktop/cmp/panel';
13
15
  import {toolbar} from '@xh/hoist/desktop/cmp/toolbar';
14
16
  import {Icon} from '@xh/hoist/icon';
@@ -39,7 +41,8 @@ const tbar = hoistCmp.factory(() => {
39
41
  placeholder: 'Search...',
40
42
  flex: 1,
41
43
  autoFocus: true,
42
- matchMode: 'any'
44
+ matchMode: 'any',
45
+ includeFields: ['value']
43
46
  })
44
47
  );
45
48
  });
@@ -47,7 +50,50 @@ const tbar = hoistCmp.factory(() => {
47
50
  const body = hoistCmp.factory<ValuesTabModel>(({model}) => {
48
51
  const {isCustomFilter} = model.headerFilterModel;
49
52
  if (isCustomFilter) return customFilterPlaceholder();
50
- return vframe(grid(), hiddenValuesMessage());
53
+ return vframe(storeFilterSelect(), grid(), hiddenValuesMessage());
54
+ });
55
+
56
+ const storeFilterSelect = hoistCmp.factory<ValuesTabModel>(({model}) => {
57
+ const {gridModel, allVisibleRecsChecked, filterText, headerFilterModel} = model,
58
+ {store} = gridModel,
59
+ selectAllId = XH.genId(),
60
+ addToFilterId = XH.genId();
61
+
62
+ return vbox({
63
+ className: 'store-filter-header',
64
+ items: [
65
+ hframe(
66
+ checkbox({
67
+ id: selectAllId,
68
+ disabled: store.empty,
69
+ displayUnsetState: true,
70
+ value: allVisibleRecsChecked,
71
+ onChange: () => model.toggleAllRecsChecked()
72
+ }),
73
+ label({
74
+ htmlFor: selectAllId,
75
+ item: `(Select All${filterText ? ' Search Results' : ''})`
76
+ })
77
+ ),
78
+ hframe({
79
+ omit:
80
+ !filterText ||
81
+ isEmpty(model.columnFilters) ||
82
+ store.empty ||
83
+ headerFilterModel.commitOnChange,
84
+ items: [
85
+ checkbox({
86
+ id: addToFilterId,
87
+ bind: 'combineCurrentFilters'
88
+ }),
89
+ label({
90
+ htmlFor: addToFilterId,
91
+ item: 'Add current selection to filter'
92
+ })
93
+ ]
94
+ })
95
+ ]
96
+ });
51
97
  });
52
98
 
53
99
  const customFilterPlaceholder = hoistCmp.factory<ValuesTabModel>(({model}) => {
@@ -10,7 +10,7 @@ import {FieldFilterSpec} from '@xh/hoist/data';
10
10
  import {HeaderFilterModel} from '../HeaderFilterModel';
11
11
  import {checkbox} from '@xh/hoist/desktop/cmp/input';
12
12
  import {action, bindable, computed, makeObservable, observable} from '@xh/hoist/mobx';
13
- import {castArray, difference, isEmpty, partition, uniq, without} from 'lodash';
13
+ import {castArray, difference, flatten, isEmpty, map, partition, uniq, without} from 'lodash';
14
14
 
15
15
  export class ValuesTabModel extends HoistModel {
16
16
  override xhImpl = true;
@@ -26,6 +26,12 @@ export class ValuesTabModel extends HoistModel {
26
26
  /** Bound search term for `StoreFilterField` */
27
27
  @bindable filterText: string = null;
28
28
 
29
+ /*
30
+ * Merge current filter with pendingValues on commit.
31
+ * Used when commitOnChange is false.
32
+ */
33
+ @bindable combineCurrentFilters: boolean = false;
34
+
29
35
  /** FieldFilter output by this model. */
30
36
  @computed.struct
31
37
  get filter(): FieldFilterSpec {
@@ -81,11 +87,22 @@ export class ValuesTabModel extends HoistModel {
81
87
  this.headerFilterModel = headerFilterModel;
82
88
  this.gridModel = this.createGridModel();
83
89
 
84
- this.addReaction({
85
- track: () => this.pendingValues,
86
- run: () => this.syncGrid(),
87
- fireImmediately: true
88
- });
90
+ this.addReaction(
91
+ {
92
+ track: () => this.pendingValues,
93
+ run: () => this.syncGrid(),
94
+ fireImmediately: true
95
+ },
96
+ {
97
+ track: () => this.filterText,
98
+ run: () => this.onFilterTextChange(),
99
+ debounce: 300
100
+ },
101
+ {
102
+ track: () => this.combineCurrentFilters,
103
+ run: () => this.onCombineCurrentFiltersToggle()
104
+ }
105
+ );
89
106
  }
90
107
 
91
108
  syncWithFilter() {
@@ -115,6 +132,43 @@ export class ValuesTabModel extends HoistModel {
115
132
  //-------------------
116
133
  // Implementation
117
134
  //-------------------
135
+ @action
136
+ private onFilterTextChange() {
137
+ if (!this.filterText) {
138
+ this.combineCurrentFilters = false;
139
+ this.doSyncWithFilter();
140
+ return;
141
+ }
142
+
143
+ const {records} = this.gridModel.store,
144
+ currentFilterValues = flatten(map(this.columnFilters, 'value')),
145
+ checkedRecs = records.filter(
146
+ it =>
147
+ this.headerFilterModel.commitOnChange ||
148
+ !isEmpty(currentFilterValues) ||
149
+ it.get('isChecked')
150
+ ),
151
+ values = map(checkedRecs, it => it.get('value'));
152
+
153
+ this.pendingValues = uniq(
154
+ this.combineCurrentFilters ? [...currentFilterValues, ...values] : values
155
+ );
156
+ }
157
+
158
+ @action
159
+ private onCombineCurrentFiltersToggle() {
160
+ if (!this.filterText) return;
161
+
162
+ const {records} = this.gridModel.store,
163
+ currentFilterValues = flatten(map(this.columnFilters, 'value')),
164
+ checkedRecs = records.filter(it => it.get('isChecked')),
165
+ values = map(checkedRecs, it => it.get('value'));
166
+
167
+ this.pendingValues = uniq(
168
+ this.combineCurrentFilters ? [...currentFilterValues, ...values] : values
169
+ );
170
+ }
171
+
118
172
  private getFilter() {
119
173
  const {gridFilterModel, pendingValues, values, valueCount, field} = this,
120
174
  included = pendingValues.map(it => gridFilterModel.fromDisplayValue(it)),
@@ -204,7 +258,7 @@ export class ValuesTabModel extends HoistModel {
204
258
  {name: 'isChecked', type: 'bool'}
205
259
  ]
206
260
  },
207
- selModel: 'disabled',
261
+ selModel: 'single',
208
262
  emptyText: 'No records found...',
209
263
  contextMenu: null,
210
264
  // Autosize enabled to ensure that long values don't get clipped and user can scroll
@@ -217,17 +271,16 @@ export class ValuesTabModel extends HoistModel {
217
271
  onRowClicked: ({data: record}) => {
218
272
  this.setRecsChecked(!record.get('isChecked'), record.get('value'));
219
273
  },
274
+ onKeyDown: evt => {
275
+ if (evt.key === ' ' || evt.code.toUpperCase() === 'SPACE') {
276
+ const record = this.gridModel.selectedRecord;
277
+ this.setRecsChecked(!record.get('isChecked'), record.get('value'));
278
+ }
279
+ },
280
+ hideHeaders: true,
220
281
  columns: [
221
282
  {
222
283
  field: 'isChecked',
223
- headerName: ({gridModel}) => {
224
- return checkbox({
225
- disabled: gridModel.store.empty,
226
- displayUnsetState: true,
227
- value: this.allVisibleRecsChecked,
228
- onChange: () => this.toggleAllRecsChecked()
229
- });
230
- },
231
284
  width: 28,
232
285
  autosizable: false,
233
286
  pinned: true,
@@ -245,7 +298,6 @@ export class ValuesTabModel extends HoistModel {
245
298
  },
246
299
  {
247
300
  field: 'value',
248
- displayName: '(Select All)',
249
301
  align: 'left',
250
302
  comparator: (v1, v2, sortDir, abs, {defaultComparator}) => {
251
303
  const mul = sortDir === 'desc' ? -1 : 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "73.0.0-SNAPSHOT.1747146913330",
3
+ "version": "73.0.0-SNAPSHOT.1747155067044",
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",