@xh/hoist 75.0.0-SNAPSHOT.1752765224740 → 75.0.0-SNAPSHOT.1752854198386

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
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## 75.0-SNAPSHOT - Unreleased
4
4
 
5
+ ### 🎁 New Features
6
+
7
+ * Added new `GroupingChooserModel.sortDimensions` config - can be set to false to respect the order
8
+ in which dimensions are provided to the model.
9
+
5
10
  ### 🐞 Bug Fixes
6
11
 
7
12
  * DashCanvas: ensure `allowAdd=false` is not enforced if loadingState
@@ -10,7 +15,7 @@
10
15
  within the canvas, not the next parent container up that has `position: relative;`.
11
16
 
12
17
  * `useContextModel` is now reactive to a change of an (observable) resolved model when it is set.
13
- Previously this value was cached on first render.
18
+ Previously this value was cached on first render.
14
19
 
15
20
  * Fixes to framework components that bind to grids (e.g. `ColChooserButton`, `ColAutosizeButton`,
16
21
  `GridFindField`) to rebind to a new observable GridModel available via context.
@@ -26,9 +31,9 @@ Previously this value was cached on first render.
26
31
  ### 🎁 New Features
27
32
 
28
33
  * Further refinements to the `GroupingChooser` desktop UI.
29
- * Added new props `favoritesSide` and `favoritesTitle`.
30
- * Deprecated `popoverTitle` prop - use `editorTitle` instead.
31
- * Moved "Save as Favorite" button to a new compact toolbar within the popover.
34
+ * Added new props `favoritesSide` and `favoritesTitle`.
35
+ * Deprecated `popoverTitle` prop - use `editorTitle` instead.
36
+ * Moved "Save as Favorite" button to a new compact toolbar within the popover.
32
37
 
33
38
  ### 🐞 Bug Fixes
34
39
 
@@ -1,29 +1,34 @@
1
- import { HoistModel, PersistOptions } from '@xh/hoist/core';
1
+ import { HoistModel, PersistOptions, SelectOption } from '@xh/hoist/core';
2
2
  export interface GroupingChooserConfig {
3
+ /** True to accept an empty list as a valid value. */
4
+ allowEmpty?: boolean;
5
+ /**
6
+ * False (default) waits for the user to dismiss the popover before updating the
7
+ * external/observable value.
8
+ */
9
+ commitOnChange?: boolean;
3
10
  /**
4
11
  * Dimensions available for selection. When using GroupingChooser to create Cube queries,
5
12
  * it is recommended to pass the `dimensions` from the related cube (or a subset thereof).
6
13
  * Note that {@link CubeField} meets the `DimensionSpec` interface.
7
14
  */
8
15
  dimensions?: (DimensionSpec | string)[];
9
- /** Initial value as an array of dimension names, or a function to produce such an array. */
10
- initialValue?: string[] | (() => string[]);
11
16
  /**
12
17
  * Initial favorites as an array of dim name arrays, or a function to produce such an array.
13
18
  * Ignored if `persistWith.persistFavorites: false`.
14
19
  */
15
20
  initialFavorites?: string[][] | (() => string[][]);
16
- /** Options governing persistence. */
17
- persistWith?: GroupingChooserPersistOptions;
18
- /** True to accept an empty list as a valid value. */
19
- allowEmpty?: boolean;
21
+ /** Initial value as an array of dimension names, or a function to produce such an array. */
22
+ initialValue?: string[] | (() => string[]);
20
23
  /** Maximum number of dimensions allowed in a single grouping. */
21
24
  maxDepth?: number;
25
+ /** Options governing persistence. */
26
+ persistWith?: GroupingChooserPersistOptions;
22
27
  /**
23
- * False (default) waits for the user to dismiss the popover before updating the
24
- * external/observable value.
28
+ * True (default) to auto-sort dimensions by label. Set to false to show them in the order
29
+ * provided in the `dimensions` config.
25
30
  */
26
- commitOnChange?: boolean;
31
+ sortDimensions?: boolean;
27
32
  }
