@xh/hoist 80.0.0-SNAPSHOT.1768003263151 → 80.0.0-SNAPSHOT.1768251400948

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/types/cmp/grid/GridModel.d.ts +2 -2
  3. package/build/types/cmp/layout/CollapsibleSet.d.ts +14 -0
  4. package/build/types/cmp/layout/Tags.d.ts +2 -0
  5. package/build/types/cmp/tab/TabContainerModel.d.ts +1 -1
  6. package/build/types/core/enums/RenderMode.d.ts +1 -1
  7. package/build/types/desktop/cmp/button/CollapsibleSetButton.d.ts +12 -0
  8. package/build/types/desktop/cmp/dash/canvas/DashCanvasModel.d.ts +46 -6
  9. package/build/types/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWell.d.ts +19 -0
  10. package/build/types/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWellModel.d.ts +11 -0
  11. package/build/types/dynamics/desktop.d.ts +1 -0
  12. package/build/types/dynamics/mobile.d.ts +1 -0
  13. package/build/types/mobile/cmp/button/CollapsibleSetButton.d.ts +12 -0
  14. package/cmp/grid/GridModel.ts +2 -2
  15. package/cmp/layout/CollapsibleSet.scss +49 -0
  16. package/cmp/layout/CollapsibleSet.ts +135 -0
  17. package/cmp/layout/Tags.ts +2 -0
  18. package/cmp/tab/TabContainerModel.ts +1 -1
  19. package/core/enums/RenderMode.ts +1 -1
  20. package/desktop/appcontainer/AppContainer.ts +2 -0
  21. package/desktop/cmp/button/CollapsibleSetButton.ts +57 -0
  22. package/desktop/cmp/dash/canvas/DashCanvas.ts +21 -4
  23. package/desktop/cmp/dash/canvas/DashCanvasModel.ts +140 -24
  24. package/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWell.scss +34 -0
  25. package/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWell.ts +135 -0
  26. package/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWellModel.ts +65 -0
  27. package/dynamics/desktop.ts +2 -0
  28. package/dynamics/mobile.ts +2 -0
  29. package/mobile/appcontainer/AppContainer.ts +2 -0
  30. package/mobile/cmp/button/CollapsibleSetButton.ts +57 -0
  31. package/package.json +3 -3
  32. package/tsconfig.tsbuildinfo +1 -1
@@ -4,6 +4,7 @@
4
4
  *
5
5
  * Copyright © 2026 Extremely Heavy Industries Inc.
6
6
  */
7
+ import {wait} from '@xh/hoist/promise';
7
8
  import type {LayoutItem} from 'react-grid-layout';
8
9
  import {Persistable, PersistableState, PersistenceProvider, XH} from '@xh/hoist/core';
9
10
  import {required} from '@xh/hoist/data';
