@saltcorn/builder 1.0.0-rc.1 → 1.0.0-rc.3
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/builder",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.3",
|
|
4
4
|
"description": "Drag and drop view builder for Saltcorn, open-source no-code platform",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"homepage": "https://saltcorn.com",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@babel/preset-react": "7.24.7",
|
|
21
21
|
"@craftjs/core": "0.1.0-beta.20",
|
|
22
22
|
"@craftjs/utils": "0.1.0-beta.20",
|
|
23
|
-
"@saltcorn/common-code": "1.0.0-rc.
|
|
23
|
+
"@saltcorn/common-code": "1.0.0-rc.3",
|
|
24
24
|
"saltcorn-craft-layers-noeye": "0.1.0-beta.22",
|
|
25
25
|
"@fonticonpicker/react-fonticonpicker": "1.2.0",
|
|
26
26
|
"@fortawesome/fontawesome-svg-core": "1.2.34",
|
|
@@ -257,6 +257,32 @@ const SettingsPanel = () => {
|
|
|
257
257
|
);
|
|
258
258
|
};
|
|
259
259
|
|
|
260
|
+
// https://stackoverflow.com/questions/36862334/get-viewport-window-height-in-reactjs
|
|
261
|
+
function getWindowDimensions() {
|
|
262
|
+
const { innerWidth: windowWidth, innerHeight: windowHeight } = window;
|
|
263
|
+
return {
|
|
264
|
+
windowWidth,
|
|
265
|
+
windowHeight,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function useWindowDimensions() {
|
|
270
|
+
const [windowDimensions, setWindowDimensions] = useState(
|
|
271
|
+
getWindowDimensions()
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
function handleResize() {
|
|
276
|
+
setWindowDimensions(getWindowDimensions());
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
window.addEventListener("resize", handleResize);
|
|
280
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
281
|
+
}, []);
|
|
282
|
+
|
|
283
|
+
return windowDimensions;
|
|
284
|
+
}
|
|
285
|
+
|
|
260
286
|
const AddColumnButton = () => {
|
|
261
287
|
const { query, actions } = useEditor(() => {});
|
|
262
288
|
const options = useContext(optionsCtx);
|
|
@@ -369,6 +395,23 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
369
395
|
const [isEnlarged, setIsEnlarged] = useState(false);
|
|
370
396
|
const [isLeftEnlarged, setIsLeftEnlarged] = useState(false);
|
|
371
397
|
const [relationsCache, setRelationsCache] = useState({});
|
|
398
|
+
const { windowWidth, windowHeight } = useWindowDimensions();
|
|
399
|
+
|
|
400
|
+
const [builderHeight, setBuilderHeight] = useState(0);
|
|
401
|
+
const [builderTop, setBuilderTop] = useState(0);
|
|
402
|
+
|
|
403
|
+
const ref = useRef(null);
|
|
404
|
+
|
|
405
|
+
useEffect(() => {
|
|
406
|
+
if (!ref.current) return;
|
|
407
|
+
setBuilderHeight(ref.current.clientHeight);
|
|
408
|
+
const rect = ref.current.getBoundingClientRect();
|
|
409
|
+
setBuilderTop(rect.top);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
const canvasHeight =
|
|
413
|
+
Math.max(windowHeight - builderTop, builderHeight, 600) - 10;
|
|
414
|
+
|
|
372
415
|
return (
|
|
373
416
|
<ErrorBoundary>
|
|
374
417
|
<Editor onRender={RenderNode}>
|
|
@@ -382,7 +425,7 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
382
425
|
setRelationsCache,
|
|
383
426
|
}}
|
|
384
427
|
>
|
|
385
|
-
<div className="row" style={{ marginTop: "-5px" }}>
|
|
428
|
+
<div className="row" ref={ref} style={{ marginTop: "-5px" }}>
|
|
386
429
|
<div
|
|
387
430
|
className={`col-sm-auto left-builder-col ${
|
|
388
431
|
isLeftEnlarged
|
|
@@ -437,6 +480,7 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
437
480
|
</div>
|
|
438
481
|
<div
|
|
439
482
|
id="builder-main-canvas"
|
|
483
|
+
style={{ height: canvasHeight }}
|
|
440
484
|
className={`col builder-mode-${options.mode} ${
|
|
441
485
|
options.mode !== "list" ? "emptymsg" : ""
|
|
442
486
|
}`}
|
|
@@ -799,7 +799,7 @@ const ConfigField = ({
|
|
|
799
799
|
//pick first value to mimic html form behaviour
|
|
800
800
|
const options = getOptions();
|
|
801
801
|
let o;
|
|
802
|
-
if ((o = options[0]))
|
|
802
|
+
if (options && (o = options[0]))
|
|
803
803
|
useEffect(() => {
|
|
804
804
|
myOnChange(typeof o === "string" ? o : o.value || o.name || o);
|
|
805
805
|
}, []);
|
|
@@ -939,7 +939,7 @@ const ConfigField = ({
|
|
|
939
939
|
onChange={(e) => e.target && myOnChange(e.target.value)}
|
|
940
940
|
onBlur={(e) => e.target && myOnChange(e.target.value)}
|
|
941
941
|
>
|
|
942
|
-
{field.options.map((o, ix) =>
|
|
942
|
+
{(field.options || []).map((o, ix) =>
|
|
943
943
|
o.name && o.label ? (
|
|
944
944
|
<option key={ix} value={o.name}>
|
|
945
945
|
{o.label}
|