28
33
  /**
29
34
  * Metadata for dimensions that are available for selection via a GroupingChooser control.
@@ -45,9 +50,10 @@ export declare class GroupingChooserModel extends HoistModel {
45
50
  value: string[];
46
51
  favorites: string[][];
47
52
  allowEmpty: boolean;
48
- maxDepth: number;
49
53
  commitOnChange: boolean;
54
+ maxDepth: number;
50
55
  persistFavorites: boolean;
56
+ sortDimensions: boolean;
51
57
  pendingValue: string[];
52
58
  editorIsOpen: boolean;
53
59
  popoverRef: import("react").RefObject<HTMLElement> & import("react").RefCallback<HTMLElement>;
@@ -58,11 +64,13 @@ export declare class GroupingChooserModel extends HoistModel {
58
64
  get isValid(): boolean;
59
65
  get isAddEnabled(): boolean;
60
66
  get isAddFavoriteEnabled(): boolean;
61
- constructor({ dimensions, initialValue, initialFavorites, persistWith, allowEmpty, maxDepth, commitOnChange }: GroupingChooserConfig);
67
+ constructor({ allowEmpty, commitOnChange, dimensions, initialFavorites, initialValue, maxDepth, persistWith, sortDimensions }: GroupingChooserConfig);
62
68
  setDimensions(dimensions: Array<DimensionSpec | string>): void;
63
69
  setValue(value: string[]): void;
64
70
  toggleEditor(): void;
65
71
  closeEditor(): void;
72
+ /** Transform dimension names into SelectOptions, with displayName and optional sort. */
73
+ getDimSelectOpts(dims?: string[]): SelectOption[];
66
74
  addPendingDim(dimName: string): void;
67
75
  replacePendingDimAtIdx(dimName: string, idx: number): void;
68
76
  removePendingDimAtIdx(idx: number): void;