@@ -17,6 +18,7 @@ import {createObservableRef} from '@xh/hoist/utils/react';
17
18
  import {
18
19
  defaultsDeep,
19
20
  find,
21
+ omit,
20
22
  uniqBy,
21
23
  times,
22
24
  without,
@@ -41,11 +43,12 @@ export interface DashCanvasConfig extends DashConfig<DashCanvasViewSpec, DashCan
41
43
  rowHeight?: number;
42
44
 
43
45
  /**
44
- * Whether views should "compact" vertically or horizontally
46
+ * Whether views should "compact" vertically, horizontally or wrap
45
47
  * to condense space. Default `true` defaults to vertical compaction.
48
+ * Use `wrap` with caution. It only works well if all items are 1 row high.
46
49
  * See react-grid-layout docs for more information.
47
- * */
48
- compact?: boolean | 'vertical' | 'horizontal';
50
+ */
51
+ compact?: boolean | 'vertical' | 'horizontal' | 'wrap';
49
52
 
50
53
  /** Between items [x,y] in pixels. Default `[10, 10]`. */
51
54
  margin?: [number, number];
@@ -60,6 +63,35 @@ export interface DashCanvasConfig extends DashConfig<DashCanvasViewSpec, DashCan
60
63
  * Whether a grid background should be shown. Default false.
61
64
  */
62
65
  showGridBackground?: boolean;
66
+
67
+ /**
68
+ * Whether the canvas should accept drag-and-drop of views from outside
69
+ * the canvas. Default false.
70
+ */
71
+ allowsDrop?: boolean;
72
+
73
+ /**
74
+ * Optional callback to invoke after a view is successfully dropped onto the canvas.
75
+ */
76
+ onDropDone?: (viewModel: DashCanvasViewModel) => void;
77
+
78
+ /**
79
+ * Optional callback to invoke when an item is dragged over the canvas. This may be used to
80
+ * customize how the size of the dropping placeholder is calculated. The callback should
81
+ * return an object with optional properties indicating the desired width, height (in grid units),
82
+ * and offset (in pixels) of the dropping placeholder. The method's signature is the same as
83
+ * the `onDropDragOver` prop of ReactGridLayout.
84
+ * Returning `false` will prevent the dropping placeholder from being shown, and prevents a drop.
85
+ * Returning `void` will use the default behavior, which is to size the placeholder as per the
86
+ * `dropConfig.defaultItem` specification.
87
+ */
88
+ onDropDragOver?: (e: DragEvent) => OnDropDragOverResult;
89
+
90
+ /**
91
+ * Whether an overlay with an Add View button should be rendered
92
+ * when the canvas is empty. Default true.
93
+ */
94
+ showAddViewButtonWhenEmpty?: boolean;
63
95
  }
64
96
 
