@xh/hoist 80.0.0-SNAPSHOT.1767973504648 → 80.0.0-SNAPSHOT.1767974090726
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 +0 -11
- package/build/types/cmp/grid/GridModel.d.ts +2 -2
- package/build/types/cmp/layout/Tags.d.ts +0 -2
- package/build/types/cmp/tab/TabContainerModel.d.ts +1 -1
- package/build/types/desktop/cmp/dash/canvas/DashCanvasModel.d.ts +6 -46
- package/cmp/grid/GridModel.ts +2 -2
- package/cmp/layout/Tags.ts +0 -2
- package/cmp/tab/TabContainerModel.ts +1 -1
- package/desktop/cmp/dash/canvas/DashCanvas.ts +4 -21
- package/desktop/cmp/dash/canvas/DashCanvasModel.ts +24 -140
- package/package.json +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/types/desktop/cmp/button/FieldsetCollapseButton.d.ts +0 -10
- package/build/types/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWell.d.ts +0 -17
- package/build/types/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWellModel.d.ts +0 -11
- package/build/types/desktop/cmp/form/CollapsibleFieldset.d.ts +0 -11
- package/desktop/cmp/button/FieldsetCollapseButton.ts +0 -44
- package/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWell.scss +0 -26
- package/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWell.ts +0 -126
- package/desktop/cmp/dash/canvas/widgetwell/DashCanvasWidgetWellModel.ts +0 -65
- package/desktop/cmp/form/CollapsibleFieldset.scss +0 -14
- package/desktop/cmp/form/CollapsibleFieldset.ts +0 -65
package/CHANGELOG.md
CHANGED
|
@@ -11,17 +11,6 @@
|
|
|
11
11
|
so there is no deprecated alias. Any app usages should swap to `XH.appLoadObserver`.
|
|
12
12
|
* Removed additional references to deprecated `loadModel` within Hoist itself.
|
|
13
13
|
|
|
14
|
-
### 🎁 New Features
|
|
15
|
-
|
|
16
|
-
* DashCanvas:
|
|
17
|
-
* supports dragging and dropping widgets in from an external container.
|
|
18
|
-
* supports new compacting strategy: 'wrap'
|
|
19
|
-
* new elementFactory tags: `fieldset`, `legend`
|
|
20
|
-
|
|
21
|
-
### 📚 Libraries
|
|
22
|
-
|
|
23
|
-
* react-grid-layout `2.1 → 2.2.2`
|
|
24
|
-
|
|
25
14
|
## 79.0.0 - 2026-01-05
|
|
26
15
|
|
|
27
16
|
### 💥 Breaking Changes
|
|
@@ -553,9 +553,9 @@ export declare class GridModel extends HoistModel {
|
|
|
553
553
|
autosizeAsync(overrideOpts?: Omit<GridAutosizeOptions, 'mode'>): Promise<void>;
|
|
554
554
|
/**
|
|
555
555
|
* Begin an inline editing session.
|
|
556
|
-
* @param
|
|
556
|
+
* @param record - StoreRecord/ID to edit. If unspecified, the first selected StoreRecord
|
|
557
557
|
* will be used, if any, or the first overall StoreRecord in the grid.
|
|
558
|
-
* @param
|
|
558
|
+
* @param colId - ID of column on which to start editing. If unspecified, the first
|
|
559
559
|
* editable column will be used.
|
|
560
560
|
*/
|
|
561
561
|
beginEditAsync(opts?: {
|
|
@@ -10,7 +10,6 @@ export declare const a: import("@xh/hoist/core").ElementFactory<import("react").
|
|
|
10
10
|
export declare const br: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBRElement>, HTMLBRElement>>;
|
|
11
11
|
export declare const code: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
12
12
|
export declare const div: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
13
|
-
export declare const fieldset: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>>;
|
|
14
13
|
export declare const form: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>>;
|
|
15
14
|
export declare const hr: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
16
15
|
export declare const h1: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>>;
|
|
@@ -18,7 +17,6 @@ export declare const h2: import("@xh/hoist/core").ElementFactory<import("react")
|
|
|
18
17
|
export declare const h3: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>>;
|
|
19
18
|
export declare const h4: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>>;
|
|
20
19
|
export declare const label: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>>;
|
|
21
|
-
export declare const legend: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>>;
|
|
22
20
|
export declare const li: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>>;
|
|
23
21
|
export declare const nav: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
24
22
|
export declare const ol: import("@xh/hoist/core").ElementFactory<import("react").DetailedHTMLProps<import("react").OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>>;
|
|
@@ -70,7 +70,7 @@ export declare class TabContainerModel extends HoistModel {
|
|
|
70
70
|
protected lastActiveTabId: string;
|
|
71
71
|
/**
|
|
72
72
|
* @param config - TabContainer configuration.
|
|
73
|
-
* @param depth - Depth in hierarchy of nested TabContainerModels. Not for application use.
|
|
73
|
+
* @param [depth] - Depth in hierarchy of nested TabContainerModels. Not for application use.
|
|
74
74
|
*/
|
|
75
75
|
constructor({ tabs, defaultTabId, route, track, renderMode, refreshMode, persistWith, emptyText, xhImpl, switcher }: TabContainerConfig, depth?: number);
|
|
76
76
|
/** Set/replace all tabs within the container. */
|
|
@@ -14,12 +14,11 @@ export interface DashCanvasConfig extends DashConfig<DashCanvasViewSpec, DashCan
|
|
|
14
14
|
*/
|
|
15
15
|
rowHeight?: number;
|
|
16
16
|
/**
|
|
17
|
-
* Whether views should "compact" vertically
|
|
17
|
+
* Whether views should "compact" vertically or horizontally
|
|
18
18
|
* to condense space. Default `true` defaults to vertical compaction.
|
|
19
|
-
* Use `wrap` with caution. It only works well if all items are 1 row high.
|
|
20
19
|
* See react-grid-layout docs for more information.
|
|
21
|
-
*/
|
|
22
|
-
compact?: boolean | 'vertical' | 'horizontal'
|
|
20
|
+
* */
|
|
21
|
+
compact?: boolean | 'vertical' | 'horizontal';
|
|
23
22
|
/** Between items [x,y] in pixels. Default `[10, 10]`. */
|
|
24
23
|
margin?: [number, number];
|
|
25
24
|
/** Padding inside the container [x, y] in pixels. Defaults to same as `margin`. */
|
|
@@ -30,31 +29,6 @@ export interface DashCanvasConfig extends DashConfig<DashCanvasViewSpec, DashCan
|
|
|
30
29
|
* Whether a grid background should be shown. Default false.
|
|
31
30
|
*/
|
|
32
31
|
showGridBackground?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Whether the canvas should accept drag-and-drop of views from outside
|
|
35
|
-
* the canvas. Default false.
|
|
36
|
-
*/
|
|
37
|
-
allowsDrop?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Optional callback to invoke after a view is successfully dropped onto the canvas.
|
|
40
|
-
*/
|
|
41
|
-
onDropDone?: (viewModel: DashCanvasViewModel) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Optional callback to invoke when an item is dragged over the canvas. This may be used to
|
|
44
|
-
* customize how the size of the dropping placeholder is calculated. The callback should
|
|
45
|
-
* return an object with optional properties indicating the desired width, height (in grid units),
|
|
46
|
-
* and offset (in pixels) of the dropping placeholder. The method's signature is the same as
|
|
47
|
-
* the `onDropDragOver` prop of ReactGridLayout.
|
|
48
|
-
* Returning `false` will prevent the dropping placeholder from being shown, and prevents a drop.
|
|
49
|
-
* Returning `void` will use the default behavior, which is to size the placeholder as per the
|
|
50
|
-
* `dropConfig.defaultItem` specification.
|
|
51
|
-
*/
|
|
52
|
-
onDropDragOver?: (e: DragEvent) => OnDropDragOverResult;
|
|
53
|
-
/**
|
|
54
|
-
* Whether an overlay with an Add View button should be rendered
|
|
55
|
-
* when the canvas is empty. Default true.
|
|
56
|
-
*/
|
|
57
|
-
showAddViewButtonWhenEmpty?: boolean;
|
|
58
32
|
}
|
|
59
33
|
export interface DashCanvasItemState {
|
|
60
34
|
layout: DashCanvasItemLayout;
|
|
@@ -68,12 +42,6 @@ export interface DashCanvasItemLayout {
|
|
|
68
42
|
w: number;
|
|
69
43
|
h: number;
|
|
70
44
|
}
|
|
71
|
-
export type OnDropDragOverResult = {
|
|
72
|
-
w?: number;
|
|
73
|
-
h?: number;
|
|
74
|
-
dragOffsetX?: number;
|
|
75
|
-
dragOffsetY?: number;
|
|
76
|
-
} | false | void;
|
|
77
45
|
/**
|
|
78
46
|
* Model for {@link DashCanvas}, managing all configurable options for the component and publishing
|
|
79
47
|
* the observable state of its current widgets and their layout.
|
|
@@ -83,17 +51,12 @@ export declare class DashCanvasModel extends DashModel<DashCanvasViewSpec, DashC
|
|
|
83
51
|
}> {
|
|
84
52
|
columns: number;
|
|
85
53
|
rowHeight: number;
|
|
86
|
-
compact: 'vertical' | 'horizontal'
|
|
54
|
+
compact: 'vertical' | 'horizontal';
|
|
87
55
|
margin: [number, number];
|
|
88
56
|
containerPadding: [number, number];
|
|
89
57
|
showGridBackground: boolean;
|
|
90
58
|
rglHeight: number;
|
|
91
|
-
showAddViewButtonWhenEmpty: boolean;
|
|
92
|
-
DROPPING_ELEM_ID: string;
|
|
93
59
|
maxRows: number;
|
|
94
|
-
allowsDrop: boolean;
|
|
95
|
-
onDropDone: (viewModel: DashCanvasViewModel) => void;
|
|
96
|
-
draggedInView: DashCanvasItemState;
|
|
97
60
|
/** Current number of rows in canvas */
|
|
98
61
|
get rows(): number;
|
|
99
62
|
get isEmpty(): boolean;
|
|
@@ -102,7 +65,7 @@ export declare class DashCanvasModel extends DashModel<DashCanvasViewSpec, DashC
|
|
|
102
65
|
isResizing: boolean;
|
|
103
66
|
private isLoadingState;
|
|
104
67
|
get rglLayout(): any[];
|
|
105
|
-
constructor({ viewSpecs, viewSpecDefaults, initialState, layoutLocked, contentLocked, renameLocked, persistWith, emptyText, addViewButtonText, columns, rowHeight, compact, margin, maxRows, containerPadding, extraMenuItems, showGridBackground
|
|
68
|
+
constructor({ viewSpecs, viewSpecDefaults, initialState, layoutLocked, contentLocked, renameLocked, persistWith, emptyText, addViewButtonText, columns, rowHeight, compact, margin, maxRows, containerPadding, extraMenuItems, showGridBackground }: DashCanvasConfig);
|
|
106
69
|
/** Removes all views from the canvas */
|
|
107
70
|
clear(): void;
|
|
108
71
|
/**
|
|
@@ -140,10 +103,6 @@ export declare class DashCanvasModel extends DashModel<DashCanvasViewSpec, DashC
|
|
|
140
103
|
renameView(id: string): void;
|
|
141
104
|
/** Scrolls a DashCanvasView into view. */
|
|
142
105
|
ensureViewVisible(id: string): void;
|
|
143
|
-
onDrop(rglLayout: LayoutItem[], layoutItem: LayoutItem, evt: Event): void;
|
|
144
|
-
setDraggedInView(view?: DashCanvasItemState): void;
|
|
145
|
-
onDropDragOver(evt: DragEvent): OnDropDragOverResult;
|
|
146
|
-
getViewsBySpecId(id: any): DashCanvasViewModel[];
|
|
147
106
|
getPersistableState(): PersistableState<{
|
|
148
107
|
state: DashCanvasItemState[];
|
|
149
108
|
}>;
|
|
@@ -164,5 +123,6 @@ export declare class DashCanvasModel extends DashModel<DashCanvasViewSpec, DashC
|
|
|
164
123
|
private setViewLayout;
|
|
165
124
|
private getSpec;
|
|
166
125
|
private hasSpec;
|
|
126
|
+
private getViewsBySpecId;
|
|
167
127
|
private getNextAvailablePosition;
|
|
168
128
|
}
|
package/cmp/grid/GridModel.ts
CHANGED
|
@@ -1442,9 +1442,9 @@ export class GridModel extends HoistModel {
|
|
|
1442
1442
|
|
|
1443
1443
|
/**
|
|
1444
1444
|
* Begin an inline editing session.
|
|
1445
|
-
* @param
|
|
1445
|
+
* @param record - StoreRecord/ID to edit. If unspecified, the first selected StoreRecord
|
|
1446
1446
|
* will be used, if any, or the first overall StoreRecord in the grid.
|
|
1447
|
-
* @param
|
|
1447
|
+
* @param colId - ID of column on which to start editing. If unspecified, the first
|
|
1448
1448
|
* editable column will be used.
|
|
1449
1449
|
*/
|
|
1450
1450
|
async beginEditAsync(opts: {record?: StoreRecordOrId; colId?: string} = {}) {
|
package/cmp/layout/Tags.ts
CHANGED
|
@@ -29,7 +29,6 @@ export const a = elementFactory('a');
|
|
|
29
29
|
export const br = elementFactory('br');
|
|
30
30
|
export const code = elementFactory('code');
|
|
31
31
|
export const div = elementFactory('div');
|
|
32
|
-
export const fieldset = elementFactory('fieldset');
|
|
33
32
|
export const form = elementFactory('form');
|
|
34
33
|
export const hr = elementFactory('hr');
|
|
35
34
|
export const h1 = elementFactory('h1');
|
|
@@ -37,7 +36,6 @@ export const h2 = elementFactory('h2');
|
|
|
37
36
|
export const h3 = elementFactory('h3');
|
|
38
37
|
export const h4 = elementFactory('h4');
|
|
39
38
|
export const label = elementFactory('label');
|
|
40
|
-
export const legend = elementFactory('legend');
|
|
41
39
|
export const li = elementFactory('li');
|
|
42
40
|
export const nav = elementFactory('nav');
|
|
43
41
|
export const ol = elementFactory('ol');
|
|
@@ -119,7 +119,7 @@ export class TabContainerModel extends HoistModel {
|
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* @param config - TabContainer configuration.
|
|
122
|
-
* @param depth - Depth in hierarchy of nested TabContainerModels. Not for application use.
|
|
122
|
+
* @param [depth] - Depth in hierarchy of nested TabContainerModels. Not for application use.
|
|
123
123
|
*/
|
|
124
124
|
constructor(
|
|
125
125
|
{
|
|
@@ -10,7 +10,7 @@ import ReactGridLayout, {
|
|
|
10
10
|
useContainerWidth,
|
|
11
11
|
getCompactor
|
|
12
12
|
} from 'react-grid-layout';
|
|
13
|
-
import {GridBackground, type GridBackgroundProps
|
|
13
|
+
import {GridBackground, type GridBackgroundProps} from 'react-grid-layout/extras';
|
|
14
14
|
import composeRefs from '@seznam/compose-react-refs';
|
|
15
15
|
import {div, vbox, vspacer} from '@xh/hoist/cmp/layout';
|
|
16
16
|
import {
|
|
@@ -62,11 +62,7 @@ export const [DashCanvas, dashCanvas] = hoistCmp.withFactory<DashCanvasProps>({
|
|
|
62
62
|
render({className, model, rglOptions, testId}, ref) {
|
|
63
63
|
const isDraggable = !model.layoutLocked,
|
|
64
64
|
isResizable = !model.layoutLocked,
|
|
65
|
-
{width, containerRef, mounted} = useContainerWidth()
|
|
66
|
-
defaultDroppedItemDims = {
|
|
67
|
-
w: Math.floor(model.columns / 3),
|
|
68
|
-
h: Math.floor(model.columns / 3)
|
|
69
|
-
};
|
|
65
|
+
{width, containerRef, mounted} = useContainerWidth();
|
|
70
66
|
|
|
71
67
|
return refreshContextView({
|
|
72
68
|
model: model.refreshContextModel,
|
|
@@ -102,20 +98,7 @@ export const [DashCanvas, dashCanvas] = hoistCmp.withFactory<DashCanvasProps>({
|
|
|
102
98
|
resizeConfig: {
|
|
103
99
|
enabled: isResizable
|
|
104
100
|
},
|
|
105
|
-
|
|
106
|
-
enabled: model.contentLocked ? false : model.allowsDrop,
|
|
107
|
-
defaultItem: defaultDroppedItemDims,
|
|
108
|
-
onDragOver: (evt: DragEvent) => model.onDropDragOver(evt)
|
|
109
|
-
},
|
|
110
|
-
onDrop: (
|
|
111
|
-
layout: LayoutItem[],
|
|
112
|
-
layoutItem: LayoutItem,
|
|
113
|
-
evt: Event
|
|
114
|
-
) => model.onDrop(layout, layoutItem, evt),
|
|
115
|
-
compactor:
|
|
116
|
-
model.compact === 'wrap'
|
|
117
|
-
? wrapCompactor
|
|
118
|
-
: getCompactor(model.compact, false, false),
|
|
101
|
+
compactor: getCompactor(model.compact, false, false),
|
|
119
102
|
onLayoutChange: (layout: LayoutItem[]) =>
|
|
120
103
|
model.onRglLayoutChange(layout),
|
|
121
104
|
onResizeStart: () => (model.isResizing = true),
|
|
@@ -133,7 +116,7 @@ export const [DashCanvas, dashCanvas] = hoistCmp.withFactory<DashCanvasProps>({
|
|
|
133
116
|
),
|
|
134
117
|
width
|
|
135
118
|
}),
|
|
136
|
-
emptyContainerOverlay({omit: !mounted
|
|
119
|
+
emptyContainerOverlay({omit: !mounted})
|
|
137
120
|
],
|
|
138
121
|
[TEST_ID]: testId
|
|
139
122
|
})
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {wait} from '@xh/hoist/promise';
|
|
8
7
|
import type {LayoutItem} from 'react-grid-layout';
|
|
9
8
|
import {Persistable, PersistableState, PersistenceProvider, XH} from '@xh/hoist/core';
|
|
10
9
|
import {required} from '@xh/hoist/data';
|
|
@@ -18,7 +17,6 @@ import {createObservableRef} from '@xh/hoist/utils/react';
|
|
|
18
17
|
import {
|
|
19
18
|
defaultsDeep,
|
|
20
19
|
find,
|
|
21
|
-
omit,
|
|
22
20
|
uniqBy,
|
|
23
21
|
times,
|
|
24
22
|
without,
|
|
@@ -43,12 +41,11 @@ export interface DashCanvasConfig extends DashConfig<DashCanvasViewSpec, DashCan
|
|
|
43
41
|
rowHeight?: number;
|
|
44
42
|
|
|
45
43
|
/**
|
|
46
|
-
* Whether views should "compact" vertically
|
|
44
|
+
* Whether views should "compact" vertically or horizontally
|
|
47
45
|
* 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.
|
|
49
46
|
* See react-grid-layout docs for more information.
|
|
50
|
-
*/
|
|
51
|
-
compact?: boolean | 'vertical' | 'horizontal'
|
|
47
|
+
* */
|
|
48
|
+
compact?: boolean | 'vertical' | 'horizontal';
|
|
52
49
|
|
|
53
50
|
/** Between items [x,y] in pixels. Default `[10, 10]`. */
|
|
54
51
|
margin?: [number, number];
|
|
@@ -63,35 +60,6 @@ export interface DashCanvasConfig extends DashConfig<DashCanvasViewSpec, DashCan
|
|
|
63
60
|
* Whether a grid background should be shown. Default false.
|
|
64
61
|
*/
|
|
65
62
|
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;
|
|
95
63
|
}
|
|
96
64
|
|
|
97
65
|
export interface DashCanvasItemState {
|
|
@@ -108,16 +76,6 @@ export interface DashCanvasItemLayout {
|
|
|
108
76
|
h: number;
|
|
109
77
|
}
|
|
110
78
|
|
|
111
|
-
export type OnDropDragOverResult =
|
|
112
|
-
| {
|
|
113
|
-
w?: number;
|
|
114
|
-
h?: number;
|
|
115
|
-
dragOffsetX?: number;
|
|
116
|
-
dragOffsetY?: number;
|
|
117
|
-
}
|
|
118
|
-
| false
|
|
119
|
-
| void;
|
|
120
|
-
|
|
121
79
|
/**
|
|
122
80
|
* Model for {@link DashCanvas}, managing all configurable options for the component and publishing
|
|
123
81
|
* the observable state of its current widgets and their layout.
|
|
@@ -131,21 +89,16 @@ export class DashCanvasModel
|
|
|
131
89
|
//------------------------------
|
|
132
90
|
@bindable columns: number;
|
|
133
91
|
@bindable rowHeight: number;
|
|
134
|
-
@bindable compact: 'vertical' | 'horizontal'
|
|
92
|
+
@bindable compact: 'vertical' | 'horizontal';
|
|
135
93
|
@bindable.ref margin: [number, number]; // [x, y]
|
|
136
94
|
@bindable.ref containerPadding: [number, number]; // [x, y]
|
|
137
95
|
@bindable showGridBackground: boolean;
|
|
138
96
|
@bindable rglHeight: number;
|
|
139
|
-
@bindable showAddViewButtonWhenEmpty: boolean;
|
|
140
97
|
|
|
141
98
|
//-----------------------------
|
|
142
99
|
// Public properties
|
|
143
100
|
//-----------------------------
|
|
144
|
-
DROPPING_ELEM_ID = '__dropping-elem__';
|
|
145
101
|
maxRows: number;
|
|
146
|
-
allowsDrop: boolean;
|
|
147
|
-
onDropDone: (viewModel: DashCanvasViewModel) => void;
|
|
148
|
-
draggedInView: DashCanvasItemState;
|
|
149
102
|
|
|
150
103
|
/** Current number of rows in canvas */
|
|
151
104
|
get rows(): number {
|
|
@@ -165,27 +118,21 @@ export class DashCanvasModel
|
|
|
165
118
|
private isLoadingState: boolean;
|
|
166
119
|
|
|
167
120
|
get rglLayout() {
|
|
168
|
-
return this.layout
|
|
169
|
-
.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
minH: viewSpec.minHeight,
|
|
184
|
-
maxW: viewSpec.maxWidth,
|
|
185
|
-
minW: viewSpec.minWidth
|
|
186
|
-
};
|
|
187
|
-
})
|
|
188
|
-
.filter(Boolean);
|
|
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
|
+
});
|
|
189
136
|
}
|
|
190
137
|
|
|
191
138
|
constructor({
|
|
@@ -205,11 +152,7 @@ export class DashCanvasModel
|
|
|
205
152
|
maxRows = Infinity,
|
|
206
153
|
containerPadding = margin,
|
|
207
154
|
extraMenuItems,
|
|
208
|
-
showGridBackground = false
|
|
209
|
-
showAddViewButtonWhenEmpty = true,
|
|
210
|
-
allowsDrop = false,
|
|
211
|
-
onDropDone,
|
|
212
|
-
onDropDragOver
|
|
155
|
+
showGridBackground = false
|
|
213
156
|
}: DashCanvasConfig) {
|
|
214
157
|
super();
|
|
215
158
|
makeObservable(this);
|
|
@@ -257,10 +200,6 @@ export class DashCanvasModel
|
|
|
257
200
|
this.addViewButtonText = addViewButtonText;
|
|
258
201
|
this.extraMenuItems = extraMenuItems;
|
|
259
202
|
this.showGridBackground = showGridBackground;
|
|
260
|
-
this.showAddViewButtonWhenEmpty = showAddViewButtonWhenEmpty;
|
|
261
|
-
this.allowsDrop = allowsDrop;
|
|
262
|
-
this.onDropDone = onDropDone;
|
|
263
|
-
if (onDropDragOver) this.onDropDragOver = onDropDragOver;
|
|
264
203
|
|
|
265
204
|
this.loadState(initialState);
|
|
266
205
|
this.state = this.buildState();
|
|
@@ -398,59 +337,6 @@ export class DashCanvasModel
|
|
|
398
337
|
this.getView(id)?.ensureVisible();
|
|
399
338
|
}
|
|
400
339
|
|
|
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
|
-
|
|
454
340
|
//------------------------
|
|
455
341
|
// Persistable Interface
|
|
456
342
|
//------------------------
|
|
@@ -527,12 +413,6 @@ export class DashCanvasModel
|
|
|
527
413
|
|
|
528
414
|
onRglLayoutChange(rglLayout: LayoutItem[]) {
|
|
529
415
|
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
|
-
|
|
536
416
|
this.setLayout(rglLayout);
|
|
537
417
|
}
|
|
538
418
|
|
|
@@ -616,6 +496,10 @@ export class DashCanvasModel
|
|
|
616
496
|
return some(this.viewSpecs, {id});
|
|
617
497
|
}
|
|
618
498
|
|
|
499
|
+
private getViewsBySpecId(id) {
|
|
500
|
+
return this.viewModels.filter(it => it.viewSpec.id === id);
|
|
501
|
+
}
|
|
502
|
+
|
|
619
503
|
private getNextAvailablePosition({
|
|
620
504
|
width,
|
|
621
505
|
height,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "80.0.0-SNAPSHOT.
|
|
3
|
+
"version": "80.0.0-SNAPSHOT.1767974090726",
|
|
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.
|
|
65
|
+
"qs": "~6.14.0",
|
|
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.
|
|
69
|
+
"react-grid-layout": "2.1.1",
|
|
70
70
|
"react-markdown": "~10.1.0",
|
|
71
71
|
"react-onsenui": "~1.13.2",
|
|
72
72
|
"react-popper": "~2.3.0",
|