@xh/hoist 75.0.0-SNAPSHOT.1753115287677 → 75.0.0-SNAPSHOT.1753198948130

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
@@ -4,13 +4,15 @@
4
4
 
5
5
  ### 🎁 New Features
6
6
 
7
- * Added new `GridModel.expandToLevel` config to control the expansion state of tree/grouped grids.
7
+ * Added new `GridModel.expandLevel` config to control the expansion state of tree/grouped grids.
8
8
  * Replaces the use of the `agOptions.groupDefaultExpanded` on the component.
9
9
  * The most recently expanded level is persistable with other grid state.
10
10
  * The default grid context menu now supports a new item to allow users to expand/collapse out to
11
11
  a specific level/depth. Set `GridModel.levelLabels` to activate this feature.
12
12
  * Added new `GroupingChooserModel.sortDimensions` config. Set to `false` to respect the order in
13
13
  which `dimensions` are provided to the model.
14
+ * The usage of the `RelativeTimestamp` component has been streamlined by deprecating the `options`
15
+ prop. All `RelativeTimestampOptions` are now supported by this component as top-level props.
14
16
 
15
17
  ### 🐞 Bug Fixes
16
18
 
@@ -429,7 +429,7 @@ export class ActivityTrackingModel extends HoistModel implements ActivityDetailP
429
429
  exportOptions: {filename: exportFilename('activity-summary')},
430
430
  emptyText: 'No activity reported...',
431
431
  sortBy: ['cubeLabel'],
432
- expandToLevel: 1,
432
+ expandLevel: 1,
433
433
  levelLabels: () => ['Total', ...this.groupingChooserModel.valueDisplayNames],
