@xh/hoist 71.0.0-SNAPSHOT.1735062266455 → 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
@@ -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
  }
@@ -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.1735062266455",
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;