65
97
  export interface DashCanvasItemState {
@@ -76,6 +108,16 @@ export interface DashCanvasItemLayout {
76
108
  h: number;
77
109
  }
78
110
 
111
+ export type OnDropDragOverResult =
112
+ | {
113
+ w?: number;
114
+ h?: number;
115
+ dragOffsetX?: number;
116
+ dragOffsetY?: number;
117
+ }
118
+ | false
119
+ | void;
120
+
79
121
  /**
80
122
  * Model for {@link DashCanvas}, managing all configurable options for the component and publishing
81
123
  * the observable state of its current widgets and their layout.
@@ -89,16 +131,21 @@ export class DashCanvasModel
89
131
  //------------------------------
90
132
  @bindable columns: number;
91
133
  @bindable rowHeight: number;
92
- @bindable compact: 'vertical' | 'horizontal';
134
+ @bindable compact: 'vertical' | 'horizontal' | 'wrap';
93
135
  @bindable.ref margin: [number, number]; // [x, y]
94
136
  @bindable.ref containerPadding: [number, number]; // [x, y]
95
137
  @bindable showGridBackground: boolean;
96
138
  @bindable rglHeight: number;
139
+ @bindable showAddViewButtonWhenEmpty: boolean;
97
140
 
98
141
  //-----------------------------
99
142
  // Public properties
100
143
  //-----------------------------
144
+ DROPPING_ELEM_ID = '__dropping-elem__';
101
145
  maxRows: number;
146
+ allowsDrop: boolean;
147
+ onDropDone: (viewModel: DashCanvasViewModel) => void;
148
+ draggedInView: DashCanvasItemState;
102
149
 
103
150
  /** Current number of rows in canvas */
104
151
  get rows(): number {
@@ -118,21 +165,27 @@ export class DashCanvasModel
118
165
  private isLoadingState: boolean;
119
166
 
120
167
  get rglLayout() {
121
- return this.layout.map(it => {
122
- const dashCanvasView = this.getView(it.i),
123
- {autoHeight, viewSpec} = dashCanvasView;
124
-
125
- return {
126
- ...it,
127
- resizeHandles: autoHeight
128
- ? ['w', 'e']
129
- : ['s', 'w', 'e', 'n', 'sw', 'nw', 'se', 'ne'],
130
- maxH: viewSpec.maxHeight,
131
- minH: viewSpec.minHeight,
132
- maxW: viewSpec.maxWidth,
133
- minW: viewSpec.minWidth
134
- };
135
- });
168
+ return this.layout
169
+ .map(it => {
170
+ const dashCanvasView = this.getView(it.i);
171
+
172
+ // `dashCanvasView` will not be found if `it` is a dropping element.
173
+ if (!dashCanvasView) return null;
174
+
175
+ const {autoHeight, viewSpec} = dashCanvasView;
176
+
177
+ return {
178
+ ...it,
179
+ resizeHandles: autoHeight
180
+ ? ['w', 'e']
181
+ : ['s', 'w', 'e', 'n', 'sw', 'nw', 'se', 'ne'],
182
+ maxH: viewSpec.maxHeight,
183
+ minH: viewSpec.minHeight,
184
+ maxW: viewSpec.maxWidth,
185
+ minW: viewSpec.minWidth
186
+ };
187
+ })
188
+ .filter(Boolean);
136
189
  }
137
190
 
138
191
  constructor({
@@ -152,7 +205,11 @@ export class DashCanvasModel
152
205
  maxRows = Infinity,
153
206
  containerPadding = margin,
154
207
  extraMenuItems,
155
- showGridBackground = false
208
+ showGridBackground = false,
209
+ showAddViewButtonWhenEmpty = true,
210
+ allowsDrop = false,
211
+ onDropDone,
212
+ onDropDragOver
156
213
  }: DashCanvasConfig) {
157
214
  super();
158
215
  makeObservable(this);
@@ -200,6 +257,10 @@ export class DashCanvasModel
200
257
  this.addViewButtonText = addViewButtonText;
201
258
  this.extraMenuItems = extraMenuItems;
202
259
  this.showGridBackground = showGridBackground;
260
+ this.showAddViewButtonWhenEmpty = showAddViewButtonWhenEmpty;
261
+ this.allowsDrop = allowsDrop;
262
+ this.onDropDone = onDropDone;
263
+ if (onDropDragOver) this.onDropDragOver = onDropDragOver;
203
264
 
204
265
  this.loadState(initialState);
205
266
  this.state = this.buildState();
@@ -337,6 +398,59 @@ export class DashCanvasModel
337
398
  this.getView(id)?.ensureVisible();
338
399
  }
339
400
 
401
+ onDrop(rglLayout: LayoutItem[], layoutItem: LayoutItem, evt: Event) {
402
+ throwIf(
403
+ !this.draggedInView,
404
+ `No draggedInView set on DashCanvasModel prior to onDrop operation.
405
+ Typically a developer would set this in response to dragstart events from
406
+ a DashViewTray or similar component.`
407
+ );
408
+
409
+ const droppingItem: any = rglLayout.find(it => it.i === this.DROPPING_ELEM_ID);
410
+ if (!droppingItem) {
411
+ // if `onDropDragOver` returned false, we won't have a dropping item
412
+ // and we cancel the drop
413
+ this.draggedInView = null;
414
+ return;
415
+ }
416
+
417
+ const {viewSpecId, title, state} = this.draggedInView,
418
+ layout = omit(layoutItem, 'i'),
419
+ newViewModel: DashCanvasViewModel = this.addViewInternal(viewSpecId, {
420
+ title,
421
+ state,
422
+ layout
423
+ });
424
+
425
+ // Change ID of dropping item to the new view's id
426
+ // so that the new view goes where the dropping item is.
427
+ droppingItem.i = newViewModel.id;
428
+
429
+ // must wait a tick for RGL to settle
430
+ wait().then(() => {
431
+ this.draggedInView = null;
432
+ this.onRglLayoutChange(rglLayout);
433
+ this.onDropDone?.(newViewModel);
434
+ });
435
+ }
436
+
437
+ setDraggedInView(view?: DashCanvasItemState) {
438
+ this.draggedInView = view;
439
+ }
440
+
441
+ onDropDragOver(evt: DragEvent): OnDropDragOverResult {
442
+ if (!this.draggedInView) return false;
443
+
444
+ return {
445
+ w: this.draggedInView.layout.w,
446
+ h: this.draggedInView.layout.h
447
+ };
448
+ }
449
+
450
+ getViewsBySpecId(id) {
451
+ return this.viewModels.filter(it => it.viewSpec.id === id);
452
+ }
453
+
340
454
  //------------------------
341
455
  // Persistable Interface
342
456
  //------------------------
@@ -413,6 +527,12 @@ export class DashCanvasModel
413
527
 
414
528
  onRglLayoutChange(rglLayout: LayoutItem[]) {
415
529
  rglLayout = rglLayout.map(it => pick(it, ['i', 'x', 'y', 'w', 'h']));
530
+
531
+ // Early out if RGL is changing layout as user is dragging droppable
532
+ // item around the canvas. This will be called again once dragging
533
+ // has stopped and user has dropped the item onto the canvas.
534
+ if (rglLayout.some(it => it.i === this.DROPPING_ELEM_ID)) return;
535
+
416
536
  this.setLayout(rglLayout);
417
537
  }
418
538
 
@@ -496,10 +616,6 @@ export class DashCanvasModel
496
616
  return some(this.viewSpecs, {id});
497
617
  }
498
618
 
499
- private getViewsBySpecId(id) {
500
- return this.viewModels.filter(it => it.viewSpec.id === id);
501
- }
502
-
503
619
  private getNextAvailablePosition({
504
620
  width,
505
621
  height,
@@ -0,0 +1,34 @@
1
+ .xh-dash-canvas-widget-well {
2
+ padding: 0 var(--xh-pad-half-px);
3
+
4
+ .xh-collapsible-set {
5
+ padding: 0 var(--xh-pad-half-px) var(--xh-pad-half-px) var(--xh-pad-half-px);
6
+ margin: var(--xh-pad-half-px);
7
+ }
8
+
9
+ .xh-dash-canvas-draggable-widget {
10
+ border: var(--xh-border-dotted);
11
+ background-color: var(--xh-bg-alt);
12
+ padding: var(--xh-pad-half-px);
13
+ margin: var(--xh-pad-half-px);
14
+ text-wrap-mode: nowrap;
15
+ cursor: grab;
16
+
17
+ &.is-dragging {
18
+ cursor: grabbing;
19
+ // lighten background color of left behind placeholder
20
+ // when dragging
21
+ opacity: 0.25;
22
+ }
23
+
24
+ &:active {
25
+ cursor: grabbing;
26
+ }
27
+ }
28
+
29
+ &--row {
30
+ .xh-dash-canvas-draggable-widget {
31
+ align-self: flex-start;
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,135 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2025 Extremely Heavy Industries Inc.
6
+ */
7
+
8
+ import {uniqBy} from 'lodash';
9
+ import classNames from 'classnames';
10
+ import type {ReactElement} from 'react';
11
+ import {div, frame} from '@xh/hoist/cmp/layout';
12
+ import {creates, hoistCmp, HoistProps, TestSupportProps, uses} from '@xh/hoist/core';
13
+ import {DashCanvasModel, DashCanvasViewSpec} from '@xh/hoist/desktop/cmp/dash';
14
+ import {DashCanvasWidgetWellModel} from '@xh/hoist/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWellModel';
15
+ import {collapsibleSet} from '@xh/hoist/cmp/layout/CollapsibleSet';
16
+
17
+ import './DashCanvasWidgetWell.scss';
18
+
19
+ export interface DashCanvasWidgetWellProps extends HoistProps, TestSupportProps {
20
+ /** DashCanvasModel for which this widget well should allow the user to add views from. */
21
+ dashCanvasModel?: DashCanvasModel;
22
+ /** Defaults to `column` */
23
+ flexDirection?: 'row' | 'column';
24
+ }
25
+
26
+ /**
27
+ * Widget Well from which to add items to a DashCanvas by drag-and-drop.
28
+ *
29
+ * Available view specs are listed in their defined order,
30
+ * grouped by their 'groupName' property if present.
31
+ *
32
+ * Typically, an app developer would place this inside a collapsible panel to the side of
33
+ * a DashCanvas.
34
+ */
35
+ export const [DashCanvasWidgetWell, dashCanvasWidgetWell] =
36
+ hoistCmp.withFactory<DashCanvasWidgetWellProps>({
37
+ displayName: 'DashCanvasWidgetWell',
38
+ model: creates(DashCanvasWidgetWellModel),
39
+ className: 'xh-dash-canvas-widget-well',
40
+ render({dashCanvasModel, flexDirection, className, testId}) {
41
+ if (!dashCanvasModel) return;
42
+
43
+ const classes = [];
44
+ if (flexDirection === 'row') classes.push('xh-dash-canvas-widget-well--row');
45
+
46
+ return frame({
47
+ className: classNames(className, classes),
48
+ overflowY: 'auto',
49
+ flexDirection: flexDirection || 'column',
50
+ flexWrap: flexDirection === 'row' ? 'wrap' : 'nowrap',
51
+ items: createDraggableItems(dashCanvasModel, flexDirection),
52
+ testId
53
+ });
54
+ }
55
+ });
56
+
57
+ //---------------------------
58
+ // Implementation
59
+ //---------------------------
60
+ const draggableWidget = hoistCmp.factory<DashCanvasWidgetWellModel>({
61
+ displayName: 'DraggableWidget',
62
+ model: uses(DashCanvasWidgetWellModel),
63
+ render({model, viewSpec}) {
64
+ const {id, icon, title} = viewSpec as DashCanvasViewSpec;
65
+ return div({
66
+ id: `draggableFor-${id}`,
67
+ className: 'xh-dash-canvas-draggable-widget',
68
+ draggable: true,
69
+ unselectable: 'on',
70
+ onDragStart: e => model.onDragStart(e),
71
+ onDragEnd: e => model.onDragEnd(e),
72
+ items: [icon, ' ', title]
73
+ });
74
+ }
75
+ });
76
+
77
+ /**
78
+ * Used to create draggable items (for adding views)
79
+ * @internal
80
+ */
81
+ function createDraggableItems(dashCanvasModel: DashCanvasModel, flexDirection): any[] {
82
+ if (!dashCanvasModel.ref.current) return [];
83
+
84
+ const groupedItems = {},
85
+ ungroupedItems = [];
86
+
87
+ const addToGroup = (item, icon, groupName) => {
88
+ const group = groupedItems[groupName];
89
+ if (group) {
90
+ group.push({item, icon});
91
+ } else {
92
+ groupedItems[groupName] = [{item, icon}];
93
+ }
94
+ };
95
+
96
+ dashCanvasModel.viewSpecs
97
+ .filter(viewSpec => {
98
+ return (
99
+ viewSpec.allowAdd &&
100
+ (!viewSpec.unique || !dashCanvasModel.getViewsBySpecId(viewSpec.id).length)
101
+ );
102
+ })
103
+ .forEach(viewSpec => {
104
+ const {groupName} = viewSpec,
105
+ item = draggableWidget({viewSpec});
106
+
107
+ if (groupName) {
108
+ addToGroup(item, viewSpec.icon, groupName);
109
+ } else {
110
+ ungroupedItems.push(item);
111
+ }
112
+ });
113
+
114
+ return [
115
+ ...Object.keys(groupedItems).map(group => {
116
+ const label = group,
117
+ items = groupedItems[group],
118
+ sameIcons =
119
+ uniqBy<{item: ReactElement; icon: ReactElement}>(
120
+ items,
121
+ it => it.icon.props.iconName
122
+ ).length === 1,
123
+ icon = sameIcons ? items[0].icon : null;
124
+
125
+ return collapsibleSet({
126
+ icon,
127
+ collapsed: false,
128
+ label,
129
+ flexDirection,
130
+ items: items.map(it => it.item)
131
+ });
132
+ }),
133
+ ...ungroupedItems
134
+ ];
135
+ }
@@ -0,0 +1,65 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2025 Extremely Heavy Industries Inc.
6
+ */
7
+ import {DragEvent} from 'react';
8
+ import {DashCanvasModel} from '@xh/hoist/desktop/cmp/dash';
9
+ import {HoistModel, managed} from '@xh/hoist/core';
10
+ import '@xh/hoist/desktop/register';
11
+ import {makeObservable, observable} from '@xh/hoist/mobx';
12
+ import {runInAction} from 'mobx';
13
+
14
+ export class DashCanvasWidgetWellModel extends HoistModel {
15
+ @managed
16
+ @observable.ref
17
+ dashCanvasModel: DashCanvasModel;
18
+
19
+ constructor() {
20
+ super();
21
+ makeObservable(this);
22
+ }
23
+
24
+ override onLinked() {
25
+ this.addReaction({
26
+ track: () => this.componentProps,
27
+ run: () =>
28
+ runInAction(() => (this.dashCanvasModel = this.componentProps.dashCanvasModel)),
29
+ fireImmediately: true
30
+ });
31
+ }
32
+
33
+ onDragStart(evt: DragEvent<HTMLDivElement>) {
34
+ const target = evt.target as HTMLElement;
35
+ if (!target) return;
36
+
37
+ this.dashCanvasModel.showAddViewButtonWhenEmpty = false;
38
+ evt.dataTransfer.effectAllowed = 'move';
39
+ target.classList.add('is-dragging');
40
+
41
+ const viewSpecId: string = target.getAttribute('id').split('draggableFor-')[1],
42
+ viewSpec = this.dashCanvasModel.viewSpecs.find(it => it.id === viewSpecId),
43
+ {width, height} = viewSpec,
44
+ widget = {
45
+ viewSpecId,
46
+ layout: {
47
+ x: 0,
48
+ y: 0,
49
+ w: width,
50
+ h: height
51
+ }
52
+ };
53
+
54
+ this.dashCanvasModel.setDraggedInView(widget);
55
+ }
56
+
57
+ onDragEnd(evt: DragEvent<HTMLDivElement>) {
58
+ this.dashCanvasModel.showAddViewButtonWhenEmpty = true;
59
+
60
+ const target = evt.target as HTMLElement;
61
+ if (!target) return;
62
+
63
+ target.classList.remove('is-dragging');
64
+ }
65
+ }
@@ -15,6 +15,7 @@
15
15
  *
16
16
  * See the platform specific AppContainer where these implementations are actually provided.
17
17
  */
18
+ export let collapsibleSetButton = null;
18
19
  export let ColChooserModel = null;
19
20
  export let ColumnHeaderFilterModel = null;
20
21
  export let ModalSupportModel = null;
@@ -37,6 +38,7 @@ export let DynamicTabSwitcherModel = null;
37
38
  * Not for Application use.
38
39
  */
39
40
  export function installDesktopImpls(impls) {
41
+ collapsibleSetButton = impls.collapsibleSetButton;
40
42
  ColChooserModel = impls.ColChooserModel;
41
43
  ColumnHeaderFilterModel = impls.ColumnHeaderFilterModel;
42
44
  ModalSupportModel = impls.ModalSupportModel;
@@ -15,6 +15,7 @@
15
15
  *
16
16
  * See the platform specific AppContainer where these implementations are actually provided.
17
17
  */
18
+ export let collapsibleSetButton = null;
18
19
  export let ColChooserModel = null;
19
20
  export let colChooser = null;
20
21
  export let zoneMapper = null;
@@ -30,6 +31,7 @@ export let maskImpl = null;
30
31
  * Not for Application use.
31
32
  */
32
33
  export function installMobileImpls(impls) {
34
+ collapsibleSetButton = impls.collapsibleSetButton;
33
35
  ColChooserModel = impls.ColChooserModel;
34
36
  colChooser = impls.colChooser;
35
37
  zoneMapper = impls.zoneMapper;
@@ -18,6 +18,7 @@ import {pinPadImpl} from '@xh/hoist/mobile/cmp/pinpad/impl/PinPad';
18
18
  import {storeFilterFieldImpl} from '@xh/hoist/mobile/cmp/store/impl/StoreFilterField';
19
19
  import {tabContainerImpl} from '@xh/hoist/mobile/cmp/tab/impl/TabContainer';
20
20
  import {zoneMapper} from '@xh/hoist/mobile/cmp/zoneGrid/impl/ZoneMapper';
21
+ import {collapsibleSetButton} from '@xh/hoist/mobile/cmp/button/CollapsibleSetButton';
21
22
  import {elementFromContent, useOnMount} from '@xh/hoist/utils/react';
22
23
  import {isEmpty} from 'lodash';
23
24
  import {aboutDialog} from './AboutDialog';
@@ -34,6 +35,7 @@ import {toastSource} from './ToastSource';
34
35
  import {versionBar} from './VersionBar';
35
36
 
36
37
  installMobileImpls({
38
+ collapsibleSetButton,
37
39
  tabContainerImpl,
38
40
  storeFilterFieldImpl,
39
41
  pinPadImpl,
@@ -0,0 +1,57 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2026 Extremely Heavy Industries Inc.
6
+ */
7
+
8
+ import {type ReactElement, type ReactNode, type JSX, useState} from 'react';
9
+ import {tooltip as bpTooltip} from '@xh/hoist/kit/blueprint';
10
+ import {fragment} from '@xh/hoist/cmp/layout';
11
+ import {hoistCmp} from '@xh/hoist/core';
12
+ import type {Intent, HoistProps} from '@xh/hoist/core';
13
+ import {button} from '@xh/hoist/mobile/cmp/button';
14
+ import {legend} from '@xh/hoist/cmp/layout';
15
+ import {Icon} from '@xh/hoist/icon/Icon';
16
+
17
+ export interface CollapsibleSetButtonProps extends HoistProps {
18
+ icon?: ReactElement;
19
+ text: ReactNode;
20
+ tooltip?: JSX.Element | string;
21
+ clickHandler?: (boolean) => void;
22
+ intent?: Intent;
23
+ collapsed?: boolean;
24
+ disabled?: boolean;
25
+ }
26
+
27
+ export const [CollapsibleSetButton, collapsibleSetButton] =
28
+ hoistCmp.withFactory<CollapsibleSetButtonProps>({
29
+ displayName: 'CollapsibleSetButton',
30
+ model: false,
31
+ render({icon, text, tooltip, intent, clickHandler, collapsed, disabled}) {
32
+ const [isCollapsed, setIsCollapsed] = useState<boolean>(collapsed === true),
33
+ btn = button({
34
+ text: fragment(text, isCollapsed ? Icon.angleDown() : Icon.angleUp()),
35
+ icon,
36
+ outlined: isCollapsed && !intent,
37
+ minimal: !intent || (intent && !isCollapsed),
38
+ intent,
39
+ disabled,
40
+ onClick: () => {
41
+ const val = !isCollapsed;
42
+ setIsCollapsed(val);
43
+ clickHandler?.(val);
44
+ }
45
+ });
46
+
47
+ return legend(
48
+ tooltip
49
+ ? bpTooltip({
50
+ item: btn,
51
+ content: tooltip,
52
+ intent
53
+ })
54
+ : btn
55
+ );
56
+ }
57
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "80.0.0-SNAPSHOT.1768003263151",
3
+ "version": "80.0.0-SNAPSHOT.1768251400948",
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",
@@ -62,11 +62,11 @@
62
62
  "moment": "~2.30.1",
63
63
  "numbro": "~2.5.0",
64
64
  "onsenui": "~2.12.8",
65
- "qs": "~6.14.0",
65
+ "qs": "~6.14.1",
66
66
  "react-beautiful-dnd": "~13.1.0",
67
67
  "react-dates": "~21.8.0",
68
68
  "react-dropzone": "~10.2.2",
69
- "react-grid-layout": "2.1.1",
69
+ "react-grid-layout": "2.2.2",
70
70
  "react-markdown": "~10.1.0",
71
71
  "react-onsenui": "~1.13.2",
72
72
  "react-popper": "~2.3.0",