@xh/hoist 71.0.0-SNAPSHOT.1735061320692 → 71.0.0-SNAPSHOT.1735236372248

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
@@ -13,7 +13,7 @@
13
13
  `@xh/hoist/cmp/loadingindicator`.
14
14
  * `TreeMap` and `SplitTreeMap` are now cross-platform and can be used in mobile applications.
15
15
  Their import paths have changed from `@xh/hoist/desktop/cmp/treemap` to `@xh/hoist/cmp/treemap`.
16
-
16
+ * The `RefreshButton` `model` prop has been renamed `target` for clarity and consistency.
17
17
  ### 🎁 New Features
18
18
 
19
19
  * Major Improvements to ViewManager component
@@ -36,6 +36,11 @@ export interface QueryConfig {
36
36
  includeRoot?: boolean;
37
37
  /** True to include leaf nodes in return.*/
38
38
  includeLeaves?: boolean;
39
+ /**
40
+ * True (default) to recursively omit single-child parents in the hierarchy.
41
+ * Apps can implement further omit logic using `omitFn`.
42
+ */
43
+ omitRedundantNodes?: boolean;
39
44
  /**
40
45
  * Optional function to be called for each aggregate node to determine if it should be "locked",
41
46
  * preventing drill-down into its children. Defaults to Cube.lockFn.
@@ -60,12 +65,13 @@ export declare class Query {
60
65
  readonly filter: Filter;
61
66
  readonly includeRoot: boolean;
62
67
  readonly includeLeaves: boolean;
68
+ readonly omitRedundantNodes: boolean;
63
69
  readonly cube: Cube;
64
70
  readonly lockFn: LockFn;
65
71
  readonly bucketSpecFn: BucketSpecFn;
66
72
  readonly omitFn: OmitFn;
67
73
  private readonly _testFn;
68
- constructor({ cube, fields, dimensions, filter, includeRoot, includeLeaves, lockFn, bucketSpecFn, omitFn }: QueryConfig);
74
+ constructor({ cube, fields, dimensions, filter, includeRoot, includeLeaves, omitRedundantNodes, lockFn, bucketSpecFn, omitFn }: QueryConfig);
69
75
  clone(overrides: Partial<QueryConfig>): Query;
70
76
  test(record: StoreRecord): boolean;
71
77
  /**
@@ -1,13 +1,16 @@
1
1
  /// <reference types="react" />
2
- import { HoistModel } from '@xh/hoist/core';
2
+ import { Loadable } from '@xh/hoist/core';
3
3
  import '@xh/hoist/desktop/register';
4
4
  import { ButtonProps } from './Button';
5
- export type RefreshButtonProps = ButtonProps<HoistModel>;
5
+ export interface RefreshButtonProps extends ButtonProps {
6
+ /** Object to refresh when clicked. */
7
+ target?: Loadable;
8
+ }
6
9
  /**
7
10
  * Convenience Button preconfigured for use as a trigger for a refresh operation.
8
11
  *
9
- * If an onClick handler is provided it will be used. Otherwise this button will
10
- * be linked to any model in props with LoadSupport enabled, or the contextual
12
+ * If an onClick handler is provided it will be used. Otherwise, this button will
13
+ * be linked to the target in props with LoadSupport enabled, or the contextual
11
14
  * See {@link RefreshContextModel}.
12
15
  */
13
16
  export declare const RefreshButton: import("react").FC<RefreshButtonProps>, refreshButton: import("@xh/hoist/core").ElementFactory<RefreshButtonProps>;
@@ -1,8 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { HoistModel } from '@xh/hoist/core';
2
+ import { Loadable } from '@xh/hoist/core';
3
3
  import { ButtonProps } from '@xh/hoist/mobile/cmp/button';
4
4
  import '@xh/hoist/mobile/register';
5
- export type RefreshButtonProps = ButtonProps<HoistModel>;
5
+ export interface RefreshButtonProps extends ButtonProps {
6
+ /** Object to refresh when clicked. */
7
+ target?: Loadable;
8
+ }
6
9
  /**
7
10
  * Convenience Button preconfigured for use as a trigger for a refresh operation.
8
11
  *
@@ -1,4 +1,4 @@
1
- import { HoistService } from '@xh/hoist/core';
1
+ import { HoistService, TrackOptions } from '@xh/hoist/core';
2
2
  import { GridModel, Column } from '@xh/hoist/cmp/grid';
3
3
  import { StoreRecord } from '@xh/hoist/data';
4
4
  /**
@@ -50,7 +50,7 @@ export interface ExportOptions {
50
50
  */
