@saltcorn/builder 0.9.4-beta.2 → 0.9.4-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
|
@@ -53,6 +53,10 @@ import {
|
|
|
53
53
|
faTrashAlt,
|
|
54
54
|
faSave,
|
|
55
55
|
} from "@fortawesome/free-solid-svg-icons";
|
|
56
|
+
import {
|
|
57
|
+
faCaretSquareLeft,
|
|
58
|
+
faCaretSquareRight,
|
|
59
|
+
} from "@fortawesome/free-regular-svg-icons";
|
|
56
60
|
import {
|
|
57
61
|
Accordion,
|
|
58
62
|
ErrorBoundary,
|
|
@@ -391,6 +395,7 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
391
395
|
const [uploadedFiles, setUploadedFiles] = useState([]);
|
|
392
396
|
const nodekeys = useRef([]);
|
|
393
397
|
const [isSaving, setIsSaving] = useState(false);
|
|
398
|
+
const [isEnlarged, setIsEnlarged] = useState(false);
|
|
394
399
|
const [relationsCache, setRelationsCache] = useState({});
|
|
395
400
|
|
|
396
401
|
return (
|
|
@@ -472,13 +477,19 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
472
477
|
</div>
|
|
473
478
|
</div>
|
|
474
479
|
<div className="col-sm-auto builder-sidebar">
|
|
475
|
-
<div style={{ width: "16rem" }}>
|
|
480
|
+
<div style={{ width: isEnlarged ? "28rem" : "16rem" }}>
|
|
476
481
|
<NextButton layout={layout} />
|
|
477
482
|
<HistoryPanel />
|
|
478
483
|
<FontAwesomeIcon
|
|
479
484
|
icon={faSave}
|
|
480
485
|
className={isSaving ? "d-inline" : "d-none"}
|
|
481
486
|
/>
|
|
487
|
+
<FontAwesomeIcon
|
|
488
|
+
icon={isEnlarged ? faCaretSquareRight : faCaretSquareLeft}
|
|
489
|
+
className={"float-end me-2 mt-1 fa-lg"}
|
|
490
|
+
onClick={() => setIsEnlarged(!isEnlarged)}
|
|
491
|
+
/>
|
|
492
|
+
|
|
482
493
|
<SettingsPanel />
|
|
483
494
|
</div>
|
|
484
495
|
</div>
|
|
@@ -8,7 +8,7 @@ import React, { Fragment, useState, useContext, useEffect } from "react";
|
|
|
8
8
|
import { ntimes } from "./Columns";
|
|
9
9
|
import { Column } from "./Column";
|
|
10
10
|
import optionsCtx from "../context";
|
|
11
|
-
import { setAPropGen, buildOptions } from "./utils";
|
|
11
|
+
import { setAPropGen, buildOptions, ConfigField } from "./utils";
|
|
12
12
|
|
|
13
13
|
import { Element, useNode } from "@craftjs/core";
|
|
14
14
|
|
|
@@ -31,14 +31,16 @@ const Tabs = ({
|
|
|
31
31
|
independent,
|
|
32
32
|
startClosed,
|
|
33
33
|
field,
|
|
34
|
+
setting_tab_n,
|
|
34
35
|
}) => {
|
|
35
36
|
const {
|
|
36
37
|
selected,
|
|
37
38
|
connectors: { connect, drag },
|
|
39
|
+
actions: { setProp },
|
|
38
40
|
} = useNode((node) => ({ selected: node.events.selected }));
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
);
|
|
41
|
+
|
|
42
|
+
const showTab = setting_tab_n;
|
|
43
|
+
const setShowTab = (n) => setProp((prop) => (prop.setting_tab_n = n));
|
|
42
44
|
const [showTabs, setShowTabs] = useState(
|
|
43
45
|
tabsStyle === "Accordion" && startClosed ? [] : [true]
|
|
44
46
|
);
|
|
@@ -178,8 +180,10 @@ const TabsSettings = () => {
|
|
|
178
180
|
deeplink: node.data.props.deeplink,
|
|
179
181
|
disable_inactive: node.data.props.disable_inactive,
|
|
180
182
|
serverRendered: node.data.props.serverRendered,
|
|
183
|
+
setting_tab_n: node.data.props.setting_tab_n,
|
|
181
184
|
tabId: node.data.props.tabId,
|
|
182
185
|
titles: node.data.props.titles,
|
|
186
|
+
showif: node.data.props.showif,
|
|
183
187
|
field: node.data.props.field,
|
|
184
188
|
}));
|
|
185
189
|
const {
|
|
@@ -194,7 +198,10 @@ const TabsSettings = () => {
|
|
|
194
198
|
field,
|
|
195
199
|
serverRendered,
|
|
196
200
|
tabId,
|
|
201
|
+
showif,
|
|
202
|
+
setting_tab_n,
|
|
197
203
|
} = node;
|
|
204
|
+
const use_setting_tab_n = setting_tab_n || 0;
|
|
198
205
|
const options = useContext(optionsCtx);
|
|
199
206
|
useEffect(() => {
|
|
200
207
|
if (field)
|
|
@@ -263,42 +270,6 @@ const TabsSettings = () => {
|
|
|
263
270
|
</Fragment>
|
|
264
271
|
) : (
|
|
265
272
|
<Fragment>
|
|
266
|
-
<tr>
|
|
267
|
-
<th>
|
|
268
|
-
<label>Number of sections</label>
|
|
269
|
-
</th>
|
|
270
|
-
<td>
|
|
271
|
-
<input
|
|
272
|
-
type="number"
|
|
273
|
-
className="form-control"
|
|
274
|
-
value={ntabs}
|
|
275
|
-
step="1"
|
|
276
|
-
min="0"
|
|
277
|
-
max="20"
|
|
278
|
-
onChange={setAProp("ntabs")}
|
|
279
|
-
/>
|
|
280
|
-
</td>
|
|
281
|
-
</tr>
|
|
282
|
-
<tr>
|
|
283
|
-
<th colSpan="2">Titles</th>
|
|
284
|
-
</tr>
|
|
285
|
-
{ntimes(ntabs, (ix) => (
|
|
286
|
-
<tr key={ix}>
|
|
287
|
-
<th>{ix + 1}</th>
|
|
288
|
-
<td>
|
|
289
|
-
<input
|
|
290
|
-
type="text"
|
|
291
|
-
className="form-control text-to-display"
|
|
292
|
-
value={titles[ix]}
|
|
293
|
-
onChange={(e) => {
|
|
294
|
-
if (!e.target) return;
|
|
295
|
-
const value = e.target.value;
|
|
296
|
-
setProp((prop) => (prop.titles[ix] = value));
|
|
297
|
-
}}
|
|
298
|
-
/>
|
|
299
|
-
</td>
|
|
300
|
-
</tr>
|
|
301
|
-
))}
|
|
302
273
|
{tabsStyle === "Accordion" ? (
|
|
303
274
|
<tr>
|
|
304
275
|
<td colSpan="2">
|
|
@@ -401,6 +372,82 @@ const TabsSettings = () => {
|
|
|
401
372
|
</td>
|
|
402
373
|
</tr>
|
|
403
374
|
) : null}
|
|
375
|
+
<tr>
|
|
376
|
+
<th>
|
|
377
|
+
<label>Number of sections</label>
|
|
378
|
+
</th>
|
|
379
|
+
<td>
|
|
380
|
+
<input
|
|
381
|
+
type="number"
|
|
382
|
+
className="form-control"
|
|
383
|
+
value={ntabs}
|
|
384
|
+
step="1"
|
|
385
|
+
min="1"
|
|
386
|
+
max="20"
|
|
387
|
+
onChange={setAProp("ntabs")}
|
|
388
|
+
/>
|
|
389
|
+
</td>
|
|
390
|
+
</tr>
|
|
391
|
+
<tr>
|
|
392
|
+
<td colSpan={2}>
|
|
393
|
+
<ConfigField
|
|
394
|
+
field={{
|
|
395
|
+
name: "setting_tab_n",
|
|
396
|
+
label: "Tab number",
|
|
397
|
+
type: "btn_select",
|
|
398
|
+
options: ntimes(ntabs, (i) => ({
|
|
399
|
+
value: i,
|
|
400
|
+
title: `${i + 1}`,
|
|
401
|
+
label: `${i + 1}`,
|
|
402
|
+
})),
|
|
403
|
+
}}
|
|
404
|
+
node={node}
|
|
405
|
+
setProp={setProp}
|
|
406
|
+
props={node}
|
|
407
|
+
></ConfigField>
|
|
408
|
+
</td>
|
|
409
|
+
</tr>
|
|
410
|
+
<tr>
|
|
411
|
+
<th colSpan="2">Title</th>
|
|
412
|
+
</tr>
|
|
413
|
+
<tr>
|
|
414
|
+
<td colSpan={2}>
|
|
415
|
+
<input
|
|
416
|
+
type="text"
|
|
417
|
+
className="form-control text-to-display"
|
|
418
|
+
value={titles[use_setting_tab_n] || ""}
|
|
419
|
+
onChange={(e) => {
|
|
420
|
+
if (!e.target) return;
|
|
421
|
+
const value = e.target.value;
|
|
422
|
+
setProp((prop) => (prop.titles[use_setting_tab_n] = value));
|
|
423
|
+
}}
|
|
424
|
+
/>
|
|
425
|
+
</td>
|
|
426
|
+
</tr>
|
|
427
|
+
{options.mode === "show" ? (
|
|
428
|
+
<Fragment>
|
|
429
|
+
<tr>
|
|
430
|
+
<th colSpan="2">Show if formula</th>
|
|
431
|
+
</tr>
|
|
432
|
+
<tr>
|
|
433
|
+
<td colSpan={2}>
|
|
434
|
+
<input
|
|
435
|
+
type="text"
|
|
436
|
+
className="form-control text-to-display"
|
|
437
|
+
value={showif?.[use_setting_tab_n] || ""}
|
|
438
|
+
onChange={(e) => {
|
|
439
|
+
if (!e.target) return;
|
|
440
|
+
const value = e.target.value;
|
|
441
|
+
setProp((prop) => {
|
|
442
|
+
if (!prop.showif) prop.showif = [];
|
|
443
|
+
prop.showif[use_setting_tab_n] = value;
|
|
444
|
+
});
|
|
445
|
+
}}
|
|
446
|
+
/>
|
|
447
|
+
</td>
|
|
448
|
+
</tr>
|
|
449
|
+
</Fragment>
|
|
450
|
+
) : null}
|
|
404
451
|
</Fragment>
|
|
405
452
|
)}
|
|
406
453
|
</tbody>
|
|
@@ -414,6 +461,7 @@ const TabsSettings = () => {
|
|
|
414
461
|
Tabs.craft = {
|
|
415
462
|
props: {
|
|
416
463
|
titles: ["Tab1", "Tab2"],
|
|
464
|
+
showif: [],
|
|
417
465
|
ntabs: 2,
|
|
418
466
|
tabsStyle: "Tabs",
|
|
419
467
|
independent: false,
|
|
@@ -421,8 +469,10 @@ Tabs.craft = {
|
|
|
421
469
|
deeplink: true,
|
|
422
470
|
disable_inactive: false,
|
|
423
471
|
serverRendered: false,
|
|
472
|
+
setting_tab_n: 0,
|
|
424
473
|
tabId: "",
|
|
425
474
|
},
|
|
475
|
+
defaultProps: { setting_tab_n: 0, ntabs: 2 },
|
|
426
476
|
displayName: "Tabs",
|
|
427
477
|
related: {
|
|
428
478
|
settings: TabsSettings,
|
|
@@ -1245,12 +1245,20 @@ const ButtonOrLinkSettingsRows = ({
|
|
|
1245
1245
|
<option value={addBtnClass("btn-secondary")}>Secondary button</option>
|
|
1246
1246
|
<option value={addBtnClass("btn-success")}>Success button</option>
|
|
1247
1247
|
<option value={addBtnClass("btn-danger")}>Danger button</option>
|
|
1248
|
+
<option value={addBtnClass("btn-warning")}>Warning button</option>
|
|
1249
|
+
<option value={addBtnClass("btn-info")}>Info button</option>
|
|
1248
1250
|
<option value={addBtnClass("btn-outline-primary")}>
|
|
1249
1251
|
Primary outline button
|
|
1250
1252
|
</option>
|
|
1251
1253
|
<option value={addBtnClass("btn-outline-secondary")}>
|
|
1252
1254
|
Secondary outline button
|
|
1253
1255
|
</option>
|
|
1256
|
+
<option value={addBtnClass("btn-outline-warning")}>
|
|
1257
|
+
Warning outline button
|
|
1258
|
+
</option>{" "}
|
|
1259
|
+
<option value={addBtnClass("btn-outline-info")}>
|
|
1260
|
+
Info outline button
|
|
1261
|
+
</option>
|
|
1254
1262
|
<option value={addBtnClass("btn-custom-color")}>
|
|
1255
1263
|
Button custom color
|
|
1256
1264
|
</option>
|
|
@@ -253,6 +253,7 @@ const layoutToNodes = (layout, query, actions, parent = "ROOT") => {
|
|
|
253
253
|
<Tabs
|
|
254
254
|
key={ix}
|
|
255
255
|
titles={segment.titles}
|
|
256
|
+
showif={segment.showif}
|
|
256
257
|
ntabs={segment.ntabs}
|
|
257
258
|
independent={segment.independent}
|
|
258
259
|
startClosed={segment.startClosed}
|
|
@@ -529,6 +530,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT") => {
|
|
|
529
530
|
type: "tabs",
|
|
530
531
|
contents,
|
|
531
532
|
titles: node.props.titles,
|
|
533
|
+
showif: node.props.showif,
|
|
532
534
|
tabsStyle: node.props.tabsStyle,
|
|
533
535
|
field: node.props.field,
|
|
534
536
|
independent: node.props.independent,
|