@saltcorn/builder 1.7.0-beta.1 → 1.7.0-beta.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.7.0-beta.
|
|
3
|
+
"version": "1.7.0-beta.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",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@fortawesome/free-solid-svg-icons": "5.15.2",
|
|
31
31
|
"@fortawesome/react-fontawesome": "0.1.14",
|
|
32
32
|
"@monaco-editor/react": "4.7.0",
|
|
33
|
-
"@saltcorn/common-code": "1.7.0-beta.
|
|
33
|
+
"@saltcorn/common-code": "1.7.0-beta.3",
|
|
34
34
|
"@tippyjs/react": "4.2.6",
|
|
35
35
|
"babel-loader": "9.2.1",
|
|
36
36
|
"ckeditor4-react": "2.0.0",
|
|
@@ -121,6 +121,7 @@ const Columns = ({
|
|
|
121
121
|
colClasses,
|
|
122
122
|
colStyles,
|
|
123
123
|
customClass,
|
|
124
|
+
isFormula,
|
|
124
125
|
breakpoints,
|
|
125
126
|
}) => {
|
|
126
127
|
const {
|
|
@@ -149,7 +150,9 @@ const Columns = ({
|
|
|
149
150
|
}
|
|
150
151
|
return (
|
|
151
152
|
<div
|
|
152
|
-
className={`row builder-columns ${
|
|
153
|
+
className={`row builder-columns ${
|
|
154
|
+
(!isFormula?.customClass && customClass) || ""
|
|
155
|
+
} ${selected ? "selected-node" : ""} ${
|
|
153
156
|
typeof gx !== "undefined" && gx !== null ? `gx-${gx}` : ""
|
|
154
157
|
} ${typeof gy !== "undefined" && gy !== null ? `gy-${gy}` : ""}`}
|
|
155
158
|
ref={(dom) => connect(drag(dom))}
|
|
@@ -204,6 +207,7 @@ const ColumnsSettings = () => {
|
|
|
204
207
|
colClasses: node.data.props.colClasses,
|
|
205
208
|
colStyles: node.data.props.colStyles,
|
|
206
209
|
customClass: node.data.props.customClass,
|
|
210
|
+
isFormula: node.data.props.isFormula,
|
|
207
211
|
currentSettingsTab: node.data.props.currentSettingsTab,
|
|
208
212
|
}));
|
|
209
213
|
const {
|
|
@@ -409,6 +413,8 @@ const ColumnsSettings = () => {
|
|
|
409
413
|
name: "customClass",
|
|
410
414
|
label: t("Custom class"),
|
|
411
415
|
type: "String",
|
|
416
|
+
canBeFormula: true,
|
|
417
|
+
formulaInEdit: true,
|
|
412
418
|
}}
|
|
413
419
|
node={node}
|
|
414
420
|
setProp={setProp}
|
|
@@ -434,6 +440,7 @@ Columns.craft = {
|
|
|
434
440
|
breakpoints: ["sm", "sm"],
|
|
435
441
|
setting_col_n: 0,
|
|
436
442
|
customClass: "",
|
|
443
|
+
isFormula: {},
|
|
437
444
|
},
|
|
438
445
|
related: {
|
|
439
446
|
settings: ColumnsSettings,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/* globals $, validate_expression_elem */
|
|
7
7
|
|
|
8
|
-
import React, { useContext, Fragment } from "react";
|
|
8
|
+
import React, { useContext, Fragment, useRef } from "react";
|
|
9
9
|
|
|
10
10
|
import { Element, useNode } from "@craftjs/core";
|
|
11
11
|
import { Column } from "./Column";
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
49
49
|
import { faScroll, faRobot } from "@fortawesome/free-solid-svg-icons";
|
|
50
50
|
import { BoxModelEditor } from "./BoxModelEditor";
|
|
51
|
+
import { SingleLineEditor } from "./MonacoEditor";
|
|
51
52
|
import previewCtx from "../preview_context";
|
|
52
53
|
|
|
53
54
|
export /**
|
|
@@ -344,6 +345,7 @@ const ContainerSettings = () => {
|
|
|
344
345
|
* @returns {function}
|
|
345
346
|
*/
|
|
346
347
|
const setAProp = setAPropGen(setProp);
|
|
348
|
+
const showIfEditorRef = useRef(null);
|
|
347
349
|
//console.log("transform", transform);
|
|
348
350
|
|
|
349
351
|
return (
|
|
@@ -1033,14 +1035,15 @@ const ContainerSettings = () => {
|
|
|
1033
1035
|
)}
|
|
1034
1036
|
<tr>
|
|
1035
1037
|
<td colSpan={2}>
|
|
1036
|
-
<
|
|
1037
|
-
|
|
1038
|
-
placeholder={t("Example: x === y")}
|
|
1039
|
-
className="form-control text-to-display"
|
|
1038
|
+
<SingleLineEditor
|
|
1039
|
+
ref={showIfEditorRef}
|
|
1040
1040
|
value={showIfFormula}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1041
|
+
setProp={setProp}
|
|
1042
|
+
propKey="showIfFormula"
|
|
1043
|
+
placeholder={t("Example: x === y")}
|
|
1044
|
+
onInput={(value) =>
|
|
1045
|
+
validate_expression_elem(value, showIfEditorRef.current)
|
|
1046
|
+
}
|
|
1044
1047
|
/>
|
|
1045
1048
|
<div style={{ marginTop: "-5px" }}>
|
|
1046
1049
|
<small className="text-muted font-monospace">
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
* @module components/elements/Tabs
|
|
4
4
|
* @subcategory components / elements
|
|
5
5
|
*/
|
|
6
|
+
/* globals validate_expression_elem */
|
|
6
7
|
|
|
7
|
-
import React, { Fragment, useState, useContext, useEffect } from "react";
|
|
8
|
+
import React, { Fragment, useState, useContext, useEffect, useRef } from "react";
|
|
8
9
|
import useTranslation from "../../hooks/useTranslation";
|
|
9
10
|
import { ntimes } from "./Columns";
|
|
10
11
|
import { Column } from "./Column";
|
|
11
12
|
import optionsCtx from "../context";
|
|
12
13
|
import { setAPropGen, buildOptions, ConfigField } from "./utils";
|
|
13
14
|
import { ArrayManager } from "./ArrayManager";
|
|
15
|
+
import { SingleLineEditor } from "./MonacoEditor";
|
|
14
16
|
|
|
15
17
|
import { Element, useNode } from "@craftjs/core";
|
|
16
18
|
|
|
@@ -235,6 +237,7 @@ const TabsSettings = () => {
|
|
|
235
237
|
});
|
|
236
238
|
}, [field]);
|
|
237
239
|
const setAProp = setAPropGen(setProp);
|
|
240
|
+
const showIfEditorRef = useRef(null);
|
|
238
241
|
const styleOptions = ["Tabs", "Pills", "Accordion"];
|
|
239
242
|
if (["show", "edit"].includes(options.mode))
|
|
240
243
|
styleOptions.push("Value switch");
|
|
@@ -456,19 +459,18 @@ const TabsSettings = () => {
|
|
|
456
459
|
</tr>
|
|
457
460
|
<tr>
|
|
458
461
|
<td colSpan={2}>
|
|
459
|
-
<
|
|
460
|
-
|
|
461
|
-
spellCheck={false}
|
|
462
|
-
className="form-control text-to-display"
|
|
462
|
+
<SingleLineEditor
|
|
463
|
+
ref={showIfEditorRef}
|
|
463
464
|
value={showif?.[use_setting_tab_n] || ""}
|
|
464
|
-
onChange={(
|
|
465
|
-
if (!e.target) return;
|
|
466
|
-
const value = e.target.value;
|
|
465
|
+
onChange={(value) => {
|
|
467
466
|
setProp((prop) => {
|
|
468
467
|
if (!prop.showif) prop.showif = [];
|
|
469
468
|
prop.showif[use_setting_tab_n] = value;
|
|
470
469
|
});
|
|
471
470
|
}}
|
|
471
|
+
onInput={(value) =>
|
|
472
|
+
validate_expression_elem(value, showIfEditorRef.current)
|
|
473
|
+
}
|
|
472
474
|
/>
|
|
473
475
|
</td>
|
|
474
476
|
</tr>
|
|
@@ -327,14 +327,23 @@ export /**
|
|
|
327
327
|
* @param {object} props.node
|
|
328
328
|
* @param {string} props.nodekey
|
|
329
329
|
* @param {string} props.children
|
|
330
|
+
* @param {boolean} [props.allowInEdit] also offer the formula in edit views
|
|
330
331
|
* @returns {Fragment}
|
|
331
332
|
* @namespace
|
|
332
333
|
* @category saltcorn-builder
|
|
333
334
|
* @subcategory components / elements / utils
|
|
334
335
|
*/
|
|
335
|
-
const OrFormula = ({
|
|
336
|
+
const OrFormula = ({
|
|
337
|
+
setProp,
|
|
338
|
+
isFormula,
|
|
339
|
+
node,
|
|
340
|
+
nodekey,
|
|
341
|
+
children,
|
|
342
|
+
allowInEdit,
|
|
343
|
+
}) => {
|
|
336
344
|
const { mode } = React.useContext(optionsCtx);
|
|
337
|
-
const allowFormula =
|
|
345
|
+
const allowFormula =
|
|
346
|
+
mode === "show" || mode === "list" || (allowInEdit && mode === "edit");
|
|
338
347
|
/**
|
|
339
348
|
* @returns {void}
|
|
340
349
|
*/
|
|
@@ -1616,6 +1625,7 @@ const SettingsRow = ({
|
|
|
1616
1625
|
<OrFormula
|
|
1617
1626
|
nodekey={field.name}
|
|
1618
1627
|
isFormula={node.isFormula}
|
|
1628
|
+
allowInEdit={field.formulaInEdit}
|
|
1619
1629
|
{...{ setProp, node }}
|
|
1620
1630
|
>
|
|
1621
1631
|
<ConfigField
|
|
@@ -409,6 +409,7 @@ const layoutToNodes = (
|
|
|
409
409
|
header_label={col.header_label}
|
|
410
410
|
col_width={col.col_width}
|
|
411
411
|
showif={col.showif}
|
|
412
|
+
cell_css_formula={col.cell_css_formula}
|
|
412
413
|
col_width_units={col.col_width_units}
|
|
413
414
|
contents={toTag(col.contents)}
|
|
414
415
|
{...addProps}
|
|
@@ -427,6 +428,7 @@ const layoutToNodes = (
|
|
|
427
428
|
gx={segment.gx}
|
|
428
429
|
gy={segment.gy}
|
|
429
430
|
customClass={segment.customClass}
|
|
431
|
+
isFormula={segment.isFormula || {}}
|
|
430
432
|
vAligns={segment.vAligns}
|
|
431
433
|
colClasses={segment.colClasses}
|
|
432
434
|
colStyles={segment.colStyles}
|
|
@@ -469,6 +471,7 @@ const layoutToNodes = (
|
|
|
469
471
|
gx={segment.gx}
|
|
470
472
|
gy={segment.gy}
|
|
471
473
|
customClass={segment.customClass}
|
|
474
|
+
isFormula={segment.isFormula || {}}
|
|
472
475
|
vAligns={segment.vAligns}
|
|
473
476
|
colClasses={segment.colClasses}
|
|
474
477
|
colStyles={segment.colStyles}
|
|
@@ -635,6 +638,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT", options) => {
|
|
|
635
638
|
alignment: node.props.alignment,
|
|
636
639
|
header_label: node.props.header_label,
|
|
637
640
|
showif: node.props.showif,
|
|
641
|
+
cell_css_formula: node.props.cell_css_formula,
|
|
638
642
|
...customProps,
|
|
639
643
|
};
|
|
640
644
|
(addFields || []).forEach((f) => {
|
|
@@ -728,6 +732,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT", options) => {
|
|
|
728
732
|
besides: widths.map((w, ix) => go(nodes[node.linkedNodes["Col" + ix]])),
|
|
729
733
|
breakpoints: node.props.breakpoints,
|
|
730
734
|
customClass: node.props.customClass,
|
|
735
|
+
isFormula: node.props.isFormula,
|
|
731
736
|
gx: node.props.gx != null ? +node.props.gx : undefined,
|
|
732
737
|
gy: node.props.gy != null ? +node.props.gy : undefined,
|
|
733
738
|
aligns: node.props.aligns,
|