51
51
  columns?: 'VISIBLE' | 'ALL' | string[] | ((g: GridModel) => string[]);
52
52
  /** True to enable activity tracking of exports (default false). */
53
- track?: boolean;
53
+ track?: boolean | Partial<TrackOptions>;
54
54
  /** Timeout (in ms) for export request - defaults to 30 seconds. */
55
55
  timeout?: number;
56
56
  }
@@ -52,6 +52,12 @@ export interface QueryConfig {
52
52
  /** True to include leaf nodes in return.*/
53
53
  includeLeaves?: boolean;
54
54
 
55
+ /**
56
+ * True (default) to recursively omit single-child parents in the hierarchy.
57
+ * Apps can implement further omit logic using `omitFn`.
58
+ */
59
+ omitRedundantNodes?: boolean;
60
+
55
61
  /**
56
62
  * Optional function to be called for each aggregate node to determine if it should be "locked",
57
63
  * preventing drill-down into its children. Defaults to Cube.lockFn.
@@ -79,6 +85,7 @@ export class Query {
79
85
  readonly filter: Filter;
80
86
  readonly includeRoot: boolean;
81
87
  readonly includeLeaves: boolean;
88
+ readonly omitRedundantNodes: boolean;
82
89
  readonly cube: Cube;
83
90
  readonly lockFn: LockFn;
84
91
  readonly bucketSpecFn: BucketSpecFn;
@@ -93,6 +100,7 @@ export class Query {
93
100
  filter = null,
94
101
  includeRoot = false,
95
102
  includeLeaves = false,
103
+ omitRedundantNodes = true,
96
104
  lockFn = cube.lockFn,
97
105
  bucketSpecFn = cube.bucketSpecFn,
98
106
  omitFn = cube.omitFn
@@ -102,6 +110,7 @@ export class Query {
102
110
  this.dimensions = this.parseDimensions(dimensions);
103
111
  this.includeRoot = includeRoot;
104
112
  this.includeLeaves = includeLeaves;
113
+ this.omitRedundantNodes = omitRedundantNodes;
105
114
  this.filter = parseFilter(filter);
106
115
  this.lockFn = lockFn;
107
116
  this.bucketSpecFn = bucketSpecFn;
@@ -117,6 +126,7 @@ export class Query {
117
126
  filter: this.filter,
118
127
  includeRoot: this.includeRoot,
119
128
  includeLeaves: this.includeLeaves,
129
+ omitRedundantNodes: this.omitRedundantNodes,
120
130
  lockFn: this.lockFn,
121
131
  bucketSpecFn: this.bucketSpecFn,
122
132
  omitFn: this.omitFn,
@@ -153,6 +163,7 @@ export class Query {
153
163
  this.cube === other.cube &&
154
164
  this.includeRoot === other.includeRoot &&
155
165
  this.includeLeaves === other.includeLeaves &&
166
+ this.omitRedundantNodes === other.omitRedundantNodes &&
156
167
  this.bucketSpecFn == other.bucketSpecFn &&
157
168
  this.omitFn == other.omitFn &&
158
169
  this.lockFn == other.lockFn
@@ -65,12 +65,14 @@ export abstract class BaseRow {
65
65
 
66
66
  // 3a) Before attaching examine that we don't have a chain of redundant nodes
67
67
  // (not sure if loop needed -- are these redundant relations transitive?)
68
- while (dataChildren?.length === 1) {
69
- const childRow = dataChildren[0]._meta;
70
- if (this.isRedundantChild(this, childRow)) {
71
- dataChildren = childRow.data.children;
72
- } else {
73
- break;
68
+ if (view.query.omitRedundantNodes) {
69
+ while (dataChildren?.length === 1) {
70
+ const childRow = dataChildren[0]._meta;
71
+ if (this.isRedundantChild(this, childRow)) {
72
+ dataChildren = childRow.data.children;
73
+ } else {
74
+ break;
75
+ }
74
76
  }
75
77
  }
76
78
 
@@ -4,35 +4,34 @@
4
4
  *
5
5
  * Copyright © 2024 Extremely Heavy Industries Inc.
6
6
  */
7
- import {hoistCmp, HoistModel, RefreshContextModel, useContextModel} from '@xh/hoist/core';
7
+ import {hoistCmp, Loadable, RefreshContextModel, useContextModel} from '@xh/hoist/core';
8
8
  import '@xh/hoist/desktop/register';
9
9
  import {Icon} from '@xh/hoist/icon';
10
- import {errorIf, withDefault} from '@xh/hoist/utils/js';
11
10
  import {button, ButtonProps} from './Button';
11
+ import {apiRemoved} from '@xh/hoist/utils/js';
12
12
 
13
- export type RefreshButtonProps = ButtonProps<HoistModel>;
13
+ export interface RefreshButtonProps extends ButtonProps {
14
+ /** Object to refresh when clicked. */
15
+ target?: Loadable;
16
+ }
14
17
 
15
18
  /**
16
19
  * Convenience Button preconfigured for use as a trigger for a refresh operation.
17
20
  *
18
- * If an onClick handler is provided it will be used. Otherwise this button will
19
- * be linked to any model in props with LoadSupport enabled, or the contextual
21
+ * If an onClick handler is provided it will be used. Otherwise, this button will
22
+ * be linked to the target in props with LoadSupport enabled, or the contextual
20
23
  * See {@link RefreshContextModel}.
21
24
  */
22
25
  export const [RefreshButton, refreshButton] = hoistCmp.withFactory<RefreshButtonProps>({
23
26
  displayName: 'RefreshButton',
24
- model: false, // For consistency with all other buttons -- the model prop here could be replaced by 'target'
27
+ model: false,
25
28
 
26
- render({model, onClick, ...props}, ref) {
27
- const refreshContextModel = useContextModel(RefreshContextModel);
29
+ render({target, onClick, ...props}, ref) {
30
+ apiRemoved('model', {test: props.model, msg: 'Use target instead.'});
28
31
 
32
+ const refreshContextModel = useContextModel(RefreshContextModel);
29
33
  if (!onClick) {
30
- let target: HoistModel = model;
31
- errorIf(
32
- target && !target.loadSupport,
33
- 'Models provided to RefreshButton must enable LoadSupport.'
34
- );
35
- target = withDefault(target, refreshContextModel);
34
+ target ??= refreshContextModel;
36
35
  onClick = target ? () => target.refreshAsync() : null;
37
36
  }
38
37
 
@@ -55,7 +55,7 @@ export const restGridToolbar = hoistCmp.factory({
55
55
  omit: !model.gridModel.enableExport
56
56
  }),
57
57
  refreshButton({
58
- model,
58
+ target: model,
59
59
  omit: !model.showRefreshButton
60
60
  })
61
61
  );
@@ -74,7 +74,7 @@ const selectorPanel = hoistCmp.factory<ManageDialogModel>({
74
74
  onFilterChange: f => (model.filter = f)
75
75
  }),
76
76
  filler(),
77
- refreshButton({model})
77
+ refreshButton({target: model})
78
78
  ]
79
79
  });
80
80
  }