434
434
  columns: [
435
435
  {
@@ -40,11 +40,12 @@ const clientDetail = hoistCmp.factory<ClientDetailModel>(({model}) => {
40
40
  items: [
41
41
  relativeTimestamp({
42
42
  timestamp: data.createdTime,
43
- options: {prefix: 'Session established'}
43
+ prefix: 'Session established'
44
44
  }),
45
45
  relativeTimestamp({
46
46
  timestamp: data.lastReceivedTime,
47
- options: {prefix: 'Last heartbeat', emptyResult: 'No heartbeat yet'}
47
+ prefix: 'Last heartbeat',
48
+ emptyResult: 'No heartbeat yet'
48
49
  })
49
50
  ]
50
51
  })
@@ -43,7 +43,7 @@ export class ClusterObjectsModel extends HoistModel {
43
43
  @managed gridModel = new GridModel({
44
44
  selModel: 'multiple',
45
45
  treeMode: true,
46
- expandToLevel: 2,
46
+ expandLevel: 2,
47
47
  autosizeOptions: {mode: 'managed', includeCollapsedChildren: true},
48
48
  enableExport: true,
49
49
  exportOptions: {filename: exportFilenameWithDate('cluster-objects'), columns: 'ALL'},
@@ -148,11 +148,8 @@ const formPanel = hoistCmp.factory<AlertBannerModel>(({model}) => {
148
148
  field: 'expires',
149
149
  info: relativeTimestamp({
150
150
  timestamp: formModel.values.expires,
151
- options: {
152
- allowFuture: true,
153
- emptyResult:
154
- 'Set a date & time to automatically hide this banner.'
155
- }
151
+ allowFuture: true,
152
+ emptyResult: 'Set a date & time to automatically hide this banner.'
156
153
  }),
157
154
  item: dateInput({
158
155
  enableClear: true,
@@ -58,7 +58,7 @@ export interface GridConfig {
58
58
  * Depth level to expand to on initial load. 0 = all collapsed, 1 = top level expanded, etc.
59
59
  * Defaults to 0 for tree grids (i.e. treeMode = true), 1 for standard grouped grids.
60
60
  */
61
- expandToLevel?: number;
61
+ expandLevel?: number;
62
62
  /** True (default) to show a count of group member rows within each full-width group row. */
63
63
  showGroupRowCounts?: boolean;
64
64
  /** Size of text in grid. If undefined, will default and bind to `XH.sizingMode`. */
@@ -261,7 +261,7 @@ export declare class GridModel extends HoistModel {
261
261
  expandState: any;
262
262
  sortBy: GridSorter[];
263
263
  groupBy: string[];
264
- expandToLevel: number;
264
+ expandLevel: number;
265
265
  get persistableColumnState(): ColumnState[];
266
266
  showSummary: boolean | VSide;
267
267
  emptyText: ReactNode;
@@ -435,7 +435,7 @@ export declare class GridModel extends HoistModel {
435
435
  /** Collapse all parent rows in grouped or tree grid. */
436
436
  collapseAll(): void;
437
437
  /** Expand all parent rows in grouped or tree grid to the specified level. */
438
- setExpandToLevel(level: number): void;
438
+ expandToLevel(level: number): void;
439
439
  /**
440
440
  * Sort this grid.
441
441
  * This method is a no-op if provided any sorters without a corresponding column.
@@ -1,5 +1,5 @@
1
1
  import { BoxProps, HoistProps } from '@xh/hoist/core';
2
- interface RelativeTimestampProps extends HoistProps, BoxProps {
2
+ interface RelativeTimestampProps extends HoistProps, BoxProps, RelativeTimestampOptions {
3
3
  /**
4
4
  * Property on context model containing timestamp.
5
5
  * Specify as an alternative to direct `timestamp` prop (and minimize parent re-renders).
@@ -7,7 +7,11 @@ interface RelativeTimestampProps extends HoistProps, BoxProps {
7
7
  bind?: string;
8
8
  /** Date or milliseconds representing the starting time / time to compare. See also `bind`. */
9
9
  timestamp?: Date | number;
10
- /** Formatting options */
10
+ /**
11
+ * Formatting options.
12
+ *
13
+ * @deprecated - these options should be spread into this object directly.
14
+ */
11
15
  options?: RelativeTimestampOptions;
12
16
  }
13
17
  export interface RelativeTimestampOptions {
@@ -73,7 +73,7 @@ export interface ZoneGridConfig {
73
73
  /** Column ID(s) by which to do full-width grouping. */
74
74
  groupBy?: Some<string>;
75
75
  /** Group level to expand to on initial load. 0 = all collapsed, 1 = only top level expanded. */
76
- expandToLevel?: number;
76
+ expandLevel?: number;
77
77
  /** True (default) to show a count of group member rows within each full-width group row. */
78
78
  showGroupRowCounts?: boolean;
79
79
  /** True to highlight the currently hovered row. */
package/cmp/grid/Grid.ts CHANGED
@@ -246,7 +246,7 @@ export class GridLocalModel extends HoistModel {
246
246
  navigateToNextCell: this.navigateToNextCell,
247
247
  processCellForClipboard: this.processCellForClipboard,
248
248
  initialGroupOrderComparator: model.groupSortFn ? this.groupSortComparator : undefined,
249
- groupDefaultExpanded: model.expandToLevel,
249
+ groupDefaultExpanded: model.expandLevel,
250
250
  groupDisplayType: 'groupRows',
251
251
  groupRowRendererParams: {
252
252
  innerRenderer: model.groupRowRenderer,
@@ -172,7 +172,7 @@ export interface GridConfig {
172
172
  * Depth level to expand to on initial load. 0 = all collapsed, 1 = top level expanded, etc.
173
173
  * Defaults to 0 for tree grids (i.e. treeMode = true), 1 for standard grouped grids.
174
174
  */
175
- expandToLevel?: number;
175
+ expandLevel?: number;
176
176
 
177
177
  /** True (default) to show a count of group member rows within each full-width group row. */
178
178
  showGroupRowCounts?: boolean;
@@ -426,7 +426,7 @@ export class GridModel extends HoistModel {
426
426
  @observable.ref expandState: any = {};
427
427
  @observable.ref sortBy: GridSorter[] = [];
428
428
  @observable.ref groupBy: string[] = null;
429
- @observable expandToLevel: number = 0;
429
+ @observable expandLevel: number = 0;
430
430
 
431
431
  get persistableColumnState(): ColumnState[] {
432
432
  return this.cleanColumnState(this.columnState);
@@ -540,7 +540,7 @@ export class GridModel extends HoistModel {
540
540
  restoreDefaultsWarning = GridModel.DEFAULT_RESTORE_DEFAULTS_WARNING,
541
541
  fullRowEditing = false,
542
542
  clicksToEdit = 2,
543
- expandToLevel = treeMode ? 0 : 1,
543
+ expandLevel = treeMode ? 0 : 1,
544
544
  levelLabels,
545
545
  highlightRowOnClick = XH.isMobileApp,
546
546
  experimental,
@@ -588,7 +588,7 @@ export class GridModel extends HoistModel {
588
588
  this.clicksToExpand = clicksToExpand;
589
589
  this.clicksToEdit = clicksToEdit;
590
590
  this.highlightRowOnClick = highlightRowOnClick;
591
- this.expandToLevel = expandToLevel;
591
+ this.expandLevel = expandLevel;
592
592
  this.levelLabels = levelLabels;
593
593
 
594
594
  throwIf(
@@ -644,9 +644,9 @@ export class GridModel extends HoistModel {
644
644
  });
645
645
 
646
646
  this.addReaction({
647
- track: () => [this.expandToLevel, this.isReady],
647
+ track: () => [this.expandLevel, this.isReady],
648
648
  run: () => {
649
- this.agApi?.setGridOption('groupDefaultExpanded', this.expandToLevel);
649
+ this.agApi?.setGridOption('groupDefaultExpanded', this.expandLevel);
650
650
  }
651
651
  });
652
652
 
@@ -1028,18 +1028,18 @@ export class GridModel extends HoistModel {
1028
1028
 
1029
1029
  /** Expand all parent rows in grouped or tree grid. (Note, this is recursive for trees!) */
1030
1030
  expandAll() {
1031
- this.setExpandToLevel(this.maxDepth);
1031
+ this.expandToLevel(this.maxDepth);
1032
1032
  }
1033
1033
 
1034
1034
  /** Collapse all parent rows in grouped or tree grid. */
1035
1035
  collapseAll() {
1036
- this.setExpandToLevel(0);
1036
+ this.expandToLevel(0);
1037
1037
  }
1038
1038
 
1039
1039
  /** Expand all parent rows in grouped or tree grid to the specified level. */
1040
1040
  @action
1041
- setExpandToLevel(level: number) {
1042
- this.expandToLevel = level;
1041
+ expandToLevel(level: number) {
1042
+ this.expandLevel = level;
1043
1043
  }
1044
1044
 
1045
1045
  /**
@@ -83,12 +83,12 @@ export function initPersist(
83
83
  : rootPersistWith;
84
84
  PersistenceProvider.create({
85
85
  persistOptions: {
86
- path: `${path}.expandToLevel`,
86
+ path: `${path}.expandLevel`,
87
87
  ...persistWith
88
88
  },
89
89
  target: {
90
- getPersistableState: () => new PersistableState(gridModel.expandToLevel),
91
- setPersistableState: ({value}) => gridModel.setExpandToLevel(value)
90
+ getPersistableState: () => new PersistableState(gridModel.expandLevel),
91
+ setPersistableState: ({value}) => gridModel.expandToLevel(value)
92
92
  },
93
93
  owner: gridModel
94
94
  });
@@ -283,7 +283,7 @@ function levelExpandAction(gridModel: GridModel): RecordAction {
283
283
  text: 'Expand to ...',
284
284
  displayFn: () => {
285
285
  // Don't show for degenerate shallow grid models, or if we don't have labels
286
- const {maxDepth, expandToLevel} = gridModel;
286
+ const {maxDepth, expandLevel} = gridModel;
287
287
  if (maxDepth <= 1) return {hidden: true};
288
288
 
289
289
  // Validate level labels.
@@ -300,13 +300,13 @@ function levelExpandAction(gridModel: GridModel): RecordAction {
300
300
 
301
301
  const items = levelLabels.map((label, idx) => {
302
302
  const isCurrLevel =
303
- expandToLevel === idx ||
304
- (expandToLevel > maxDepth && idx === levelLabels.length - 1);
303
+ expandLevel === idx ||
304
+ (expandLevel > maxDepth && idx === levelLabels.length - 1);
305
305
 
306
306
  return {
307
307
  icon: isCurrLevel ? Icon.check() : null,
308
308
  text: label,
309
- actionFn: () => gridModel.setExpandToLevel(idx)
309
+ actionFn: () => gridModel.expandToLevel(idx)
310
310
  };
311
311
  });
312
312
  return {items};
@@ -4,6 +4,7 @@
4
4
  *
5
5
  * Copyright © 2025 Extremely Heavy Industries Inc.
6
6
  */
7
+ import {getLayoutProps} from '@xh/hoist/utils/react';
7
8
  import {inRange, isNil} from 'lodash';
8
9
  import moment from 'moment';
9
10
  import {box, span} from '@xh/hoist/cmp/layout';
@@ -20,9 +21,9 @@ import {fmtCompactDate, fmtDateTime} from '@xh/hoist/format';
20
21
  import {action, computed, makeObservable, observable} from '@xh/hoist/mobx';
21
22
  import {Timer} from '@xh/hoist/utils/async';
22
23
  import {DAYS, HOURS, LocalDate, SECONDS} from '@xh/hoist/utils/datetime';
23
- import {logWarn, withDefault} from '@xh/hoist/utils/js';
24
+ import {apiDeprecated, logWarn, withDefault} from '@xh/hoist/utils/js';
24
25
 
25
- interface RelativeTimestampProps extends HoistProps, BoxProps {
26
+ interface RelativeTimestampProps extends HoistProps, BoxProps, RelativeTimestampOptions {
26
27
  /**
27
28
  * Property on context model containing timestamp.
28
29
  * Specify as an alternative to direct `timestamp` prop (and minimize parent re-renders).
@@ -32,7 +33,11 @@ interface RelativeTimestampProps extends HoistProps, BoxProps {
32
33
  /** Date or milliseconds representing the starting time / time to compare. See also `bind`. */
33
34
  timestamp?: Date | number;
34
35
 
35
- /** Formatting options */
36
+ /**
37
+ * Formatting options.
38
+ *
39
+ * @deprecated - these options should be spread into this object directly.
40
+ */
36
41
  options?: RelativeTimestampOptions;
37
42
  }
38
43
 
@@ -91,13 +96,13 @@ export const [RelativeTimestamp, relativeTimestamp] = hoistCmp.withFactory<Relat
91
96
  displayName: 'RelativeTimestamp',
92
97
  className: 'xh-relative-timestamp',
93
98
 
94
- render({className, bind, timestamp, options, ...rest}, ref) {
95
- const impl = useLocalModel(RelativeTimestampLocalModel);
96
-
99
+ render({className, bind, timestamp, ...rest}, ref) {
100
+ const impl = useLocalModel(RelativeTimestampLocalModel),
101
+ layoutProps = getLayoutProps(rest);
97
102
  return box({
98
103
  className,
99
104
  ref,
100
- ...rest,
105
+ ...layoutProps,
101
106
  item: span({
102
107
  className: 'xh-title-tip',
103
108
  item: impl.display,
@@ -128,7 +133,15 @@ class RelativeTimestampLocalModel extends HoistModel {
128
133
 
129
134
  @computed.struct
130
135
  get options(): RelativeTimestampOptions {
131
- return this.componentProps.options;
136
+ const {componentProps} = this;
137
+
138
+ apiDeprecated('options', {
139
+ test: componentProps.options,
140
+ msg: 'Spread options directly in this object instead',
141
+ v: `77`
142
+ });
143
+
144
+ return componentProps.options ?? componentProps;
132
145
  }
133
146
 
134
147
  constructor() {
@@ -148,7 +148,7 @@ export interface ZoneGridConfig {
148
148
  groupBy?: Some<string>;
149
149
 
150
150
  /** Group level to expand to on initial load. 0 = all collapsed, 1 = only top level expanded. */
151
- expandToLevel?: number;
151
+ expandLevel?: number;
152
152
 
153
153
  /** True (default) to show a count of group member rows within each full-width group row. */
154
154
  showGroupRowCounts?: boolean;
@@ -189,7 +189,7 @@ export class LeftRightChooserModel extends HoistModel {
189
189
  onRowDoubleClicked: e => this.onRowDoubleClicked(e),
190
190
  columns: [leftTextCol, groupCol],
191
191
  contextMenu: false,
192
- expandToLevel: leftGroupingExpanded ? 1 : 0,
192
+ expandLevel: leftGroupingExpanded ? 1 : 0,
193
193
  xhImpl: true
194
194
  });
195
195
 
@@ -201,7 +201,7 @@ export class LeftRightChooserModel extends HoistModel {
201
201
  onRowDoubleClicked: e => this.onRowDoubleClicked(e),
202
202
  columns: [rightTextCol, groupCol],
203
203
  contextMenu: false,
204
- expandToLevel: rightGroupingExpanded ? 1 : 0,
204
+ expandLevel: rightGroupingExpanded ? 1 : 0,
205
205
  xhImpl: true
206
206
  });
207
207
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "75.0.0-SNAPSHOT.1753115287677",
3
+ "version": "75.0.0-SNAPSHOT.1753198948130",
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",