@vuu-ui/vuu-layout 4.1.0 → 5.0.0-alpha.2
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/package.json +14 -15
- package/src/tools/config-wrapper/ConfigWrapper.js +2 -1
- package/src/tools/devtools-box/layout-configurator.js +293 -0
- package/src/tools/devtools-tree/layout-tree-viewer.js +40 -0
- package/types/drag-drop/BoxModel.d.ts +3 -3
- package/types/src/Component.d.ts +0 -6
- package/types/src/LayoutContainer.d.ts +0 -6
- package/types/src/debug.d.ts +0 -2
- package/types/src/dock-layout/DockLayout.d.ts +0 -7
- package/types/src/dock-layout/Drawer.d.ts +0 -17
- package/types/src/dock-layout/index.d.ts +0 -2
- package/types/src/drag-drop/BoxModel.d.ts +0 -143
- package/types/src/drag-drop/DragState.d.ts +0 -46
- package/types/src/drag-drop/Draggable.d.ts +0 -24
- package/types/src/drag-drop/DropTarget.d.ts +0 -60
- package/types/src/drag-drop/DropTargetRenderer.d.ts +0 -17
- package/types/src/drag-drop/dragDropTypes.d.ts +0 -51
- package/types/src/drag-drop/index.d.ts +0 -3
- package/types/src/flexbox/Flexbox.d.ts +0 -3
- package/types/src/flexbox/FlexboxLayout.d.ts +0 -5
- package/types/src/flexbox/Splitter.d.ts +0 -12
- package/types/src/flexbox/flexbox-utils.d.ts +0 -12
- package/types/src/flexbox/flexboxTypes.d.ts +0 -52
- package/types/src/flexbox/index.d.ts +0 -2
- package/types/src/flexbox/useSplitterResizing.d.ts +0 -2
- package/types/src/index.d.ts +0 -20
- package/types/src/layout-action.d.ts +0 -19
- package/types/src/layout-header/ActionButton.d.ts +0 -8
- package/types/src/layout-header/Header.d.ts +0 -15
- package/types/src/layout-header/index.d.ts +0 -1
- package/types/src/layout-header/useHeader.d.ts +0 -20
- package/types/src/layout-provider/LayoutProvider.d.ts +0 -20
- package/types/src/layout-provider/LayoutProviderContext.d.ts +0 -15
- package/types/src/layout-provider/index.d.ts +0 -2
- package/types/src/layout-provider/useLayoutDragDrop.d.ts +0 -4
- package/types/src/layout-reducer/flexUtils.d.ts +0 -22
- package/types/src/layout-reducer/index.d.ts +0 -4
- package/types/src/layout-reducer/insert-layout-element.d.ts +0 -8
- package/types/src/layout-reducer/layout-reducer.d.ts +0 -3
- package/types/src/layout-reducer/layoutTypes.d.ts +0 -135
- package/types/src/layout-reducer/layoutUtils.d.ts +0 -44
- package/types/src/layout-reducer/move-layout-element.d.ts +0 -3
- package/types/src/layout-reducer/remove-layout-element.d.ts +0 -3
- package/types/src/layout-reducer/replace-layout-element.d.ts +0 -6
- package/types/src/layout-reducer/resize-flex-children.d.ts +0 -4
- package/types/src/layout-reducer/wrap-layout-element.d.ts +0 -9
- package/types/src/layout-view/View.d.ts +0 -10
- package/types/src/layout-view/useView.d.ts +0 -20
- package/types/src/layout-view/useViewBroadcastChannel.d.ts +0 -7
- package/types/src/layout-view/useViewResize.d.ts +0 -7
- package/types/src/layout-view/viewTypes.d.ts +0 -48
- package/types/src/layout-view-actions/ViewContext.d.ts +0 -35
- package/types/src/layout-view-actions/useViewActionDispatcher.d.ts +0 -4
- package/types/src/layout-view-actions/useViewContributions.d.ts +0 -9
- package/types/src/palette/Palette.d.ts +0 -21
- package/types/src/palette/index.d.ts +0 -1
- package/types/src/placeholder/LayoutStartPanel.d.ts +0 -5
- package/types/src/placeholder/Placeholder.d.ts +0 -16
- package/types/src/placeholder/index.d.ts +0 -1
- package/types/src/responsive/index.d.ts +0 -2
- package/types/src/responsive/measureMinimumNodeSize.d.ts +0 -1
- package/types/src/responsive/overflowUtils.d.ts +0 -2
- package/types/src/responsive/useResizeObserver.d.ts +0 -13
- package/types/src/responsive/utils.d.ts +0 -6
- package/types/src/stack/Stack.d.ts +0 -3
- package/types/src/stack/StackLayout.d.ts +0 -6
- package/types/src/stack/index.d.ts +0 -3
- package/types/src/stack/stackTypes.d.ts +0 -24
- package/types/src/tabs/TabPanel.d.ts +0 -7
- package/types/src/tabs/index.d.ts +0 -1
- package/types/src/tools/config-wrapper/ConfigWrapper.d.ts +0 -2
- package/types/src/tools/config-wrapper/index.d.ts +0 -1
- package/types/src/tools/devtools-box/layout-configurator.d.ts +0 -31
- package/types/src/tools/devtools-tree/layout-tree-viewer.d.ts +0 -6
- package/types/src/tools/index.d.ts +0 -3
- package/types/src/use-persistent-state.d.ts +0 -8
- package/types/src/utils/index.d.ts +0 -5
- package/types/src/utils/pathUtils.d.ts +0 -31
- package/types/src/utils/propUtils.d.ts +0 -5
- package/types/src/utils/refUtils.d.ts +0 -2
- package/types/src/utils/styleUtils.d.ts +0 -3
- package/types/src/utils/typeOf.d.ts +0 -5
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "
|
|
2
|
+
"version": "5.0.0-alpha.2",
|
|
3
3
|
"description": "VUU Layout Components",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"author": "heswell",
|
|
6
7
|
"license": "Apache-2.0",
|
|
7
8
|
"scripts": {
|
|
8
|
-
"build:dev": "node ../../scripts/run-build.mjs",
|
|
9
9
|
"build": "node ../../scripts/run-build-rslib.ts",
|
|
10
10
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
11
11
|
},
|
|
12
12
|
"types": "types/index.d.ts",
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@vuu-ui/vuu-data-types": "
|
|
15
|
-
"@vuu-ui/vuu-filter-types": "
|
|
14
|
+
"@vuu-ui/vuu-data-types": "5.0.0-alpha.2",
|
|
15
|
+
"@vuu-ui/vuu-filter-types": "5.0.0-alpha.2"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@salt-ds/core": "1.74.0",
|
|
19
19
|
"@salt-ds/styles": "0.4.2",
|
|
20
20
|
"@salt-ds/window": "0.1.2",
|
|
21
|
-
"@vuu-ui/vuu-data-react": "
|
|
22
|
-
"@vuu-ui/vuu-datatable": "
|
|
23
|
-
"@vuu-ui/vuu-filters": "
|
|
24
|
-
"@vuu-ui/vuu-popups": "
|
|
25
|
-
"@vuu-ui/vuu-table": "
|
|
26
|
-
"@vuu-ui/vuu-ui-controls": "
|
|
27
|
-
"@vuu-ui/vuu-utils": "
|
|
21
|
+
"@vuu-ui/vuu-data-react": "5.0.0-alpha.2",
|
|
22
|
+
"@vuu-ui/vuu-datatable": "5.0.0-alpha.2",
|
|
23
|
+
"@vuu-ui/vuu-filters": "5.0.0-alpha.2",
|
|
24
|
+
"@vuu-ui/vuu-popups": "5.0.0-alpha.2",
|
|
25
|
+
"@vuu-ui/vuu-table": "5.0.0-alpha.2",
|
|
26
|
+
"@vuu-ui/vuu-ui-controls": "5.0.0-alpha.2",
|
|
27
|
+
"@vuu-ui/vuu-utils": "5.0.0-alpha.2"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"clsx": "^2.0.0",
|
|
@@ -39,12 +39,11 @@
|
|
|
39
39
|
],
|
|
40
40
|
"exports": {
|
|
41
41
|
".": {
|
|
42
|
+
"types": "./types/index.d.ts",
|
|
42
43
|
"import": "./src/index.js",
|
|
43
|
-
"default": "./src/index.js"
|
|
44
|
-
"types": "./types/index.d.ts"
|
|
44
|
+
"default": "./src/index.js"
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"module": "./src/index.js",
|
|
48
|
-
"name": "@vuu-ui/vuu-layout"
|
|
49
|
-
"type": "module"
|
|
48
|
+
"name": "@vuu-ui/vuu-layout"
|
|
50
49
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import react, { useState } from "react";
|
|
3
|
-
import { LayoutConfigurator
|
|
3
|
+
import { LayoutConfigurator } from "../devtools-box/layout-configurator.js";
|
|
4
|
+
import { LayoutTreeViewer } from "../devtools-tree/layout-tree-viewer.js";
|
|
4
5
|
import { followPathToComponent } from "../../index.js";
|
|
5
6
|
const ConfigWrapper = ({ children })=>{
|
|
6
7
|
const designMode = false;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FormField, Input } from "@salt-ds/core";
|
|
3
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
4
|
+
import { useWindow } from "@salt-ds/window";
|
|
5
|
+
import layout_configurator from "./layout-configurator.css";
|
|
6
|
+
const NO_STYLE = {};
|
|
7
|
+
const DIMENSIONS = {
|
|
8
|
+
margin: {
|
|
9
|
+
top: "marginTop",
|
|
10
|
+
right: "marginRight",
|
|
11
|
+
bottom: "marginBottom",
|
|
12
|
+
left: "marginLeft"
|
|
13
|
+
},
|
|
14
|
+
border: {
|
|
15
|
+
top: "borderTopWidth",
|
|
16
|
+
right: "borderRightWidth",
|
|
17
|
+
bottom: "borderBottomWidth",
|
|
18
|
+
left: "borderLeftWidth"
|
|
19
|
+
},
|
|
20
|
+
padding: {
|
|
21
|
+
top: "paddingTop",
|
|
22
|
+
right: "paddingRight",
|
|
23
|
+
bottom: "paddingBottom",
|
|
24
|
+
left: "paddingLeft"
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const LayoutBox = ({ feature, children, style, onChange })=>/*#__PURE__*/ jsxs("div", {
|
|
28
|
+
className: `LayoutBox layout-${feature} layout-outer`,
|
|
29
|
+
children: [
|
|
30
|
+
/*#__PURE__*/ jsxs("div", {
|
|
31
|
+
className: "layout-top",
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ jsx("span", {
|
|
34
|
+
className: "layout-title",
|
|
35
|
+
children: feature
|
|
36
|
+
}),
|
|
37
|
+
/*#__PURE__*/ jsx(FormField, {
|
|
38
|
+
className: "layout-input",
|
|
39
|
+
style: {
|
|
40
|
+
width: 30
|
|
41
|
+
},
|
|
42
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
43
|
+
value: style.top,
|
|
44
|
+
onChange: (evt, value)=>onChange(feature, "top", value)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ jsxs("div", {
|
|
50
|
+
className: "layout-inner",
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ jsx("div", {
|
|
53
|
+
className: "layout-left",
|
|
54
|
+
children: /*#__PURE__*/ jsx(FormField, {
|
|
55
|
+
className: "layout-input",
|
|
56
|
+
style: {
|
|
57
|
+
width: 30
|
|
58
|
+
},
|
|
59
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
60
|
+
value: style.left,
|
|
61
|
+
onChange: (evt, value)=>onChange(feature, "left", value)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
}),
|
|
65
|
+
children,
|
|
66
|
+
/*#__PURE__*/ jsx("div", {
|
|
67
|
+
className: "layout-right",
|
|
68
|
+
children: /*#__PURE__*/ jsx(FormField, {
|
|
69
|
+
className: "layout-input",
|
|
70
|
+
style: {
|
|
71
|
+
width: 30
|
|
72
|
+
},
|
|
73
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
74
|
+
value: style.right,
|
|
75
|
+
onChange: (evt, value)=>onChange(feature, "right", value)
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
}),
|
|
81
|
+
/*#__PURE__*/ jsx("div", {
|
|
82
|
+
className: "layout-bottom",
|
|
83
|
+
children: /*#__PURE__*/ jsx(FormField, {
|
|
84
|
+
className: "layout-input",
|
|
85
|
+
style: {
|
|
86
|
+
width: 30
|
|
87
|
+
},
|
|
88
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
89
|
+
value: style.bottom,
|
|
90
|
+
onChange: (evt, value)=>onChange(feature, "bottom", value)
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
const MARGIN_STYLES = {
|
|
97
|
+
margin: true,
|
|
98
|
+
marginTop: true,
|
|
99
|
+
marginRight: true,
|
|
100
|
+
marginBottom: true,
|
|
101
|
+
marginLeft: true
|
|
102
|
+
};
|
|
103
|
+
const PADDING_STYLES = {
|
|
104
|
+
padding: true,
|
|
105
|
+
paddingTop: true,
|
|
106
|
+
paddingRight: true,
|
|
107
|
+
paddingBottom: true,
|
|
108
|
+
paddingLeft: true
|
|
109
|
+
};
|
|
110
|
+
const BORDER_STYLES = {
|
|
111
|
+
border: true,
|
|
112
|
+
borderColor: true,
|
|
113
|
+
borderWidth: true,
|
|
114
|
+
borderTopWidth: true,
|
|
115
|
+
borderRightWidth: true,
|
|
116
|
+
borderBottomWidth: true,
|
|
117
|
+
borderLeftWidth: true
|
|
118
|
+
};
|
|
119
|
+
const CSS_DIGIT = "(\\d+)(?:px)?";
|
|
120
|
+
const CSS_MEASURE = `^(?:${CSS_DIGIT}(?:\\s${CSS_DIGIT}(?:\\s${CSS_DIGIT}(?:\\s${CSS_DIGIT})?)?)?)$`;
|
|
121
|
+
const CSS_REX = new RegExp(CSS_MEASURE);
|
|
122
|
+
const BORDER_REX = /^(?:(\d+)(?:px)\ssolid\s([a-zA-Z,0-9().]+))$/;
|
|
123
|
+
const LayoutConfigurator = ({ height, managedStyle, onChange, style, width })=>{
|
|
124
|
+
const targetWindow = useWindow();
|
|
125
|
+
useComponentCssInjection({
|
|
126
|
+
testId: "vuu-layout-configurator",
|
|
127
|
+
css: layout_configurator,
|
|
128
|
+
window: targetWindow
|
|
129
|
+
});
|
|
130
|
+
const state = normalizeStyle(managedStyle);
|
|
131
|
+
const handleChange = (feature, dimension, strValue)=>{
|
|
132
|
+
const value = parseInt(strValue || "0", 10);
|
|
133
|
+
const property = DIMENSIONS[feature][dimension];
|
|
134
|
+
onChange(property, value);
|
|
135
|
+
};
|
|
136
|
+
const { marginTop: mt = 0, marginRight: mr = 0, marginBottom: mb = 0, marginLeft: ml = 0 } = state;
|
|
137
|
+
const { borderTopWidth: bt = 0, borderRightWidth: br = 0, borderBottomWidth: bb = 0, borderLeftWidth: bl = 0 } = state;
|
|
138
|
+
const { paddingTop: pt = 0, paddingRight: pr = 0, paddingBottom: pb = 0, paddingLeft: pl = 0 } = state;
|
|
139
|
+
return /*#__PURE__*/ jsx("div", {
|
|
140
|
+
className: "LayoutConfigurator",
|
|
141
|
+
style: {
|
|
142
|
+
width,
|
|
143
|
+
height,
|
|
144
|
+
...style
|
|
145
|
+
},
|
|
146
|
+
children: /*#__PURE__*/ jsx(LayoutBox, {
|
|
147
|
+
feature: "margin",
|
|
148
|
+
style: {
|
|
149
|
+
top: mt,
|
|
150
|
+
right: mr,
|
|
151
|
+
bottom: mb,
|
|
152
|
+
left: ml
|
|
153
|
+
},
|
|
154
|
+
onChange: handleChange,
|
|
155
|
+
children: /*#__PURE__*/ jsx(LayoutBox, {
|
|
156
|
+
feature: "border",
|
|
157
|
+
style: {
|
|
158
|
+
top: bt,
|
|
159
|
+
right: br,
|
|
160
|
+
bottom: bb,
|
|
161
|
+
left: bl
|
|
162
|
+
},
|
|
163
|
+
onChange: handleChange,
|
|
164
|
+
children: /*#__PURE__*/ jsx(LayoutBox, {
|
|
165
|
+
feature: "padding",
|
|
166
|
+
style: {
|
|
167
|
+
top: pt,
|
|
168
|
+
right: pr,
|
|
169
|
+
bottom: pb,
|
|
170
|
+
left: pl
|
|
171
|
+
},
|
|
172
|
+
onChange: handleChange,
|
|
173
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
174
|
+
className: "layout-content"
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
function XXXnormalizeStyles(layoutStyle = NO_STYLE, visualStyle = NO_STYLE) {
|
|
182
|
+
const { margin, marginTop, marginRight, marginBottom, marginLeft, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, ...style } = layoutStyle;
|
|
183
|
+
if ("number" == typeof margin) style.marginTop = style.marginRight = style.marginBottom = style.marginLeft = margin;
|
|
184
|
+
else if ("string" == typeof margin) {
|
|
185
|
+
const match = CSS_REX.exec(margin);
|
|
186
|
+
if (null === match) console.error(`Invalid css value for margin '${margin}'`);
|
|
187
|
+
else {
|
|
188
|
+
const [, pos1, pos2, pos3, pos4] = match;
|
|
189
|
+
const pos123 = pos1 && pos2 && pos3;
|
|
190
|
+
if (pos123 && pos4) {
|
|
191
|
+
style.marginTop = parseInt(pos1, 10);
|
|
192
|
+
style.marginRight = parseInt(pos2, 10);
|
|
193
|
+
style.marginBottom = parseInt(pos3, 10);
|
|
194
|
+
style.marginLeft = parseInt(pos4, 10);
|
|
195
|
+
} else if (pos123) {
|
|
196
|
+
style.marginTop = parseInt(pos1, 10);
|
|
197
|
+
style.marginRight = style.marginLeft = parseInt(pos2, 10);
|
|
198
|
+
style.marginBottom = parseInt(pos3, 10);
|
|
199
|
+
} else if (pos1 && pos2) {
|
|
200
|
+
style.marginTop = style.marginBottom = parseInt(pos1, 10);
|
|
201
|
+
style.marginRight = style.marginLeft = parseInt(pos2, 10);
|
|
202
|
+
} else style.marginTop = style.marginRight = style.marginBottom = style.marginLeft = parseInt(pos1, 10);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if ("number" == typeof marginTop) style.marginTop = marginTop;
|
|
206
|
+
if ("number" == typeof marginRight) style.marginRight = marginRight;
|
|
207
|
+
if ("number" == typeof marginBottom) style.marginBottom = marginBottom;
|
|
208
|
+
if ("number" == typeof marginLeft) style.marginLeft = marginLeft;
|
|
209
|
+
if ("number" == typeof padding) style.paddingTop = style.paddingRight = style.paddingBottom = style.paddingLeft = padding;
|
|
210
|
+
else if ("string" == typeof padding) {
|
|
211
|
+
const match = CSS_REX.exec(padding);
|
|
212
|
+
if (null === match) console.error(`Invalid css value for padding '${padding}'`);
|
|
213
|
+
else {
|
|
214
|
+
const [, pos1, pos2, pos3, pos4] = match;
|
|
215
|
+
const pos123 = pos1 && pos2 && pos3;
|
|
216
|
+
if (pos123 && pos4) {
|
|
217
|
+
style.paddingTop = parseInt(pos1, 10);
|
|
218
|
+
style.paddingRight = parseInt(pos2, 10);
|
|
219
|
+
style.paddingBottom = parseInt(pos3, 10);
|
|
220
|
+
style.paddingLeft = parseInt(pos4, 10);
|
|
221
|
+
} else if (pos123) {
|
|
222
|
+
style.paddingTop = parseInt(pos1, 10);
|
|
223
|
+
style.paddingRight = style.paddingLeft = parseInt(pos2, 10);
|
|
224
|
+
style.paddingBottom = parseInt(pos3, 10);
|
|
225
|
+
} else if (pos1 && pos2) {
|
|
226
|
+
style.paddingTop = style.paddingBottom = parseInt(pos1, 10);
|
|
227
|
+
style.paddingRight = style.paddingLeft = parseInt(pos2, 10);
|
|
228
|
+
} else style.paddingTop = style.paddingRight = style.paddingBottom = style.paddinggLeft = parseInt(pos1, 10);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if ("number" == typeof paddingTop) style.paddingTop = paddingTop;
|
|
232
|
+
if ("number" == typeof paddingRight) style.paddingRight = paddingRight;
|
|
233
|
+
if ("number" == typeof paddingBottom) style.paddingBottom = paddingBottom;
|
|
234
|
+
if ("number" == typeof paddingLeft) style.paddingLeft = paddingLeft;
|
|
235
|
+
return normalizeStyle(style);
|
|
236
|
+
}
|
|
237
|
+
function normalizeStyle(managedStyle = NO_STYLE) {
|
|
238
|
+
const style = {
|
|
239
|
+
...managedStyle
|
|
240
|
+
};
|
|
241
|
+
let match;
|
|
242
|
+
let { border, borderWidth, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth, borderColor, margin, marginTop, marginRight, marginBottom, marginLeft, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, ...rest } = style;
|
|
243
|
+
let marginStyles = {};
|
|
244
|
+
let paddingStyles = {};
|
|
245
|
+
if ("number" == typeof margin) {
|
|
246
|
+
style.marginTop = style.marginRight = style.marginBottom = style.marginLeft = margin;
|
|
247
|
+
marginStyles = {
|
|
248
|
+
marginTop: margin,
|
|
249
|
+
marginRight: margin,
|
|
250
|
+
marginBottom: margin,
|
|
251
|
+
marginLeft: margin
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
if ("number" == typeof padding) {
|
|
255
|
+
style.paddingTop = style.paddingRight = style.paddingBottom = style.paddingLeft = padding;
|
|
256
|
+
paddingStyles = {
|
|
257
|
+
paddingTop: padding,
|
|
258
|
+
paddingRight: padding,
|
|
259
|
+
paddingBottom: padding,
|
|
260
|
+
paddingLeft: padding
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
if (!border && !borderWidth && !borderTopWidth && !borderRightWidth && !borderBottomWidth && !borderLeftWidth) return style;
|
|
264
|
+
{
|
|
265
|
+
if ("string" == typeof border && (match = BORDER_REX.exec(border))) {
|
|
266
|
+
[, borderWidth, borderColor] = match;
|
|
267
|
+
borderWidth = parseInt(borderWidth, 10);
|
|
268
|
+
}
|
|
269
|
+
if (borderWidth) {
|
|
270
|
+
borderTopWidth = void 0 === borderTopWidth ? borderWidth : borderTopWidth;
|
|
271
|
+
borderRightWidth = void 0 === borderRightWidth ? borderWidth : borderRightWidth;
|
|
272
|
+
borderBottomWidth = void 0 === borderBottomWidth ? borderWidth : borderBottomWidth;
|
|
273
|
+
borderLeftWidth = void 0 === borderLeftWidth ? borderWidth : borderLeftWidth;
|
|
274
|
+
}
|
|
275
|
+
borderColor = borderColor || "black";
|
|
276
|
+
const boxShadow = `
|
|
277
|
+
${borderColor} ${borderLeftWidth || 0}px ${borderTopWidth || 0}px 0 0 inset,
|
|
278
|
+
${borderColor} ${-borderRightWidth || 0}px ${-borderBottomWidth || 0}px 0 0 inset`;
|
|
279
|
+
return {
|
|
280
|
+
...rest,
|
|
281
|
+
...marginStyles,
|
|
282
|
+
...paddingStyles,
|
|
283
|
+
borderTopWidth,
|
|
284
|
+
borderRightWidth,
|
|
285
|
+
borderBottomWidth,
|
|
286
|
+
borderLeftWidth,
|
|
287
|
+
borderColor,
|
|
288
|
+
borderStyle: "solid",
|
|
289
|
+
boxShadow
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
export { BORDER_STYLES, LayoutConfigurator, MARGIN_STYLES, PADDING_STYLES, XXXnormalizeStyles };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import react from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
5
|
+
import { useWindow } from "@salt-ds/window";
|
|
6
|
+
import { typeOf } from "../../utils/index.js";
|
|
7
|
+
import layout_tree_viewer from "./layout-tree-viewer.css";
|
|
8
|
+
import { TreeTable } from "@vuu-ui/vuu-datatable";
|
|
9
|
+
const classBaseTree = "hwLayoutTreeViewer";
|
|
10
|
+
const toTreeJson = (component, path = "0")=>({
|
|
11
|
+
label: typeOf(component),
|
|
12
|
+
path,
|
|
13
|
+
childNodes: react.Children.map(component.props.children, (child, i)=>toTreeJson(child, path ? `${path}.${i}` : `${i}`))
|
|
14
|
+
});
|
|
15
|
+
const LayoutTreeViewer = ({ layout, onSelect: _, style })=>{
|
|
16
|
+
const targetWindow = useWindow();
|
|
17
|
+
useComponentCssInjection({
|
|
18
|
+
testId: "vuu-layout-tree-viewer",
|
|
19
|
+
css: layout_tree_viewer,
|
|
20
|
+
window: targetWindow
|
|
21
|
+
});
|
|
22
|
+
const treeJson = [
|
|
23
|
+
toTreeJson(layout)
|
|
24
|
+
];
|
|
25
|
+
const handleSelection = (row)=>{
|
|
26
|
+
console.log({
|
|
27
|
+
row
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
return /*#__PURE__*/ jsx("div", {
|
|
31
|
+
className: clsx(classBaseTree),
|
|
32
|
+
style: style,
|
|
33
|
+
children: /*#__PURE__*/ jsx(TreeTable, {
|
|
34
|
+
source: treeJson,
|
|
35
|
+
selectionModel: "single",
|
|
36
|
+
onSelect: handleSelection
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export { LayoutTreeViewer };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReactElement } from "react";
|
|
2
|
-
import { LayoutModel } from "@vuu-ui/vuu-utils";
|
|
3
|
-
import { DragDropRect, DropPos, RelativePosition } from "./dragDropTypes";
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import { type LayoutModel } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import type { DragDropRect, DropPos, RelativePosition } from "./dragDropTypes";
|
|
4
4
|
export declare const positionValues: {
|
|
5
5
|
north: number;
|
|
6
6
|
east: number;
|
package/types/src/Component.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from "react";
|
|
2
|
-
export interface LayoutContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
dropTarget?: boolean;
|
|
4
|
-
resizeable?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare const LayoutContainer: import("react").ForwardRefExoticComponent<LayoutContainerProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/types/src/debug.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from "react";
|
|
2
|
-
export type DockLayoutProps = HTMLAttributes<HTMLDivElement>;
|
|
3
|
-
declare function DockLayout(props: DockLayoutProps): import("react").JSX.Element;
|
|
4
|
-
declare namespace DockLayout {
|
|
5
|
-
var displayName: string;
|
|
6
|
-
}
|
|
7
|
-
export default DockLayout;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from "react";
|
|
2
|
-
export interface DrawerProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
clickToOpen?: boolean;
|
|
4
|
-
defaultOpen?: boolean;
|
|
5
|
-
inline?: boolean;
|
|
6
|
-
open?: boolean;
|
|
7
|
-
peekaboo?: boolean;
|
|
8
|
-
position?: "left" | "right" | "top" | "bottom";
|
|
9
|
-
sizeOpen?: number;
|
|
10
|
-
sizeClosed?: number;
|
|
11
|
-
toggleButton?: "start" | "end";
|
|
12
|
-
}
|
|
13
|
-
declare function Drawer({ children, className: classNameProp, clickToOpen, defaultOpen, sizeOpen, sizeClosed, style: styleProp, open: openProp, position, inline, onClick, peekaboo, toggleButton, ...props }: DrawerProps): import("react").JSX.Element;
|
|
14
|
-
declare namespace Drawer {
|
|
15
|
-
var displayName: string;
|
|
16
|
-
}
|
|
17
|
-
export default Drawer;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from "react";
|
|
2
|
-
import { LayoutModel } from "@vuu-ui/vuu-utils";
|
|
3
|
-
import { DragDropRect, DropPos, RelativePosition } from "./dragDropTypes";
|
|
4
|
-
export declare const positionValues: {
|
|
5
|
-
north: number;
|
|
6
|
-
east: number;
|
|
7
|
-
south: number;
|
|
8
|
-
west: number;
|
|
9
|
-
header: number;
|
|
10
|
-
centre: number;
|
|
11
|
-
absolute: number;
|
|
12
|
-
};
|
|
13
|
-
export declare const RelativeDropPosition: {
|
|
14
|
-
AFTER: RelativePosition;
|
|
15
|
-
BEFORE: RelativePosition;
|
|
16
|
-
};
|
|
17
|
-
export declare const Position: Readonly<{
|
|
18
|
-
North: Readonly<{
|
|
19
|
-
offset: number;
|
|
20
|
-
valueOf: () => number;
|
|
21
|
-
toString: () => "absolute" | "centre" | "east" | "header" | "north" | "south" | "west";
|
|
22
|
-
North: boolean;
|
|
23
|
-
South: boolean;
|
|
24
|
-
East: boolean;
|
|
25
|
-
West: boolean;
|
|
26
|
-
Header: boolean;
|
|
27
|
-
Centre: boolean;
|
|
28
|
-
NorthOrSouth: boolean;
|
|
29
|
-
EastOrWest: boolean;
|
|
30
|
-
NorthOrWest: boolean;
|
|
31
|
-
SouthOrEast: boolean;
|
|
32
|
-
Absolute: boolean;
|
|
33
|
-
}>;
|
|
34
|
-
East: Readonly<{
|
|
35
|
-
offset: number;
|
|
36
|
-
valueOf: () => number;
|
|
37
|
-
toString: () => "absolute" | "centre" | "east" | "header" | "north" | "south" | "west";
|
|
38
|
-
North: boolean;
|
|
39
|
-
South: boolean;
|
|
40
|
-
East: boolean;
|
|
41
|
-
West: boolean;
|
|
42
|
-
Header: boolean;
|
|
43
|
-
Centre: boolean;
|
|
44
|
-
NorthOrSouth: boolean;
|
|
45
|
-
EastOrWest: boolean;
|
|
46
|
-
NorthOrWest: boolean;
|
|
47
|
-
SouthOrEast: boolean;
|
|
48
|
-
Absolute: boolean;
|
|
49
|
-
}>;
|
|
50
|
-
South: Readonly<{
|
|
51
|
-
offset: number;
|
|
52
|
-
valueOf: () => number;
|
|
53
|
-
toString: () => "absolute" | "centre" | "east" | "header" | "north" | "south" | "west";
|
|
54
|
-
North: boolean;
|
|
55
|
-
South: boolean;
|
|
56
|
-
East: boolean;
|
|
57
|
-
West: boolean;
|
|
58
|
-
Header: boolean;
|
|
59
|
-
Centre: boolean;
|
|
60
|
-
NorthOrSouth: boolean;
|
|
61
|
-
EastOrWest: boolean;
|
|
62
|
-
NorthOrWest: boolean;
|
|
63
|
-
SouthOrEast: boolean;
|
|
64
|
-
Absolute: boolean;
|
|
65
|
-
}>;
|
|
66
|
-
West: Readonly<{
|
|
67
|
-
offset: number;
|
|
68
|
-
valueOf: () => number;
|
|
69
|
-
toString: () => "absolute" | "centre" | "east" | "header" | "north" | "south" | "west";
|
|
70
|
-
North: boolean;
|
|
71
|
-
South: boolean;
|
|
72
|
-
East: boolean;
|
|
73
|
-
West: boolean;
|
|
74
|
-
Header: boolean;
|
|
75
|
-
Centre: boolean;
|
|
76
|
-
NorthOrSouth: boolean;
|
|
77
|
-
EastOrWest: boolean;
|
|
78
|
-
NorthOrWest: boolean;
|
|
79
|
-
SouthOrEast: boolean;
|
|
80
|
-
Absolute: boolean;
|
|
81
|
-
}>;
|
|
82
|
-
Header: Readonly<{
|
|
83
|
-
offset: number;
|
|
84
|
-
valueOf: () => number;
|
|
85
|
-
toString: () => "absolute" | "centre" | "east" | "header" | "north" | "south" | "west";
|
|
86
|
-
North: boolean;
|
|
87
|
-
South: boolean;
|
|
88
|
-
East: boolean;
|
|
89
|
-
West: boolean;
|
|
90
|
-
Header: boolean;
|
|
91
|
-
Centre: boolean;
|
|
92
|
-
NorthOrSouth: boolean;
|
|
93
|
-
EastOrWest: boolean;
|
|
94
|
-
NorthOrWest: boolean;
|
|
95
|
-
SouthOrEast: boolean;
|
|
96
|
-
Absolute: boolean;
|
|
97
|
-
}>;
|
|
98
|
-
Centre: Readonly<{
|
|
99
|
-
offset: number;
|
|
100
|
-
valueOf: () => number;
|
|
101
|
-
toString: () => "absolute" | "centre" | "east" | "header" | "north" | "south" | "west";
|
|
102
|
-
North: boolean;
|
|
103
|
-
South: boolean;
|
|
104
|
-
East: boolean;
|
|
105
|
-
West: boolean;
|
|
106
|
-
Header: boolean;
|
|
107
|
-
Centre: boolean;
|
|
108
|
-
NorthOrSouth: boolean;
|
|
109
|
-
EastOrWest: boolean;
|
|
110
|
-
NorthOrWest: boolean;
|
|
111
|
-
SouthOrEast: boolean;
|
|
112
|
-
Absolute: boolean;
|
|
113
|
-
}>;
|
|
114
|
-
Absolute: Readonly<{
|
|
115
|
-
offset: number;
|
|
116
|
-
valueOf: () => number;
|
|
117
|
-
toString: () => "absolute" | "centre" | "east" | "header" | "north" | "south" | "west";
|
|
118
|
-
North: boolean;
|
|
119
|
-
South: boolean;
|
|
120
|
-
East: boolean;
|
|
121
|
-
West: boolean;
|
|
122
|
-
Header: boolean;
|
|
123
|
-
Centre: boolean;
|
|
124
|
-
NorthOrSouth: boolean;
|
|
125
|
-
EastOrWest: boolean;
|
|
126
|
-
NorthOrWest: boolean;
|
|
127
|
-
SouthOrEast: boolean;
|
|
128
|
-
Absolute: boolean;
|
|
129
|
-
}>;
|
|
130
|
-
}>;
|
|
131
|
-
export interface Measurements {
|
|
132
|
-
[key: string]: DragDropRect;
|
|
133
|
-
}
|
|
134
|
-
export declare class BoxModel {
|
|
135
|
-
static measure(model: ReactElement, dropTargetPaths?: string[]): Measurements;
|
|
136
|
-
static allBoxesContainingPoint(layout: LayoutModel, measurements: Measurements, x: number, y: number, validDropTargets?: string[]): LayoutModel[];
|
|
137
|
-
}
|
|
138
|
-
export declare function pointPositionWithinRect(x: number, y: number, rect: DragDropRect, borderZone?: number): {
|
|
139
|
-
pctX: number;
|
|
140
|
-
pctY: number;
|
|
141
|
-
closeToTheEdge: number;
|
|
142
|
-
};
|
|
143
|
-
export declare function getPosition(x: number, y: number, rect: DragDropRect, targetOrientation?: "row" | "column"): DropPos;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { DragDropRect } from './dragDropTypes';
|
|
2
|
-
export type IntrinsicSizes = {
|
|
3
|
-
height?: number;
|
|
4
|
-
width?: number;
|
|
5
|
-
};
|
|
6
|
-
interface ZoneRange {
|
|
7
|
-
hi: number;
|
|
8
|
-
lo: number;
|
|
9
|
-
}
|
|
10
|
-
type DragConstraint = {
|
|
11
|
-
zone: {
|
|
12
|
-
x: ZoneRange;
|
|
13
|
-
y: ZoneRange;
|
|
14
|
-
};
|
|
15
|
-
pos: {
|
|
16
|
-
x: ZoneRange;
|
|
17
|
-
y: ZoneRange;
|
|
18
|
-
};
|
|
19
|
-
mouse: {
|
|
20
|
-
x: ZoneRange;
|
|
21
|
-
y: ZoneRange;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
interface ExtendedZoneRange {
|
|
25
|
-
lo: boolean;
|
|
26
|
-
hi: boolean;
|
|
27
|
-
mousePct: number;
|
|
28
|
-
mousePos: number;
|
|
29
|
-
pos: number;
|
|
30
|
-
}
|
|
31
|
-
export declare class DragState {
|
|
32
|
-
constraint: DragConstraint;
|
|
33
|
-
x: ExtendedZoneRange;
|
|
34
|
-
y: ExtendedZoneRange;
|
|
35
|
-
intrinsicSize: IntrinsicSizes | undefined;
|
|
36
|
-
constructor(zone: DragDropRect, mouseX: number, mouseY: number, measurements: DragDropRect, intrinsicSize?: IntrinsicSizes);
|
|
37
|
-
init(zone: DragDropRect, mouseX: number, mouseY: number, rect: DragDropRect, intrinsicSize?: IntrinsicSizes): void;
|
|
38
|
-
outOfBounds(): boolean;
|
|
39
|
-
inBounds(): boolean;
|
|
40
|
-
dropX(): number;
|
|
41
|
-
dropY(): number;
|
|
42
|
-
hasIntrinsicSize(): number | undefined;
|
|
43
|
-
update(xy: 'x' | 'y', mousePos: number): boolean;
|
|
44
|
-
private dropXY;
|
|
45
|
-
}
|
|
46
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { rect } from "@vuu-ui/vuu-utils";
|
|
2
|
-
import { ReactElement } from "react";
|
|
3
|
-
import { IntrinsicSizes } from "./DragState";
|
|
4
|
-
import { DropTarget } from "./DropTarget";
|
|
5
|
-
export type DragStartCallback = (e: MouseEvent, x: number, y: number) => void;
|
|
6
|
-
export type DragMoveCallback = (x: number | undefined, y: number | undefined) => void;
|
|
7
|
-
export type DragEndCallback = (droppedTarget?: Partial<DropTarget>) => void;
|
|
8
|
-
export type DragInstructions = {
|
|
9
|
-
DoNotRemove?: boolean;
|
|
10
|
-
DoNotTransform?: boolean;
|
|
11
|
-
dragThreshold?: number;
|
|
12
|
-
DriftHomeIfNoDropTarget?: boolean;
|
|
13
|
-
RemoveDraggableOnDragEnd?: boolean;
|
|
14
|
-
};
|
|
15
|
-
export declare const Draggable: {
|
|
16
|
-
handleMousedown(e: MouseEvent, dragStartCallback: DragStartCallback, dragInstructions?: DragInstructions): void;
|
|
17
|
-
initDrag(rootContainer: ReactElement, dragContainerPath: string, { top, left, right, bottom }: rect, dragPos: {
|
|
18
|
-
x: number;
|
|
19
|
-
y: number;
|
|
20
|
-
}, dragHandler: {
|
|
21
|
-
drag: DragMoveCallback;
|
|
22
|
-
drop: DragEndCallback;
|
|
23
|
-
}, intrinsicSize?: IntrinsicSizes, dropTargets?: string[]): string;
|
|
24
|
-
};
|