@@ -4,13 +4,16 @@
4
4
  *
5
5
  * Copyright © 2024 Extremely Heavy Industries Inc.
6
6
  */
7
- import {hoistCmp, HoistModel, RefreshContextModel, useContextModel} from '@xh/hoist/core';
7
+ import {hoistCmp, Loadable, RefreshContextModel, useContextModel} from '@xh/hoist/core';
8
8
  import {Icon} from '@xh/hoist/icon';
9
9
  import {button, ButtonProps} from '@xh/hoist/mobile/cmp/button';
10
10
  import '@xh/hoist/mobile/register';
11
- import {errorIf} from '@xh/hoist/utils/js';
11
+ import {apiRemoved} from '@xh/hoist/utils/js';
12
12
 
13
- export type RefreshButtonProps = ButtonProps<HoistModel>;
13
+ export interface RefreshButtonProps extends ButtonProps {
14
+ /** Object to refresh when clicked. */
15
+ target?: Loadable;
16
+ }
14
17
 
15
18
  /**
16
19
  * Convenience Button preconfigured for use as a trigger for a refresh operation.
@@ -21,18 +24,15 @@ export type RefreshButtonProps = ButtonProps<HoistModel>;
21
24
  */
22
25
  export const [RefreshButton, refreshButton] = hoistCmp.withFactory<RefreshButtonProps>({
23
26
  displayName: 'RefreshButton',
24
- model: false, // For consistency with all other buttons -- the model prop here could be replaced by 'target'
27
+ model: false,
25
28
 
26
- render({model, icon = Icon.sync(), onClick, ...props}) {
27
- const refreshContextModel = useContextModel(RefreshContextModel);
29
+ render({target, icon = Icon.sync(), onClick, ...props}) {
30
+ apiRemoved('model', {test: props.model, msg: 'Use target instead.'});
28
31
 
32
+ const refreshContextModel = useContextModel(RefreshContextModel);
29
33
  if (!onClick) {
30
- errorIf(
31
- model && !model.loadSupport,
32
- 'Models provided to RefreshButton must enable LoadSupport.'
33
- );
34
- model = model ?? refreshContextModel;
35
- onClick = model ? () => model.refreshAsync() : null;
34
+ target ??= refreshContextModel;
35
+ onClick = target ? () => target.refreshAsync() : null;
36
36
  }
37
37
 
38
38
  return button({icon, onClick, ...props});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "71.0.0-SNAPSHOT.1735061320692",
3
+ "version": "71.0.0-SNAPSHOT.1735236372248",
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",
@@ -5,17 +5,16 @@
5
5
  * Copyright © 2024 Extremely Heavy Industries Inc.
6
6
  */
7
7
  import {ExcelFormat} from '@xh/hoist/cmp/grid';
8
- import {HoistService, XH} from '@xh/hoist/core';
8
+ import {HoistService, TrackOptions, XH} from '@xh/hoist/core';
9
9
  import {fmtDate} from '@xh/hoist/format';
10
10
  import {Icon} from '@xh/hoist/icon';
11
11
  import {isLocalDate, SECONDS} from '@xh/hoist/utils/datetime';
12
- import {throwIf, withDefault} from '@xh/hoist/utils/js';
12
+ import {withDefault} from '@xh/hoist/utils/js';
13
13
  import download from 'downloadjs';
14
14
  import {StatusCodes} from 'http-status-codes';
15
15
  import {
16
16
  castArray,
17
17
  countBy,
18
- isArray,
19
18
  isEmpty,
20
19
  isFunction,
21
20
  isNil,
@@ -56,21 +55,6 @@ export class GridExportService extends HoistService {
56
55
  timeout = 30 * SECONDS
57
56
  }: ExportOptions = {}
58
57
  ) {
59
- throwIf(!gridModel, 'GridModel required for export');
60
- throwIf(
61
- !isString(filename) && !isFunction(filename),
62
- 'Export filename must be either a string or a closure'
63
- );
64
- throwIf(
65
- !['excel', 'excelTable', 'csv'].includes(type),
66
- `Invalid export type "${type}". Must be either "excel", "excelTable" or "csv"`
67
- );
68
- throwIf(
69
- !(isFunction(columns) || isArray(columns) || ['ALL', 'VISIBLE'].includes(columns)),
70
- 'Invalid columns config - must be "ALL", "VISIBLE", an array of colIds, or a function'
71
- );
72
- throwIf(!isBoolean(track), 'Invalid track value - must be either true or false');
73
-
74
58
  if (isFunction(filename)) filename = filename(gridModel);
75
59
 
76
60
  const config = XH.configService.get('xhExportConfig', {}),
@@ -153,11 +137,13 @@ export class GridExportService extends HoistService {
153
137
  XH.successToast('Export complete.');
154
138
 
155
139
  if (track) {
140
+ const trackOpts = track !== true ? track : null;
156
141
  XH.track({
157
142
  category: 'Export',
158
143
  message: `Downloaded ${filename}${fileExt}`,
159
144
  data: {rows: rows.length, columns: exportColumns.length},
160
- logData: true
145
+ logData: true,
146
+ ...trackOpts
161
147
  });
162
148
  }
163
149
  } catch (e) {
@@ -460,7 +446,7 @@ export interface ExportOptions {
460
446
  columns?: 'VISIBLE' | 'ALL' | string[] | ((g: GridModel) => string[]);
461
447
 
462
448
  /** True to enable activity tracking of exports (default false). */
463
- track?: boolean;
449
+ track?: boolean | Partial<TrackOptions>;
464
450
 
465
451
  /** Timeout (in ms) for export request - defaults to 30 seconds. */
466
452
  timeout?: number;