@@ -1,4 +1,4 @@
1
- import { HoistException } from '../';
1
+ import { HoistException, PlainObject } from '../';
2
2
  export interface ExceptionHandlerOptions {
3
3
  /** Text (ideally user-friendly) describing the error. */
4
4
  message?: string;
@@ -113,8 +113,13 @@ export declare class ExceptionHandler {
113
113
  */
114
114
  logOnServerAsync(options: ExceptionHandlerLoggingOptions): Promise<boolean>;
115
115
  /**
116
- * Serialize an error object safely for submission to server, or user display.
117
- * This method will avoid circular references and will trim the depth of the object.
116
+ * Sanitize an exception for submission to server. This method will avoid circular references
117
+ * trim the depth of the object, and redact sensitive info (e.g. passwords).
118
+ */
119
+ sanitizeException(exception: HoistException): PlainObject;
120
+ /**
121
+ * Serialize an error object safely for user display. This method will avoid circular
122
+ * references, trim the depth of the object, and redact sensitive info (e.g. passwords).
118
123
  */
119
124
  stringifyErrorSafely(exception: HoistException): string;
120
125
  private parseArgs;
@@ -122,6 +127,5 @@ export declare class ExceptionHandler {
122
127
  private logException;
123
128
  private parseOptions;
124
129
  private sessionMismatch;
125
- private cleanStack;
126
130
  private cloneAndTrim;
127
131
  }
@@ -5,14 +5,39 @@
5
5
  * Copyright © 2025 Extremely Heavy Industries Inc.
6
6
  */
7
7
 
8
- import {HoistModel, PersistableState, PersistenceProvider, PersistOptions} from '@xh/hoist/core';
8
+ import {
9
+ HoistModel,
10
+ PersistableState,
11
+ PersistenceProvider,
12
+ PersistOptions,
13
+ SelectOption
14
+ } from '@xh/hoist/core';
9
15
  import {genDisplayName} from '@xh/hoist/data';
10
16
  import {action, computed, makeObservable, observable} from '@xh/hoist/mobx';
11
17
  import {executeIfFunction, throwIf} from '@xh/hoist/utils/js';
12
18
  import {createObservableRef} from '@xh/hoist/utils/react';
13
- import {difference, isArray, isEmpty, isEqual, isObject, isString, keys, sortBy} from 'lodash';
19
+ import {
20
+ compact,
21
+ difference,
22
+ isArray,
23
+ isEmpty,
24
+ isEqual,
25
+ isObject,
26
+ isString,
27
+ keys,
28
+ sortBy
29
+ } from 'lodash';
14
30
 
15
31
  export interface GroupingChooserConfig {
32
+ /** True to accept an empty list as a valid value. */
33
+ allowEmpty?: boolean;
34
+
35
+ /**
36
+ * False (default) waits for the user to dismiss the popover before updating the
37
+ * external/observable value.
38
+ */
39
+ commitOnChange?: boolean;
40
+
16
41
  /**
17
42
  * Dimensions available for selection. When using GroupingChooser to create Cube queries,
18
43
  * it is recommended to pass the `dimensions` from the related cube (or a subset thereof).
@@ -20,29 +45,26 @@ export interface GroupingChooserConfig {
20
45
  */
21
46
  dimensions?: (DimensionSpec | string)[];
22
47
 
23
- /** Initial value as an array of dimension names, or a function to produce such an array. */
24
- initialValue?: string[] | (() => string[]);
25
-
26
48
  /**
27
49
  * Initial favorites as an array of dim name arrays, or a function to produce such an array.
28
50
  * Ignored if `persistWith.persistFavorites: false`.
29
51
  */
30
52
  initialFavorites?: string[][] | (() => string[][]);
31
53
 
32
- /** Options governing persistence. */
33
- persistWith?: GroupingChooserPersistOptions;
34
-
35
- /** True to accept an empty list as a valid value. */
36
- allowEmpty?: boolean;
54
+ /** Initial value as an array of dimension names, or a function to produce such an array. */
55
+ initialValue?: string[] | (() => string[]);
37
56
 
38
57
  /** Maximum number of dimensions allowed in a single grouping. */
39
58
  maxDepth?: number;
40
59
 
60
+ /** Options governing persistence. */
61
+ persistWith?: GroupingChooserPersistOptions;
62
+
41
63
  /**
42
- * False (default) waits for the user to dismiss the popover before updating the
43
- * external/observable value.
64
+ * True (default) to auto-sort dimensions by label. Set to false to show them in the order
65
+ * provided in the `dimensions` config.
44
66
  */
45
- commitOnChange?: boolean;
67
+ sortDimensions?: boolean;
46
68
  }
47
69
 
48
70
  /**
@@ -70,9 +92,10 @@ export class GroupingChooserModel extends HoistModel {
70
92
  @observable.ref favorites: string[][] = [];
71
93
 
72
94
  allowEmpty: boolean;
73
- maxDepth: number;
74
95
  commitOnChange: boolean;
96
+ maxDepth: number;
75
97
  persistFavorites: boolean = false;
98
+ sortDimensions: boolean;
76
99
 
77
100
  // Implementation fields for Control
78
101
  @observable.ref pendingValue: string[] = [];
@@ -117,20 +140,22 @@ export class GroupingChooserModel extends HoistModel {
117
140
  }
118
141
 
119
142
  constructor({
143
+ allowEmpty = false,
144
+ commitOnChange = false,
120
145
  dimensions,
121
- initialValue = [],
122
146
  initialFavorites = [],
123
- persistWith = null,
124
- allowEmpty = false,
147
+ initialValue = [],
125
148
  maxDepth = null,
126
- commitOnChange = false
149
+ persistWith = null,
150
+ sortDimensions = true
127
151
  }: GroupingChooserConfig) {
128
152
  super();
129
153
  makeObservable(this);
130
154
 
131
155
  this.allowEmpty = allowEmpty;
132
- this.maxDepth = maxDepth;
133
156
  this.commitOnChange = commitOnChange;
157
+ this.maxDepth = maxDepth;
158
+ this.sortDimensions = sortDimensions;
134
159
 
135
160
  this.setDimensions(dimensions);
136
161
 
@@ -187,6 +212,15 @@ export class GroupingChooserModel extends HoistModel {
187
212
  this.editorIsOpen = false;
188
213
  }
189
214
 
215
+ /** Transform dimension names into SelectOptions, with displayName and optional sort. */
216
+ getDimSelectOpts(dims: string[] = this.availableDims): SelectOption[] {
217
+ const ret = compact(dims).map(dimName => ({
218
+ value: dimName,
219
+ label: this.getDimDisplayName(dimName)
220
+ }));
221
+ return this.sortDimensions ? sortBy(ret, 'label') : ret;
222
+ }
223
+
190
224
  //-------------------------
191
225
  // Value handling
192
226
  //-------------------------
@@ -210,7 +210,7 @@ export class Exception {
210
210
 
211
211
  private static createInternal(attributes: PlainObject, baseError?: Error) {
212
212
  const {message, ...rest} = attributes;
213
- return Object.assign(
213
+ const ret = Object.assign(
214
214
  baseError ?? new Error(message),
215
215
  {
216
216
  isRoutine: false,
@@ -218,6 +218,11 @@ export class Exception {
218
218
  },
219
219
  rest
220
220
  ) as HoistException;
221
+
222
+ // statuses of 0, 4XX, 5XX are server errors, so stack irrelevant and potentially misleading
223
+ if (ret.stack == null || /^[045]/.test(ret.httpStatus)) delete ret.stack;
224
+
225
+ return ret;
221
226
  }
222
227
  }
223
228
 
@@ -185,8 +185,7 @@ export class ExceptionHandler {
185
185
  async logOnServerAsync(options: ExceptionHandlerLoggingOptions): Promise<boolean> {
186
186
  const {exception, userAlerted, userMessage} = options;
187
187
  try {
188
- const error = this.stringifyErrorSafely(exception),
189
- username = XH.getUsername();
188
+ const username = XH.getUsername();
190
189
 
191
190
  if (!username) {
192
191
  logWarn('Error report cannot be submitted to UI server - user unknown', this);
@@ -194,7 +193,7 @@ export class ExceptionHandler {
194
193
  }
195
194
 
196
195
  const data: PlainObject = {
197
- error: JSON.parse(error),
196
+ error: this.sanitizeException(exception),
198
197
  userAlerted
199
198
  };
200
199
  if (userMessage) data.userMessage = stripTags(userMessage);
@@ -216,8 +215,16 @@ export class ExceptionHandler {
216
215
  }
217
216
 
218
217
  /**
219
- * Serialize an error object safely for submission to server, or user display.
220
- * This method will avoid circular references and will trim the depth of the object.
218
+ * Sanitize an exception for submission to server. This method will avoid circular references
219
+ * trim the depth of the object, and redact sensitive info (e.g. passwords).
220
+ */
221
+ sanitizeException(exception: HoistException): PlainObject {
222
+ return JSON.parse(this.stringifyErrorSafely(exception));
223
+ }
224
+
225
+ /**
226
+ * Serialize an error object safely for user display. This method will avoid circular
227
+ * references, trim the depth of the object, and redact sensitive info (e.g. passwords).
221
228
  */
222
229
  stringifyErrorSafely(exception: HoistException): string {
223
230
  try {
@@ -287,8 +294,6 @@ export class ExceptionHandler {
287
294
  this.hideParams(e, opts);
288
295
  }
289
296
 
290
- this.cleanStack(e);
291
-
292
297
  return {e, opts};
293
298
  }
294
299
 
@@ -342,12 +347,6 @@ export class ExceptionHandler {
342
347
  return e.name === 'SessionMismatchException';
343
348
  }
344
349
 
345
- private cleanStack(e: HoistException) {
346
- // statuses of 0, 4XX, 5XX are server errors, so the javascript stack
347
- // is irrelevant and potentially misleading
348
- if (/^[045]/.test(e.httpStatus)) delete e.stack;
349
- }
350
-
351
350
  private cloneAndTrim(obj, depth = 5) {
352
351
  // Create a depth-constrained, deep copy of an object for safe-use in stringify
353
352
  // - Skip private _XXXX properties.
@@ -29,7 +29,7 @@ import {dragDropContext, draggable, droppable} from '@xh/hoist/kit/react-beautif
29
29
  import {apiDeprecated, elemWithin, getTestId} from '@xh/hoist/utils/js';
30
30
  import {splitLayoutProps} from '@xh/hoist/utils/react';
31
31
  import classNames from 'classnames';
32
- import {compact, isEmpty, isNil, isUndefined, sortBy} from 'lodash';
32
+ import {isEmpty, isNil, isUndefined} from 'lodash';
33
33
  import './GroupingChooser.scss';
34
34
  import {ReactNode} from 'react';
35
35
 
@@ -264,7 +264,7 @@ const dimensionList = hoistCmp.factory<GroupingChooserModel>({
264
264
  const dimensionRow = hoistCmp.factory<GroupingChooserModel>({
265
265
  render({model, dimension, idx}) {
266
266
  // The options for this select include its current value
267
- const options = getDimOptions([...model.availableDims, dimension], model);
267
+ const options = model.getDimSelectOpts([...model.availableDims, dimension]);
268
268
 
269
269
  return draggable({
270
270
  key: dimension,
@@ -346,7 +346,8 @@ const dimensionRow = hoistCmp.factory<GroupingChooserModel>({
346
346
  const addDimensionControl = hoistCmp.factory<GroupingChooserModel>({
347
347
  render({model}) {
348
348
  if (!model.isAddEnabled) return null;
349
- const options = getDimOptions(model.availableDims, model);
349
+
350
+ const options = model.getDimSelectOpts();
350
351
  return div({
351
352
  className: 'xh-grouping-chooser__add-control',
352
353
  items: [
@@ -372,9 +373,8 @@ const addDimensionControl = hoistCmp.factory<GroupingChooserModel>({
372
373
  });
373
374
 
374
375
  /**
375
- * Extract integer values from CSS transform string.
376
- * Works for both `translate` and `translate3d`
377
- * e.g. `translate3d(250px, 150px, 0px)` is equivalent to [250, 150, 0]
376
+ * Extract integer values from CSS transform string. Works for both `translate` and `translate3d`.
377
+ * e.g. `translate3d(250px, 150px, 0px) -> [250, 150, 0]`
378
378
  */
379
379
  function parseTransform(transformStr: string): number[] {
380
380
  return transformStr
@@ -383,16 +383,6 @@ function parseTransform(transformStr: string): number[] {
383
383
  ?.map(it => parseInt(it));
384
384
  }
385
385
 
386
- /**
387
- * Convert a list of dim names into select options
388
- */
389
- function getDimOptions(dims, model) {
390
- const ret = compact(dims).map(dimName => {
391
- return {value: dimName, label: model.getDimDisplayName(dimName)};
392
- });
393
- return sortBy(ret, 'label');
394
- }
395
-
396
386
  //------------------
397
387
  // Favorites
398
388
  //------------------
@@ -15,7 +15,7 @@ import '@xh/hoist/mobile/register';
15
15
  import {dialogPanel, panel} from '@xh/hoist/mobile/cmp/panel';
16
16
  import {splitLayoutProps} from '@xh/hoist/utils/react';
17
17
  import classNames from 'classnames';
18
- import {compact, isEmpty, sortBy} from 'lodash';
18
+ import {isEmpty} from 'lodash';
19
19
 
20
20
  import './GroupingChooser.scss';
21
21
 
@@ -134,7 +134,7 @@ const dimensionList = hoistCmp.factory<GroupingChooserModel>({
134
134
  const dimensionRow = hoistCmp.factory<GroupingChooserModel>({
135
135
  render({model, dimension, idx}) {
136
136
  // The options for this select include its current value
137
- const options = getDimOptions([...model.availableDims, dimension], model);
137
+ const options = model.getDimSelectOpts([...model.availableDims, dimension]);
138
138
 
139
139
  return draggable({
140
140
  key: dimension,
@@ -182,7 +182,8 @@ const dimensionRow = hoistCmp.factory<GroupingChooserModel>({
182
182
  const addDimensionControl = hoistCmp.factory<GroupingChooserModel>({
183
183
  render({model}) {
184
184
  if (!model.isAddEnabled) return null;
185
- const options = getDimOptions(model.availableDims, model);
185
+
186
+ const options = model.getDimSelectOpts();
186
187
  return div({
187
188
  className: 'xh-grouping-chooser__add-control',
188
189
  items: [
@@ -203,16 +204,6 @@ const addDimensionControl = hoistCmp.factory<GroupingChooserModel>({
203
204
  }
204
205
  });
205
206
 
206
- /**
207
- * Convert a list of dim names into select options
208
- */
209
- function getDimOptions(dims, model) {
210
- const ret = compact(dims).map(dimName => {
211
- return {value: dimName, label: model.getDimDisplayName(dimName)};
212
- });
213
- return sortBy(ret, 'label');
214
- }
215
-
216
207
  //------------------
217
208
  // Favorites
218
209
  //------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "75.0.0-SNAPSHOT.1752765224740",
3
+ "version": "75.0.0-SNAPSHOT.1752854198386",
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",
@@ -202,8 +202,10 @@ const enhancePromise = promisePrototype => {
202
202
  if (!options) return this;
203
203
 
204
204
  const startTime = Date.now(),
205
- doTrack = (exception: unknown = null) => {
206
- if (exception && exception['isRoutine']) return;
205
+ doTrack = (rejectReason: unknown = null) => {
206
+ const exception = rejectReason != null ? Exception.create(rejectReason) : null;
207
+
208
+ if (exception?.isRoutine) return;
207
209
 
208
210
  const endTime = Date.now(),
209
211
  opts: TrackOptions = isString(options) ? {message: options} : {...options};
@@ -222,7 +224,14 @@ const enhancePromise = promisePrototype => {
222
224
  ) {
223
225
  opts.elapsed = null;
224
226
  }
225
- if (exception) opts.severity = 'ERROR';
227
+ if (exception) {
228
+ opts.severity = 'ERROR';
229
+ opts.data = {
230
+ error: XH.exceptionHandler.sanitizeException(exception),
231
+ data: opts.data
232
+ };
233
+ opts.correlationId = opts.correlationId ?? exception.correlationId;
234
+ }
226
235
 
227
236
  XH.track(opts);
228
237
  };