@saltcorn/builder 0.5.6-beta.3 → 0.6.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 +18 -10
- package/dist/builder_bundle.js.map +1 -0
- package/package.json +6 -3
- package/src/components/Builder.js +230 -86
- package/src/components/Library.js +184 -0
- package/src/components/Toolbox.js +130 -69
- package/src/components/elements/Action.js +68 -108
- package/src/components/elements/Aggregation.js +0 -1
- package/src/components/elements/BoxModelEditor.js +374 -0
- package/src/components/elements/Column.js +4 -1
- package/src/components/elements/Columns.js +1 -2
- package/src/components/elements/Container.js +208 -274
- package/src/components/elements/DropDownFilter.js +16 -1
- package/src/components/elements/Field.js +1 -1
- package/src/components/elements/Image.js +92 -33
- package/src/components/elements/Link.js +139 -133
- package/src/components/elements/SearchBar.js +1 -1
- package/src/components/elements/Text.js +60 -26
- package/src/components/elements/ToggleFilter.js +12 -14
- package/src/components/elements/View.js +46 -19
- package/src/components/elements/ViewLink.js +62 -72
- package/src/components/elements/boxmodel.html +253 -0
- package/src/components/elements/utils.js +324 -65
- package/src/components/storage.js +30 -18
|
@@ -20,11 +20,16 @@ import { View } from "./elements/View";
|
|
|
20
20
|
import { SearchBar } from "./elements/SearchBar";
|
|
21
21
|
import { Link } from "./elements/Link";
|
|
22
22
|
import optionsCtx from "./context";
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
BoundingBox,
|
|
25
|
+
Diagram3Fill,
|
|
26
|
+
SegmentedNav,
|
|
27
|
+
TextareaT,
|
|
28
|
+
} from "react-bootstrap-icons";
|
|
24
29
|
|
|
25
30
|
const headOr = (xs, def) => (xs && xs.length > 0 ? xs[0] : def);
|
|
26
31
|
|
|
27
|
-
const WrapElem = ({
|
|
32
|
+
export const WrapElem = ({
|
|
28
33
|
children,
|
|
29
34
|
connectors,
|
|
30
35
|
icon,
|
|
@@ -32,6 +37,7 @@ const WrapElem = ({
|
|
|
32
37
|
text,
|
|
33
38
|
fontSize,
|
|
34
39
|
title,
|
|
40
|
+
innerClass,
|
|
35
41
|
bold,
|
|
36
42
|
label,
|
|
37
43
|
disable,
|
|
@@ -39,11 +45,14 @@ const WrapElem = ({
|
|
|
39
45
|
<div
|
|
40
46
|
className={`${
|
|
41
47
|
disable ? "text-muted" : ""
|
|
42
|
-
} wrap-builder-elem
|
|
48
|
+
} d-inline-flex wrap-builder-elem align-items-center justify-content-center`}
|
|
43
49
|
title={title}
|
|
44
50
|
ref={disable ? undefined : (ref) => connectors.create(ref, children)}
|
|
45
51
|
>
|
|
46
|
-
<div
|
|
52
|
+
<div
|
|
53
|
+
className={`inner ${innerClass || ""}`}
|
|
54
|
+
style={fontSize ? { fontSize } : {}}
|
|
55
|
+
>
|
|
47
56
|
{(text && (bold ? <strong>{text}</strong> : text)) ||
|
|
48
57
|
(icons &&
|
|
49
58
|
icons.map((ic, ix) => <i key={ix} className={`${ic}`}></i>)) ||
|
|
@@ -67,6 +76,7 @@ const TextElem = ({ connectors }) => (
|
|
|
67
76
|
const ColumnsElem = ({ connectors }) => (
|
|
68
77
|
<WrapElem
|
|
69
78
|
connectors={connectors}
|
|
79
|
+
innerClass="mt-m1px"
|
|
70
80
|
icon="fas fa-columns"
|
|
71
81
|
title="Split into columns"
|
|
72
82
|
label="Columns"
|
|
@@ -215,7 +225,7 @@ const ToggleFilterElem = ({ connectors, fields }) => (
|
|
|
215
225
|
const JoinFieldElem = ({ connectors, options }) => (
|
|
216
226
|
<WrapElem
|
|
217
227
|
connectors={connectors}
|
|
218
|
-
icon={<Diagram3Fill className="mb-2 h5"/>}
|
|
228
|
+
icon={<Diagram3Fill className="mb-2 h5" />}
|
|
219
229
|
title="Join field"
|
|
220
230
|
label="Join"
|
|
221
231
|
disable={options.parent_field_list.length === 0}
|
|
@@ -299,29 +309,45 @@ export const ToolboxShow = () => {
|
|
|
299
309
|
} = options;
|
|
300
310
|
return (
|
|
301
311
|
<Fragment>
|
|
302
|
-
<
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
<
|
|
315
|
-
connectors={connectors}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
<
|
|
323
|
-
|
|
324
|
-
|
|
312
|
+
<div className="toolbar-row">
|
|
313
|
+
<TextElem connectors={connectors} />
|
|
314
|
+
<ColumnsElem connectors={connectors} />
|
|
315
|
+
</div>
|
|
316
|
+
<div className="toolbar-row">
|
|
317
|
+
<FieldElem
|
|
318
|
+
connectors={connectors}
|
|
319
|
+
fields={fields}
|
|
320
|
+
field_view_options={field_view_options}
|
|
321
|
+
/>
|
|
322
|
+
<LineBreakElem connectors={connectors} />
|
|
323
|
+
</div>
|
|
324
|
+
<div className="toolbar-row">
|
|
325
|
+
<JoinFieldElem connectors={connectors} options={options} />
|
|
326
|
+
<ViewLinkElem connectors={connectors} options={options} />
|
|
327
|
+
</div>
|
|
328
|
+
<div className="toolbar-row">
|
|
329
|
+
<ActionElem connectors={connectors} options={options} />
|
|
330
|
+
<LinkElem connectors={connectors} />
|
|
331
|
+
</div>
|
|
332
|
+
<div className="toolbar-row">
|
|
333
|
+
<AggregationElem
|
|
334
|
+
connectors={connectors}
|
|
335
|
+
child_field_list={child_field_list}
|
|
336
|
+
agg_field_opts={agg_field_opts}
|
|
337
|
+
/>
|
|
338
|
+
<ViewElem connectors={connectors} views={views} />
|
|
339
|
+
</div>
|
|
340
|
+
<div className="toolbar-row">
|
|
341
|
+
<ContainerElem connectors={connectors} />
|
|
342
|
+
<CardElem connectors={connectors} />
|
|
343
|
+
</div>
|
|
344
|
+
<div className="toolbar-row">
|
|
345
|
+
<TabsElem connectors={connectors} />
|
|
346
|
+
<ImageElem connectors={connectors} images={images} />
|
|
347
|
+
</div>
|
|
348
|
+
<div className="toolbar-row">
|
|
349
|
+
<HTMLElem connectors={connectors} />
|
|
350
|
+
</div>
|
|
325
351
|
</Fragment>
|
|
326
352
|
);
|
|
327
353
|
};
|
|
@@ -332,19 +358,30 @@ export const ToolboxFilter = () => {
|
|
|
332
358
|
const { fields, views } = options;
|
|
333
359
|
return (
|
|
334
360
|
<Fragment>
|
|
335
|
-
<
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
<
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
<
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
<
|
|
361
|
+
<div className="toolbar-row">
|
|
362
|
+
<TextElem connectors={connectors} />
|
|
363
|
+
<ColumnsElem connectors={connectors} />
|
|
364
|
+
</div>
|
|
365
|
+
<div className="toolbar-row">
|
|
366
|
+
<LineBreakElem connectors={connectors} />
|
|
367
|
+
<DropDownFilterElem connectors={connectors} fields={fields} />
|
|
368
|
+
</div>
|
|
369
|
+
<div className="toolbar-row">
|
|
370
|
+
<ToggleFilterElem connectors={connectors} fields={fields} />
|
|
371
|
+
<SearchElem connectors={connectors} />
|
|
372
|
+
</div>
|
|
373
|
+
<div className="toolbar-row">
|
|
374
|
+
<ActionElem connectors={connectors} options={options} />
|
|
375
|
+
<ContainerElem connectors={connectors} />
|
|
376
|
+
</div>
|
|
377
|
+
<div className="toolbar-row">
|
|
378
|
+
<CardElem connectors={connectors} />
|
|
379
|
+
<TabsElem connectors={connectors} />
|
|
380
|
+
</div>
|
|
381
|
+
<div className="toolbar-row">
|
|
382
|
+
<ViewElem connectors={connectors} views={views} />
|
|
383
|
+
<HTMLElem connectors={connectors} />
|
|
384
|
+
</div>
|
|
348
385
|
</Fragment>
|
|
349
386
|
);
|
|
350
387
|
};
|
|
@@ -355,22 +392,34 @@ export const ToolboxEdit = () => {
|
|
|
355
392
|
const { fields, field_view_options, images, views } = options;
|
|
356
393
|
return (
|
|
357
394
|
<Fragment>
|
|
358
|
-
<
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
<
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
395
|
+
<div className="toolbar-row">
|
|
396
|
+
<TextElem connectors={connectors} />
|
|
397
|
+
<ColumnsElem connectors={connectors} />
|
|
398
|
+
</div>
|
|
399
|
+
<div className="toolbar-row">
|
|
400
|
+
<FieldElem
|
|
401
|
+
connectors={connectors}
|
|
402
|
+
fields={fields}
|
|
403
|
+
field_view_options={field_view_options}
|
|
404
|
+
/>
|
|
405
|
+
<LineBreakElem connectors={connectors} />
|
|
406
|
+
</div>
|
|
407
|
+
<div className="toolbar-row">
|
|
408
|
+
<ActionElem connectors={connectors} options={options} />
|
|
409
|
+
<ContainerElem connectors={connectors} />
|
|
410
|
+
</div>
|
|
411
|
+
<div className="toolbar-row">
|
|
412
|
+
<CardElem connectors={connectors} />
|
|
413
|
+
<TabsElem connectors={connectors} />
|
|
414
|
+
</div>
|
|
415
|
+
<div className="toolbar-row">
|
|
416
|
+
<LinkElem connectors={connectors} />
|
|
417
|
+
<ImageElem connectors={connectors} images={images} />
|
|
418
|
+
</div>
|
|
419
|
+
<div className="toolbar-row">
|
|
420
|
+
<HTMLElem connectors={connectors} />
|
|
421
|
+
<ViewElem connectors={connectors} views={views} />
|
|
422
|
+
</div>
|
|
374
423
|
</Fragment>
|
|
375
424
|
);
|
|
376
425
|
};
|
|
@@ -381,18 +430,30 @@ export const ToolboxPage = () => {
|
|
|
381
430
|
const { views, images } = options;
|
|
382
431
|
return (
|
|
383
432
|
<Fragment>
|
|
384
|
-
<
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
<
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
<
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
433
|
+
<div className="toolbar-row">
|
|
434
|
+
<TextElem connectors={connectors} />
|
|
435
|
+
<ColumnsElem connectors={connectors} />
|
|
436
|
+
</div>
|
|
437
|
+
<div className="toolbar-row">
|
|
438
|
+
<LineBreakElem connectors={connectors} />
|
|
439
|
+
<HTMLElem connectors={connectors} />
|
|
440
|
+
</div>
|
|
441
|
+
<div className="toolbar-row">
|
|
442
|
+
<CardElem connectors={connectors} />
|
|
443
|
+
<ImageElem connectors={connectors} images={images} />{" "}
|
|
444
|
+
</div>
|
|
445
|
+
<div className="toolbar-row">
|
|
446
|
+
<LinkElem connectors={connectors} />
|
|
447
|
+
<ViewElem connectors={connectors} views={views} />
|
|
448
|
+
</div>
|
|
449
|
+
<div className="toolbar-row">
|
|
450
|
+
<SearchElem connectors={connectors} />
|
|
451
|
+
<ActionElem connectors={connectors} options={options} />
|
|
452
|
+
</div>
|
|
453
|
+
<div className="toolbar-row">
|
|
454
|
+
<ContainerElem connectors={connectors} />
|
|
455
|
+
<TabsElem connectors={connectors} />
|
|
456
|
+
</div>
|
|
396
457
|
</Fragment>
|
|
397
458
|
);
|
|
398
459
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { Fragment, useContext } from "react";
|
|
2
2
|
import { useNode } from "@craftjs/core";
|
|
3
3
|
import optionsCtx from "../context";
|
|
4
|
-
import faIcons from "./faicons";
|
|
5
4
|
import {
|
|
6
5
|
blockProps,
|
|
7
6
|
BlockSetting,
|
|
@@ -9,8 +8,8 @@ import {
|
|
|
9
8
|
OrFormula,
|
|
10
9
|
ConfigForm,
|
|
11
10
|
setInitialConfig,
|
|
11
|
+
ButtonOrLinkSettingsRows,
|
|
12
12
|
} from "./utils";
|
|
13
|
-
import FontIconPicker from "@fonticonpicker/react-fonticonpicker";
|
|
14
13
|
|
|
15
14
|
export const Action = ({
|
|
16
15
|
name,
|
|
@@ -19,16 +18,29 @@ export const Action = ({
|
|
|
19
18
|
action_style,
|
|
20
19
|
action_icon,
|
|
21
20
|
action_size,
|
|
21
|
+
action_bgcol,
|
|
22
|
+
action_bordercol,
|
|
23
|
+
action_textcol,
|
|
22
24
|
}) => {
|
|
23
25
|
const {
|
|
24
26
|
selected,
|
|
25
27
|
connectors: { connect, drag },
|
|
26
28
|
} = useNode((node) => ({ selected: node.events.selected }));
|
|
29
|
+
|
|
27
30
|
const btn = (
|
|
28
31
|
<button
|
|
29
32
|
className={`btn ${action_style || "btn-primary"} ${action_size || ""}`}
|
|
30
33
|
{...blockProps(block)}
|
|
31
34
|
ref={(dom) => connect(drag(dom))}
|
|
35
|
+
style={
|
|
36
|
+
action_style === "btn-custom-color"
|
|
37
|
+
? {
|
|
38
|
+
backgroundColor: action_bgcol || "#000000",
|
|
39
|
+
borderColor: action_bordercol || "#000000",
|
|
40
|
+
color: action_textcol || "#000000",
|
|
41
|
+
}
|
|
42
|
+
: {}
|
|
43
|
+
}
|
|
32
44
|
>
|
|
33
45
|
{action_icon ? <i className={`${action_icon} mr-1`}></i> : ""}
|
|
34
46
|
{action_label || name}
|
|
@@ -49,6 +61,9 @@ export const ActionSettings = () => {
|
|
|
49
61
|
action_style: node.data.props.action_style,
|
|
50
62
|
action_size: node.data.props.action_size,
|
|
51
63
|
action_icon: node.data.props.action_icon,
|
|
64
|
+
action_bgcol: node.data.props.action_bgcol,
|
|
65
|
+
action_bordercol: node.data.props.action_bordercol,
|
|
66
|
+
action_textcol: node.data.props.action_textcol,
|
|
52
67
|
}));
|
|
53
68
|
const {
|
|
54
69
|
actions: { setProp },
|
|
@@ -59,119 +74,64 @@ export const ActionSettings = () => {
|
|
|
59
74
|
confirm,
|
|
60
75
|
configuration,
|
|
61
76
|
action_label,
|
|
62
|
-
action_style,
|
|
63
|
-
action_size,
|
|
64
|
-
action_icon,
|
|
65
77
|
} = node;
|
|
66
78
|
const options = useContext(optionsCtx);
|
|
67
79
|
const getCfgFields = (fv) => (options.actionConfigForms || {})[fv];
|
|
68
80
|
const cfgFields = getCfgFields(name);
|
|
69
|
-
console.log({ action_icon });
|
|
70
81
|
return (
|
|
71
82
|
<div>
|
|
72
83
|
<table className="w-100">
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
onChange={(e) => {
|
|
82
|
-
setProp((prop) => (prop.name = e.target.value));
|
|
83
|
-
setInitialConfig(
|
|
84
|
-
setProp,
|
|
85
|
-
e.target.value,
|
|
86
|
-
getCfgFields(e.target.value)
|
|
87
|
-
);
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
{options.actions.map((f, ix) => (
|
|
91
|
-
<option key={ix} value={f}>
|
|
92
|
-
{f}
|
|
93
|
-
</option>
|
|
94
|
-
))}
|
|
95
|
-
</select>
|
|
96
|
-
</td>
|
|
97
|
-
</tr>
|
|
98
|
-
<tr>
|
|
99
|
-
<td colSpan="2">
|
|
100
|
-
<label>Label (leave blank for default)</label>
|
|
101
|
-
<OrFormula nodekey="action_label" {...{ setProp, isFormula, node }}>
|
|
102
|
-
<input
|
|
103
|
-
type="text"
|
|
84
|
+
<tbody>
|
|
85
|
+
<tr>
|
|
86
|
+
<td>
|
|
87
|
+
<label>Action</label>
|
|
88
|
+
</td>
|
|
89
|
+
<td>
|
|
90
|
+
<select
|
|
91
|
+
value={name}
|
|
104
92
|
className="form-control"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
<
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
value={action_size}
|
|
148
|
-
onChange={(e) =>
|
|
149
|
-
setProp((prop) => (prop.action_size = e.target.value))
|
|
150
|
-
}
|
|
151
|
-
>
|
|
152
|
-
<option value="">Standard</option>
|
|
153
|
-
<option value="btn-lg">Large</option>
|
|
154
|
-
<option value="btn-sm">Small</option>
|
|
155
|
-
<option value="btn-block">Block</option>
|
|
156
|
-
<option value="btn-block btn-lg">Large block</option>
|
|
157
|
-
</select>
|
|
158
|
-
</td>
|
|
159
|
-
</tr>
|
|
160
|
-
<tr>
|
|
161
|
-
<td>
|
|
162
|
-
<label>Icon</label>
|
|
163
|
-
</td>
|
|
164
|
-
<td>
|
|
165
|
-
<FontIconPicker
|
|
166
|
-
value={action_icon}
|
|
167
|
-
icons={faIcons}
|
|
168
|
-
onChange={(value) =>
|
|
169
|
-
setProp((prop) => (prop.action_icon = value))
|
|
170
|
-
}
|
|
171
|
-
isMulti={false}
|
|
172
|
-
/>
|
|
173
|
-
</td>
|
|
174
|
-
</tr><MinRoleSettingRow minRole={minRole} setProp={setProp} />
|
|
93
|
+
onChange={(e) => {
|
|
94
|
+
setProp((prop) => (prop.name = e.target.value));
|
|
95
|
+
setInitialConfig(
|
|
96
|
+
setProp,
|
|
97
|
+
e.target.value,
|
|
98
|
+
getCfgFields(e.target.value)
|
|
99
|
+
);
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
{options.actions.map((f, ix) => (
|
|
103
|
+
<option key={ix} value={f}>
|
|
104
|
+
{f}
|
|
105
|
+
</option>
|
|
106
|
+
))}
|
|
107
|
+
</select>
|
|
108
|
+
</td>
|
|
109
|
+
</tr>
|
|
110
|
+
<tr>
|
|
111
|
+
<td colSpan="2">
|
|
112
|
+
<label>Label (leave blank for default)</label>
|
|
113
|
+
<OrFormula
|
|
114
|
+
nodekey="action_label"
|
|
115
|
+
{...{ setProp, isFormula, node }}
|
|
116
|
+
>
|
|
117
|
+
<input
|
|
118
|
+
type="text"
|
|
119
|
+
className="form-control"
|
|
120
|
+
value={action_label}
|
|
121
|
+
onChange={(e) =>
|
|
122
|
+
setProp((prop) => (prop.action_label = e.target.value))
|
|
123
|
+
}
|
|
124
|
+
/>
|
|
125
|
+
</OrFormula>
|
|
126
|
+
</td>
|
|
127
|
+
</tr>
|
|
128
|
+
<ButtonOrLinkSettingsRows
|
|
129
|
+
setProp={setProp}
|
|
130
|
+
keyPrefix="action_"
|
|
131
|
+
values={node}
|
|
132
|
+
/>
|
|
133
|
+
<MinRoleSettingRow minRole={minRole} setProp={setProp} />
|
|
134
|
+
</tbody>
|
|
175
135
|
</table>
|
|
176
136
|
{options.mode === "show" ? (
|
|
177
137
|
<div className="form-check">
|
|
@@ -188,7 +148,7 @@ export const ActionSettings = () => {
|
|
|
188
148
|
</div>
|
|
189
149
|
) : null}
|
|
190
150
|
<BlockSetting block={block} setProp={setProp} />
|
|
191
|
-
|
|
151
|
+
|
|
192
152
|
{cfgFields ? (
|
|
193
153
|
<ConfigForm
|
|
194
154
|
fields={cfgFields}
|