@saltcorn/builder 1.0.0 → 1.1.0-beta.0
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/dist/builder_bundle.js +2 -92
- package/package.json +2 -2
- package/src/components/Builder.js +11 -1
- package/src/components/Library.js +1 -2
- package/src/components/elements/Action.js +1 -0
- package/src/components/elements/Aggregation.js +4 -4
- package/src/components/elements/Columns.js +1 -1
- package/src/components/elements/Container.js +56 -0
- package/src/components/elements/DropDownFilter.js +1 -1
- package/src/components/elements/DropMenu.js +4 -1
- package/src/components/elements/Field.js +4 -4
- package/src/components/elements/Image.js +1 -1
- package/src/components/elements/JoinField.js +2 -2
- package/src/components/elements/LineBreak.js +11 -4
- package/src/components/elements/Link.js +1 -0
- package/src/components/elements/ListColumn.js +1 -1
- package/src/components/elements/Tabs.js +1 -1
- package/src/components/elements/Text.js +5 -6
- package/src/components/elements/ToggleFilter.js +1 -1
- package/src/components/elements/ViewLink.js +1 -0
- package/src/components/elements/utils.js +112 -22
- package/src/components/elements/faicons.js +0 -1643
|
@@ -12,10 +12,15 @@ import {
|
|
|
12
12
|
faChevronRight,
|
|
13
13
|
faInfoCircle,
|
|
14
14
|
faQuestionCircle,
|
|
15
|
+
faBold,
|
|
16
|
+
faItalic,
|
|
17
|
+
faFont,
|
|
18
|
+
faCommentSlash,
|
|
19
|
+
faUnderline,
|
|
20
|
+
faTerminal,
|
|
15
21
|
} from "@fortawesome/free-solid-svg-icons";
|
|
16
22
|
import { useNode, Element } from "@craftjs/core";
|
|
17
23
|
import FontIconPicker from "@fonticonpicker/react-fonticonpicker";
|
|
18
|
-
import faIcons from "./faicons";
|
|
19
24
|
import { Columns, ntimes } from "./Columns";
|
|
20
25
|
import Tippy from "@tippyjs/react";
|
|
21
26
|
import { RelationType } from "@saltcorn/common-code";
|
|
@@ -61,7 +66,8 @@ const BlockSetting = ({ block, setProp }) => (
|
|
|
61
66
|
);
|
|
62
67
|
|
|
63
68
|
export const BlockOrInlineSetting = ({ block, inline, textStyle, setProp }) =>
|
|
64
|
-
!textStyle ||
|
|
69
|
+
!textStyle ||
|
|
70
|
+
!textStyleToArray(textStyle).some((ts) => ts && ts.startsWith("h")) ? (
|
|
65
71
|
<BlockSetting block={block} setProp={setProp} />
|
|
66
72
|
) : (
|
|
67
73
|
<div className="form-check">
|
|
@@ -326,6 +332,89 @@ const TextStyleSelect = ({ textStyle, setProp }) => {
|
|
|
326
332
|
</select>
|
|
327
333
|
);
|
|
328
334
|
};
|
|
335
|
+
const textStyleToArray = (textStyle) =>
|
|
336
|
+
Array.isArray(textStyle) ? textStyle : !textStyle ? [] : [textStyle];
|
|
337
|
+
|
|
338
|
+
const TextStyleSelectBtns = ({ textStyle, setProp }) => {
|
|
339
|
+
const styleArray = textStyleToArray(textStyle);
|
|
340
|
+
const clickH = (h) => {
|
|
341
|
+
const noH = styleArray.filter((s) => !(s.length == 2 && s[0] === "h"));
|
|
342
|
+
const selected = styleArray.includes(`h${h}`);
|
|
343
|
+
if (!selected) noH.push(`h${h}`);
|
|
344
|
+
setProp((prop) => (prop.textStyle = noH));
|
|
345
|
+
};
|
|
346
|
+
const clickStyle = (style) => {
|
|
347
|
+
const noH = styleArray.filter((s) => s !== style);
|
|
348
|
+
const selected = styleArray.includes(style);
|
|
349
|
+
if (!selected) noH.push(style);
|
|
350
|
+
setProp((prop) => (prop.textStyle = noH));
|
|
351
|
+
};
|
|
352
|
+
const StyleButton = ({ styleName, icon, title, size }) => (
|
|
353
|
+
<button
|
|
354
|
+
type="button"
|
|
355
|
+
title={title}
|
|
356
|
+
onClick={() => clickStyle(styleName)}
|
|
357
|
+
className={`btn btn-sm btn-${
|
|
358
|
+
!styleArray.includes(styleName) ? "outline-" : ""
|
|
359
|
+
}secondary style-${styleName}`}
|
|
360
|
+
>
|
|
361
|
+
<FontAwesomeIcon icon={icon} size={size || undefined} />
|
|
362
|
+
</button>
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
return (
|
|
366
|
+
<div>
|
|
367
|
+
<div className="btn-group w-100" role="group">
|
|
368
|
+
{[1, 2, 3, 4, 5, 6].map((h) => (
|
|
369
|
+
<button
|
|
370
|
+
key={h}
|
|
371
|
+
type="button"
|
|
372
|
+
title={`Heading ${h}`}
|
|
373
|
+
onClick={() => clickH(h)}
|
|
374
|
+
className={`btn btn-sm btn-${
|
|
375
|
+
!styleArray.includes(`h${h}`) ? "outline-" : ""
|
|
376
|
+
}secondary style-h${h}`}
|
|
377
|
+
>
|
|
378
|
+
H{h}
|
|
379
|
+
</button>
|
|
380
|
+
))}
|
|
381
|
+
</div>
|
|
382
|
+
<div className="btn-group w-100" role="group">
|
|
383
|
+
<StyleButton
|
|
384
|
+
styleName="fw-bold"
|
|
385
|
+
icon={faBold}
|
|
386
|
+
title="Bold"
|
|
387
|
+
></StyleButton>
|
|
388
|
+
<StyleButton
|
|
389
|
+
styleName="fst-italic"
|
|
390
|
+
icon={faItalic}
|
|
391
|
+
title="Italics"
|
|
392
|
+
></StyleButton>
|
|
393
|
+
<StyleButton
|
|
394
|
+
styleName="small"
|
|
395
|
+
icon={faFont}
|
|
396
|
+
title="Small"
|
|
397
|
+
size="xs"
|
|
398
|
+
></StyleButton>
|
|
399
|
+
<StyleButton
|
|
400
|
+
styleName="text-muted"
|
|
401
|
+
icon={faCommentSlash}
|
|
402
|
+
title="Muted"
|
|
403
|
+
></StyleButton>
|
|
404
|
+
<StyleButton
|
|
405
|
+
styleName="text-underline"
|
|
406
|
+
icon={faUnderline}
|
|
407
|
+
title="Underline"
|
|
408
|
+
></StyleButton>
|
|
409
|
+
<StyleButton
|
|
410
|
+
styleName="font-monospace"
|
|
411
|
+
icon={faTerminal}
|
|
412
|
+
title="Monospace"
|
|
413
|
+
></StyleButton>
|
|
414
|
+
</div>
|
|
415
|
+
</div>
|
|
416
|
+
);
|
|
417
|
+
};
|
|
329
418
|
|
|
330
419
|
export /**
|
|
331
420
|
* @param {object} props
|
|
@@ -357,11 +446,8 @@ export /**
|
|
|
357
446
|
const TextStyleRow = ({ textStyle, setProp }) => {
|
|
358
447
|
return (
|
|
359
448
|
<tr>
|
|
360
|
-
<td>
|
|
361
|
-
<
|
|
362
|
-
</td>
|
|
363
|
-
<td>
|
|
364
|
-
<TextStyleSelect textStyle={textStyle} setProp={setProp} />
|
|
449
|
+
<td colSpan={2}>
|
|
450
|
+
<TextStyleSelectBtns textStyle={textStyle} setProp={setProp} />
|
|
365
451
|
</td>
|
|
366
452
|
</tr>
|
|
367
453
|
);
|
|
@@ -544,7 +630,7 @@ export /**
|
|
|
544
630
|
* @namespace
|
|
545
631
|
*/
|
|
546
632
|
const SelectUnits = ({ vert, autoable, ...props }) => {
|
|
547
|
-
const options = ["px", "%", vert ? "vh" : "vw", "em", "rem"];
|
|
633
|
+
const options = ["px", "%", vert ? "vh" : "vw", "em", "rem", "cm"];
|
|
548
634
|
if (autoable) options.push("auto");
|
|
549
635
|
return <select {...props}>{buildOptions(options)}</select>;
|
|
550
636
|
};
|
|
@@ -811,7 +897,7 @@ const ConfigField = ({
|
|
|
811
897
|
const options = getOptions();
|
|
812
898
|
return (
|
|
813
899
|
<select
|
|
814
|
-
className=
|
|
900
|
+
className={`field-${field?.name} form-control form-select`}
|
|
815
901
|
value={value || ""}
|
|
816
902
|
onChange={(e) => e.target && myOnChange(e.target.value)}
|
|
817
903
|
onBlur={(e) => e.target && myOnChange(e.target.value)}
|
|
@@ -830,7 +916,7 @@ const ConfigField = ({
|
|
|
830
916
|
return (
|
|
831
917
|
<input
|
|
832
918
|
type="text"
|
|
833
|
-
className=
|
|
919
|
+
className={`field-${field?.name} form-control`}
|
|
834
920
|
value={value || ""}
|
|
835
921
|
onChange={(e) => e.target && myOnChange(e.target.value)}
|
|
836
922
|
/>
|
|
@@ -838,7 +924,7 @@ const ConfigField = ({
|
|
|
838
924
|
},
|
|
839
925
|
Font: () => (
|
|
840
926
|
<select
|
|
841
|
-
className="form-control form-select"
|
|
927
|
+
className="fontselect form-control form-select"
|
|
842
928
|
value={value || ""}
|
|
843
929
|
onChange={(e) => e.target && myOnChange(e.target.value)}
|
|
844
930
|
onBlur={(e) => e.target && myOnChange(e.target.value)}
|
|
@@ -856,7 +942,7 @@ const ConfigField = ({
|
|
|
856
942
|
Integer: () => (
|
|
857
943
|
<input
|
|
858
944
|
type="number"
|
|
859
|
-
className=
|
|
945
|
+
className={`field-${field?.name} form-control`}
|
|
860
946
|
step={field.step || 1}
|
|
861
947
|
min={field.min}
|
|
862
948
|
max={field.max}
|
|
@@ -867,7 +953,7 @@ const ConfigField = ({
|
|
|
867
953
|
Float: () => (
|
|
868
954
|
<input
|
|
869
955
|
type="number"
|
|
870
|
-
className=
|
|
956
|
+
className={`field-${field?.name} form-control`}
|
|
871
957
|
value={value || ""}
|
|
872
958
|
step={0.01}
|
|
873
959
|
onChange={(e) => e.target && myOnChange(e.target.value)}
|
|
@@ -878,7 +964,7 @@ const ConfigField = ({
|
|
|
878
964
|
<div className="form-check">
|
|
879
965
|
<input
|
|
880
966
|
type="checkbox"
|
|
881
|
-
className=
|
|
967
|
+
className={`field-${field?.name} form-check-input`}
|
|
882
968
|
checked={value}
|
|
883
969
|
onChange={(e) => e.target && myOnChange(e.target.checked)}
|
|
884
970
|
/>
|
|
@@ -889,7 +975,7 @@ const ConfigField = ({
|
|
|
889
975
|
<textarea
|
|
890
976
|
rows="6"
|
|
891
977
|
type="text"
|
|
892
|
-
className=
|
|
978
|
+
className={`field-${field?.name} form-control`}
|
|
893
979
|
value={value}
|
|
894
980
|
onChange={(e) => e.target && myOnChange(e.target.value)}
|
|
895
981
|
/>
|
|
@@ -898,7 +984,7 @@ const ConfigField = ({
|
|
|
898
984
|
<textarea
|
|
899
985
|
rows="6"
|
|
900
986
|
type="text"
|
|
901
|
-
className=
|
|
987
|
+
className={`field-${field?.name} form-control`}
|
|
902
988
|
value={value}
|
|
903
989
|
onChange={(e) => e.target && myOnChange(e.target.value)}
|
|
904
990
|
spellCheck={false}
|
|
@@ -934,7 +1020,7 @@ const ConfigField = ({
|
|
|
934
1020
|
} else
|
|
935
1021
|
return (
|
|
936
1022
|
<select
|
|
937
|
-
className=
|
|
1023
|
+
className={`field-${field?.name} form-control form-select`}
|
|
938
1024
|
value={value || ""}
|
|
939
1025
|
onChange={(e) => e.target && myOnChange(e.target.value)}
|
|
940
1026
|
onBlur={(e) => e.target && myOnChange(e.target.value)}
|
|
@@ -963,7 +1049,7 @@ const ConfigField = ({
|
|
|
963
1049
|
title={o.title || o.value}
|
|
964
1050
|
type="button"
|
|
965
1051
|
style={{ width: `${Math.floor(100 / field.options.length)}%` }}
|
|
966
|
-
className={`btn btn-sm btn-${
|
|
1052
|
+
className={`field-${field?.name} btn btn-sm btn-${
|
|
967
1053
|
value !== o.value ? "outline-" : ""
|
|
968
1054
|
}secondary ${field.btnClass || ""}`}
|
|
969
1055
|
onClick={() => myOnChange(o.value)}
|
|
@@ -991,7 +1077,7 @@ const ConfigField = ({
|
|
|
991
1077
|
<input
|
|
992
1078
|
type="number"
|
|
993
1079
|
value={(isStyle ? styleVal : value) || ""}
|
|
994
|
-
className=
|
|
1080
|
+
className={`field-${field?.name} w-50 form-control-sm d-inline dimunit`}
|
|
995
1081
|
disabled={field.autoable && styleDim === "auto"}
|
|
996
1082
|
onChange={(e) =>
|
|
997
1083
|
e?.target &&
|
|
@@ -1013,7 +1099,7 @@ const ConfigField = ({
|
|
|
1013
1099
|
"px"
|
|
1014
1100
|
)}
|
|
1015
1101
|
autoable={field.autoable}
|
|
1016
|
-
className={`w-${
|
|
1102
|
+
className={`field-${field?.name} w-${
|
|
1017
1103
|
styleDim === "auto" ? 100 : 50
|
|
1018
1104
|
} form-control-sm d-inline dimunit`}
|
|
1019
1105
|
vert={!field.horiz}
|
|
@@ -1265,6 +1351,7 @@ const ButtonOrLinkSettingsRows = ({
|
|
|
1265
1351
|
linkFirst = false,
|
|
1266
1352
|
linkIsBlank = false,
|
|
1267
1353
|
allowRunOnLoad = false,
|
|
1354
|
+
faIcons = [],
|
|
1268
1355
|
}) => {
|
|
1269
1356
|
const setAProp = setAPropGen(setProp);
|
|
1270
1357
|
const addBtnClass = (s) => (btnClass ? `${btnClass} ${s}` : s);
|
|
@@ -1353,7 +1440,7 @@ const ButtonOrLinkSettingsRows = ({
|
|
|
1353
1440
|
setProp((prop) => (prop[keyPrefix + "icon"] = value))
|
|
1354
1441
|
}
|
|
1355
1442
|
isMulti={false}
|
|
1356
|
-
icons={faIcons}
|
|
1443
|
+
icons={faIcons || []}
|
|
1357
1444
|
/>
|
|
1358
1445
|
</td>
|
|
1359
1446
|
</tr>
|
|
@@ -1481,7 +1568,10 @@ export const recursivelyCloneToElems = (query) => (nodeId, ix) => {
|
|
|
1481
1568
|
};
|
|
1482
1569
|
|
|
1483
1570
|
export const isBlock = (block, inline, textStyle) =>
|
|
1484
|
-
!textStyle ||
|
|
1571
|
+
!textStyle ||
|
|
1572
|
+
!textStyleToArray(textStyle).some((ts) => ts && ts.startsWith("h"))
|
|
1573
|
+
? block
|
|
1574
|
+
: !inline;
|
|
1485
1575
|
|
|
1486
1576
|
export const setAPropGen =
|
|
1487
1577
|
(setProp) =>
|